Skip to content

Commit ef7e2c1

Browse files
committed
conver arrow functions into plain old functions, move props type declarations into separate types
1 parent e7546ea commit ef7e2c1

File tree

2 files changed

+30
-27
lines changed

2 files changed

+30
-27
lines changed

src/components/notification-detail.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,26 @@ type INotificationsSettingsDetailsProps = {
1414
notificationsSettings: Scheduler.INotificationsSettings;
1515
};
1616

17-
const NotificationsSettingsItem: React.FC<INotificationsSettingsItemProps> = ({
18-
label,
19-
value
20-
}) => {
17+
function NotificationsSettingsItem(props: INotificationsSettingsItemProps) {
2118
const displayValue =
22-
typeof value === 'boolean' ? (value ? 'Yes' : 'No') : value;
19+
typeof props.value === 'boolean'
20+
? props.value
21+
? 'Yes'
22+
: 'No'
23+
: props.value;
2324

2425
return (
2526
<LabeledValue
26-
label={label}
27+
label={props.label}
2728
value={displayValue}
2829
style={{ flex: '1 1 100%' }}
2930
/>
3031
);
31-
};
32+
}
3233

33-
export const NotificationsSettingsDetails: React.FC<
34-
INotificationsSettingsDetailsProps
35-
> = ({ notificationsSettings }) => {
34+
export function NotificationsSettingsDetails(
35+
props: INotificationsSettingsDetailsProps
36+
): JSX.Element {
3637
const trans = useTranslator('jupyterlab');
3738

3839
return (
@@ -43,7 +44,7 @@ export const NotificationsSettingsDetails: React.FC<
4344
</FormLabel>
4445
<Stack spacing={2}>
4546
<FormLabel component="legend">{trans.__('Send to')}</FormLabel>
46-
{notificationsSettings.send_to.map((email, idx) => (
47+
{props.notificationsSettings.send_to.map((email, idx) => (
4748
<NotificationsSettingsItem
4849
key={idx}
4950
label={trans.__(`Send to ${idx + 1}`)}
@@ -53,7 +54,7 @@ export const NotificationsSettingsDetails: React.FC<
5354
<FormLabel component="legend">
5455
{trans.__('Notification Events')}
5556
</FormLabel>
56-
{notificationsSettings.events.map((event, idx) => (
57+
{props.notificationsSettings.events.map((event, idx) => (
5758
<NotificationsSettingsItem
5859
key={idx}
5960
label={trans.__(`Event ${idx + 1}`)}
@@ -62,10 +63,10 @@ export const NotificationsSettingsDetails: React.FC<
6263
))}
6364
<NotificationsSettingsItem
6465
label={trans.__('Include output')}
65-
value={notificationsSettings.include_output}
66+
value={props.notificationsSettings.include_output}
6667
/>
6768
</Stack>
6869
</CardContent>
6970
</Card>
7071
);
71-
};
72+
}

src/components/notification-picker.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ type INotificationsSettingsProps = {
2323
handleModelChange: (model: ICreateJobModel) => void;
2424
};
2525

26+
type NotificationEventsSelect = {
27+
id: string;
28+
availableEvents: string[];
29+
selectChange: (e: SelectChangeEvent<string>) => void;
30+
disabled: boolean;
31+
};
32+
2633
export function NotificationsSettings({
2734
notificationEvents,
2835
id,
@@ -181,37 +188,32 @@ export function NotificationsSettings({
181188
);
182189
}
183190

184-
const NotificationEventsSelect: React.FC<{
185-
id: string;
186-
availableEvents: string[];
187-
selectChange: (e: SelectChangeEvent<string>) => void;
188-
disabled: boolean;
189-
}> = ({ id, availableEvents, selectChange, disabled }) => {
191+
function NotificationEventsSelect(props: NotificationEventsSelect) {
190192
const trans = useTranslator('jupyterlab');
191193
const label = trans.__('Notification Events');
192-
const labelId = `${id}-label`;
194+
const labelId = `${props.id}-label`;
193195

194196
return (
195197
<FormControl>
196-
<InputLabel id={labelId} disabled={disabled}>
198+
<InputLabel id={labelId} disabled={props.disabled}>
197199
{label}
198200
</InputLabel>
199201
<Select
200202
labelId={labelId}
201-
id={id}
203+
id={props.id}
202204
label={label}
203-
onChange={selectChange}
204-
disabled={disabled}
205+
onChange={props.selectChange}
206+
disabled={props.disabled}
205207
>
206-
{availableEvents.map(e => (
208+
{props.availableEvents.map(e => (
207209
<MenuItem key={e} value={e}>
208210
{e}
209211
</MenuItem>
210212
))}
211213
</Select>
212214
</FormControl>
213215
);
214-
};
216+
}
215217

216218
const SelectedEventsChips: React.FC<{
217219
selectedEvents: string[];

0 commit comments

Comments
 (0)