diff --git a/dashboard/src/components/EditableField.vue b/dashboard/src/components/EditableField.vue new file mode 100644 index 000000000..e497468ed --- /dev/null +++ b/dashboard/src/components/EditableField.vue @@ -0,0 +1,68 @@ + + + + + {{ label }} + + + {{ $t('main.dialog.save') }} + {{ $t('main.dialog.cancel') }} + + + {{ value }} + + + + + + + + {{ $t('main.dialog.edit') }} + + + diff --git a/dashboard/src/views/ProfileView.vue b/dashboard/src/views/ProfileView.vue index 0e788c452..718fcc75a 100644 --- a/dashboard/src/views/ProfileView.vue +++ b/dashboard/src/views/ProfileView.vue @@ -10,6 +10,7 @@ import { TOKEN_TYPES } from '../constants.js'; import NotificationSettings from '../components/NotificationSettings.vue'; import AppPasswords from '../components/AppPasswords.vue'; import SettingsItem from '../components/SettingsItem.vue'; +import EditableField from '../components/EditableField.vue'; import PrimaryEmailDialog from '../components/dialogs/PrimaryEmailDialog.vue'; import FallbackEmailDialog from '../components/dialogs/FallbackEmailDialog.vue'; import PasswordChangeDialog from '../components/dialogs/PasswordChangeDialog.vue'; @@ -31,6 +32,8 @@ const tokensModel = TokensModel.create(); const profile = inject('profile'); const refreshProfile = inject('refreshProfile'); +const savingDisplayName = ref(false); + const config = ref({}); const inputDialog = useTemplateRef('inputDialog'); const primaryEmailDialog = useTemplateRef('primaryEmailDialog'); @@ -49,22 +52,15 @@ async function onSelectLanguage(lang) { } // Profile edits -async function onChangeDisplayName(currentDisplayName) { - const displayName = await inputDialog.value.prompt({ - message: t('profile.changeDisplayName.title'), - value: currentDisplayName, - confirmLabel: t('main.dialog.save'), - confirmStyle: 'primary', - rejectLabel: t('main.dialog.cancel'), - rejectStyle: 'secondary', - }); +async function onDisplayNameSave(newName) { + savingDisplayName.value = true; - if (!displayName || currentDisplayName === displayName) return; + const error = await profileModel.setDisplayName(newName); + savingDisplayName.value = false; - const error = await profileModel.setDisplayName(displayName); if (error) return console.error('Failed to set displayName', error); - await refreshProfile(); + profile.value.displayName = newName; } function onChangeEmail(currentEmail) { @@ -227,13 +223,7 @@ onMounted(async () => { - - {{ $t('main.displayName') }} - {{ profile.displayName }} - - - {{ $t('main.dialog.edit') }} - +