diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-03-23 15:56:18 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-23 15:56:18 -0600 |
commit | 71c80433c2921d13c4dc35f5dad7fba2efe00ba5 (patch) | |
tree | 57566c63b2b27c2d20ed8c69a028933f64e3028c /apps/files | |
parent | a5a29ee27a8e93d83f8916f4f0a7857c880e1156 (diff) | |
parent | 40228c0c2b17c800fa5e227b4d2e8d074da82075 (diff) | |
download | nextcloud-server-71c80433c2921d13c4dc35f5dad7fba2efe00ba5.tar.gz nextcloud-server-71c80433c2921d13c4dc35f5dad7fba2efe00ba5.zip |
Merge pull request #4007 from nextcloud/backport-27155
Change showTemporary notifications for closable ones
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/app.js | 3 | ||||
-rw-r--r-- | apps/files/js/file-upload.js | 16 | ||||
-rw-r--r-- | apps/files/js/fileinfomodel.js | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 88 | ||||
-rw-r--r-- | apps/files/js/files.js | 25 | ||||
-rw-r--r-- | apps/files/js/tagsplugin.js | 2 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 2 |
7 files changed, 75 insertions, 63 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js index 17e92de90dd..d46a0b8f9df 100644 --- a/apps/files/js/app.js +++ b/apps/files/js/app.js @@ -54,7 +54,7 @@ var showHidden = $('#showHiddenFiles').val() === "1"; this.$showHiddenFiles.prop('checked', showHidden); if ($('#fileNotFound').val() === "1") { - OC.Notification.showTemporary(t('files', 'File could not be found')); + OC.Notification.show(t('files', 'File could not be found'), {type: 'error'}); } this._filesConfig = new OC.Backbone.Model({ @@ -315,4 +315,3 @@ $(document).ready(function() { OCA.Files.App.initialize(); }); }); - diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 2b28380e0b0..ad4d03a1bdb 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -462,7 +462,7 @@ OC.Uploader.prototype = _.extend({ deferred.resolve(); return; } - OC.Notification.showTemporary(t('files', 'Could not create folder "{dir}"', {dir: fullPath})); + OC.Notification.show(t('files', 'Could not create folder "{dir}"', {dir: fullPath}), {type: 'error'}); deferred.reject(); }); }, function() { @@ -544,7 +544,7 @@ OC.Uploader.prototype = _.extend({ }, showUploadCancelMessage: _.debounce(function() { - OC.Notification.showTemporary(t('files', 'Upload cancelled.'), {timeout: 10}); + OC.Notification.show(t('files', 'Upload cancelled.'), {timeout : 7, type: 'error'}); }, 500), /** * callback for the conflicts dialog @@ -907,19 +907,15 @@ OC.Uploader.prototype = _.extend({ self.showConflict(upload); } else if (status === 404) { // target folder does not exist any more - OC.Notification.showTemporary( - t('files', 'Target folder "{dir}" does not exist any more', {dir: upload.getFullPath()}) - ); + OC.Notification.show(t('files', 'Target folder "{dir}" does not exist any more', {dir: upload.getFullPath()} ), {type: 'error'}); self.cancelUploads(); } else if (status === 507) { // not enough space - OC.Notification.showTemporary( - t('files', 'Not enough free space') - ); + OC.Notification.show(t('files', 'Not enough free space'), {type: 'error'}); self.cancelUploads(); } else { // HTTP connection problem or other error - OC.Notification.showTemporary(data.errorThrown, {timeout: 10}); + OC.Notification.show(data.errorThrown, {type: 'error'}); } if (upload) { @@ -1113,5 +1109,3 @@ OC.Uploader.prototype = _.extend({ return this.fileUploadParam; } }, OC.Backbone.Events); - - diff --git a/apps/files/js/fileinfomodel.js b/apps/files/js/fileinfomodel.js index 9d1eac31940..2205c7e6477 100644 --- a/apps/files/js/fileinfomodel.js +++ b/apps/files/js/fileinfomodel.js @@ -112,7 +112,7 @@ deferred.resolve(status, data); }) .fail(function(status) { - OC.Notification.showTemporary(t('files', 'Could not load info for file "{file}"', {file: self.get('name')})); + OC.Notification.show(t('files', 'Could not load info for file "{file}"', {file: self.get('name')}), {type: 'error'}); deferred.reject(status); }); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 1385fe26771..7e79399bba5 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -1630,7 +1630,7 @@ if (status === 403) { // Go home this.changeDirectory('/'); - OC.Notification.showTemporary(t('files', 'This operation is forbidden')); + OC.Notification.show(t('files', 'This operation is forbidden'), {type: 'error'}); return false; } @@ -1638,8 +1638,8 @@ if (status === 500) { // Go home this.changeDirectory('/'); - OC.Notification.showTemporary( - t('files', 'This directory is unavailable, please check the logs or contact the administrator') + OC.Notification.show(t('files', 'This directory is unavailable, please check the logs or contact the administrator'), + {type: 'error'} ); return false; } @@ -1649,8 +1649,8 @@ if (this.getCurrentDirectory() !== '/') { this.changeDirectory('/'); // TODO: read error message from exception - OC.Notification.showTemporary( - t('files', 'Storage is temporarily not available') + OC.Notification.show(t('files', 'Storage is temporarily not available'), + {type: 'error'} ); } return false; @@ -1963,12 +1963,12 @@ .fail(function(status) { if (status === 412) { // TODO: some day here we should invoke the conflict dialog - OC.Notification.showTemporary( - t('files', 'Could not move "{file}", target exists', {file: fileName}) + OC.Notification.show(t('files', 'Could not move "{file}", target exists', + {file: fileName}), {type: 'error'} ); } else { - OC.Notification.showTemporary( - t('files', 'Could not move "{file}"', {file: fileName}) + OC.Notification.show(t('files', 'Could not move "{file}"', + {file: fileName}), {type: 'error'} ); } }) @@ -2085,31 +2085,28 @@ // TODO: 409 means current folder does not exist, redirect ? if (status === 404) { // source not found, so remove it from the list - OC.Notification.showTemporary( - t( - 'files', - 'Could not rename "{fileName}", it does not exist any more', - {fileName: oldName} - ) + OC.Notification.show(t('files', 'Could not rename "{fileName}", it does not exist any more', + {fileName: oldName}), {timeout: 7, type: 'error'} ); + self.remove(newName, {updateSummary: true}); return; } else if (status === 412) { // target exists - OC.Notification.showTemporary( - t( - 'files', - 'The name "{targetName}" is already used in the folder "{dir}". Please choose a different name.', - { - targetName: newName, - dir: self.getCurrentDirectory() - } - ) + OC.Notification.show( + t('files', 'The name "{targetName}" is already used in the folder "{dir}". Please choose a different name.', + { + targetName: newName, + dir: self.getCurrentDirectory(), + }), + { + type: 'error' + } ); } else { // restore the item to its previous state - OC.Notification.showTemporary( - t('files', 'Could not rename "{fileName}"', {fileName: oldName}) + OC.Notification.show(t('files', 'Could not rename "{fileName}"', + {fileName: oldName}), {type: 'error'} ); } updateInList(oldFileInfo); @@ -2191,16 +2188,20 @@ self.addAndFetchFileInfo(targetPath, '', {scrollTo: true}).then(function(status, data) { deferred.resolve(status, data); }, function() { - OC.Notification.showTemporary(t('files', 'Could not create file "{file}"', {file: name})); + OC.Notification.show(t('files', 'Could not create file "{file}"', + {file: name}), {type: 'error'} + ); }); }) .fail(function(status) { if (status === 412) { - OC.Notification.showTemporary( - t('files', 'Could not create file "{file}" because it already exists', {file: name}) + OC.Notification.show(t('files', 'Could not create file "{file}" because it already exists', + {file: name}), {type: 'error'} ); } else { - OC.Notification.showTemporary(t('files', 'Could not create file "{file}"', {file: name})); + OC.Notification.show(t('files', 'Could not create file "{file}"', + {file: name}), {type: 'error'} + ); } deferred.reject(status); }); @@ -2237,7 +2238,9 @@ self.addAndFetchFileInfo(targetPath, '', {scrollTo:true}).then(function(status, data) { deferred.resolve(status, data); }, function() { - OC.Notification.showTemporary(t('files', 'Could not create folder "{dir}"', {dir: name})); + OC.Notification.show(t('files', 'Could not create folder "{dir}"', + {dir: name}), {type: 'error'} + ); }); }) .fail(function(createStatus) { @@ -2246,20 +2249,22 @@ // add it to the list, for completeness self.addAndFetchFileInfo(targetPath, '', {scrollTo:true}) .done(function(status, data) { - OC.Notification.showTemporary( - t('files', 'Could not create folder "{dir}" because it already exists', {dir: name}) + OC.Notification.show(t('files', 'Could not create folder "{dir}" because it already exists', + {dir: name}), {type: 'error'} ); // still consider a failure deferred.reject(createStatus, data); }) .fail(function() { - OC.Notification.showTemporary( - t('files', 'Could not create folder "{dir}"', {dir: name}) + OC.Notification.show(t('files', 'Could not create folder "{dir}"', + {dir: name}), {type: 'error'} ); deferred.reject(status); }); } else { - OC.Notification.showTemporary(t('files', 'Could not create folder "{dir}"', {dir: name})); + OC.Notification.show(t('files', 'Could not create folder "{dir}"', + {dir: name}), {type: 'error'} + ); deferred.reject(createStatus); } }); @@ -2314,7 +2319,9 @@ deferred.resolve(status, data); }) .fail(function(status) { - OC.Notification.showTemporary(t('files', 'Could not create file "{file}"', {file: name})); + OC.Notification.show(t('files', 'Could not create file "{file}"', + {file: name}), {type: 'error'} + ); deferred.reject(status); }); @@ -2423,9 +2430,8 @@ removeFromList(file); } else { // only reset the spinner for that one file - OC.Notification.showTemporary( - t('files', 'Error deleting file "{fileName}".', {fileName: file}), - {timeout: 10} + OC.Notification.show(t('files', 'Error deleting file "{fileName}".', + {fileName: file}), {type: 'error'} ); var deleteAction = self.findFileEl(file).find('.action.delete'); deleteAction.removeClass('icon-loading-small').addClass('icon-delete'); @@ -2689,7 +2695,7 @@ */ _showPermissionDeniedNotification: function() { var message = t('core', 'You don’t have permission to upload or create files here'); - OC.Notification.showTemporary(message); + OC.Notification.show(message, {type: 'error'}); }, /** diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 5b345a45b67..a30194013e5 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -117,21 +117,34 @@ ownerDisplayName = $('#ownerDisplayName').val(); if (usedSpacePercent > 98) { if (owner !== oc_current_user) { - OC.Notification.showTemporary(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!', - { owner: ownerDisplayName })); + OC.Notification.show(t('files', 'Storage of {owner} is full, files can not be updated or synced anymore!', + {owner: ownerDisplayName}), {type: 'error'} + ); return; } - OC.Notification.show(t('files', 'Your storage is full, files can not be updated or synced anymore!')); + OC.Notification.show(t('files', + 'Your storage is full, files can not be updated or synced anymore!'), + {type : 'error'} + ); return; } if (usedSpacePercent > 90) { if (owner !== oc_current_user) { - OC.Notification.showTemporary(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)', - { usedSpacePercent: usedSpacePercent, owner: ownerDisplayName })); + OC.Notification.show(t('files', 'Storage of {owner} is almost full ({usedSpacePercent}%)', + { + usedSpacePercent: usedSpacePercent, + owner: ownerDisplayName + }), + { + type: 'error' + } + ); return; } OC.Notification.show(t('files', 'Your storage is almost full ({usedSpacePercent}%)', - {usedSpacePercent: usedSpacePercent})); + {usedSpacePercent: usedSpacePercent}), + {type : 'error'} + ); } }, diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 9bb4ba33598..67bd9c667c8 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -233,7 +233,7 @@ if(response.responseJSON && response.responseJSON.message) { message = ': ' + response.responseJSON.message; } - OC.Notification.showTemporary(t('files', 'An error occurred while trying to update the tags') + message); + OC.Notification.show(t('files', 'An error occurred while trying to update the tags' + message), {type: 'error'}); toggleStar($actionEl, isFavorite); }); } diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index f3c04c48cb3..865aa35ac6a 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -68,7 +68,7 @@ describe('OCA.Files.FileList tests', function() { useHTTPS: false }); redirectStub = sinon.stub(OC, 'redirect'); - notificationStub = sinon.stub(OC.Notification, 'showTemporary'); + notificationStub = sinon.stub(OC.Notification, 'show'); // prevent resize algo to mess up breadcrumb order while // testing bcResizeStub = sinon.stub(OCA.Files.BreadCrumb.prototype, '_resize'); |