Bug 242 - delete error not reported
authorBob Gallagher <bob.gallagher@riftio.com>
Mon, 3 Apr 2017 22:11:00 +0000 (18:11 -0400)
committerBob Gallagher <bob.gallagher@riftio.com>
Mon, 3 Apr 2017 22:15:49 +0000 (18:15 -0400)
- add delete error handler

Change-Id: I73225edaeba18149dbc2fa36cf566d8fa4f60359
Signed-off-by: Bob Gallagher <bob.gallagher@riftio.com>
skyquake/plugins/composer/src/src/components/filemanager/FileManagerSource.js
skyquake/plugins/composer/src/src/stores/ComposerAppStore.js

index 4b36277..1f0fd80 100644 (file)
@@ -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.
index c07fffd..c677a44 100644 (file)
@@ -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({