@@ -16,7 +16,7 @@ import Select, { SelectChangeEvent } from '@mui/material/Select';
16
16
import { Stack } from './stack' ;
17
17
import { useTranslator } from '../hooks' ;
18
18
19
- type NotificationsSettingsProps = {
19
+ type NotificationsConfigProps = {
20
20
notificationEvents : string [ ] ;
21
21
id : string ;
22
22
model : ICreateJobModel ;
@@ -36,33 +36,30 @@ type SelectedEventsChipsProps = {
36
36
disabled : boolean ;
37
37
} ;
38
38
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 {
45
42
const trans = useTranslator ( 'jupyterlab' ) ;
46
43
const [ selectedEvents , setSelectedEvents ] = useState < string [ ] > (
47
- model . notificationsSettings ?. selectedEvents || [ ]
44
+ props . model . notificationsSettings ?. selectedEvents || [ ]
48
45
) ;
49
46
const [ enableNotification , setEnableNotification ] = useState < boolean > (
50
- model . notificationsSettings ?. enableNotification ?? true
47
+ props . model . notificationsSettings ?. enableNotification ?? true
51
48
) ;
52
49
const [ sendToInput , setSendToInput ] = useState < string > (
53
- model . notificationsSettings ?. sendTo ?. join ( ', ' ) || ''
50
+ props . model . notificationsSettings ?. sendTo ?. join ( ', ' ) || ''
54
51
) ;
55
52
const [ includeOutput , setIncludeOutput ] = useState < boolean > (
56
- model . notificationsSettings ?. includeOutput || false
53
+ props . model . notificationsSettings ?. includeOutput || false
57
54
) ;
58
55
59
56
const enableNotificationChange = ( e : React . ChangeEvent < HTMLInputElement > ) => {
60
57
const updatedEnableNotification = e . target . checked ;
61
58
setEnableNotification ( updatedEnableNotification ) ;
62
- modelChange ( {
63
- ...model ,
59
+ props . handleModelChange ( {
60
+ ...props . model ,
64
61
notificationsSettings : {
65
- ...model . notificationsSettings ,
62
+ ...props . model . notificationsSettings ,
66
63
enableNotification : updatedEnableNotification
67
64
}
68
65
} ) ;
@@ -74,16 +71,16 @@ export function NotificationsSettings({
74
71
if ( ! selectedEvents . includes ( newEvent ) ) {
75
72
const updatedEvents = [ ...selectedEvents , newEvent ] ;
76
73
setSelectedEvents ( updatedEvents ) ;
77
- modelChange ( {
78
- ...model ,
74
+ props . handleModelChange ( {
75
+ ...props . model ,
79
76
notificationsSettings : {
80
- ...model . notificationsSettings ,
77
+ ...props . model . notificationsSettings ,
81
78
selectedEvents : updatedEvents
82
79
}
83
80
} ) ;
84
81
}
85
82
} ,
86
- [ selectedEvents , model , modelChange ]
83
+ [ selectedEvents , props . model , props . handleModelChange ]
87
84
) ;
88
85
89
86
const sendToChange = useCallback ( ( e : React . ChangeEvent < HTMLInputElement > ) => {
@@ -96,11 +93,14 @@ export function NotificationsSettings({
96
93
. map ( email => email . trim ( ) )
97
94
. filter ( email => email ) ;
98
95
const updatedNotification = {
99
- ...model . notificationsSettings ,
96
+ ...props . model . notificationsSettings ,
100
97
sendTo : emailArray
101
98
} ;
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 ] ) ;
104
104
105
105
const keyDown = useCallback (
106
106
( e : React . KeyboardEvent ) => {
@@ -115,10 +115,10 @@ export function NotificationsSettings({
115
115
const includeOutputChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
116
116
const updatedValue = event . target . checked ;
117
117
setIncludeOutput ( updatedValue ) ;
118
- modelChange ( {
119
- ...model ,
118
+ props . handleModelChange ( {
119
+ ...props . model ,
120
120
notificationsSettings : {
121
- ...model . notificationsSettings ,
121
+ ...props . model . notificationsSettings ,
122
122
includeOutput : updatedValue
123
123
}
124
124
} ) ;
@@ -130,18 +130,18 @@ export function NotificationsSettings({
130
130
event => event !== eventToDelete
131
131
) ;
132
132
setSelectedEvents ( updatedEvents ) ;
133
- modelChange ( {
134
- ...model ,
133
+ props . handleModelChange ( {
134
+ ...props . model ,
135
135
notifications : {
136
- ...model . notificationsSettings ,
136
+ ...props . model . notificationsSettings ,
137
137
selectedEvents : updatedEvents
138
138
}
139
139
} ) ;
140
140
} ,
141
- [ selectedEvents , model , modelChange ]
141
+ [ selectedEvents , props . model , props . handleModelChange ]
142
142
) ;
143
143
144
- if ( ! notificationEvents . length ) {
144
+ if ( ! props . notificationEvents . length ) {
145
145
return null ;
146
146
}
147
147
@@ -168,8 +168,8 @@ export function NotificationsSettings({
168
168
disabled = { ! enableNotification }
169
169
/>
170
170
< NotificationEventsSelect
171
- id = { id }
172
- availableEvents = { notificationEvents . filter (
171
+ id = { props . id }
172
+ availableEvents = { props . notificationEvents . filter (
173
173
e => ! selectedEvents . includes ( e )
174
174
) }
175
175
selectChange = { selectChange }
0 commit comments