From 94e8cd5cacb8ed789c42d263aea0ed7d3a59a3f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 31 Oct 2018 11:23:23 +0100 Subject: [PATCH 1/2] Do not set indeterminate state for file shares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- core/js/sharedialogshareelistview.js | 4 +++- core/js/shareitemmodel.js | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 2627d5fa66256..7026387284d23 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -460,7 +460,9 @@ var $edit = _this.$('#canEdit-' + _this.cid + '-' + sharee.shareId); if($edit.length === 1) { $edit.prop('checked', sharee.editPermissionState === 'checked'); - $edit.prop('indeterminate', sharee.editPermissionState === 'indeterminate'); + if (sharee.isFolder) { + $edit.prop('indeterminate', sharee.editPermissionState === 'indeterminate'); + } } }); this.$('.popovermenu').on('afterHide', function() { diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index c28d85efbf0fa..7d6fdd0a7dee7 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -614,6 +614,12 @@ var hcp = this.hasCreatePermission(shareIndex); var hup = this.hasUpdatePermission(shareIndex); var hdp = this.hasDeletePermission(shareIndex); + if (this.isFile()) { + if (hcp || hup || hdp) { + return 'checked'; + } + return ''; + } if (!hcp && !hup && !hdp) { return ''; } From a83a320e5d86c6c44ca11150262cac4bfbb85356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 31 Oct 2018 12:12:24 +0100 Subject: [PATCH 2/2] Add tests for edit permission state on file shares MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../tests/specs/sharedialogshareelistview.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/core/js/tests/specs/sharedialogshareelistview.js b/core/js/tests/specs/sharedialogshareelistview.js index 8e34225d199de..e51fc2df72d87 100644 --- a/core/js/tests/specs/sharedialogshareelistview.js +++ b/core/js/tests/specs/sharedialogshareelistview.js @@ -90,6 +90,37 @@ describe('OC.Share.ShareDialogShareeListView', function () { }); describe('Sets correct initial checkbox state', function () { + + it('marks edit box as unchecked for file shares without edit permissions', function () { + shareModel.set('shares', [{ + id: 100, + item_source: 123, + permissions: 1, + share_type: OC.Share.SHARE_TYPE_USER, + share_with: 'user1', + share_with_displayname: 'User One', + uid_owner: oc_current_user, + itemType: 'file' + }]); + listView.render(); + expect(listView.$el.find("input[name='edit']").is(':not(:checked)')).toEqual(true); + }); + + it('marks edit box as checked for file shares', function () { + shareModel.set('shares', [{ + id: 100, + item_source: 123, + permissions: 1 | OC.PERMISSION_UPDATE, + share_type: OC.Share.SHARE_TYPE_USER, + share_with: 'user1', + share_with_displayname: 'User One', + uid_owner: oc_current_user, + itemType: 'file' + }]); + listView.render(); + expect(listView.$el.find("input[name='edit']").is(':checked')).toEqual(true); + }); + it('marks edit box as indeterminate when only some permissions are given', function () { shareModel.set('shares', [{ id: 100,