Merge pull request #19413 from owncloud/share-nopermission-link
Still show share link when recipient but no share permission
This commit is contained in:
commit
851390a69a
|
@ -103,11 +103,20 @@
|
||||||
name: 'Share',
|
name: 'Share',
|
||||||
displayName: '',
|
displayName: '',
|
||||||
mime: 'all',
|
mime: 'all',
|
||||||
permissions: OC.PERMISSION_SHARE,
|
permissions: OC.PERMISSION_ALL,
|
||||||
icon: OC.imagePath('core', 'actions/share'),
|
icon: OC.imagePath('core', 'actions/share'),
|
||||||
type: OCA.Files.FileActions.TYPE_INLINE,
|
type: OCA.Files.FileActions.TYPE_INLINE,
|
||||||
actionHandler: function(fileName) {
|
actionHandler: function(fileName) {
|
||||||
fileList.showDetailsView(fileName, 'shareTabView');
|
fileList.showDetailsView(fileName, 'shareTabView');
|
||||||
|
},
|
||||||
|
render: function(actionSpec, isDefault, context) {
|
||||||
|
var permissions = parseInt(context.$file.attr('data-permissions'), 10);
|
||||||
|
// if no share permissions but share owner exists, still show the link
|
||||||
|
if ((permissions & OC.PERMISSION_SHARE) !== 0 || context.$file.attr('data-share-owner')) {
|
||||||
|
return fileActions._defaultRenderAction.call(fileActions, actionSpec, isDefault, context);
|
||||||
|
}
|
||||||
|
// don't render anything
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -157,26 +166,7 @@
|
||||||
// if the statuses are loaded already, use them for the icon
|
// if the statuses are loaded already, use them for the icon
|
||||||
// (needed when scrolling to the next page)
|
// (needed when scrolling to the next page)
|
||||||
if (hasUserShares || hasLinkShare || $tr.attr('data-share-recipients') || $tr.attr('data-share-owner')) {
|
if (hasUserShares || hasLinkShare || $tr.attr('data-share-recipients') || $tr.attr('data-share-owner')) {
|
||||||
var permissions = $tr.data('permissions');
|
|
||||||
OC.Share.markFileAsShared($tr, true, hasLinkShare);
|
OC.Share.markFileAsShared($tr, true, hasLinkShare);
|
||||||
if ((permissions & OC.PERMISSION_SHARE) === 0 && $tr.attr('data-share-owner')) {
|
|
||||||
// if no share action exists because the admin disabled sharing for this user
|
|
||||||
// we create a share notification action to inform the user about files
|
|
||||||
// shared with him otherwise we just update the existing share action.
|
|
||||||
// TODO: make this work like/with OC.Share.markFileAsShared()
|
|
||||||
$tr.find('.fileactions .action-share-notification').remove();
|
|
||||||
var shareNotification = '<a class="action action-share-notification permanent"' +
|
|
||||||
' data-action="Share-Notification" href="#" original-title="">' +
|
|
||||||
' <img class="svg" src="' + OC.imagePath('core', 'actions/share') + '"></img>';
|
|
||||||
$tr.find('.fileactions').append(function() {
|
|
||||||
var shareBy = escapeHTML($tr.attr('data-share-owner'));
|
|
||||||
var $result = $(shareNotification + '<span> ' + shareBy + '</span></span>');
|
|
||||||
$result.on('click', function() {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return $result;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -179,7 +179,7 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
expect(OC.basename(getImageUrl($tr.find('.filename .thumbnail')))).toEqual('folder-shared.svg');
|
expect(OC.basename(getImageUrl($tr.find('.filename .thumbnail')))).toEqual('folder-shared.svg');
|
||||||
expect($action.find('img').length).toEqual(1);
|
expect($action.find('img').length).toEqual(1);
|
||||||
});
|
});
|
||||||
it('shows static share text when file shared with user that has no share permission', function() {
|
it('shows share action when shared with user who has no share permission', function() {
|
||||||
var $action, $tr;
|
var $action, $tr;
|
||||||
fileList.setFiles([{
|
fileList.setFiles([{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -193,14 +193,9 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
shareOwner: 'User One'
|
shareOwner: 'User One'
|
||||||
}]);
|
}]);
|
||||||
$tr = fileList.$el.find('tbody tr:first');
|
$tr = fileList.$el.find('tbody tr:first');
|
||||||
expect($tr.find('.action-share').length).toEqual(0);
|
expect($tr.find('.action-share').length).toEqual(1);
|
||||||
$action = $tr.find('.action-share-notification');
|
|
||||||
expect($action.find('>span').text().trim()).toEqual('User One');
|
|
||||||
expect(OC.basename($action.find('img').attr('src'))).toEqual('share.svg');
|
|
||||||
expect(OC.basename(getImageUrl($tr.find('.filename .thumbnail')))).toEqual('folder-shared.svg');
|
|
||||||
expect($action.find('img').length).toEqual(1);
|
|
||||||
});
|
});
|
||||||
it('do not show static share text when share exists but neither permission nor owner is available', function() {
|
it('do not show share action when share exists but neither permission nor owner is available', function() {
|
||||||
var $action, $tr;
|
var $action, $tr;
|
||||||
fileList.setFiles([{
|
fileList.setFiles([{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -214,8 +209,6 @@ describe('OCA.Sharing.Util tests', function() {
|
||||||
}]);
|
}]);
|
||||||
$tr = fileList.$el.find('tbody tr:first');
|
$tr = fileList.$el.find('tbody tr:first');
|
||||||
expect($tr.find('.action-share').length).toEqual(0);
|
expect($tr.find('.action-share').length).toEqual(0);
|
||||||
$action = $tr.find('.action-share-notification');
|
|
||||||
expect($action.length).toEqual(0);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe('Share action', function() {
|
describe('Share action', function() {
|
||||||
|
|
Loading…
Reference in New Issue