summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-21 11:15:00 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-21 11:15:00 +0100
commit8852fdaee3ee9b6bb52cbafcf358199321eb2307 (patch)
tree57816c31c2b480d42f04b05a2f49ff0dc391585d /apps/files_sharing
parente983bd7db074878d2418bdfcc22daf4689d9ec54 (diff)
parent6e6e002280587dea3b8ba5ae55f0514295f29108 (diff)
downloadnextcloud-server-8852fdaee3ee9b6bb52cbafcf358199321eb2307.tar.gz
nextcloud-server-8852fdaee3ee9b6bb52cbafcf358199321eb2307.zip
Merge pull request #22789 from owncloud/dav-sharesproperty
Add webdav property for share info in PROPFIND response
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/js/share.js57
-rw-r--r--apps/files_sharing/js/sharedfilelist.js10
-rw-r--r--apps/files_sharing/tests/js/shareSpec.js33
3 files changed, 55 insertions, 45 deletions
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 2711b2392e9..5ec7824758f 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -60,6 +60,9 @@
if (fileData.recipientsDisplayName) {
tr.attr('data-share-recipients', fileData.recipientsDisplayName);
}
+ if (fileData.shareTypes) {
+ tr.attr('data-share-types', fileData.shareTypes.join(','));
+ }
return tr;
};
@@ -77,6 +80,7 @@
fileList._getWebdavProperties = function() {
var props = oldGetWebdavProperties.apply(this, arguments);
props.push('{' + NS_OC + '}owner-display-name');
+ props.push('{' + NS_OC + '}share-types');
return props;
};
@@ -88,40 +92,45 @@
if (permissionsProp && permissionsProp.indexOf('S') >= 0) {
data.shareOwner = props['{' + NS_OC + '}owner-display-name'];
}
+
+ var shareTypesProp = props['{' + NS_OC + '}share-types'];
+ if (shareTypesProp) {
+ data.shareTypes = _.chain(shareTypesProp).filter(function(xmlvalue) {
+ return (xmlvalue.namespaceURI === NS_OC && xmlvalue.nodeName.split(':')[1] === 'share-type');
+ }).map(function(xmlvalue) {
+ return parseInt(xmlvalue.textContent || xmlvalue.text, 10);
+ }).value();
+ }
+
return data;
});
// use delegate to catch the case with multiple file lists
fileList.$el.on('fileActionsReady', function(ev){
- var fileList = ev.fileList;
var $files = ev.$files;
- function updateIcons($files) {
- if (!$files) {
- // if none specified, update all
- $files = fileList.$fileList.find('tr');
+ _.each($files, function(file) {
+ var $tr = $(file);
+ var shareTypes = $tr.attr('data-share-types');
+ if (shareTypes) {
+ var hasLink = false;
+ var hasShares = false;
+ _.each(shareTypes.split(',') || [], function(shareType) {
+ shareType = parseInt(shareType, 10);
+ if (shareType === OC.Share.SHARE_TYPE_LINK) {
+ hasLink = true;
+ } else if (shareType === OC.Share.SHARE_TYPE_USER) {
+ hasShares = true;
+ } else if (shareType === OC.Share.SHARE_TYPE_GROUP) {
+ hasShares = true;
+ }
+ });
+ OCA.Sharing.Util._updateFileActionIcon($tr, hasShares, hasLink);
}
- _.each($files, function(file) {
- var $tr = $(file);
- var shareStatus = OC.Share.statuses[$tr.data('id')];
- OCA.Sharing.Util._updateFileActionIcon($tr, !!shareStatus, shareStatus && shareStatus.link);
- });
- }
-
- if (!OCA.Sharing.sharesLoaded){
- OC.Share.loadIcons('file', fileList, function() {
- // since we don't know which files are affected, just refresh them all
- updateIcons();
- });
- // assume that we got all shares, so switching directories
- // will not invalidate that list
- OCA.Sharing.sharesLoaded = true;
- }
- else{
- updateIcons($files);
- }
+ });
});
+
fileList.$el.on('changeDirectory', function() {
OCA.Sharing.sharesLoaded = false;
});
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index a799d4a94c2..da0f957ed99 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -286,6 +286,8 @@
// using a hash to make them unique,
// this is only a list to be displayed
data.recipients = {};
+ // share types
+ data.shareTypes = {};
// counter is cheaper than calling _.keys().length
data.recipientsCount = 0;
data.mtime = file.share.stime;
@@ -308,6 +310,8 @@
data.recipientsCount++;
}
+ data.shareTypes[file.share.type] = true;
+
delete file.share;
return memo;
}, {})
@@ -324,6 +328,12 @@
data.recipientsCount
);
delete data.recipientsCount;
+ if (self._sharedWithUser) {
+ // only for outgoing shres
+ delete data.shareTypes;
+ } else {
+ data.shareTypes = _.keys(data.shareTypes);
+ }
})
// Finish the chain by getting the result
.value();
diff --git a/apps/files_sharing/tests/js/shareSpec.js b/apps/files_sharing/tests/js/shareSpec.js
index 7607ada50ba..c488bd94fab 100644
--- a/apps/files_sharing/tests/js/shareSpec.js
+++ b/apps/files_sharing/tests/js/shareSpec.js
@@ -53,35 +53,21 @@ describe('OCA.Sharing.Util tests', function() {
permissions: OC.PERMISSION_ALL,
etag: 'abc',
shareOwner: 'User One',
- isShareMountPoint: false
+ isShareMountPoint: false,
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}];
-
- OCA.Sharing.sharesLoaded = true;
- OC.Share.statuses = {
- 1: {link: false, path: '/subdir'}
- };
});
afterEach(function() {
delete OCA.Sharing.sharesLoaded;
delete OC.Share.droppedDown;
fileList.destroy();
fileList = null;
- OC.Share.statuses = {};
- OC.Share.currentShares = {};
});
describe('Sharing data in table row', function() {
// TODO: test data-permissions, data-share-owner, etc
});
describe('Share action icon', function() {
- beforeEach(function() {
- OC.Share.statuses = {1: {link: false, path: '/subdir'}};
- OCA.Sharing.sharesLoaded = true;
- });
- afterEach(function() {
- OC.Share.statuses = {};
- OCA.Sharing.sharesLoaded = false;
- });
it('do not shows share text when not shared', function() {
var $action, $tr;
OC.Share.statuses = {};
@@ -93,7 +79,8 @@ describe('OCA.Sharing.Util tests', function() {
mimetype: 'httpd/unix-directory',
size: 12,
permissions: OC.PERMISSION_ALL,
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: []
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -111,7 +98,8 @@ describe('OCA.Sharing.Util tests', function() {
mimetype: 'text/plain',
size: 12,
permissions: OC.PERMISSION_ALL,
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -131,7 +119,8 @@ describe('OCA.Sharing.Util tests', function() {
mimetype: 'text/plain',
size: 12,
permissions: OC.PERMISSION_ALL,
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_LINK]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -151,7 +140,8 @@ describe('OCA.Sharing.Util tests', function() {
size: 12,
permissions: OC.PERMISSION_ALL,
shareOwner: 'User One',
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');
@@ -171,7 +161,8 @@ describe('OCA.Sharing.Util tests', function() {
size: 12,
permissions: OC.PERMISSION_ALL,
recipientsDisplayName: 'User One, User Two',
- etag: 'abc'
+ etag: 'abc',
+ shareTypes: [OC.Share.SHARE_TYPE_USER]
}]);
$tr = fileList.$el.find('tbody tr:first');
$action = $tr.find('.action-share');