fix(files_sharing): show message when nickname is not valid

Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
pull/53279/head
skjnldsv 2025-05-28 18:12:47 +07:00
parent cccf5a29ad
commit 972a73e8bc
1 changed files with 18 additions and 1 deletions

@ -49,13 +49,15 @@
<script lang="ts">
import { defineComponent } from 'vue'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import { loadState } from '@nextcloud/initial-state'
import { getFilenameValidity } from '../../../files/src/utils/filenameValidity'
export default defineComponent({
name: 'PublicAuthPrompt',
@ -91,6 +93,21 @@ export default defineComponent({
},
},
watch: {
name() {
// Check validity of the new name
const newName = this.name.trim?.() || ''
const input = (this.$refs.input as Vue|undefined)?.$el.querySelector('input')
if (!input) {
return
}
const validity = getFilenameValidity(newName)
input.setCustomValidity(validity)
input.reportValidity()
},
},
beforeMount() {
// Pre-load the name from local storage if already set by another app
// like Talk, Colabora or Text...