fix(files_sharing): ugly hacks to update permissions on share creation

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/51250/head
Ferdinand Thiessen 7 months ago
parent 92a93393e1
commit a8358dad8c
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400
  1. 1
      apps/files_sharing/src/mixins/ShareDetails.js
  2. 3
      apps/files_sharing/src/mixins/SharesMixin.js
  3. 7
      apps/files_sharing/src/models/Share.ts
  4. 25
      apps/files_sharing/src/views/SharingDetailsTab.vue

@ -51,6 +51,7 @@ export default {
scope: 'permissions',
},
],
hideDownload: false,
share_type: shareRequestObject.shareType,
share_with: shareRequestObject.shareWith,
is_no_user: shareRequestObject.isNoUser,

@ -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

@ -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<ShareAttribute> {
return this._share.attributes
return this._share.attributes || []
}
/**
@ -241,6 +245,7 @@ export default class Share {
*/
get hideDownload(): boolean {
return this._share.hide_download === true
|| this.attributes.find?.(({ scope, key, value }) => scope === 'permissions' && key === 'download' && !value) !== undefined
}
/**

@ -1005,16 +1005,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)

Loading…
Cancel
Save