From 662de917abb666b684322099bc6e6118446c374f 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 a18f35378c327..e702ef5f5fd6f 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -278,7 +278,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 5d0e5e38d42ab..f2a5a01232131 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -916,12 +916,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 adc10274d75dd33135a4277c2c9dad2366c5732f 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.ts | 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 960df60c3d3d4..61cffab86f261 100644 --- a/apps/files_sharing/src/mixins/ShareDetails.js +++ b/apps/files_sharing/src/mixins/ShareDetails.js @@ -51,6 +51,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 e702ef5f5fd6f..fbefebfcc36fa 100644 --- a/apps/files_sharing/src/mixins/SharesMixin.js +++ b/apps/files_sharing/src/mixins/SharesMixin.js @@ -287,7 +287,7 @@ export default { } }) - this.updateQueue.add(async () => { + return this.updateQueue.add(async () => { this.saving = true this.errors = {} try { @@ -319,7 +319,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.ts b/apps/files_sharing/src/models/Share.ts index bfc6357240d2f..ea466363d62cc 100644 --- a/apps/files_sharing/src/models/Share.ts +++ b/apps/files_sharing/src/models/Share.ts @@ -21,6 +21,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 @@ -77,7 +81,7 @@ export default class Share { * Get the share attributes */ get attributes(): Array { - 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 f2a5a01232131..54c0c43ec5458 100644 --- a/apps/files_sharing/src/views/SharingDetailsTab.vue +++ b/apps/files_sharing/src/views/SharingDetailsTab.vue @@ -913,16 +913,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 991c61dc0407317c224cbbef58f2a3ec87a7e50a 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 c12e8a9211107..9fee729c977f7 100644 --- a/apps/files_sharing/src/components/SharingInput.vue +++ b/apps/files_sharing/src/components/SharingInput.vue @@ -5,10 +5,10 @@