Skip to content

Commit e2a4dc8

Browse files
authored
Merge pull request #28209 from nextcloud/backport/27751/stable22
2 parents 2663b10 + f60ea8a commit e2a4dc8

14 files changed

Lines changed: 816 additions & 174 deletions

File tree

apps/federatedfilesharing/lib/OCM/CloudFederationProviderFiles.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
use OCP\Share\IManager;
6161
use OCP\Share\IShare;
6262
use OCP\Util;
63+
use Psr\Log\LoggerInterface;
6364

6465
class CloudFederationProviderFiles implements ICloudFederationProvider {
6566

@@ -251,7 +252,8 @@ public function shareReceived(ICloudFederationShare $share) {
251252
\OC::$server->getGroupManager(),
252253
\OC::$server->getUserManager(),
253254
$shareWith,
254-
\OC::$server->query(IEventDispatcher::class)
255+
\OC::$server->query(IEventDispatcher::class),
256+
\OC::$server->get(LoggerInterface::class)
255257
);
256258

257259
try {

apps/files/js/fileactions.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@
155155
if (_.isFunction(action.render)) {
156156
actionSpec.render = action.render;
157157
}
158+
if (_.isFunction(action.shouldRender)) {
159+
actionSpec.shouldRender = action.shouldRender;
160+
}
158161
if (!this.actions[mime]) {
159162
this.actions[mime] = {};
160163
}
@@ -397,6 +400,11 @@
397400
* @param {OCA.Files.FileActionContext} context rendering context
398401
*/
399402
_renderInlineAction: function(actionSpec, isDefault, context) {
403+
if (actionSpec.shouldRender) {
404+
if (!actionSpec.shouldRender(context)) {
405+
return;
406+
}
407+
}
400408
var renderFunc = actionSpec.render || _.bind(this._defaultRenderAction, this);
401409
var $actionEl = renderFunc(actionSpec, isDefault, context);
402410
if (!$actionEl || !$actionEl.length) {

apps/files/js/gotoplugin.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
if (this.disallowedLists.indexOf(fileList.id) !== -1) {
3030
return;
3131
}
32+
// lists where the "Open" default action is disabled should
33+
// also have the goto action disabled
34+
if (fileList._defaultFileActionsDisabled) {
35+
return
36+
}
3237
var fileActions = fileList.fileActions;
3338

3439
fileActions.registerAction({

apps/files_sharing/js/app.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ OCA.Sharing.App = {
141141
{
142142
id: 'shares.pending',
143143
showPending: true,
144+
detailsViewEnabled: false,
145+
defaultFileActionsDisabled: true,
144146
sharedWithUser: true,
145147
fileActions: this._acceptShareAction(),
146148
config: OCA.Files.App.getFilesConfig(),
@@ -296,7 +298,11 @@ OCA.Sharing.App = {
296298
type: OCA.Files.FileActions.TYPE_INLINE,
297299
actionHandler(fileName, context) {
298300
const shareId = context.$file.data('shareId')
299-
$.post(OC.linkToOCS('apps/files_sharing/api/v1/shares/pending', 2) + shareId)
301+
let shareBase = 'shares/pending'
302+
if (context.$file.attr('data-remote-id')) {
303+
shareBase = 'remote_shares/pending'
304+
}
305+
$.post(OC.linkToOCS('apps/files_sharing/api/v1/' + shareBase, 2) + shareId)
300306
.success(function(result) {
301307
context.fileList.remove(context.fileInfoModel.attributes.name)
302308
}).fail(function() {
@@ -311,10 +317,23 @@ OCA.Sharing.App = {
311317
permissions: OC.PERMISSION_ALL,
312318
iconClass: 'icon-close',
313319
type: OCA.Files.FileActions.TYPE_INLINE,
320+
shouldRender(context) {
321+
// disable rejecting group shares from the pending list because they anyway
322+
// land back into that same list
323+
if (context.$file.attr('data-remote-id') && parseInt(context.$file.attr('data-share-type'), 10) === OC.Share.SHARE_TYPE_REMOTE_GROUP) {
324+
return false
325+
}
326+
return true
327+
},
314328
actionHandler(fileName, context) {
315329
const shareId = context.$file.data('shareId')
330+
let shareBase = 'shares'
331+
if (context.$file.attr('data-remote-id')) {
332+
shareBase = 'remote_shares/pending'
333+
}
334+
316335
$.ajax({
317-
url: OC.linkToOCS('apps/files_sharing/api/v1/shares', 2) + shareId,
336+
url: OC.linkToOCS('apps/files_sharing/api/v1/' + shareBase, 2) + shareId,
318337
type: 'DELETE',
319338
}).success(function(result) {
320339
context.fileList.remove(context.fileInfoModel.attributes.name)

apps/files_sharing/js/dist/additionalScripts.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/additionalScripts.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/dist/files_sharing.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/files_sharing/js/sharedfilelist.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@
9696
$tr.attr('data-share-permissions', permission)
9797
}
9898

99+
if (fileData.remoteId) {
100+
$tr.attr('data-remote-id', fileData.remoteId)
101+
}
102+
103+
if (fileData.shareType) {
104+
$tr.attr('data-share-type', fileData.shareType)
105+
}
106+
99107
// add row with expiration date for link only shares - influenced by _createRow of filelist
100108
if (this._linksOnly) {
101109
var expirationTimestamp = 0
@@ -212,6 +220,18 @@
212220
}
213221
}
214222

223+
var pendingRemoteShares = {
224+
url: OC.linkToOCS('apps/files_sharing/api/v1/remote_shares', 2) + 'pending',
225+
/* jshint camelcase: false */
226+
data: {
227+
format: 'json'
228+
},
229+
type: 'GET',
230+
beforeSend: function(xhr) {
231+
xhr.setRequestHeader('OCS-APIREQUEST', 'true')
232+
}
233+
}
234+
215235
var shares = {
216236
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
217237
/* jshint camelcase: false */
@@ -245,6 +265,7 @@
245265
promises.push($.ajax(deletedShares))
246266
} else if (this._showPending) {
247267
promises.push($.ajax(pendingShares))
268+
promises.push($.ajax(pendingRemoteShares))
248269
} else {
249270
promises.push($.ajax(shares))
250271

@@ -292,7 +313,12 @@
292313
}
293314

294315
if (additionalShares && additionalShares.ocs && additionalShares.ocs.data) {
295-
files = files.concat(this._makeFilesFromShares(additionalShares.ocs.data, !this._sharedWithUser))
316+
if (this._showPending) {
317+
// in this case the second callback is about pending remote shares
318+
files = files.concat(this._makeFilesFromRemoteShares(additionalShares.ocs.data))
319+
} else {
320+
files = files.concat(this._makeFilesFromShares(additionalShares.ocs.data, !this._sharedWithUser))
321+
}
296322
}
297323

298324
this.setFiles(files)
@@ -311,12 +337,29 @@
311337
mtime: share.mtime * 1000,
312338
mimetype: share.mimetype,
313339
type: share.type,
340+
// remote share types are different and need to be mapped
341+
shareType: (parseInt(share.share_type, 10) === 1) ? OC.Share.SHARE_TYPE_REMOTE_GROUP : OC.Share.SHARE_TYPE_REMOTE,
314342
id: share.file_id,
315343
path: OC.dirname(share.mountpoint),
316344
permissions: share.permissions,
317345
tags: share.tags || []
318346
}
319347

348+
if (share.remote_id) {
349+
// remote share
350+
if (share.accepted !== '1') {
351+
file.name = OC.basename(share.name)
352+
file.path = '/'
353+
}
354+
file.remoteId = share.remote_id
355+
file.shareOwnerId = share.owner
356+
}
357+
358+
if (!file.mimetype) {
359+
// pending shares usually have no type, so default to showing a directory icon
360+
file.mimetype = 'dir-shared'
361+
}
362+
320363
file.shares = [{
321364
id: share.id,
322365
type: OC.Share.SHARE_TYPE_REMOTE

apps/files_sharing/lib/AppInfo/Application.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
use OCP\Share\IManager;
6161
use OCP\Util;
6262
use Psr\Container\ContainerInterface;
63+
use Psr\Log\LoggerInterface;
6364
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6465
use Symfony\Component\EventDispatcher\GenericEvent;
6566

@@ -98,7 +99,8 @@ public function __construct(array $urlParams = []) {
9899
$server->getGroupManager(),
99100
$server->getUserManager(),
100101
$uid,
101-
$server->query(IEventDispatcher::class)
102+
$server->query(IEventDispatcher::class),
103+
$server->get(LoggerInterface::class)
102104
);
103105
});
104106

0 commit comments

Comments
 (0)