Skip to content

Commit c782ac8

Browse files
committed
extract SelectedEventsChips props type into a separate type declaration
1 parent ef7e2c1 commit c782ac8

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

src/components/notification-picker.tsx

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,32 @@ import Select, { SelectChangeEvent } from '@mui/material/Select';
1616
import { Stack } from './stack';
1717
import { useTranslator } from '../hooks';
1818

19-
type INotificationsSettingsProps = {
19+
type NotificationsSettingsProps = {
2020
notificationEvents: string[];
2121
id: string;
2222
model: ICreateJobModel;
2323
handleModelChange: (model: ICreateJobModel) => void;
2424
};
2525

26-
type NotificationEventsSelect = {
26+
type NotificationEventsSelectProps = {
2727
id: string;
2828
availableEvents: string[];
2929
selectChange: (e: SelectChangeEvent<string>) => void;
3030
disabled: boolean;
3131
};
3232

33+
type SelectedEventsChipsProps = {
34+
selectedEvents: string[];
35+
deleteSelectedEvent: (eventToDelete: string) => () => void;
36+
disabled: boolean;
37+
};
38+
3339
export function NotificationsSettings({
3440
notificationEvents,
3541
id,
3642
model,
3743
handleModelChange: modelChange
38-
}: INotificationsSettingsProps): JSX.Element | null {
44+
}: NotificationsSettingsProps): JSX.Element | null {
3945
const trans = useTranslator('jupyterlab');
4046
const [selectedEvents, setSelectedEvents] = useState<string[]>(
4147
model.notificationsSettings?.selectedEvents || []
@@ -188,7 +194,7 @@ export function NotificationsSettings({
188194
);
189195
}
190196

191-
function NotificationEventsSelect(props: NotificationEventsSelect) {
197+
function NotificationEventsSelect(props: NotificationEventsSelectProps) {
192198
const trans = useTranslator('jupyterlab');
193199
const label = trans.__('Notification Events');
194200
const labelId = `${props.id}-label`;
@@ -215,20 +221,18 @@ function NotificationEventsSelect(props: NotificationEventsSelect) {
215221
);
216222
}
217223

218-
const SelectedEventsChips: React.FC<{
219-
selectedEvents: string[];
220-
deleteSelectedEvent: (eventToDelete: string) => () => void;
221-
disabled: boolean;
222-
}> = ({ selectedEvents, deleteSelectedEvent, disabled }) => (
223-
<Cluster gap={3} justifyContent="flex-start">
224-
{selectedEvents.map(e => (
225-
<Chip
226-
key={e}
227-
label={e}
228-
variant="outlined"
229-
onDelete={deleteSelectedEvent(e)}
230-
disabled={disabled}
231-
/>
232-
))}
233-
</Cluster>
234-
);
224+
function SelectedEventsChips(props: SelectedEventsChipsProps) {
225+
return (
226+
<Cluster gap={3} justifyContent="flex-start">
227+
{props.selectedEvents.map(e => (
228+
<Chip
229+
key={e}
230+
label={e}
231+
variant="outlined"
232+
onDelete={props.deleteSelectedEvent(e)}
233+
disabled={props.disabled}
234+
/>
235+
))}
236+
</Cluster>
237+
);
238+
}

0 commit comments

Comments
 (0)