@@ -7,7 +7,8 @@ import Box from '@material-ui/core/Box';
77import { withStyles } from '@material-ui/core/styles' ;
88
99import { ActionDialog , Tooltip } from 'netpyne/components' ;
10- import { NETPYNE_COMMANDS } from '../../../constants' ;
10+ import { NETPYNE_COMMANDS , MODEL_STATE } from '../../../constants' ;
11+ import { PYTHON_CALL } from '../../../redux/actions/general' ;
1112import FileBrowser from '../../general/FileBrowser' ;
1213import Checkbox from '../../general/Checkbox' ;
1314
@@ -179,8 +180,21 @@ class ImportExportHLS extends React.Component {
179180 }
180181 }
181182
183+ handleConfirmation ( command , args ) {
184+ this . props . openConfirmationDialog ( {
185+ title : 'Warning' ,
186+ message : 'A NetPyNE model has already been instantiated or simulated.'
187+ + ' Continuing with this import action will use the old value of netParams and simConfig for the new model. Do you want to continue?' ,
188+ onConfirm : {
189+ type : PYTHON_CALL ,
190+ cmd : command ,
191+ args,
192+ } ,
193+ } ) ;
194+ }
195+
182196 render ( ) {
183- const { classes } = this . props ;
197+ const { classes, modelState } = this . props ;
184198 switch ( this . props . mode ) {
185199 case 'IMPORT' :
186200 var content = (
@@ -309,18 +323,34 @@ class ImportExportHLS extends React.Component {
309323 var title = 'Export as Python script' ;
310324 break ;
311325 }
326+
312327 return (
313- < ActionDialog
314- command = { command }
315- message = { message }
316- buttonLabel = { buttonLabel }
317- args = { this . state }
318- title = { title }
319- isFormValid = { this . isFormValid }
320- { ...this . props }
321- >
322- { content }
323- </ ActionDialog >
328+ this . props . mode === 'IMPORT' ? (
329+ < ActionDialog
330+ command = { command }
331+ message = { message }
332+ buttonLabel = { buttonLabel }
333+ args = { this . state }
334+ title = { title }
335+ isFormValid = { this . isFormValid }
336+ callback = { modelState === MODEL_STATE . INSTANTIATED || modelState === MODEL_STATE . SIMULATED ? ( command , args ) => { this . handleConfirmation ( command , args ) ; } : undefined }
337+ { ...this . props }
338+ >
339+ { content }
340+ </ ActionDialog >
341+ ) : (
342+ < ActionDialog
343+ command = { command }
344+ message = { message }
345+ buttonLabel = { buttonLabel }
346+ args = { this . state }
347+ title = { title }
348+ isFormValid = { this . isFormValid }
349+ { ...this . props }
350+ >
351+ { content }
352+ </ ActionDialog >
353+ )
324354 ) ;
325355 }
326356}
0 commit comments