@@ -11,6 +11,17 @@ import StatefulSelect from '../ui/StatefulSelect';
1111
1212import { getTriggerEntity , getJobAction } from './NotificationTrigger' ;
1313
14+ function NotificationTriggerMetadataModifyType ( ) {
15+ return (
16+ < >
17+ < Field name = "field" component = { TextField } label = "Field" fullWidth />
18+ < Field name = "language" component = { TextField } label = "Language" fullWidth />
19+ < Field name = "track" component = { TextField } label = "Track" fullWidth />
20+ < Field name = "interval" component = { TextField } label = "Interval" fullWidth />
21+ </ >
22+ ) ;
23+ }
24+
1425function NotificationTriggerItemType ( props ) {
1526 const { initialValues = { } , valueSelector, dirty } = props ;
1627 const name = props ?. id || 'notificationDocument.trigger.item' ;
@@ -62,13 +73,13 @@ function NotificationTriggerStorageType(props) {
6273 const name = props ?. id || 'notificationDocument.trigger.storage' ;
6374 let initialvalue ;
6475 if ( dirty ) {
65- const item = valueSelector ( name ) ;
66- initialvalue = item && Object . keys ( item ) [ 0 ] ;
76+ const storage = valueSelector ( name ) ;
77+ initialvalue = storage && Object . keys ( storage ) [ 0 ] ;
6778 } else {
6879 const { notificationDocument = { } } = initialValues ;
6980 const { trigger = { } } = notificationDocument ;
70- const { item } = trigger ;
71- initialvalue = item && Object . keys ( item ) [ 0 ] ;
81+ const { storage } = trigger ;
82+ initialvalue = storage && Object . keys ( storage ) [ 0 ] ;
7283 }
7384 const onChange = ( event , newValue , previousValue ) => {
7485 const prevState = valueSelector ( name ) ;
@@ -96,10 +107,12 @@ function NotificationTriggerStorageType(props) {
96107 >
97108 < MenuItem value = "create" > Create</ MenuItem >
98109 < MenuItem value = "delete" > Delete</ MenuItem >
110+ < MenuItem value = "modify" > Modify</ MenuItem >
99111 < MenuItem value = "filename" > Filename</ MenuItem >
100112 </ StatefulSelect >
101113 < Field name = "create" type = "hidden" component = "input" />
102114 < Field name = "delete" type = "hidden" component = "input" />
115+ < Field name = "modify" type = "hidden" component = "input" />
103116 < Field name = "filename" type = "hidden" component = "input" />
104117 </ >
105118 ) ;
@@ -110,13 +123,13 @@ function NotificationTriggerFileType(props) {
110123 const name = props ?. id || 'notificationDocument.trigger.file' ;
111124 let initialvalue ;
112125 if ( dirty ) {
113- const item = valueSelector ( name ) ;
114- initialvalue = item && Object . keys ( item ) [ 0 ] ;
126+ const file = valueSelector ( name ) ;
127+ initialvalue = file && Object . keys ( file ) [ 0 ] ;
115128 } else {
116129 const { notificationDocument = { } } = initialValues ;
117130 const { trigger = { } } = notificationDocument ;
118- const { item } = trigger ;
119- initialvalue = item && Object . keys ( item ) [ 0 ] ;
131+ const { file } = trigger ;
132+ initialvalue = file && Object . keys ( file ) [ 0 ] ;
120133 }
121134 const onChange = ( event , newValue , previousValue ) => {
122135 const prevState = valueSelector ( name ) ;
@@ -147,12 +160,14 @@ function NotificationTriggerFileType(props) {
147160 < MenuItem value = "hash" > Hash</ MenuItem >
148161 < MenuItem value = "close" > Close</ MenuItem >
149162 < MenuItem value = "delete" > Delete</ MenuItem >
163+ < MenuItem value = "lost" > Lost</ MenuItem >
150164 </ StatefulSelect >
151165 < Field name = "new" type = "hidden" component = "input" />
152166 < Field name = "change" type = "hidden" component = "input" />
153167 < Field name = "hash" type = "hidden" component = "input" />
154168 < Field name = "close" type = "hidden" component = "input" />
155169 < Field name = "delete" type = "hidden" component = "input" />
170+ < Field name = "lost" type = "hidden" component = "input" />
156171 </ >
157172 ) ;
158173}
@@ -162,13 +177,13 @@ function NotificationTriggerGroupType(props) {
162177 const name = props ?. id || 'notificationDocument.trigger.group' ;
163178 let initialvalue ;
164179 if ( dirty ) {
165- const item = valueSelector ( name ) ;
166- initialvalue = item && Object . keys ( item ) [ 0 ] ;
180+ const group = valueSelector ( name ) ;
181+ initialvalue = group && Object . keys ( group ) [ 0 ] ;
167182 } else {
168183 const { notificationDocument = { } } = initialValues ;
169184 const { trigger = { } } = notificationDocument ;
170- const { item } = trigger ;
171- initialvalue = item && Object . keys ( item ) [ 0 ] ;
185+ const { group } = trigger ;
186+ initialvalue = group && Object . keys ( group ) [ 0 ] ;
172187 }
173188 const onChange = ( event , newValue , previousValue ) => {
174189 const prevState = valueSelector ( name ) ;
@@ -210,13 +225,13 @@ function NotificationTriggerShapeType(props) {
210225 const name = props ?. id || 'notificationDocument.trigger.shape' ;
211226 let initialvalue ;
212227 if ( dirty ) {
213- const item = valueSelector ( name ) ;
214- initialvalue = item && Object . keys ( item ) [ 0 ] ;
228+ const shape = valueSelector ( name ) ;
229+ initialvalue = shape && Object . keys ( shape ) [ 0 ] ;
215230 } else {
216231 const { notificationDocument = { } } = initialValues ;
217232 const { trigger = { } } = notificationDocument ;
218- const { item } = trigger ;
219- initialvalue = item && Object . keys ( item ) [ 0 ] ;
233+ const { shape } = trigger ;
234+ initialvalue = shape && Object . keys ( shape ) [ 0 ] ;
220235 }
221236 const onChange = ( event , newValue , previousValue ) => {
222237 const prevState = valueSelector ( name ) ;
@@ -258,13 +273,13 @@ function NotificationTriggerAccessType(props) {
258273 const name = props ?. id || 'notificationDocument.trigger.access' ;
259274 let initialvalue ;
260275 if ( dirty ) {
261- const item = valueSelector ( name ) ;
262- initialvalue = item && Object . keys ( item ) [ 0 ] ;
276+ const access = valueSelector ( name ) ;
277+ initialvalue = access && Object . keys ( access ) [ 0 ] ;
263278 } else {
264279 const { notificationDocument = { } } = initialValues ;
265280 const { trigger = { } } = notificationDocument ;
266- const { item } = trigger ;
267- initialvalue = item && Object . keys ( item ) [ 0 ] ;
281+ const { access } = trigger ;
282+ initialvalue = access && Object . keys ( access ) [ 0 ] ;
268283 }
269284 const onChange = ( event , newValue , previousValue ) => {
270285 const prevState = valueSelector ( name ) ;
@@ -306,13 +321,13 @@ function NotificationTriggerQuotaType(props) {
306321 const name = props ?. id || 'notificationDocument.trigger.quota' ;
307322 let initialvalue ;
308323 if ( dirty ) {
309- const item = valueSelector ( name ) ;
310- initialvalue = item && Object . keys ( item ) [ 0 ] ;
324+ const quota = valueSelector ( name ) ;
325+ initialvalue = quota && Object . keys ( quota ) [ 0 ] ;
311326 } else {
312327 const { notificationDocument = { } } = initialValues ;
313328 const { trigger = { } } = notificationDocument ;
314- const { item } = trigger ;
315- initialvalue = item && Object . keys ( item ) [ 0 ] ;
329+ const { quota } = trigger ;
330+ initialvalue = quota && Object . keys ( quota ) [ 0 ] ;
316331 }
317332 const onChange = ( event , newValue , previousValue ) => {
318333 const prevState = valueSelector ( name ) ;
@@ -354,17 +369,17 @@ function NotificationTriggerDocumentType(props) {
354369 const name = props ?. id || 'notificationDocument.trigger.document' ;
355370 let initialvalue ;
356371 if ( dirty ) {
357- const item = valueSelector ( name ) ;
358- initialvalue = item && Object . keys ( item ) [ 0 ] ;
372+ const document = valueSelector ( name ) ;
373+ initialvalue = document && Object . keys ( document ) [ 0 ] ;
359374 } else {
360375 const { notificationDocument = { } } = initialValues ;
361376 const { trigger = { } } = notificationDocument ;
362- const { item } = trigger ;
363- initialvalue = item && Object . keys ( item ) [ 0 ] ;
377+ const { document } = trigger ;
378+ initialvalue = document && Object . keys ( document ) [ 0 ] ;
364379 }
365380 const onChange = ( event , newValue , previousValue ) => {
366381 const prevState = valueSelector ( name ) ;
367- const setValue = '' ;
382+ const setValue = newValue === 'modify' ? { } : '' ;
368383 if ( prevState ) {
369384 const newState = update ( prevState , {
370385 [ newValue ] : {
@@ -377,6 +392,23 @@ function NotificationTriggerDocumentType(props) {
377392 props ?. change ( name , { [ newValue ] : setValue } ) ;
378393 }
379394 } ;
395+ // TODO Refactor as standalone component
396+ // eslint-disable-next-line react/no-unstable-nested-components
397+ function ValueComponent ( value ) {
398+ switch ( value ) {
399+ case 'modify' :
400+ return (
401+ < FormSection
402+ name = "modify"
403+ component = { NotificationTriggerMetadataModifyType }
404+ id = { `${ name } .modify` }
405+ { ...props }
406+ />
407+ ) ;
408+ default :
409+ return null ;
410+ }
411+ }
380412 return (
381413 < >
382414 < StatefulSelect
@@ -385,12 +417,16 @@ function NotificationTriggerDocumentType(props) {
385417 fullWidth
386418 onChange = { onChange }
387419 name = { name }
420+ // eslint-disable-next-line react/jsx-no-bind
421+ ValueComponent = { ValueComponent }
388422 >
389423 < MenuItem value = "create" > Create</ MenuItem >
390424 < MenuItem value = "delete" > Delete</ MenuItem >
425+ < MenuItem value = "modify" > Modify</ MenuItem >
391426 </ StatefulSelect >
392427 < Field name = "create" type = "hidden" component = "input" />
393428 < Field name = "delete" type = "hidden" component = "input" />
429+ < Field name = "modify" type = "hidden" component = "input" />
394430 </ >
395431 ) ;
396432}
@@ -400,13 +436,13 @@ function NotificationTriggerDeletionLockType(props) {
400436 const name = props ?. id || 'notificationDocument.trigger.deletionLock' ;
401437 let initialvalue ;
402438 if ( dirty ) {
403- const item = valueSelector ( name ) ;
404- initialvalue = item && Object . keys ( item ) [ 0 ] ;
439+ const deletionLock = valueSelector ( name ) ;
440+ initialvalue = deletionLock && Object . keys ( deletionLock ) [ 0 ] ;
405441 } else {
406442 const { notificationDocument = { } } = initialValues ;
407443 const { trigger = { } } = notificationDocument ;
408- const { item } = trigger ;
409- initialvalue = item && Object . keys ( item ) [ 0 ] ;
444+ const { deletionLock } = trigger ;
445+ initialvalue = deletionLock && Object . keys ( deletionLock ) [ 0 ] ;
410446 }
411447 const onChange = ( event , newValue , previousValue ) => {
412448 const prevState = valueSelector ( name ) ;
@@ -447,17 +483,6 @@ function NotificationTriggerDeletionLockType(props) {
447483 ) ;
448484}
449485
450- function NotificationTriggerMetadataModifyType ( ) {
451- return (
452- < >
453- < Field name = "field" component = { TextField } label = "Field" fullWidth />
454- < Field name = "language" component = { TextField } label = "Language" fullWidth />
455- < Field name = "track" component = { TextField } label = "Track" fullWidth />
456- < Field name = "interval" component = { TextField } label = "Interval" fullWidth />
457- </ >
458- ) ;
459- }
460-
461486function NotificationTriggerMetadataType ( props ) {
462487 const { initialValues = { } , valueSelector, dirty } = props ;
463488 const name = props ?. id || 'notificationDocument.trigger.metadata' ;
@@ -536,8 +561,8 @@ function NotificationTriggerCollectionType(props) {
536561 const name = props ?. id || 'notificationDocument.trigger.collection' ;
537562 let initialvalue ;
538563 if ( dirty ) {
539- const item = valueSelector ( name ) ;
540- initialvalue = item && Object . keys ( item ) [ 0 ] ;
564+ const collection = valueSelector ( name ) ;
565+ initialvalue = collection && Object . keys ( collection ) [ 0 ] ;
541566 } else {
542567 const { notificationDocument = { } } = initialValues ;
543568 const { trigger = { } } = notificationDocument ;
@@ -667,7 +692,7 @@ function NotificationJobTriggerType(props) {
667692 < MenuItem value = "update" > Update</ MenuItem >
668693 < MenuItem value = "create" > Create</ MenuItem >
669694 < MenuItem value = "stop" > Stop</ MenuItem >
670- < MenuItem value = "finish" > Finish </ MenuItem >
695+ < MenuItem value = "finished" > Finished </ MenuItem >
671696 < MenuItem value = "fail" > Fail</ MenuItem >
672697 </ StatefulSelect >
673698 < FormSection name = "filter" component = { NotificationJobTriggerFilterType } />
0 commit comments