Skip to content
Merged
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
Next Next commit
Refactor migrated addShare method
Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Sep 13, 2023
commit cec466ed3bdd35a7143a159eb5f46af013f87cff
33 changes: 15 additions & 18 deletions apps/files_sharing/src/views/SharingDetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ export default {
incomingShare.password = this.share.password
}

const share = await this.addShare(incomingShare, this.fileInfo, this.config)
const share = await this.addShare(incomingShare, this.fileInfo)
this.share = share
this.$emit('add:share', this.share)
} else {
Expand All @@ -791,36 +791,33 @@ export default {
/**
* Process the new share request
*
* @param {object} value the multiselect option
* @param {Share} share incoming share object
* @param {object} fileInfo file data
* @param {Config} config instance configs
*/
async addShare(value, fileInfo, config) {
// Clear the displayed selection
this.value = null
async addShare(share, fileInfo) {

// handle externalResults from OCA.Sharing.ShareSearch
if (value.handler) {
const share = await value.handler(this)
this.$emit('add:share', new Share(share))
if (share.handler) {
const shareFromHandler = await share.handler(this)
this.$emit('add:share', new Share(shareFromHandler))
return true
}

// this.loading = true // Are we adding loaders the new share flow?
console.debug('Adding a new share from the input for', value)
console.debug('Adding a new share from the input for', share)
try {
const path = (fileInfo.path + '/' + fileInfo.name).replace('//', '/')
const share = await this.createShare({
const resultingShare = await this.createShare({
path,
shareType: value.shareType,
shareWith: value.shareWith,
permissions: value.permissions,
shareType: share.shareType,
shareWith: share.shareWith,
permissions: share.permissions,
attributes: JSON.stringify(fileInfo.shareAttributes),
...(value.note ? { note: value.note } : {}),
...(value.password ? { password: value.password } : {}),
...(value.expireDate ? { expireDate: value.expireDate } : {}),
...(share.note ? { note: share.note } : {}),
...(share.password ? { password: share.password } : {}),
...(share.expireDate ? { expireDate: share.expireDate } : {}),
})
return share
return resultingShare
} catch (error) {
console.error('Error while adding new share', error)
} finally {
Expand Down