aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/components/SharingInput.vue
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_sharing/src/components/SharingInput.vue')
-rw-r--r--apps/files_sharing/src/components/SharingInput.vue40
1 files changed, 34 insertions, 6 deletions
diff --git a/apps/files_sharing/src/components/SharingInput.vue b/apps/files_sharing/src/components/SharingInput.vue
index ab079369f73..b30301d2290 100644
--- a/apps/files_sharing/src/components/SharingInput.vue
+++ b/apps/files_sharing/src/components/SharingInput.vue
@@ -56,6 +56,7 @@ import debounce from 'debounce'
import Multiselect from '@nextcloud/vue/dist/Components/Multiselect'
import Config from '../services/ConfigService'
+import GeneratePassword from '../utils/GeneratePassword'
import Share from '../models/Share'
import ShareRequests from '../mixins/ShareRequests'
import ShareTypes from '../mixins/ShareTypes'
@@ -448,9 +449,6 @@ export default {
return true
}
- // TODO: reset the search string when done
- // https://github.com/shentao/vue-multiselect/issues/633
-
// handle externalResults from OCA.Sharing.ShareSearch
if (value.handler) {
const share = await value.handler(this)
@@ -459,25 +457,55 @@ export default {
}
this.loading = true
+ console.debug('Adding a new share from the input for', value)
try {
+ let password = null
+
+ if (this.config.enforcePasswordForPublicLink
+ && value.shareType === this.SHARE_TYPES.SHARE_TYPE_EMAIL) {
+ password = await GeneratePassword()
+ }
+
const path = (this.fileInfo.path + '/' + this.fileInfo.name).replace('//', '/')
const share = await this.createShare({
path,
shareType: value.shareType,
shareWith: value.shareWith,
+ password,
permissions: this.fileInfo.sharePermissions & OC.getCapabilities().files_sharing.default_permissions,
})
- this.$emit('add:share', share)
- this.getRecommendations()
+ // If we had a password, we need to show it to the user as it was generated
+ if (password) {
+ share.newPassword = password
+ // Wait for the newly added share
+ const component = await new Promise(resolve => {
+ this.$emit('add:share', share, resolve)
+ })
+
+ // open the menu on the
+ // freshly created share component
+ component.open = true
+ } else {
+ // Else we just add it normally
+ this.$emit('add:share', share)
+ }
+
+ // reset the search string when done
+ // FIXME: https://github.com/shentao/vue-multiselect/issues/633
+ if (this.$refs.multiselect?.$refs?.VueMultiselect?.search) {
+ this.$refs.multiselect.$refs.VueMultiselect.search = ''
+ }
- } catch (response) {
+ await this.getRecommendations()
+ } catch (error) {
// focus back if any error
const input = this.$refs.multiselect.$el.querySelector('input')
if (input) {
input.focus()
}
this.query = value.shareWith
+ console.error('Error while adding new share', error)
} finally {
this.loading = false
}