summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-07-01 17:26:00 +0200
committerVincent Petry <vincent@nextcloud.com>2021-08-10 13:27:53 +0200
commitdf835ed3502ac1c283abffe00f35b150ecbefe9c (patch)
tree52208cc3a5d08e12ce34b3ea3b13b1e0421c1fbd
parent5bd4ed19d4e499918bd4bedc4bb3d12090781794 (diff)
downloadnextcloud-server-df835ed3502ac1c283abffe00f35b150ecbefe9c.tar.gz
nextcloud-server-df835ed3502ac1c283abffe00f35b150ecbefe9c.zip
Extend pending shares list to include remote shares
And adjust the accept/decline actions to use the right endpoint for remote shares. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
-rw-r--r--apps/files_sharing/js/app.js13
-rw-r--r--apps/files_sharing/js/sharedfilelist.js35
-rw-r--r--apps/files_sharing/src/share.js3
3 files changed, 48 insertions, 3 deletions
diff --git a/apps/files_sharing/js/app.js b/apps/files_sharing/js/app.js
index 713560e556b..c25ae7c8b1b 100644
--- a/apps/files_sharing/js/app.js
+++ b/apps/files_sharing/js/app.js
@@ -296,7 +296,11 @@ OCA.Sharing.App = {
type: OCA.Files.FileActions.TYPE_INLINE,
actionHandler(fileName, context) {
const shareId = context.$file.data('shareId')
- $.post(OC.linkToOCS('apps/files_sharing/api/v1/shares/pending', 2) + shareId)
+ let shareBase = 'shares/pending'
+ if (context.$file.attr('data-remote-id')) {
+ shareBase = 'remote_shares/pending'
+ }
+ $.post(OC.linkToOCS('apps/files_sharing/api/v1/' + shareBase, 2) + shareId)
.success(function(result) {
context.fileList.remove(context.fileInfoModel.attributes.name)
}).fail(function() {
@@ -313,8 +317,13 @@ OCA.Sharing.App = {
type: OCA.Files.FileActions.TYPE_INLINE,
actionHandler(fileName, context) {
const shareId = context.$file.data('shareId')
+ let shareBase = 'shares'
+ if (context.$file.attr('data-remote-id')) {
+ shareBase = 'remote_shares/pending'
+ }
+
$.ajax({
- url: OC.linkToOCS('apps/files_sharing/api/v1/shares', 2) + shareId,
+ url: OC.linkToOCS('apps/files_sharing/api/v1/' + shareBase, 2) + shareId,
type: 'DELETE',
}).success(function(result) {
context.fileList.remove(context.fileInfoModel.attributes.name)
diff --git a/apps/files_sharing/js/sharedfilelist.js b/apps/files_sharing/js/sharedfilelist.js
index 962f8a16915..a2239941d6b 100644
--- a/apps/files_sharing/js/sharedfilelist.js
+++ b/apps/files_sharing/js/sharedfilelist.js
@@ -212,6 +212,18 @@
}
}
+ var pendingRemoteShares = {
+ url: OC.linkToOCS('apps/files_sharing/api/v1/remote_shares', 2) + 'pending',
+ /* jshint camelcase: false */
+ data: {
+ format: 'json'
+ },
+ type: 'GET',
+ beforeSend: function(xhr) {
+ xhr.setRequestHeader('OCS-APIREQUEST', 'true')
+ }
+ }
+
var shares = {
url: OC.linkToOCS('apps/files_sharing/api/v1') + 'shares',
/* jshint camelcase: false */
@@ -245,6 +257,7 @@
promises.push($.ajax(deletedShares))
} else if (this._showPending) {
promises.push($.ajax(pendingShares))
+ promises.push($.ajax(pendingRemoteShares))
} else {
promises.push($.ajax(shares))
@@ -292,7 +305,12 @@
}
if (additionalShares && additionalShares.ocs && additionalShares.ocs.data) {
- files = files.concat(this._makeFilesFromShares(additionalShares.ocs.data, !this._sharedWithUser))
+ if (this._showPending) {
+ // in this case the second callback is about pending remote shares
+ files = files.concat(this._makeFilesFromRemoteShares(additionalShares.ocs.data))
+ } else {
+ files = files.concat(this._makeFilesFromShares(additionalShares.ocs.data, !this._sharedWithUser))
+ }
}
this.setFiles(files)
@@ -317,6 +335,21 @@
tags: share.tags || []
}
+ if (share.remote_id) {
+ // remote share
+ if (share.accepted !== '1') {
+ file.name = OC.basename(share.name)
+ file.path = '/'
+ }
+ file.remoteId = share.remote_id
+ file.shareOwnerId = share.owner
+ }
+
+ if (!file.type) {
+ // pending shares usually have no type, so default to showing a directory icon
+ file.mimetype = 'httpd/unix-directory'
+ }
+
file.shares = [{
id: share.id,
type: OC.Share.SHARE_TYPE_REMOTE
diff --git a/apps/files_sharing/src/share.js b/apps/files_sharing/src/share.js
index 385d42eaaea..ab41db7e8cd 100644
--- a/apps/files_sharing/src/share.js
+++ b/apps/files_sharing/src/share.js
@@ -104,6 +104,9 @@ import escapeHTML from 'escape-html'
if (fileData.shareTypes) {
tr.attr('data-share-types', fileData.shareTypes.join(','))
}
+ if (fileData.remoteId) {
+ tr.attr('data-remote-id', fileData.remoteId)
+ }
return tr
}