From 3e09295fa118085b0bf779986278749882437adf Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sat, 10 Feb 2024 19:37:13 +0100 Subject: [PATCH] fix(settings): Use status states from `NcInputField` instead of custom handling Co-authored-by: Ferdinand Thiessen Co-authored-by: Pytal <24800714+Pytal@users.noreply.github.com> Signed-off-by: Ferdinand Thiessen --- .../PersonalInfo/DetailsSection.vue | 4 +- .../PersonalInfo/EmailSection/Email.vue | 253 ++++++++---------- .../EmailSection/EmailSection.vue | 4 - .../PersonalInfo/LanguageSection/Language.vue | 63 ++--- .../LanguageSection/LanguageSection.vue | 25 +- .../PersonalInfo/LocaleSection/Locale.vue | 84 +++--- .../LocaleSection/LocaleSection.vue | 15 +- .../ProfileSection/ProfileCheckbox.vue | 2 +- .../shared/AccountPropertySection.vue | 70 ++--- .../PersonalInfo/shared/FederationControl.vue | 116 ++------ .../shared/FederationControlActions.vue | 181 +++++++++++++ .../src/constants/AccountPropertyConstants.js | 9 +- 12 files changed, 420 insertions(+), 406 deletions(-) create mode 100644 apps/settings/src/components/PersonalInfo/shared/FederationControlActions.vue diff --git a/apps/settings/src/components/PersonalInfo/DetailsSection.vue b/apps/settings/src/components/PersonalInfo/DetailsSection.vue index 075ed6f71e2..2774f2c1c8e 100644 --- a/apps/settings/src/components/PersonalInfo/DetailsSection.vue +++ b/apps/settings/src/components/PersonalInfo/DetailsSection.vue @@ -99,7 +99,7 @@ export default { flex-direction: column; margin: 10px 32px 10px 0; gap: 16px 0; - color: var(--color-text-lighter); + color: var(--color-text-maxcontrast); &__groups, &__quota { @@ -117,7 +117,7 @@ export default { font-weight: bold; } - &::v-deep .material-design-icon { + &:deep(.material-design-icon) { align-self: flex-start; margin-top: 2px; } diff --git a/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue b/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue index 1fff440c50e..99917bb4f7e 100644 --- a/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue +++ b/apps/settings/src/components/PersonalInfo/EmailSection/Email.vue @@ -23,63 +23,69 @@ @@ -74,9 +65,6 @@ import debounce from 'debounce' import NcInputField from '@nextcloud/vue/dist/Components/NcInputField.js' import NcTextArea from '@nextcloud/vue/dist/Components/NcTextArea.js' -import AlertCircle from 'vue-material-design-icons/AlertCircleOutline.vue' -import AlertOctagon from 'vue-material-design-icons/AlertOctagon.vue' -import Check from 'vue-material-design-icons/Check.vue' import HeaderBar from './HeaderBar.vue' @@ -87,9 +75,6 @@ export default { name: 'AccountPropertySection', components: { - AlertCircle, - AlertOctagon, - Check, HeaderBar, NcInputField, NcTextArea, @@ -147,9 +132,9 @@ export default { data() { return { initialValue: this.value, - helperText: null, - showCheckmarkIcon: false, - showErrorIcon: false, + helperText: '', + isSuccess: false, + hasError: false, } }, @@ -170,12 +155,13 @@ export default { debouncePropertyChange() { return debounce(async function(value) { - this.helperText = null - if (this.$refs.input && this.$refs.input.validationMessage) { - this.helperText = this.$refs.input.validationMessage + this.helperText = this.$refs.input?.$refs.input?.validationMessage || '' + if (this.helperText !== '') { return } - if (this.onValidate && !this.onValidate(value)) { + this.hasError = this.onValidate && !this.onValidate(value) + if (this.hasError) { + this.helperText = t('settings', 'Invalid value') return } await this.updateProperty(value) @@ -208,13 +194,13 @@ export default { if (this.onSave) { this.onSave(value) } - this.showCheckmarkIcon = true - setTimeout(() => { this.showCheckmarkIcon = false }, 2000) + this.isSuccess = true + setTimeout(() => { this.isSuccess = false }, 2000) } else { this.$emit('update:value', this.initialValue) handleError(error, errorMessage) - this.showErrorIcon = true - setTimeout(() => { this.showErrorIcon = false }, 2000) + this.hasError = true + setTimeout(() => { this.hasError = false }, 2000) } }, }, @@ -226,25 +212,15 @@ section { padding: 10px 10px; .property { - display: grid; - align-items: center; - - textarea { - resize: vertical; - grid-area: 1 / 1; - width: 100%; - } - - input { - grid-area: 1 / 1; - width: 100%; - } + display: flex; + flex-direction: row; + align-items: start; + gap: 4px; .property__actions-container { - grid-area: 1 / 1; + margin-top: 6px; justify-self: flex-end; align-self: flex-end; - height: 30px; display: flex; gap: 0 2px; diff --git a/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue b/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue index bf22c0ac081..64f603932b6 100644 --- a/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue +++ b/apps/settings/src/components/PersonalInfo/shared/FederationControl.vue @@ -2,6 +2,7 @@ - @copyright 2021, Christopher Ng - - @author Christopher Ng + - @author Ferdinand Thiessen - - @license GNU AGPL version 3 or any later version - @@ -25,51 +26,37 @@ class="federation-actions" :class="{ 'federation-actions--additional': additional }" :aria-label="ariaLabel" - :default-icon="scopeIcon" :disabled="disabled"> - - {{ supportedScopes.includes(federationScope.name) ? federationScope.tooltip : federationScope.tooltipDisabled }} - + + diff --git a/apps/settings/src/components/PersonalInfo/shared/FederationControlActions.vue b/apps/settings/src/components/PersonalInfo/shared/FederationControlActions.vue new file mode 100644 index 00000000000..d37d7fa2fba --- /dev/null +++ b/apps/settings/src/components/PersonalInfo/shared/FederationControlActions.vue @@ -0,0 +1,181 @@ + + + + + diff --git a/apps/settings/src/constants/AccountPropertyConstants.js b/apps/settings/src/constants/AccountPropertyConstants.js index eb35482fb32..2dcb6c98f9c 100644 --- a/apps/settings/src/constants/AccountPropertyConstants.js +++ b/apps/settings/src/constants/AccountPropertyConstants.js @@ -24,6 +24,7 @@ * SYNC to be kept in sync with `lib/public/Accounts/IAccountManager.php` */ +import { mdiAccountGroup, mdiCellphone, mdiLock, mdiWeb } from '@mdi/js' import { translate as t } from '@nextcloud/l10n' /** Enum of account properties */ @@ -167,28 +168,28 @@ export const SCOPE_PROPERTY_ENUM = Object.freeze({ displayName: t('settings', 'Private'), tooltip: t('settings', 'Only visible to people matched via phone number integration through Talk on mobile'), tooltipDisabled: t('settings', 'Not available as this property is required for core functionality including file sharing and calendar invitations'), - iconClass: 'icon-phone', + icon: mdiCellphone, }, [SCOPE_ENUM.LOCAL]: { name: SCOPE_ENUM.LOCAL, displayName: t('settings', 'Local'), tooltip: t('settings', 'Only visible to people on this instance and guests'), // tooltipDisabled is not required here as this scope is supported by all account properties - iconClass: 'icon-password', + icon: mdiLock, }, [SCOPE_ENUM.FEDERATED]: { name: SCOPE_ENUM.FEDERATED, displayName: t('settings', 'Federated'), tooltip: t('settings', 'Only synchronize to trusted servers'), tooltipDisabled: t('settings', 'Not available as federation has been disabled for your account, contact your system administration if you have any questions'), - iconClass: 'icon-contacts-dark', + icon: mdiAccountGroup, }, [SCOPE_ENUM.PUBLISHED]: { name: SCOPE_ENUM.PUBLISHED, displayName: t('settings', 'Published'), tooltip: t('settings', 'Synchronize to trusted servers and the global and public address book'), tooltipDisabled: t('settings', 'Not available as publishing account specific data to the lookup server is not allowed, contact your system administration if you have any questions'), - iconClass: 'icon-link', + icon: mdiWeb, }, })