Skip to content

Commit eadc28a

Browse files
committed
NotificationsSettings --> NotificationsConfig
1 parent c782ac8 commit eadc28a

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

src/components/notification-picker.tsx renamed to src/components/notification-config.tsx

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

19-
type NotificationsSettingsProps = {
19+
type NotificationsConfigProps = {
2020
notificationEvents: string[];
2121
id: string;
2222
model: ICreateJobModel;
@@ -36,33 +36,30 @@ type SelectedEventsChipsProps = {
3636
disabled: boolean;
3737
};
3838

39-
export function NotificationsSettings({
40-
notificationEvents,
41-
id,
42-
model,
43-
handleModelChange: modelChange
44-
}: NotificationsSettingsProps): JSX.Element | null {
39+
export function NotificationsConfig(
40+
props: NotificationsConfigProps
41+
): JSX.Element | null {
4542
const trans = useTranslator('jupyterlab');
4643
const [selectedEvents, setSelectedEvents] = useState<string[]>(
47-
model.notificationsSettings?.selectedEvents || []
44+
props.model.notificationsSettings?.selectedEvents || []
4845
);
4946
const [enableNotification, setEnableNotification] = useState<boolean>(
50-
model.notificationsSettings?.enableNotification ?? true
47+
props.model.notificationsSettings?.enableNotification ?? true
5148
);
5249
const [sendToInput, setSendToInput] = useState<string>(
53-
model.notificationsSettings?.sendTo?.join(', ') || ''
50+
props.model.notificationsSettings?.sendTo?.join(', ') || ''
5451
);
5552
const [includeOutput, setIncludeOutput] = useState<boolean>(
56-
model.notificationsSettings?.includeOutput || false
53+
props.model.notificationsSettings?.includeOutput || false
5754
);
5855

5956
const enableNotificationChange = (e: React.ChangeEvent<HTMLInputElement>) => {
6057
const updatedEnableNotification = e.target.checked;
6158
setEnableNotification(updatedEnableNotification);
62-
modelChange({
63-
...model,
59+
props.handleModelChange({
60+
...props.model,
6461
notificationsSettings: {
65-
...model.notificationsSettings,
62+
...props.model.notificationsSettings,
6663
enableNotification: updatedEnableNotification
6764
}
6865
});
@@ -74,16 +71,16 @@ export function NotificationsSettings({
7471
if (!selectedEvents.includes(newEvent)) {
7572
const updatedEvents = [...selectedEvents, newEvent];
7673
setSelectedEvents(updatedEvents);
77-
modelChange({
78-
...model,
74+
props.handleModelChange({
75+
...props.model,
7976
notificationsSettings: {
80-
...model.notificationsSettings,
77+
...props.model.notificationsSettings,
8178
selectedEvents: updatedEvents
8279
}
8380
});
8481
}
8582
},
86-
[selectedEvents, model, modelChange]
83+
[selectedEvents, props.model, props.handleModelChange]
8784
);
8885

8986
const sendToChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {
@@ -96,11 +93,14 @@ export function NotificationsSettings({
9693
.map(email => email.trim())
9794
.filter(email => email);
9895
const updatedNotification = {
99-
...model.notificationsSettings,
96+
...props.model.notificationsSettings,
10097
sendTo: emailArray
10198
};
102-
modelChange({ ...model, notificationsSettings: updatedNotification });
103-
}, [sendToInput, model, modelChange]);
99+
props.handleModelChange({
100+
...props.model,
101+
notificationsSettings: updatedNotification
102+
});
103+
}, [sendToInput, props.model, props.handleModelChange]);
104104

105105
const keyDown = useCallback(
106106
(e: React.KeyboardEvent) => {
@@ -115,10 +115,10 @@ export function NotificationsSettings({
115115
const includeOutputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
116116
const updatedValue = event.target.checked;
117117
setIncludeOutput(updatedValue);
118-
modelChange({
119-
...model,
118+
props.handleModelChange({
119+
...props.model,
120120
notificationsSettings: {
121-
...model.notificationsSettings,
121+
...props.model.notificationsSettings,
122122
includeOutput: updatedValue
123123
}
124124
});
@@ -130,18 +130,18 @@ export function NotificationsSettings({
130130
event => event !== eventToDelete
131131
);
132132
setSelectedEvents(updatedEvents);
133-
modelChange({
134-
...model,
133+
props.handleModelChange({
134+
...props.model,
135135
notifications: {
136-
...model.notificationsSettings,
136+
...props.model.notificationsSettings,
137137
selectedEvents: updatedEvents
138138
}
139139
});
140140
},
141-
[selectedEvents, model, modelChange]
141+
[selectedEvents, props.model, props.handleModelChange]
142142
);
143143

144-
if (!notificationEvents.length) {
144+
if (!props.notificationEvents.length) {
145145
return null;
146146
}
147147

@@ -168,8 +168,8 @@ export function NotificationsSettings({
168168
disabled={!enableNotification}
169169
/>
170170
<NotificationEventsSelect
171-
id={id}
172-
availableEvents={notificationEvents.filter(
171+
id={props.id}
172+
availableEvents={props.notificationEvents.filter(
173173
e => !selectedEvents.includes(e)
174174
)}
175175
selectChange={selectChange}

src/mainviews/create-job.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Cluster } from '../components/cluster';
1111
import { ComputeTypePicker } from '../components/compute-type-picker';
1212
import { CreateScheduleOptions } from '../components/create-schedule-options';
1313
import { EnvironmentPicker } from '../components/environment-picker';
14-
import { NotificationsSettings } from '../components/notification-picker';
14+
import { NotificationsConfig } from '../components/notification-config';
1515
import {
1616
OutputFormatPicker,
1717
outputFormatsForEnvironment
@@ -542,7 +542,7 @@ export function CreateJob(props: ICreateJobProps): JSX.Element {
542542
value={props.model.computeType}
543543
/>
544544
{envsByName[props.model.environment]?.notifications_enabled && (
545-
<NotificationsSettings
545+
<NotificationsConfig
546546
notificationEvents={
547547
envsByName[props.model.environment].notification_events
548548
}

0 commit comments

Comments
 (0)