Skip to content

Commit a442a79

Browse files
Merge pull request #46279 from nextcloud/backport/46068/stable27
[stable27] fix(ExternalSharing): Handle template shares from external sources
2 parents 0e64da6 + 8517c28 commit a442a79

File tree

4 files changed

+9
-84
lines changed

4 files changed

+9
-84
lines changed

apps/files_sharing/src/components/SharingInput.vue

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import debounce from 'debounce'
5353
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'
5454
5555
import Config from '../services/ConfigService.js'
56-
import GeneratePassword from '../utils/GeneratePassword.js'
5756
import Share from '../models/Share.js'
5857
import ShareRequests from '../mixins/ShareRequests.js'
5958
import ShareTypes from '../mixins/ShareTypes.js'
@@ -463,81 +462,6 @@ export default {
463462
...this.shareTypeToIcon(result.value.shareType),
464463
}
465464
},
466-
467-
/**
468-
* Process the new share request
469-
*
470-
* @param {object} value the multiselect option
471-
*/
472-
async addShare(value) {
473-
// Clear the displayed selection
474-
this.value = null
475-
476-
if (value.lookup) {
477-
await this.getSuggestions(this.query, true)
478-
479-
this.$nextTick(() => {
480-
// open the dropdown again
481-
this.$refs.select.$children[0].open = true
482-
})
483-
return true
484-
}
485-
486-
// handle externalResults from OCA.Sharing.ShareSearch
487-
if (value.handler) {
488-
const share = await value.handler(this)
489-
this.$emit('add:share', new Share(share))
490-
return true
491-
}
492-
493-
this.loading = true
494-
console.debug('Adding a new share from the input for', value)
495-
try {
496-
let password = null
497-
498-
if (this.config.enforcePasswordForPublicLink
499-
&& value.shareType === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
500-
password = await GeneratePassword()
501-
}
502-
503-
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
504-
const share = await this.createShare({
505-
path,
506-
shareType: value.shareType,
507-
shareWith: value.shareWith,
508-
password,
509-
permissions: this.fileInfo.sharePermissions & OC.getCapabilities().files_sharing.default_permissions,
510-
attributes: JSON.stringify(this.fileInfo.shareAttributes),
511-
})
512-
513-
// If we had a password, we need to show it to the user as it was generated
514-
if (password) {
515-
share.newPassword = password
516-
// Wait for the newly added share
517-
const component = await new Promise(resolve => {
518-
this.$emit('add:share', share, resolve)
519-
})
520-
521-
// open the menu on the
522-
// freshly created share component
523-
component.open = true
524-
} else {
525-
// Else we just add it normally
526-
this.$emit('add:share', share)
527-
}
528-
529-
await this.getRecommendations()
530-
} catch (error) {
531-
this.$nextTick(() => {
532-
// open the dropdown again on error
533-
this.$refs.select.$children[0].open = true
534-
})
535-
this.query = value.shareWith
536-
console.error('Error while adding new share', error)
537-
} finally {
538-
this.loading = false
539-
}
540-
},
541465
},
542466
}
543467
</script>

apps/files_sharing/src/mixins/ShareDetails.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ export default {
99
// TODO : Better name/interface for handler required
1010
// For example `externalAppCreateShareHook` with proper documentation
1111
if (shareRequestObject.handler) {
12+
const handlerInput = {}
1213
if (this.suggestions) {
13-
shareRequestObject.suggestions = this.suggestions
14-
shareRequestObject.fileInfo = this.fileInfo
15-
shareRequestObject.query = this.query
14+
handlerInput.suggestions = this.suggestions
15+
handlerInput.fileInfo = this.fileInfo
16+
handlerInput.query = this.query
1617
}
17-
share = await shareRequestObject.handler(shareRequestObject)
18-
share = new Share(share)
18+
const externalShareRequestObject = await shareRequestObject.handler(handlerInput)
19+
share = this.mapShareRequestToShareObject(externalShareRequestObject)
1920
} else {
2021
share = this.mapShareRequestToShareObject(shareRequestObject)
2122
}

dist/files_sharing-files_sharing_tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files_sharing-files_sharing_tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)