diff options
author | Vincent Petry <pvince81@owncloud.com> | 2016-08-17 12:25:58 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2017-04-26 13:38:12 +0200 |
commit | 17a31a51c62e36500f59b3c2d385ab79258f6bb6 (patch) | |
tree | d73fc6bb6a326cc34832c963bcda26e7417f35e1 /core | |
parent | 5b5c3a1773dab4960d41aafc4150859a308311b7 (diff) | |
download | nextcloud-server-17a31a51c62e36500f59b3c2d385ab79258f6bb6.tar.gz nextcloud-server-17a31a51c62e36500f59b3c2d385ab79258f6bb6.zip |
Fix share indicator handling
Properly update the fileInfoModel with the updated share types, which
also updates the file list row indicator properly
Diffstat (limited to 'core')
-rw-r--r-- | core/js/shareitemmodel.js | 14 | ||||
-rw-r--r-- | core/js/tests/specs/shareitemmodelSpec.js | 61 |
2 files changed, 75 insertions, 0 deletions
diff --git a/core/js/shareitemmodel.js b/core/js/shareitemmodel.js index 41f9eb5e0aa..4118a8a0188 100644 --- a/core/js/shareitemmodel.js +++ b/core/js/shareitemmodel.js @@ -841,6 +841,20 @@ } } return time; + }, + + /** + * Returns a list of share types from the existing shares. + * + * @return {Array.<int>} array of share types + */ + getShareTypes: function() { + var result; + result = _.pluck(this.getSharesWithCurrentItem(), 'share_type'); + if (this.hasLinkShare()) { + result.push(OC.Share.SHARE_TYPE_LINK); + } + return _.uniq(result); } }); diff --git a/core/js/tests/specs/shareitemmodelSpec.js b/core/js/tests/specs/shareitemmodelSpec.js index 771a9263709..3b17051508e 100644 --- a/core/js/tests/specs/shareitemmodelSpec.js +++ b/core/js/tests/specs/shareitemmodelSpec.js @@ -924,5 +924,66 @@ describe('OC.Share.ShareItemModel', function() { expect(errorStub.lastCall.args[1]).toEqual('Some error message'); }); }); + + describe('getShareTypes', function() { + + var dataProvider = [ + [ + ], + [ + OC.Share.SHARE_TYPE_USER, + OC.Share.SHARE_TYPE_USER, + ], + [ + OC.Share.SHARE_TYPE_USER, + OC.Share.SHARE_TYPE_GROUP, + OC.Share.SHARE_TYPE_LINK, + OC.Share.SHARE_TYPE_REMOTE + ], + [ + OC.Share.SHARE_TYPE_USER, + OC.Share.SHARE_TYPE_GROUP, + OC.Share.SHARE_TYPE_GROUP, + OC.Share.SHARE_TYPE_LINK, + OC.Share.SHARE_TYPE_LINK, + OC.Share.SHARE_TYPE_REMOTE, + OC.Share.SHARE_TYPE_REMOTE, + OC.Share.SHARE_TYPE_REMOTE + ], + [ + OC.Share.SHARE_TYPE_LINK, + OC.Share.SHARE_TYPE_LINK, + OC.Share.SHARE_TYPE_USER + ] + ]; + + _.each(dataProvider, function testCase(shareTypes, i) { + it('returns set of share types for case ' + i, function() { + /* jshint camelcase: false */ + fetchReshareDeferred.resolve(makeOcsResponse([])); + + var id = 100; + var shares = _.map(shareTypes, function(shareType) { + return { + id: id++, + item_source: 123, + permissions: 31, + share_type: shareType, + uid_owner: 'root' + }; + }); + + var expectedResult = _.uniq(shareTypes).sort(); + + fetchSharesDeferred.resolve(makeOcsResponse(shares)); + + OC.currentUser = 'root'; + + model.fetch(); + + expect(model.getShareTypes().sort()).toEqual(expectedResult); + }); + }); + }); }); |