From da48d43e0ae5bfd6e9805574f9c7785aed73d10c Mon Sep 17 00:00:00 2001 From: Bob Gallagher Date: Mon, 3 Apr 2017 18:11:00 -0400 Subject: [PATCH] Bug 242 - delete error not reported - add delete error handler Change-Id: I73225edaeba18149dbc2fa36cf566d8fa4f60359 Signed-off-by: Bob Gallagher --- .../filemanager/FileManagerSource.js | 20 ++++++++++++++----- .../src/src/stores/ComposerAppStore.js | 10 ++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js b/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js index 4b36277ae..1f0fd80f9 100644 --- a/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js +++ b/skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js @@ -100,16 +100,26 @@ const FileManagerSource = { beforeSend: Utils.addAuthorizationStub, url: 'api/file-manager?api_server=' + utils.getSearchParams(window.location).api_server +'&package_type=' + type + '&package_id=' + id + '&package_path=' + path , success: function(data) { - resolve({ - data: data, - path: path - }); + if (data.output.status == 'True') { + resolve({ + data: data, + path: path + }); + } else { + reject({ + data: data, + path: path + }) + } }, error: function(error) { if (typeof error == 'string') { error = JSON.parse(error); } - reject(error); + reject({ + path: path, + data: error + }); } }).fail(function(xhr){ //Authentication and the handling of fail states should be wrapped up into a connection class. diff --git a/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js b/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js index c07fffd64..c677a44a6 100644 --- a/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js +++ b/skyquake/plugins/composer/src/src/stores/ComposerAppStore.js @@ -172,6 +172,7 @@ class ComposerAppStore { addFileSuccess: FileManagerActions.addFileSuccess, deletePackageFile: FileManagerActions.deletePackageFile, deleteFileSuccess: FileManagerActions.deleteFileSuccess, + deleteFileError: FileManagerActions.deleteFileError, closeFileManagerSockets: FileManagerActions.closeFileManagerSockets, openFileManagerSockets: FileManagerActions.openFileManagerSockets, openDownloadMonitoringSocketSuccess: FileManagerActions.openDownloadMonitoringSocketSuccess, @@ -681,6 +682,15 @@ class ComposerAppStore { files: files }) } + deleteFileError = (error) => { + const filepath = error.path; + const message = error.data && error.data.output ? ' (' + error.data.output['error-trace'] + ')' : ' (server error)'; + console.log('Unable to delete', filepath, 'Error:', message); + ComposerAppActions.showError.defer({ + errorMessage: 'Unable to delete ' + filepath + message + '. ' + }); + } + newPathNameUpdated = (event) => { const value = event.target.value; this.setState({ -- 2.25.1