Skip to content

Commit 9ce6f52

Browse files
committed
Apply prettier to AdvancedOptionsMenu, ConfigElement
1 parent 7554bbd commit 9ce6f52

File tree

3 files changed

+52
-31
lines changed

3 files changed

+52
-31
lines changed

ui/frontend/.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ node_modules
1212
*.scss
1313

1414
# Slowly migrate files that we've touched
15+
!AdvancedOptionsMenu.tsx
1516
!BuildMenu.tsx
1617
!ButtonSet.tsx
18+
!ConfigElement.tsx
1719
!Header.tsx
1820
!HelpExample.tsx
1921
!Notifications.tsx

ui/frontend/AdvancedOptionsMenu.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import React, { useCallback } from 'react';
22

3-
import * as config from './reducers/configuration';
43
import { Either as EitherConfig, Select as SelectConfig } from './ConfigElement';
54
import MenuGroup from './MenuGroup';
5+
import { useAppDispatch, useAppSelector } from './hooks';
6+
import * as config from './reducers/configuration';
67
import * as selectors from './selectors';
78
import { Backtrace, Edition } from './types';
8-
import { useAppDispatch, useAppSelector } from './hooks';
99

1010
const AdvancedOptionsMenu: React.FC = () => {
1111
const isEditionDefault = useAppSelector(selectors.isEditionDefault);
@@ -16,7 +16,10 @@ const AdvancedOptionsMenu: React.FC = () => {
1616
const dispatch = useAppDispatch();
1717

1818
const changeEdition = useCallback((e: Edition) => dispatch(config.changeEdition(e)), [dispatch]);
19-
const changeBacktrace = useCallback((b: Backtrace) => dispatch(config.changeBacktrace(b)), [dispatch]);
19+
const changeBacktrace = useCallback(
20+
(b: Backtrace) => dispatch(config.changeBacktrace(b)),
21+
[dispatch],
22+
);
2023

2124
return (
2225
<MenuGroup title="Advanced options">
@@ -39,7 +42,8 @@ const AdvancedOptionsMenu: React.FC = () => {
3942
b={Backtrace.Enabled}
4043
value={backtrace}
4144
isNotDefault={isBacktraceSet}
42-
onChange={changeBacktrace} />
45+
onChange={changeBacktrace}
46+
/>
4347
</MenuGroup>
4448
);
4549
};

ui/frontend/ConfigElement.tsx

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,54 @@ interface EitherProps<T extends string> extends ConfigElementProps {
1414
onChange: (_: T) => void;
1515
}
1616

17-
export const Either =
18-
<T extends string,>({ id, a, b, aLabel = a, bLabel = b, value, onChange, ...rest }: EitherProps<T>) => (
19-
<ConfigElement {...rest}>
20-
<div className={styles.toggle}>
21-
<input id={`${id}-a`}
22-
name={id}
23-
value={a}
24-
type="radio"
25-
checked={value === a}
26-
onChange={() => onChange(a as T)} />
27-
<label htmlFor={`${id}-a`}>{aLabel}</label>
28-
<input id={`${id}-b`}
29-
name={id}
30-
value={b}
31-
type="radio"
32-
checked={value === b}
33-
onChange={() => onChange(b as T)} />
34-
<label htmlFor={`${id}-b`}>{bLabel}</label>
35-
</div>
36-
</ConfigElement>
37-
);
17+
export const Either = <T extends string>({
18+
id,
19+
a,
20+
b,
21+
aLabel = a,
22+
bLabel = b,
23+
value,
24+
onChange,
25+
...rest
26+
}: EitherProps<T>) => (
27+
<ConfigElement {...rest}>
28+
<div className={styles.toggle}>
29+
<input
30+
id={`${id}-a`}
31+
name={id}
32+
value={a}
33+
type="radio"
34+
checked={value === a}
35+
onChange={() => onChange(a as T)}
36+
/>
37+
<label htmlFor={`${id}-a`}>{aLabel}</label>
38+
<input
39+
id={`${id}-b`}
40+
name={id}
41+
value={b}
42+
type="radio"
43+
checked={value === b}
44+
onChange={() => onChange(b as T)}
45+
/>
46+
<label htmlFor={`${id}-b`}>{bLabel}</label>
47+
</div>
48+
</ConfigElement>
49+
);
3850

3951
interface SelectProps<T extends string> extends ConfigElementProps {
4052
children: React.ReactNode;
4153
value: T;
4254
onChange: (_: T) => void;
4355
}
4456

45-
export const Select = <T extends string,>({ value, onChange, children, ...rest }: SelectProps<T>) => (
57+
export const Select = <T extends string>({
58+
value,
59+
onChange,
60+
children,
61+
...rest
62+
}: SelectProps<T>) => (
4663
<ConfigElement {...rest}>
47-
<select className={styles.select} value={value} onChange={e => onChange(e.target.value as T)}>
64+
<select className={styles.select} value={value} onChange={(e) => onChange(e.target.value as T)}>
4865
{children}
4966
</select>
5067
</ConfigElement>
@@ -54,16 +71,14 @@ interface ConfigElementProps {
5471
children?: React.ReactNode;
5572
name: string;
5673
isNotDefault?: boolean;
57-
aside?: JSX.Element,
74+
aside?: JSX.Element;
5875
}
5976

6077
const ConfigElement: React.FC<ConfigElementProps> = ({ name, isNotDefault, aside, children }) => (
6178
<MenuItem>
6279
<div className={styles.container}>
6380
<span className={isNotDefault ? styles.notDefault : styles.name}>{name}</span>
64-
<div className={styles.value}>
65-
{children}
66-
</div>
81+
<div className={styles.value}>{children}</div>
6782
</div>
6883
{aside}
6984
</MenuItem>

0 commit comments

Comments
 (0)