diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-11-09 09:45:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-09 09:45:55 +0100 |
commit | e0aaca17263f15b3c14a1981c056da4040d5d98b (patch) | |
tree | f8fb3474044a4208ae4752e8e4b145ec9c039e2d /apps/files | |
parent | eab2b3b7aee7734c5c1253a1be3896e0ecf7947c (diff) | |
parent | a9540fe99044fd26f5c876438ae83697dbd1fe8e (diff) | |
download | nextcloud-server-e0aaca17263f15b3c14a1981c056da4040d5d98b.tar.gz nextcloud-server-e0aaca17263f15b3c14a1981c056da4040d5d98b.zip |
Merge pull request #7046 from nextcloud/hide-summary-file-actions-when-selected-file-does-not-match
Hide summary file actions when a selected file does not match
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/filelist.js | 20 | ||||
-rw-r--r-- | apps/files/tests/js/filelistSpec.js | 23 |
2 files changed, 43 insertions, 0 deletions
diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 68a450e9130..12caa9da55f 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -2825,11 +2825,31 @@ this.$el.find('#headerName a.name>span:first').text(selection); this.$el.find('#modified a>span:first').text(''); this.$el.find('table').addClass('multiselect'); + this.$el.find('.selectedActions .copy-move').toggleClass('hidden', !this.isSelectedCopiableOrMovable()); + this.$el.find('.selectedActions .download').toggleClass('hidden', !this.isSelectedDownloadable()); this.$el.find('.delete-selected').toggleClass('hidden', !this.isSelectedDeletable()); } }, /** + * Check whether all selected files are copiable or movable + */ + isSelectedCopiableOrMovable: function() { + return _.reduce(this.getSelectedFiles(), function(copiableOrMovable, file) { + return copiableOrMovable && (file.permissions & OC.PERMISSION_UPDATE); + }, true); + }, + + /** + * Check whether all selected files are downloadable + */ + isSelectedDownloadable: function() { + return _.reduce(this.getSelectedFiles(), function(downloadable, file) { + return downloadable && (file.permissions & OC.PERMISSION_READ); + }, true); + }, + + /** * Check whether all selected files are deletable */ isSelectedDeletable: function() { diff --git a/apps/files/tests/js/filelistSpec.js b/apps/files/tests/js/filelistSpec.js index 8bb188e3602..fd011474eb1 100644 --- a/apps/files/tests/js/filelistSpec.js +++ b/apps/files/tests/js/filelistSpec.js @@ -94,6 +94,7 @@ describe('OCA.Files.FileList tests', function() { '<input type="checkbox" id="select_all_files" class="select-all checkbox">' + '<a class="name columntitle" data-sort="name"><span>Name</span><span class="sort-indicator"></span></a>' + '<span id="selectedActionsList" class="selectedActions hidden">' + + '<a href class="copy-move">Move or copy</a>' + '<a href class="download"><img src="actions/download.svg">Download</a>' + '<a href class="delete-selected">Delete</a></span>' + '</th>' + @@ -2024,6 +2025,28 @@ describe('OCA.Files.FileList tests', function() { }); }); describe('Selection overlay', function() { + it('show doesnt show the copy/move action if one or more files are not copiable/movable', function () { + fileList.setFiles(testFiles); + $('#permissions').val(OC.PERMISSION_READ | OC.PERMISSION_UPDATE); + $('.select-all').click(); + expect(fileList.$el.find('.selectedActions .copy-move').hasClass('hidden')).toEqual(false); + testFiles[0].permissions = OC.PERMISSION_READ; + $('.select-all').click(); + fileList.setFiles(testFiles); + $('.select-all').click(); + expect(fileList.$el.find('.selectedActions .copy-move').hasClass('hidden')).toEqual(true); + }); + it('show doesnt show the download action if one or more files are not downloadable', function () { + fileList.setFiles(testFiles); + $('#permissions').val(OC.PERMISSION_READ | OC.PERMISSION_UPDATE); + $('.select-all').click(); + expect(fileList.$el.find('.selectedActions .download').hasClass('hidden')).toEqual(false); + testFiles[0].permissions = OC.PERMISSION_UPDATE; + $('.select-all').click(); + fileList.setFiles(testFiles); + $('.select-all').click(); + expect(fileList.$el.find('.selectedActions .download').hasClass('hidden')).toEqual(true); + }); it('show doesnt show the delete action if one or more files are not deletable', function () { fileList.setFiles(testFiles); $('#permissions').val(OC.PERMISSION_READ | OC.PERMISSION_DELETE); |