@ -21,13 +21,8 @@ class RecorderUI {
this . parentSelf . _view . recorderCount . innerText = 0
this . parentSelf . _view . recorderCount . innerText = 0
} )
} )
executionContext . event . register ( 'contextChanged' , ( ) => {
executionContext . event . register ( 'contextChanged' , this . recorder . clearAll . bind ( this . recorder ) )
this . recorder . clearAll ( )
runTabEvent . register ( 'clearInstance' , this . recorder . clearAll . bind ( this . recorder ) )
} )
runTabEvent . register ( 'clearInstance' , ( ) => {
this . recorder . clearAll ( )
} )
}
}
render ( ) {
render ( ) {
@ -50,9 +45,11 @@ class RecorderUI {
var currentFile = this . parentSelf . _deps . config . get ( 'currentFile' )
var currentFile = this . parentSelf . _deps . config . get ( 'currentFile' )
this . parentSelf . _deps . fileManager . fileProviderOf ( currentFile ) . get ( currentFile , ( error , json ) => {
this . parentSelf . _deps . fileManager . fileProviderOf ( currentFile ) . get ( currentFile , ( error , json ) => {
if ( error ) {
if ( error ) {
modalDialogCustom . alert ( 'Invalid Scenario File ' + error )
return modalDialogCustom . alert ( 'Invalid Scenario File ' + error )
} else {
}
if ( currentFile . match ( '.json$' ) ) {
if ( ! currentFile . match ( '.json$' ) ) {
modalDialogCustom . alert ( 'A scenario file is required. Please make sure a scenario file is currently displayed in the editor. The file must be of type JSON. Use the "Save Transactions" Button to generate a new Scenario File.' )
}
try {
try {
var obj = JSON . parse ( json )
var obj = JSON . parse ( json )
var txArray = obj . transactions || [ ]
var txArray = obj . transactions || [ ]
@ -70,10 +67,6 @@ class RecorderUI {
this . parentSelf . _view . instanceContainer . appendChild ( this . parentSelf . _deps . udappUI . renderInstanceFromABI ( abi , address , contractName ) )
this . parentSelf . _view . instanceContainer . appendChild ( this . parentSelf . _deps . udappUI . renderInstanceFromABI ( abi , address , contractName ) )
} )
} )
}
}
} else {
modalDialogCustom . alert ( 'A scenario file is required. Please make sure a scenario file is currently displayed in the editor. The file must be of type JSON. Use the "Save Transactions" Button to generate a new Scenario File.' )
}
}
} )
} )
}
}
@ -83,17 +76,13 @@ class RecorderUI {
var path = fileManager . currentPath ( )
var path = fileManager . currentPath ( )
modalDialogCustom . prompt ( null , 'Transactions will be saved in a file under ' + path , 'scenario.json' , input => {
modalDialogCustom . prompt ( null , 'Transactions will be saved in a file under ' + path , 'scenario.json' , input => {
var fileProvider = fileManager . fileProviderOf ( path )
var fileProvider = fileManager . fileProviderOf ( path )
if ( fileProvider ) {
if ( ! fileProvider ) return
var newFile = path + '/' + input
var newFile = path + '/' + input
helper . createNonClashingName ( newFile , fileProvider , ( error , newFile ) => {
helper . createNonClashingName ( newFile , fileProvider , ( error , newFile ) => {
if ( error ) return modalDialogCustom . alert ( 'Failed to create file. ' + newFile + ' ' + error )
if ( error ) return modalDialogCustom . alert ( 'Failed to create file. ' + newFile + ' ' + error )
if ( ! fileProvider . set ( newFile , txJSON ) ) {
if ( ! fileProvider . set ( newFile , txJSON ) ) return modalDialogCustom . alert ( 'Failed to create file ' + newFile )
modalDialogCustom . alert ( 'Failed to create file ' + newFile )
} else {
fileManager . switchFile ( newFile )
fileManager . switchFile ( newFile )
}
} )
} )
}
} )
} )
}
}