Merge pull request #4007 from nextcloud/backport-27155

Change showTemporary notifications for closable ones
This commit is contained in:
Morris Jobke 2017-03-23 15:56:18 -06:00 committed by GitHub
commit 71c80433c2
12 changed files with 98 additions and 78 deletions

View File

@ -482,9 +482,9 @@
$form.find('.message').prop('disabled', false);
if(!_.isUndefined(commentId)) {
OC.Notification.showTemporary(t('comments', 'Error occurred while updating comment with id {id}', {id: commentId}));
OC.Notification.show(t('comments', 'Error occurred while updating comment with id {id}', {id: commentId}), {type: 'error'});
} else {
OC.Notification.showTemporary(t('comments', 'Error occurred while posting comment'));
OC.Notification.show(t('comments', 'Error occurred while posting comment'), {type: 'error'});
}
},

View File

@ -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();
});
});

View File

@ -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);

View File

@ -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);
});

View File

@ -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 dont have permission to upload or create files here');
OC.Notification.showTemporary(message);
OC.Notification.show(message, {type: 'error'});
},
/**

View File

@ -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'}
);
}
},

View File

@ -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);
});
}

View File

@ -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');

View File

@ -157,7 +157,9 @@ OCA.External.StatusManager = {
},
error: function (jqxhr, state, error) {
self.mountPointList = [];
OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the list of external mount points: {type}', {type: error}));
OC.Notification.show(t('files_external', 'Couldn\'t get the list of external mount points: {type}',
{type: error}), {type: 'error'}
);
},
complete: function () {
self.isGetMountPointListRunning = false;
@ -265,7 +267,9 @@ OCA.External.StatusManager = {
// check if we have a list first
if (list === undefined && !self.emptyWarningShown) {
self.emptyWarningShown = true;
OC.Notification.showTemporary(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server'));
OC.Notification.show(t('files_external', 'Couldn\'t get the list of Windows network drive mount points: empty response from the server'),
{type: 'error'}
);
return;
}
if (list && list.length > 0) {
@ -295,7 +299,9 @@ OCA.External.StatusManager = {
}
});
if (showNotification) {
OC.Notification.showTemporary(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information'));
OC.Notification.show(t('files_external', 'Some of the configured external mount points are not connected. Please click on the red row(s) for more information'),
{type: 'error'}
);
}
}
});
@ -414,14 +420,14 @@ OCA.External.StatusManager = {
}
},
success: function (data) {
OC.Notification.showTemporary(t('files_external', 'Credentials saved'));
OC.Notification.show(t('files_external', 'Credentials saved'), {type: 'error'});
dialog.ocdialog('close');
/* Trigger status check again */
OCA.External.StatusManager.recheckConnectivityForMount([OC.basename(data.mountPoint)], true);
},
error: function () {
$('.oc-dialog-close').show();
OC.Notification.showTemporary(t('files_external', 'Credentials saving failed'));
OC.Notification.show(t('files_external', 'Credentials saving failed'), {type: 'error'});
}
});
return false;

View File

@ -133,11 +133,14 @@
fileInfoModel.trigger('busy', fileInfoModel, false);
self.$el.find('.versions').removeClass('hidden');
self._toggleLoading(false);
OC.Notification.showTemporary(
t('files_version', 'Failed to revert {file} to revision {timestamp}.', {
OC.Notification.show(t('files_version', 'Failed to revert {file} to revision {timestamp}.',
{
file: versionModel.getFullPath(),
timestamp: OC.Util.formatDate(versionModel.get('timestamp') * 1000)
})
}),
{
type: 'error'
}
);
}
});

View File

@ -224,7 +224,7 @@ describe('OCA.Versions.VersionsTabView', function() {
expect(changes.etag).toBeDefined();
});
it('shows notification on revert error', function() {
var notificationStub = sinon.stub(OC.Notification, 'showTemporary');
var notificationStub = sinon.stub(OC.Notification, 'show');
tabView.$el.find('.revertVersion').eq(1).click();

View File

@ -17,11 +17,10 @@ $(document).ready(function(){
var text = t('core', '{version} is available. Get more information on how to update.', {version: oc_updateState.updateVersion}),
element = $('<a>').attr('href', oc_updateState.updateLink).attr('target','_blank').text(text);
OC.Notification.showTemporary(
element,
OC.Notification.show(element,
{
isHTML: true
isHTML: true,
type: 'error'
}
);
});