55 * This source code is licensed under the license found in the LICENSE file in
66 * the root directory of this source tree.
77 */
8- import { ActionTypes } from 'lib/stores/ConfigStore' ;
9- import Button from 'components/Button/Button.react' ;
10- import ConfigDialog from 'dashboard/Data/Config/ConfigDialog.react' ;
11- import EmptyState from 'components/EmptyState/EmptyState.react' ;
12- import Icon from 'components/Icon/Icon.react' ;
13- import { isDate } from 'lib/DateUtils' ;
14- import Parse from 'parse' ;
15- import React from 'react' ;
16- import SidebarAction from 'components/Sidebar/SidebarAction' ;
17- import subscribeTo from 'lib/subscribeTo' ;
18- import TableHeader from 'components/Table/TableHeader.react' ;
19- import TableView from 'dashboard/TableView.react' ;
20- import Toolbar from 'components/Toolbar/Toolbar.react' ;
8+ import { ActionTypes } from 'lib/stores/ConfigStore' ;
9+ import Button from 'components/Button/Button.react' ;
10+ import ConfigDialog from 'dashboard/Data/Config/ConfigDialog.react' ;
11+ import DeleteParameterDialog from 'dashboard/Data/Config/DeleteParameterDialog.react' ;
12+ import EmptyState from 'components/EmptyState/EmptyState.react' ;
13+ import Icon from 'components/Icon/Icon.react' ;
14+ import { isDate } from 'lib/DateUtils' ;
15+ import Parse from 'parse' ;
16+ import React from 'react' ;
17+ import SidebarAction from 'components/Sidebar/SidebarAction' ;
18+ import subscribeTo from 'lib/subscribeTo' ;
19+ import TableHeader from 'components/Table/TableHeader.react' ;
20+ import TableView from 'dashboard/TableView.react' ;
21+ import Toolbar from 'components/Toolbar/Toolbar.react' ;
2122
2223@subscribeTo ( 'Config' , 'config' )
2324class Config extends TableView {
@@ -28,6 +29,7 @@ class Config extends TableView {
2829 this . action = new SidebarAction ( 'Create a parameter' , this . createParameter . bind ( this ) ) ;
2930 this . state = {
3031 modalOpen : false ,
32+ showDeleteParameterDialog : false ,
3133 modalParam : '' ,
3234 modalType : 'String' ,
3335 modalValue : '' ,
@@ -56,20 +58,28 @@ class Config extends TableView {
5658 }
5759
5860 renderExtras ( ) {
59- if ( ! this . state . modalOpen ) {
60- return null ;
61- }
6261 const { currentApp = { } } = this . context ;
63- return (
64- < ConfigDialog
65- onConfirm = { this . saveParam . bind ( this ) }
66- onCancel = { ( ) => this . setState ( { modalOpen : false } ) }
67- param = { this . state . modalParam }
68- type = { this . state . modalType }
69- value = { this . state . modalValue }
70- masterKeyOnly = { this . state . modalMasterKeyOnly }
71- parseServerVersion = { currentApp . serverInfo && currentApp . serverInfo . parseServerVersion } />
72- ) ;
62+ let extras = null ;
63+ if ( this . state . modalOpen ) {
64+ extras = (
65+ < ConfigDialog
66+ onConfirm = { this . saveParam . bind ( this ) }
67+ onCancel = { ( ) => this . setState ( { modalOpen : false } ) }
68+ param = { this . state . modalParam }
69+ type = { this . state . modalType }
70+ value = { this . state . modalValue }
71+ masterKeyOnly = { this . state . modalMasterKeyOnly }
72+ parseServerVersion = { currentApp . serverInfo && currentApp . serverInfo . parseServerVersion } />
73+ ) ;
74+ } else if ( this . state . showDeleteParameterDialog ) {
75+ extras = (
76+ < DeleteParameterDialog
77+ param = { this . state . modalParam }
78+ onCancel = { ( ) => this . setState ( { showDeleteParameterDialog : false } ) }
79+ onConfirm = { this . deleteParam . bind ( this , this . state . modalParam ) } />
80+ ) ;
81+ }
82+ return extras ;
7383 }
7484
7585 renderRow ( data ) {
@@ -119,6 +129,11 @@ class Config extends TableView {
119129 }
120130 openModal ( )
121131 }
132+
133+ let openDeleteParameterDialog = ( ) => this . setState ( {
134+ showDeleteParameterDialog : true ,
135+ modalParam : data . param
136+ } ) ;
122137
123138 return (
124139 < tr key = { data . param } >
@@ -127,7 +142,7 @@ class Config extends TableView {
127142 < td style = { columnStyleLarge } onClick = { openModalValueColumn } > { value } </ td >
128143 < td style = { columnStyleSmall } onClick = { openModal } > { data . masterKeyOnly . toString ( ) } </ td >
129144 < td style = { { textAlign : 'center' } } >
130- < a onClick = { this . deleteParam . bind ( this , data . param ) } >
145+ < a onClick = { openDeleteParameterDialog } >
131146 < Icon width = { 16 } height = { 16 } name = 'trash-solid' fill = '#ff395e' />
132147 </ a >
133148 </ td >
@@ -196,7 +211,9 @@ class Config extends TableView {
196211 this . props . config . dispatch (
197212 ActionTypes . DELETE ,
198213 { param : name }
199- )
214+ ) . then ( ( ) => {
215+ this . setState ( { showDeleteParameterDialog : false } ) ;
216+ } ) ;
200217 }
201218
202219 createParameter ( ) {
0 commit comments