mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 20:18:08 +00:00
enhancement: Profile settings accessibility improvements (#2054)
* profile settings in to separate form * update locale texts * replce woot-submit-button with woot-button * disable button if value is empty * change condition * code climate fixes
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
"LINK": "Profile Settings",
|
"LINK": "Profile Settings",
|
||||||
"TITLE": "Profile Settings",
|
"TITLE": "Profile Settings",
|
||||||
"BTN_TEXT": "Update Profile",
|
"BTN_TEXT": "Update Profile",
|
||||||
|
"UPDATE_SUCCESS": "Your profile has been updated successfully",
|
||||||
|
"PASSWORD_UPDATE_SUCCESS": "Your password has been changed successfully",
|
||||||
"AFTER_EMAIL_CHANGED": "Your profile has been updated successfully, please login again as your login credentials are changed",
|
"AFTER_EMAIL_CHANGED": "Your profile has been updated successfully, please login again as your login credentials are changed",
|
||||||
"FORM": {
|
"FORM": {
|
||||||
"AVATAR": "Profile Image",
|
"AVATAR": "Profile Image",
|
||||||
@@ -16,7 +18,8 @@
|
|||||||
},
|
},
|
||||||
"PASSWORD_SECTION": {
|
"PASSWORD_SECTION": {
|
||||||
"TITLE": "Password",
|
"TITLE": "Password",
|
||||||
"NOTE": "Updating your password would reset your logins in multiple devices."
|
"NOTE": "Updating your password would reset your logins in multiple devices.",
|
||||||
|
"BTN_TEXT": "Change password"
|
||||||
},
|
},
|
||||||
"ACCESS_TOKEN": {
|
"ACCESS_TOKEN": {
|
||||||
"TITLE": "Access Token",
|
"TITLE": "Access Token",
|
||||||
@@ -64,11 +67,7 @@
|
|||||||
},
|
},
|
||||||
"AVAILABILITY": {
|
"AVAILABILITY": {
|
||||||
"LABEL": "Availability",
|
"LABEL": "Availability",
|
||||||
"STATUSES_LIST": [
|
"STATUSES_LIST": ["Online", "Busy", "Offline"]
|
||||||
"Online",
|
|
||||||
"Busy",
|
|
||||||
"Offline"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"EMAIL": {
|
"EMAIL": {
|
||||||
"LABEL": "Your email address",
|
"LABEL": "Your email address",
|
||||||
@@ -147,6 +146,5 @@
|
|||||||
},
|
},
|
||||||
"SUBMIT": "Submit"
|
"SUBMIT": "Submit"
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="columns profile--settings ">
|
<div class="columns profile--settings">
|
||||||
<form @submit.prevent="updateUser">
|
<form @submit.prevent="updateUser('profile')">
|
||||||
<div class="small-12 row profile--settings--row">
|
<div class="small-12 row profile--settings--row">
|
||||||
<div class="columns small-3 ">
|
<div class="columns small-3">
|
||||||
<h4 class="block-title">
|
<h4 class="block-title">
|
||||||
{{ $t('PROFILE_SETTINGS.FORM.PROFILE_SECTION.TITLE') }}
|
{{ $t('PROFILE_SETTINGS.FORM.PROFILE_SECTION.TITLE') }}
|
||||||
</h4>
|
</h4>
|
||||||
@@ -49,10 +49,15 @@
|
|||||||
{{ $t('PROFILE_SETTINGS.FORM.EMAIL.ERROR') }}
|
{{ $t('PROFILE_SETTINGS.FORM.EMAIL.ERROR') }}
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
<woot-button type="submit" :is-loading="isProfileUpdating">
|
||||||
|
{{ $t('PROFILE_SETTINGS.BTN_TEXT') }}
|
||||||
|
</woot-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</form>
|
||||||
|
<form @submit.prevent="updateUser('password')">
|
||||||
<div class="profile--settings--row row">
|
<div class="profile--settings--row row">
|
||||||
<div class="columns small-3 ">
|
<div class="columns small-3">
|
||||||
<h4 class="block-title">
|
<h4 class="block-title">
|
||||||
{{ $t('PROFILE_SETTINGS.FORM.PASSWORD_SECTION.TITLE') }}
|
{{ $t('PROFILE_SETTINGS.FORM.PASSWORD_SECTION.TITLE') }}
|
||||||
</h4>
|
</h4>
|
||||||
@@ -85,27 +90,30 @@
|
|||||||
{{ $t('PROFILE_SETTINGS.FORM.PASSWORD_CONFIRMATION.ERROR') }}
|
{{ $t('PROFILE_SETTINGS.FORM.PASSWORD_CONFIRMATION.ERROR') }}
|
||||||
</span>
|
</span>
|
||||||
</label>
|
</label>
|
||||||
|
<woot-button
|
||||||
|
:is-loading="isPasswordChanging"
|
||||||
|
type="submit"
|
||||||
|
:disabled="
|
||||||
|
!passwordConfirmation || !$v.passwordConfirmation.isEqPassword
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ $t('PROFILE_SETTINGS.FORM.PASSWORD_SECTION.BTN_TEXT') }}
|
||||||
|
</woot-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<notification-settings />
|
|
||||||
<div class="profile--settings--row row">
|
|
||||||
<div class="columns small-3 ">
|
|
||||||
<h4 class="block-title">
|
|
||||||
{{ $t('PROFILE_SETTINGS.FORM.ACCESS_TOKEN.TITLE') }}
|
|
||||||
</h4>
|
|
||||||
<p>{{ $t('PROFILE_SETTINGS.FORM.ACCESS_TOKEN.NOTE') }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="columns small-9 medium-5">
|
|
||||||
<woot-code :script="currentUser.access_token"></woot-code>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<woot-submit-button
|
|
||||||
class="button nice success button--fixed-right-top"
|
|
||||||
:button-text="$t('PROFILE_SETTINGS.BTN_TEXT')"
|
|
||||||
:loading="isUpdating"
|
|
||||||
>
|
|
||||||
</woot-submit-button>
|
|
||||||
</form>
|
</form>
|
||||||
|
<notification-settings />
|
||||||
|
<div class="profile--settings--row row">
|
||||||
|
<div class="columns small-3">
|
||||||
|
<h4 class="block-title">
|
||||||
|
{{ $t('PROFILE_SETTINGS.FORM.ACCESS_TOKEN.TITLE') }}
|
||||||
|
</h4>
|
||||||
|
<p>{{ $t('PROFILE_SETTINGS.FORM.ACCESS_TOKEN.NOTE') }}</p>
|
||||||
|
</div>
|
||||||
|
<div class="columns small-9 medium-5">
|
||||||
|
<woot-code :script="currentUser.access_token"></woot-code>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -130,7 +138,8 @@ export default {
|
|||||||
email: '',
|
email: '',
|
||||||
password: '',
|
password: '',
|
||||||
passwordConfirmation: '',
|
passwordConfirmation: '',
|
||||||
isUpdating: false,
|
isProfileUpdating: false,
|
||||||
|
isPasswordChanging: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
validations: {
|
validations: {
|
||||||
@@ -181,13 +190,17 @@ export default {
|
|||||||
this.avatarUrl = this.currentUser.avatar_url;
|
this.avatarUrl = this.currentUser.avatar_url;
|
||||||
this.displayName = this.currentUser.display_name;
|
this.displayName = this.currentUser.display_name;
|
||||||
},
|
},
|
||||||
async updateUser() {
|
async updateUser(type) {
|
||||||
this.$v.$touch();
|
this.$v.$touch();
|
||||||
if (this.$v.$invalid) {
|
if (this.$v.$invalid) {
|
||||||
this.showAlert(this.$t('PROFILE_SETTINGS.FORM.ERROR'));
|
this.showAlert(this.$t('PROFILE_SETTINGS.FORM.ERROR'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isUpdating = true;
|
if (type === 'profile') {
|
||||||
|
this.isProfileUpdating = true;
|
||||||
|
} else if (type === 'password') {
|
||||||
|
this.isPasswordChanging = true;
|
||||||
|
}
|
||||||
const hasEmailChanged = this.currentUser.email !== this.email;
|
const hasEmailChanged = this.currentUser.email !== this.email;
|
||||||
try {
|
try {
|
||||||
await this.$store.dispatch('updateProfile', {
|
await this.$store.dispatch('updateProfile', {
|
||||||
@@ -198,13 +211,20 @@ export default {
|
|||||||
displayName: this.displayName,
|
displayName: this.displayName,
|
||||||
password_confirmation: this.passwordConfirmation,
|
password_confirmation: this.passwordConfirmation,
|
||||||
});
|
});
|
||||||
this.isUpdating = false;
|
this.isProfileUpdating = false;
|
||||||
|
this.isPasswordChanging = false;
|
||||||
if (hasEmailChanged) {
|
if (hasEmailChanged) {
|
||||||
clearCookiesOnLogout();
|
clearCookiesOnLogout();
|
||||||
this.showAlert(this.$t('PROFILE_SETTINGS.AFTER_EMAIL_CHANGED'));
|
this.showAlert(this.$t('PROFILE_SETTINGS.AFTER_EMAIL_CHANGED'));
|
||||||
}
|
}
|
||||||
|
if (type === 'profile') {
|
||||||
|
this.showAlert(this.$t('PROFILE_SETTINGS.UPDATE_SUCCESS'));
|
||||||
|
} else if (type === 'password') {
|
||||||
|
this.showAlert(this.$t('PROFILE_SETTINGS.PASSWORD_UPDATE_SUCCESS'));
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.isUpdating = false;
|
this.isProfileUpdating = false;
|
||||||
|
this.isPasswordChanging = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handleImageUpload({ file, url }) {
|
handleImageUpload({ file, url }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user