Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(files_sharing): ugly hacks to update permissions on share creation
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Mar 18, 2025
commit a8358dad8c666d67713854a268d4bce78a6ffb3e
1 change: 1 addition & 0 deletions apps/files_sharing/src/mixins/ShareDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export default {
scope: 'permissions',
},
],
hideDownload: false,
share_type: shareRequestObject.shareType,
share_with: shareRequestObject.shareWith,
is_no_user: shareRequestObject.isNoUser,
Expand Down
3 changes: 1 addition & 2 deletions apps/files_sharing/src/mixins/SharesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export default {
}
})

this.updateQueue.add(async () => {
return this.updateQueue.add(async () => {
this.saving = true
this.errors = {}
try {
Expand Down Expand Up @@ -319,7 +319,6 @@ export default {
this.saving = false
}
})
return
}

// This share does not exists on the server yet
Expand Down
7 changes: 6 additions & 1 deletion apps/files_sharing/src/models/Share.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,7 +81,7 @@ export default class Share {
* Get the share attributes
*/
get attributes(): Array<ShareAttribute> {
return this._share.attributes
return this._share.attributes || []
}

/**
Expand Down Expand Up @@ -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
}

/**
Expand Down
25 changes: 19 additions & 6 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down