mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
Refactor migrated addShare method
Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
This commit is contained in:
parent
9037509729
commit
cec466ed3b
1 changed files with 15 additions and 18 deletions
|
|
@ -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 {
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue