@@ -9,6 +9,7 @@ import { ActionTypes } from 'lib/stores/ConfigStore';
99import Button from 'components/Button/Button.react' ;
1010import ConfigDialog from 'dashboard/Data/Config/ConfigDialog.react' ;
1111import DeleteParameterDialog from 'dashboard/Data/Config/DeleteParameterDialog.react' ;
12+ import AddArrayEntryDialog from 'dashboard/Data/Config/AddArrayEntryDialog.react' ;
1213import EmptyState from 'components/EmptyState/EmptyState.react' ;
1314import Icon from 'components/Icon/Icon.react' ;
1415import { isDate } from 'lib/DateUtils' ;
@@ -44,6 +45,8 @@ class Config extends TableView {
4445 confirmModalOpen : false ,
4546 lastError : null ,
4647 lastNote : null ,
48+ showAddEntryDialog : false ,
49+ addEntryParam : '' ,
4750 } ;
4851 this . noteTimeout = null ;
4952 }
@@ -111,6 +114,15 @@ class Config extends TableView {
111114 onConfirm = { this . deleteParam . bind ( this , this . state . modalParam ) }
112115 />
113116 ) ;
117+ } else if ( this . state . showAddEntryDialog ) {
118+ extras = (
119+ < AddArrayEntryDialog
120+ onCancel = { this . closeAddEntryDialog . bind ( this ) }
121+ onConfirm = { value =>
122+ this . addArrayEntry ( this . state . addEntryParam , value )
123+ }
124+ />
125+ ) ;
114126 }
115127
116128 if ( this . state . confirmModalOpen ) {
@@ -235,7 +247,8 @@ class Config extends TableView {
235247 // Define column styles
236248 const columnStyleLarge = { width : '30%' , cursor : 'pointer' } ;
237249 const columnStyleSmall = { width : '15%' , cursor : 'pointer' } ;
238- const columnStyleAction = { width : '10%' , textAlign : 'center' } ;
250+ const columnStyleValue = { width : '25%' , cursor : 'pointer' } ;
251+ const columnStyleAction = { width : '10%' } ;
239252
240253 const openModalValueColumn = ( ) => {
241254 if ( data . value instanceof Parse . File ) {
@@ -258,20 +271,20 @@ class Config extends TableView {
258271 < td style = { columnStyleSmall } onClick = { openModal } >
259272 { type }
260273 </ td >
261- < td style = { columnStyleLarge } onClick = { openModalValueColumn } >
274+ < td style = { columnStyleValue } onClick = { openModalValueColumn } >
262275 { value }
263276 </ td >
264277 < td style = { columnStyleAction } >
265278 { type === 'Array' && (
266- < a onClick = { ( ) => this . addArrayEntry ( data . param ) } >
279+ < a onClick = { ( ) => this . openAddEntryDialog ( data . param ) } >
267280 < Icon width = { 16 } height = { 16 } name = "plus-solid" />
268281 </ a >
269282 ) }
270283 </ td >
271284 < td style = { columnStyleSmall } onClick = { openModal } >
272285 { data . masterKeyOnly . toString ( ) }
273286 </ td >
274- < td style = { { textAlign : 'center' } } >
287+ < td style = { { textAlign : 'center' , width : '5%' } } >
275288 < a onClick = { openDeleteParameterDialog } >
276289 < Icon width = { 16 } height = { 16 } name = "trash-solid" fill = "#ff395e" />
277290 </ a >
@@ -473,17 +486,15 @@ class Config extends TableView {
473486 } , 3500 ) ;
474487 }
475488
476- async addArrayEntry ( param ) {
477- const input = window . prompt ( 'New array entry (JSON supported)' ) ;
478- if ( input === null ) {
479- return ;
480- }
481- let value ;
482- try {
483- value = JSON . parse ( input ) ;
484- } catch ( e ) {
485- value = input ;
486- }
489+ openAddEntryDialog ( param ) {
490+ this . setState ( { showAddEntryDialog : true , addEntryParam : param } ) ;
491+ }
492+
493+ closeAddEntryDialog ( ) {
494+ this . setState ( { showAddEntryDialog : false , addEntryParam : '' } ) ;
495+ }
496+
497+ async addArrayEntry ( param , value ) {
487498 try {
488499 this . setState ( { loading : true } ) ;
489500 await Parse . _request (
@@ -503,6 +514,7 @@ class Config extends TableView {
503514 } finally {
504515 this . setState ( { loading : false } ) ;
505516 }
517+ this . closeAddEntryDialog ( ) ;
506518 }
507519}
508520
0 commit comments