summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJan-Christoph Borchardt <hey@jancborchardt.net>2015-04-24 11:57:47 +0200
committerJan-Christoph Borchardt <hey@jancborchardt.net>2015-04-24 11:57:47 +0200
commit5b998e13d7b54de9d9c9f17205720f280b8e72cc (patch)
tree8d7957d5cc2f66e07493b7c5fec453b74184a50e /apps
parent33d197db29bcaded7b22c0d81e4e2f92004e9398 (diff)
parentf4bc852db3376f5e602c1970fe76b8698e26f32e (diff)
downloadnextcloud-server-5b998e13d7b54de9d9c9f17205720f280b8e72cc.tar.gz
nextcloud-server-5b998e13d7b54de9d9c9f17205720f280b8e72cc.zip
Merge pull request #15835 from owncloud/delete-permission-icon
Show hint if there is no delete permission
Diffstat (limited to 'apps')
-rw-r--r--apps/files/css/files.css4
-rw-r--r--apps/files/js/fileactions.js15
-rw-r--r--apps/files/tests/js/fileactionsSpec.js42
-rw-r--r--apps/files_external/tests/js/mountsfilelistSpec.js2
4 files changed, 59 insertions, 4 deletions
diff --git a/apps/files/css/files.css b/apps/files/css/files.css
index 9e55e428057..e4bf791761d 100644
--- a/apps/files/css/files.css
+++ b/apps/files/css/files.css
@@ -581,7 +581,9 @@ a.action>img {
#fileList tr:hover a.action,
#fileList a.action.permanent,
#fileList tr:focus a.action,
-#fileList a.action.permanent
+#fileList a.action.permanent,
+#fileList tr:hover a.action.no-permission:hover,
+#fileList tr:focus a.action.no-permission:focus
/*#fileList .name:focus .action*/ {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
filter: alpha(opacity=50);
diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js
index b335f1f6432..1956fda0077 100644
--- a/apps/files/js/fileactions.js
+++ b/apps/files/js/fileactions.js
@@ -288,9 +288,15 @@
} else if (mountType === 'shared-root') {
deleteTitle = t('files', 'Unshare');
}
+ var cssClasses = 'action delete icon-delete';
+ if((context.$file.data('permissions') & OC.PERMISSION_DELETE) === 0) {
+ // add css class no-permission to delete icon
+ cssClasses += ' no-permission';
+ deleteTitle = t('files', 'No permission to delete');
+ }
var $actionLink = $('<a href="#" original-title="' +
escapeHTML(deleteTitle) +
- '" class="action delete icon-delete">' +
+ '" class="' +cssClasses + '">' +
'<span class="hidden-visually">' + escapeHTML(deleteTitle) + '</span>' +
'</a>'
);
@@ -426,12 +432,17 @@
name: 'Delete',
displayName: '',
mime: 'all',
- permissions: OC.PERMISSION_DELETE,
+ // permission is READ because we show a hint instead if there is no permission
+ permissions: OC.PERMISSION_READ,
icon: function() {
return OC.imagePath('core', 'actions/delete');
},
render: _.bind(this._renderDeleteAction, this),
actionHandler: function(fileName, context) {
+ // if there is no permission to delete do nothing
+ if((context.$file.data('permissions') & OC.PERMISSION_DELETE) === 0) {
+ return;
+ }
context.fileList.do_delete(fileName, context.dir);
$('.tipsy').remove();
}
diff --git a/apps/files/tests/js/fileactionsSpec.js b/apps/files/tests/js/fileactionsSpec.js
index 828aec9b6b9..53fa8707674 100644
--- a/apps/files/tests/js/fileactionsSpec.js
+++ b/apps/files/tests/js/fileactionsSpec.js
@@ -157,6 +157,48 @@ describe('OCA.Files.FileActions tests', function() {
expect(deleteStub.getCall(0).args[1]).toEqual('/somepath/dir');
deleteStub.restore();
});
+ it('shows delete hint when no permission to delete', function() {
+ var deleteStub = sinon.stub(fileList, 'do_delete');
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ path: '/somepath/dir',
+ mimetype: 'text/plain',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456',
+ permissions: OC.PERMISSION_READ
+ };
+ var $tr = fileList.add(fileData);
+ FileActions.display($tr.find('td.filename'), true, fileList);
+
+ var $action = $tr.find('.action.delete');
+
+ expect($action.hasClass('no-permission')).toEqual(true);
+ deleteStub.restore();
+ });
+ it('shows delete hint not when permission to delete', function() {
+ var deleteStub = sinon.stub(fileList, 'do_delete');
+ var fileData = {
+ id: 18,
+ type: 'file',
+ name: 'testName.txt',
+ path: '/somepath/dir',
+ mimetype: 'text/plain',
+ size: '1234',
+ etag: 'a01234c',
+ mtime: '123456',
+ permissions: OC.PERMISSION_DELETE
+ };
+ var $tr = fileList.add(fileData);
+ FileActions.display($tr.find('td.filename'), true, fileList);
+
+ var $action = $tr.find('.action.delete');
+
+ expect($action.hasClass('no-permission')).toEqual(false);
+ deleteStub.restore();
+ });
it('passes context to action handler', function() {
var actionStub = sinon.stub();
var fileData = {
diff --git a/apps/files_external/tests/js/mountsfilelistSpec.js b/apps/files_external/tests/js/mountsfilelistSpec.js
index a4e4fec1177..c7ea819d2fe 100644
--- a/apps/files_external/tests/js/mountsfilelistSpec.js
+++ b/apps/files_external/tests/js/mountsfilelistSpec.js
@@ -128,7 +128,7 @@ describe('OCA.External.FileList tests', function() {
'?dir=/another%20mount%20points/sftp%20mount'
);
expect($tr.find('.nametext').text().trim()).toEqual('sftp mount');
- expect($tr.find('.column-scope').text().trim()).toEqual('System');
+ expect($tr.find('.column-scope > span').text().trim()).toEqual('System');
expect($tr.find('.column-backend').text().trim()).toEqual('SFTP');
$tr = $rows.eq(1);