Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
97 changes: 14 additions & 83 deletions apps/files_sharing/src/components/SharingInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

<template>
<div class="sharing-search">
<label for="sharing-search-input">{{ t('files_sharing', 'Search for share recipients') }}</label>
<NcSelect ref="select"
v-model="value"
input-id="sharing-search-input"
:input-label="t('files_sharing', 'Search for share recipients')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks cypress tests.
I agree we do not need the ID but then you need to change the selector in the Cypress tests.

class="sharing-search__input"
:disabled="!canReshare"
:loading="loading"
Expand All @@ -35,7 +34,6 @@ import debounce from 'debounce'
import NcSelect from '@nextcloud/vue/dist/Components/NcSelect.js'

import Config from '../services/ConfigService.js'
import GeneratePassword from '../utils/GeneratePassword.js'
import Share from '../models/Share.js'
import ShareRequests from '../mixins/ShareRequests.js'
import ShareTypes from '../mixins/ShareTypes.js'
Expand Down Expand Up @@ -138,8 +136,20 @@ export default {
},

methods: {
onSelected(option) {
async onSelected(option) {
this.value = null // Reset selected option

// Not a real option, but a lookup = global search button
if (option.lookup) {
await this.getSuggestions(this.query, true)
// Wait until select is re-rendered with new options
await this.$nextTick()
// Open the select again
this.$refs.select.$children[0].open = true

return
}

this.openSharingDetails(option)
},

Expand Down Expand Up @@ -445,81 +455,6 @@ export default {
...this.shareTypeToIcon(result.value.shareType),
}
},

/**
* Process the new share request
*
* @param {object} value the multiselect option
*/
async addShare(value) {
// Clear the displayed selection
this.value = null

if (value.lookup) {
await this.getSuggestions(this.query, true)

this.$nextTick(() => {
// open the dropdown again
this.$refs.select.$children[0].open = true
})
return true
}

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

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 & getCapabilities().files_sharing.default_permissions,
attributes: JSON.stringify(this.fileInfo.shareAttributes),
})

// 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)
}

await this.getRecommendations()
} catch (error) {
this.$nextTick(() => {
// open the dropdown again on error
this.$refs.select.$children[0].open = true
})
this.query = value.shareWith
console.error('Error while adding new share', error)
} finally {
this.loading = false
}
},
},
}
</script>
Expand All @@ -530,10 +465,6 @@ export default {
flex-direction: column;
margin-bottom: 4px;

label[for="sharing-search-input"] {
margin-bottom: 2px;
}

&__input {
width: 100%;
margin: 10px 0;
Expand Down
2 changes: 0 additions & 2 deletions dist/5733-5733.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/5733-5733.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/5733-5733.js.map.license

This file was deleted.

2 changes: 2 additions & 0 deletions dist/7588-7588.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/7588-7588.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/7588-7588.js.map.license
4 changes: 2 additions & 2 deletions dist/files_sharing-files_sharing_tab.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/files_sharing-files_sharing_tab.js.map

Large diffs are not rendered by default.