Disable sidebar on deleted share

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2018-06-20 20:32:19 +02:00
parent 3b835d8076
commit d86c1e9503
No known key found for this signature in database
GPG Key ID: 60C25B8C072916CF
4 changed files with 23 additions and 9 deletions

View File

@ -194,11 +194,11 @@ OCA.Sharing.App = {
actionHandler: function(fileName, context) {
var shareId = context.$file.data('shareId');
$.post(OC.linkToOCS('apps/files_sharing/api/v1/deletedshares', 2) + shareId)
.success(function(result) {
context.fileList.remove(context.fileInfoModel.attributes.name);
}).fail(function() {
OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to restore the share.'));
});
.success(function(result) {
context.fileList.remove(context.fileInfoModel.attributes.name);
}).fail(function() {
OC.Notification.showTemporary(t('files_sharing', 'Something happened. Unable to restore the share.'));
});
}
});
return fileActions;

View File

@ -42,6 +42,12 @@
var fileActions = fileList.fileActions;
var oldCreateRow = fileList._createRow;
fileList._createRow = function(fileData) {
if (fileData.permissions === 0) {
// no permission, disabling sidebar
delete fileActions.actions.all.Details;
}
var tr = oldCreateRow.apply(this, arguments);
var sharePermissions = OCA.Sharing.Util.getSharePermissions(fileData);
tr.attr('data-share-permissions', sharePermissions);
@ -158,11 +164,15 @@
permissions: OC.PERMISSION_ALL,
iconClass: 'icon-shared',
type: OCA.Files.FileActions.TYPE_INLINE,
actionHandler: function(fileName) {
fileList.showDetailsView(fileName, 'shareTabView');
actionHandler: function(fileName, context) {
// do not open sidebar if no permission on the file
var permissions = parseInt(context.$file.data('share-permissions'), 10);
if (permissions > 0) {
fileList.showDetailsView(fileName, 'shareTabView');
}
},
render: function(actionSpec, isDefault, context) {
var permissions = parseInt(context.$file.attr('data-permissions'), 10);
var permissions = parseInt(context.$file.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);

View File

@ -82,6 +82,10 @@
var permission = parseInt($tr.attr('data-permissions')) | OC.PERMISSION_DELETE;
$tr.attr('data-permissions', permission);
}
if (this._showDeleted) {
var permission = fileData.permissions;
$tr.attr('data-share-permissions', permission);
}
// add row with expiration date for link only shares - influenced by _createRow of filelist
if (this._linksOnly) {

View File

@ -79,7 +79,7 @@ class DeletedShareAPIController extends OCSController {
'share_type' => $share->getShareType(),
'uid_owner' => $share->getSharedBy(),
'displayname_owner' => $this->userManager->get($share->getSharedBy())->getDisplayName(),
'permissions' => $share->getPermissions(),
'permissions' => 0,
'stime' => $share->getShareTime()->getTimestamp(),
'parent' => null,
'expiration' => null,