diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2023-05-28 13:48:21 +0530 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2023-05-28 13:48:21 +0530 |
commit | 99ca310c73024b51fed1f3077375eed7827f2c20 (patch) | |
tree | 2bd15986f448129a2291acba90ccc6bf68a233e0 /src/components/ui | |
parent | Disable in-app auto-updates for portable windows installation (fixes #1088) (... (diff) | |
download | ferdium-app-99ca310c73024b51fed1f3077375eed7827f2c20.tar.gz ferdium-app-99ca310c73024b51fed1f3077375eed7827f2c20.tar.zst ferdium-app-99ca310c73024b51fed1f3077375eed7827f2c20.zip |
Fix issues reported by sonarqube linter
Diffstat (limited to 'src/components/ui')
-rw-r--r-- | src/components/ui/AppLoader/styles.ts | 9 | ||||
-rw-r--r-- | src/components/ui/Infobox.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/Loader.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/Radio.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/Select.tsx | 4 | ||||
-rw-r--r-- | src/components/ui/ServiceIcon.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/Slider.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/StatusBarTargetUrl.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/infobox/index.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/input/index.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/select/index.tsx | 17 | ||||
-rw-r--r-- | src/components/ui/textarea/index.tsx | 2 | ||||
-rw-r--r-- | src/components/ui/toggle/index.tsx | 9 |
13 files changed, 28 insertions, 29 deletions
diff --git a/src/components/ui/AppLoader/styles.ts b/src/components/ui/AppLoader/styles.ts index 6bf3b4f3c..5ad41913a 100644 --- a/src/components/ui/AppLoader/styles.ts +++ b/src/components/ui/AppLoader/styles.ts | |||
@@ -1,7 +1,8 @@ | |||
1 | const sloganTransition = | 1 | const sloganTransition = window?.matchMedia( |
2 | window && window.matchMedia('(prefers-reduced-motion: no-preference)') | 2 | '(prefers-reduced-motion: no-preference)', |
3 | ? 'opacity 1s ease' | 3 | ) |
4 | : 'none'; | 4 | ? 'opacity 1s ease' |
5 | : 'none'; | ||
5 | 6 | ||
6 | export default { | 7 | export default { |
7 | component: { | 8 | component: { |
diff --git a/src/components/ui/Infobox.tsx b/src/components/ui/Infobox.tsx index 1fc24816a..9782db151 100644 --- a/src/components/ui/Infobox.tsx +++ b/src/components/ui/Infobox.tsx | |||
@@ -35,7 +35,7 @@ interface IState { | |||
35 | dismissed: boolean; | 35 | dismissed: boolean; |
36 | } | 36 | } |
37 | 37 | ||
38 | // Can this file be merged into the './infobox/index.tsx' file? | 38 | // TODO: Can this file be merged into the './infobox/index.tsx' file? |
39 | @observer | 39 | @observer |
40 | class Infobox extends Component<IProps, IState> { | 40 | class Infobox extends Component<IProps, IState> { |
41 | constructor(props: IProps) { | 41 | constructor(props: IProps) { |
diff --git a/src/components/ui/Loader.tsx b/src/components/ui/Loader.tsx index 17cb35f41..37555df16 100644 --- a/src/components/ui/Loader.tsx +++ b/src/components/ui/Loader.tsx | |||
@@ -12,7 +12,7 @@ interface IProps { | |||
12 | children?: ReactNode; | 12 | children?: ReactNode; |
13 | } | 13 | } |
14 | 14 | ||
15 | // Can this file be merged into the './loader/index.tsx' file? | 15 | // TODO: Can this file be merged into the './loader/index.tsx' file? |
16 | @inject('stores') | 16 | @inject('stores') |
17 | @observer | 17 | @observer |
18 | class LoaderComponent extends Component<IProps> { | 18 | class LoaderComponent extends Component<IProps> { |
diff --git a/src/components/ui/Radio.tsx b/src/components/ui/Radio.tsx index e6cb5d5a5..b5be64c5d 100644 --- a/src/components/ui/Radio.tsx +++ b/src/components/ui/Radio.tsx | |||
@@ -10,7 +10,7 @@ type Props = { | |||
10 | showLabel: boolean; | 10 | showLabel: boolean; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | // Should this file be converted into the coding style similar to './toggle/index.tsx'? | 13 | // TODO: Should this file be converted into the coding style similar to './toggle/index.tsx'? |
14 | class Radio extends Component<Props> { | 14 | class Radio extends Component<Props> { |
15 | static defaultProps = { | 15 | static defaultProps = { |
16 | focus: false, | 16 | focus: false, |
diff --git a/src/components/ui/Select.tsx b/src/components/ui/Select.tsx index e8e305fdd..8ae2945ce 100644 --- a/src/components/ui/Select.tsx +++ b/src/components/ui/Select.tsx | |||
@@ -18,7 +18,7 @@ interface IProps { | |||
18 | multiple?: boolean; | 18 | multiple?: boolean; |
19 | } | 19 | } |
20 | 20 | ||
21 | // Can this file be merged into the './select/index.tsx' file? | 21 | // TODO: Can this file be merged into the './select/index.tsx' file? |
22 | @observer | 22 | @observer |
23 | class Select extends Component<IProps> { | 23 | class Select extends Component<IProps> { |
24 | private element: RefObject<HTMLSelectElement> = | 24 | private element: RefObject<HTMLSelectElement> = |
@@ -57,7 +57,7 @@ class Select extends Component<IProps> { | |||
57 | let selected = field.value; | 57 | let selected = field.value; |
58 | 58 | ||
59 | if (multiple) { | 59 | if (multiple) { |
60 | if (typeof field.value === 'string' && field.value.slice(0, 1) === '[') { | 60 | if (typeof field.value === 'string' && field.value.startsWith('[')) { |
61 | // Value is JSON encoded | 61 | // Value is JSON encoded |
62 | selected = JSON.parse(field.value); | 62 | selected = JSON.parse(field.value); |
63 | } else if (typeof field.value === 'object') { | 63 | } else if (typeof field.value === 'object') { |
diff --git a/src/components/ui/ServiceIcon.tsx b/src/components/ui/ServiceIcon.tsx index 39a32e44d..6920611d0 100644 --- a/src/components/ui/ServiceIcon.tsx +++ b/src/components/ui/ServiceIcon.tsx | |||
@@ -27,7 +27,7 @@ interface IProps extends WithStylesProps<typeof styles> { | |||
27 | className?: string; | 27 | className?: string; |
28 | } | 28 | } |
29 | 29 | ||
30 | // TODO - [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'? | 30 | // TODO: [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'? |
31 | @observer | 31 | @observer |
32 | class ServiceIcon extends Component<IProps> { | 32 | class ServiceIcon extends Component<IProps> { |
33 | render(): ReactNode { | 33 | render(): ReactNode { |
diff --git a/src/components/ui/Slider.tsx b/src/components/ui/Slider.tsx index be0846513..aa351ccd2 100644 --- a/src/components/ui/Slider.tsx +++ b/src/components/ui/Slider.tsx | |||
@@ -12,7 +12,7 @@ interface IProps { | |||
12 | onSliderChange?: (e: ChangeEvent) => void; | 12 | onSliderChange?: (e: ChangeEvent) => void; |
13 | } | 13 | } |
14 | 14 | ||
15 | // TODO - [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'? | 15 | // TODO: [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'? |
16 | @observer | 16 | @observer |
17 | class Slider extends Component<IProps> { | 17 | class Slider extends Component<IProps> { |
18 | onChange(e: ChangeEvent<HTMLInputElement>): void { | 18 | onChange(e: ChangeEvent<HTMLInputElement>): void { |
diff --git a/src/components/ui/StatusBarTargetUrl.tsx b/src/components/ui/StatusBarTargetUrl.tsx index 7b053f410..d969267eb 100644 --- a/src/components/ui/StatusBarTargetUrl.tsx +++ b/src/components/ui/StatusBarTargetUrl.tsx | |||
@@ -8,7 +8,7 @@ interface IProps { | |||
8 | text?: string; | 8 | text?: string; |
9 | } | 9 | } |
10 | 10 | ||
11 | // TODO - [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'? | 11 | // TODO: [TS DEBT] Should this file be converted into the coding style similar to './toggle/index.tsx'? |
12 | @observer | 12 | @observer |
13 | class StatusBarTargetUrl extends Component<IProps> { | 13 | class StatusBarTargetUrl extends Component<IProps> { |
14 | render() { | 14 | render() { |
diff --git a/src/components/ui/infobox/index.tsx b/src/components/ui/infobox/index.tsx index 3b878a9de..28ec2ff90 100644 --- a/src/components/ui/infobox/index.tsx +++ b/src/components/ui/infobox/index.tsx | |||
@@ -28,7 +28,7 @@ const buttonStyles = (theme: Theme) => { | |||
28 | const infoBoxTransition: string = 'none'; | 28 | const infoBoxTransition: string = 'none'; |
29 | const ctaTransition: string = 'none'; | 29 | const ctaTransition: string = 'none'; |
30 | 30 | ||
31 | // TODO: Not sure why, but this location alone, the `dinwo` is not defined - and it throws an error thus aborting the startup sequence of ferdium | 31 | // TODO: Not sure why, but this location alone, the `window` is not defined - and it throws an error thus aborting the startup sequence of ferdium |
32 | // if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { | 32 | // if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { |
33 | // infoBoxTransition = 'all 0.5s'; | 33 | // infoBoxTransition = 'all 0.5s'; |
34 | // ctaTransition = 'opacity 0.3s'; | 34 | // ctaTransition = 'opacity 0.3s'; |
diff --git a/src/components/ui/input/index.tsx b/src/components/ui/input/index.tsx index fe8f35607..064c1807f 100644 --- a/src/components/ui/input/index.tsx +++ b/src/components/ui/input/index.tsx | |||
@@ -67,7 +67,7 @@ class Input extends Component<IProps, IState> { | |||
67 | componentDidMount(): void { | 67 | componentDidMount(): void { |
68 | const { focus = false, data = {} } = this.props; | 68 | const { focus = false, data = {} } = this.props; |
69 | 69 | ||
70 | if (this.inputElement && this.inputElement.current) { | 70 | if (this.inputElement?.current) { |
71 | if (focus) { | 71 | if (focus) { |
72 | this.inputElement.current.focus(); | 72 | this.inputElement.current.focus(); |
73 | } | 73 | } |
diff --git a/src/components/ui/select/index.tsx b/src/components/ui/select/index.tsx index 695e70e28..017de5423 100644 --- a/src/components/ui/select/index.tsx +++ b/src/components/ui/select/index.tsx | |||
@@ -17,7 +17,7 @@ import Wrapper from '../wrapper'; | |||
17 | let popupTransition: string = 'none'; | 17 | let popupTransition: string = 'none'; |
18 | let toggleTransition: string = 'none'; | 18 | let toggleTransition: string = 'none'; |
19 | 19 | ||
20 | if (window && window.matchMedia('(prefers-reduced-motion: no-preference)')) { | 20 | if (window?.matchMedia('(prefers-reduced-motion: no-preference)')) { |
21 | popupTransition = 'all 0.3s'; | 21 | popupTransition = 'all 0.3s'; |
22 | toggleTransition = 'transform 0.3s'; | 22 | toggleTransition = 'transform 0.3s'; |
23 | } | 23 | } |
@@ -194,13 +194,13 @@ class SelectComponent extends Component<IProps, IState> { | |||
194 | componentDidUpdate(): void { | 194 | componentDidUpdate(): void { |
195 | const { open } = this.state; | 195 | const { open } = this.state; |
196 | 196 | ||
197 | if (this.searchInputRef && this.searchInputRef.current && open) { | 197 | if (this.searchInputRef?.current && open) { |
198 | this.searchInputRef.current.focus(); | 198 | this.searchInputRef.current.focus(); |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
202 | componentDidMount(): void { | 202 | componentDidMount(): void { |
203 | if (this.inputRef && this.inputRef.current) { | 203 | if (this.inputRef?.current) { |
204 | const { data } = this.props; | 204 | const { data } = this.props; |
205 | 205 | ||
206 | if (data) { | 206 | if (data) { |
@@ -215,7 +215,7 @@ class SelectComponent extends Component<IProps, IState> { | |||
215 | UNSAFE_componentWillMount(): void { | 215 | UNSAFE_componentWillMount(): void { |
216 | const { value } = this.props; | 216 | const { value } = this.props; |
217 | 217 | ||
218 | if (this.componentRef && this.componentRef.current) { | 218 | if (this.componentRef?.current) { |
219 | this.componentRef.current.removeEventListener( | 219 | this.componentRef.current.removeEventListener( |
220 | 'keydown', | 220 | 'keydown', |
221 | this.keyListener, | 221 | this.keyListener, |
@@ -285,7 +285,7 @@ class SelectComponent extends Component<IProps, IState> { | |||
285 | e.preventDefault(); | 285 | e.preventDefault(); |
286 | } | 286 | } |
287 | 287 | ||
288 | if (this.componentRef && this.componentRef.current) { | 288 | if (this.componentRef?.current) { |
289 | if (e.keyCode === 38 && selected > 0) { | 289 | if (e.keyCode === 38 && selected > 0) { |
290 | this.setState((state: IState) => ({ | 290 | this.setState((state: IState) => ({ |
291 | selected: state.selected - 1, | 291 | selected: state.selected - 1, |
@@ -302,8 +302,7 @@ class SelectComponent extends Component<IProps, IState> { | |||
302 | } | 302 | } |
303 | 303 | ||
304 | if ( | 304 | if ( |
305 | this.activeOptionRef && | 305 | this.activeOptionRef?.current && |
306 | this.activeOptionRef.current && | ||
307 | this.scrollContainerRef && | 306 | this.scrollContainerRef && |
308 | this.scrollContainerRef.current | 307 | this.scrollContainerRef.current |
309 | ) { | 308 | ) { |
@@ -350,13 +349,11 @@ class SelectComponent extends Component<IProps, IState> { | |||
350 | 349 | ||
351 | const { open, needle, value, selected, options } = this.state; | 350 | const { open, needle, value, selected, options } = this.state; |
352 | 351 | ||
353 | let selection = ''; | 352 | let selection = actionText; |
354 | if (!value && defaultValue && options![defaultValue]) { | 353 | if (!value && defaultValue && options![defaultValue]) { |
355 | selection = options![defaultValue]; | 354 | selection = options![defaultValue]; |
356 | } else if (value && options![value]) { | 355 | } else if (value && options![value]) { |
357 | selection = options![value]; | 356 | selection = options![value]; |
358 | } else { | ||
359 | selection = actionText; | ||
360 | } | 357 | } |
361 | 358 | ||
362 | return ( | 359 | return ( |
diff --git a/src/components/ui/textarea/index.tsx b/src/components/ui/textarea/index.tsx index 89e85ac11..fbdef7fc6 100644 --- a/src/components/ui/textarea/index.tsx +++ b/src/components/ui/textarea/index.tsx | |||
@@ -38,7 +38,7 @@ class TextareaComponent extends Component<IProps> { | |||
38 | componentDidMount() { | 38 | componentDidMount() { |
39 | const { data } = this.props; | 39 | const { data } = this.props; |
40 | 40 | ||
41 | if (this.textareaRef && this.textareaRef.current && data) { | 41 | if (this.textareaRef?.current && data) { |
42 | Object.keys(data).map( | 42 | Object.keys(data).map( |
43 | key => (this.textareaRef.current!.dataset[key] = data[key]), | 43 | key => (this.textareaRef.current!.dataset[key] = data[key]), |
44 | ); | 44 | ); |
diff --git a/src/components/ui/toggle/index.tsx b/src/components/ui/toggle/index.tsx index 828941886..48f68943b 100644 --- a/src/components/ui/toggle/index.tsx +++ b/src/components/ui/toggle/index.tsx | |||
@@ -16,10 +16,11 @@ interface IProps | |||
16 | className?: string; | 16 | className?: string; |
17 | } | 17 | } |
18 | 18 | ||
19 | const buttonTransition: string = | 19 | const buttonTransition: string = window?.matchMedia( |
20 | window && window.matchMedia('(prefers-reduced-motion: no-preference)') | 20 | '(prefers-reduced-motion: no-preference)', |
21 | ? 'all .5s' | 21 | ) |
22 | : 'none'; | 22 | ? 'all .5s' |
23 | : 'none'; | ||
23 | 24 | ||
24 | const styles = (theme: Theme) => ({ | 25 | const styles = (theme: Theme) => ({ |
25 | toggle: { | 26 | toggle: { |