From beb538f9f2257c266ad2066aeff2bc8d425bfe91 Mon Sep 17 00:00:00 2001 From: yemkareems Date: Wed, 5 Mar 2025 09:30:02 +0530 Subject: [PATCH 1/5] fix: pass hide download attribute while creating the share to fix github issue 50788 Signed-off-by: yemkareems --- apps/files_sharing/src/mixins/SharesMixin.js | 4 +++- apps/files_sharing/src/views/SharingDetailsTab.vue | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index 5b2dd66b1ba53..a97fbaf670e66 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -299,7 +299,9 @@ export default { // force value to string because that is what our // share api controller accepts propertyNames.forEach(name => { - if ((typeof this.share[name]) === 'object') { + if (this.share[name] === null || this.share[name] === undefined) { + properties[name] = '' + } else if ((typeof this.share[name]) === 'object') { properties[name] = JSON.stringify(this.share[name]) } else { properties[name] = this.share[name].toString() diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index 672b58ebec009..5d3af9ce590a1 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -904,12 +904,13 @@ export default { this.creating = false this.share = share this.$emit('add:share', this.share) - } else { - this.$emit('update:share', this.share) - emit('update:share', this.share) - this.queueUpdate(...permissionsAndAttributes) } + // Let's update after creation as some attrs are only available after creation + this.$emit('update:share', this.share) + emit('update:share', this.share) + this.queueUpdate(...permissionsAndAttributes) + await this.getNode() emit('files:node:updated', this.node) From 0f58178e4d0eeae0d045ed1f349ea53a90dcef8a Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 6 Mar 2025 00:25:59 +0100 Subject: [PATCH 2/5] fix(files_sharing): ugly hacks to update permissions on share creation Signed-off-by: Ferdinand Thiessen --- apps/files_sharing/src/mixins/ShareDetails.js | 1 + apps/files_sharing/src/mixins/SharesMixin.js | 3 +-- apps/files_sharing/src/models/Share.js | 6 ++++- .../src/views/SharingDetailsTab.vue | 25 ++++++++++++++----- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apps/files_sharing/src/mixins/ShareDetails.js b/apps/files_sharing/src/mixins/ShareDetails.js index 77fbd657944e0..094fefd949115 100644 --- a/apps/files_sharing/src/mixins/ShareDetails.js +++ b/apps/files_sharing/src/mixins/ShareDetails.js @@ -46,6 +46,7 @@ export default { scope: 'permissions', }, ], + hideDownload: false, share_type: shareRequestObject.shareType, share_with: shareRequestObject.shareWith, is_no_user: shareRequestObject.isNoUser, diff --git a/apps/files_sharing/src/mixins/SharesMixin.js b/apps/files_sharing/src/mixins/SharesMixin.js index a97fbaf670e66..2742860649dd3 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -308,7 +308,7 @@ export default { } }) - this.updateQueue.add(async () => { + return this.updateQueue.add(async () => { this.saving = true this.errors = {} try { @@ -340,7 +340,6 @@ export default { this.saving = false } }) - return } // This share does not exists on the server yet diff --git a/apps/files_sharing/src/models/Share.js b/apps/files_sharing/src/models/Share.js index b88d376a0ff23..a1ae8b5954054 100644 --- a/apps/files_sharing/src/models/Share.js +++ b/apps/files_sharing/src/models/Share.js @@ -39,6 +39,10 @@ export default class Share { ocsData = ocsData.ocs.data[0] } + // string to int + if (typeof ocsData.id === 'string') { + ocsData.id = Number.parseInt(ocsData.id) + } // convert int into boolean ocsData.hide_download = !!ocsData.hide_download ocsData.mail_send = !!ocsData.mail_send @@ -113,7 +117,7 @@ export default class Share { * @memberof Share */ get attributes() { - return this._share.attributes + return this._share.attributes || [] } /** diff --git a/apps/files_sharing/src/views/SharingDetailsTab.vue b/apps/files_sharing/src/views/SharingDetailsTab.vue index 5d3af9ce590a1..3169babeab132 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -901,16 +901,29 @@ export default { this.creating = true const share = await this.addShare(incomingShare) - this.creating = false + // ugly hack to make code work - we need the id to be set but at the same time we need to keep values we want to update + this.share._share.id = share.id + await this.queueUpdate(...permissionsAndAttributes) + // Also a ugly hack to update the updated permissions + for (const prop of permissionsAndAttributes) { + if (prop in share && prop in this.share) { + try { + share[prop] = this.share[prop] + } catch { + share._share[prop] = this.share[prop] + } + } + } this.share = share + this.creating = false this.$emit('add:share', this.share) + } else { + // Let's update after creation as some attrs are only available after creation + this.$emit('update:share', this.share) + emit('update:share', this.share) + this.queueUpdate(...permissionsAndAttributes) } - // Let's update after creation as some attrs are only available after creation - this.$emit('update:share', this.share) - emit('update:share', this.share) - this.queueUpdate(...permissionsAndAttributes) - await this.getNode() emit('files:node:updated', this.node) From b3d93b44c997fc68a9b9cc0288b21009fc818660 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Thu, 6 Mar 2025 00:26:28 +0100 Subject: [PATCH 3/5] fix(files_sharing): make sure IDs are unique for HTML elements Signed-off-by: Ferdinand Thiessen --- apps/files_sharing/src/components/SharingInput.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/src/components/SharingInput.vue b/apps/files_sharing/src/components/SharingInput.vue index f7a2d5cda431f..e7dca2fbb7805 100644 --- a/apps/files_sharing/src/components/SharingInput.vue +++ b/apps/files_sharing/src/components/SharingInput.vue @@ -22,10 +22,10 @@