fix: Avoid keys getting translated in availability (#1418)

This commit is contained in:
Pranav Raj S
2020-11-17 10:39:46 +05:30
committed by GitHub
parent 2d70131097
commit 3ee453c01e
34 changed files with 111 additions and 401 deletions

View File

@@ -6,7 +6,7 @@
/>
<div class="status-view--title">
{{ currentUserAvailabilityStatus }}
{{ availabilityDisplayLabel }}
</div>
</div>
@@ -47,6 +47,7 @@
<script>
import { mapGetters } from 'vuex';
import { mixin as clickaway } from 'vue-clickaway';
const AVAILABILITY_STATUS_KEYS = ['online', 'busy', 'offline'];
export default {
mixins: [clickaway],
@@ -62,14 +63,25 @@ export default {
...mapGetters({
currentUser: 'getCurrentUser',
}),
availabilityDisplayLabel() {
const availabilityIndex = AVAILABILITY_STATUS_KEYS.findIndex(
key => key === this.currentUserAvailabilityStatus
);
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST')[
availabilityIndex
];
},
currentUserAvailabilityStatus() {
return this.currentUser.availability_status;
},
availabilityStatuses() {
return this.$t('PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST').map(
status => ({
...status,
disabled: this.currentUserAvailabilityStatus === status.value,
(statusLabel, index) => ({
label: statusLabel,
value: AVAILABILITY_STATUS_KEYS[index],
disabled:
this.currentUserAvailabilityStatus ===
AVAILABILITY_STATUS_KEYS[index],
})
);
},

View File

@@ -46,7 +46,7 @@ describe('AvailabilityStatus', () => {
it('shows current user status', () => {
const statusViewTitle = availabilityStatus.find('.status-view--title');
expect(statusViewTitle.text()).toBe(currentUser.availability_status);
expect(statusViewTitle.text()).toBe('Online');
});
it('opens the menu when user clicks "change"', async () => {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "التوفر",
"STATUSES_LIST": [
{
"value": "متصل",
"label": "متصل"
},
{
"value": "مشغول",
"label": "مشغول"
},
{
"value": "غير متصل",
"label": "غير متصل"
}
"متصل",
"مشغول",
"غير متصل"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Disponibilitat",
"STATUSES_LIST": [
{
"value": "en línia",
"label": "En línia"
},
{
"value": "ocupat",
"label": "Ocupat"
},
{
"value": "fora de línia",
"label": "Fora de línia"
}
"En línia",
"Ocupat",
"Fora de línia"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Διαθεσιμότητα",
"STATUSES_LIST": [
{
"value": "online",
"label": "Στην Γραμμή"
},
{
"value": "busy",
"label": "Απασχολημένος"
},
{
"value": "offline",
"label": "Εκτός"
}
"Στην Γραμμή",
"Απασχολημένος",
"Εκτός"
]
},
"EMAIL": {

View File

@@ -57,18 +57,10 @@
},
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"STATUSES_LIST": [
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Disponibilidad",
"STATUSES_LIST": [
{
"value": "online",
"label": "En línea"
},
{
"value": "busy",
"label": "Ocupado"
},
{
"value": "offline",
"label": "Fuera de línea"
}
"En línea",
"Ocupado",
"Fuera de línea"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "در دسترس",
"STATUSES_LIST": [
{
"value": "آنلاین",
"label": نلاین"
},
{
"value": "مشغول",
"label": "مشغول"
},
{
"value": "آفلاین",
"label": "آفلاین"
}
"آنلاین",
"مشغول",
فلاین"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Disponibilité",
"STATUSES_LIST": [
{
"value": "online",
"label": "En ligne"
},
{
"value": "busy",
"label": "Occupé(e)"
},
{
"value": "offline",
"label": "Hors-ligne"
}
"En ligne",
"Occupé(e)",
"Hors-ligne"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "利用可能期間",
"STATUSES_LIST": [
{
"value": "オンライン",
"label": "オライン"
},
{
"value": "取り込み中",
"label": "取り込み中"
},
{
"value": "オフライン",
"label": "オフライン"
}
"オンライン",
"取り込み中",
"オライン"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "ലഭ്യത",
"STATUSES_LIST": [
{
"value": "online",
"label": "ഓ‌ലൈൻ"
},
{
"value": "busy",
"label": "തിരക്ക്"
},
{
"value": "offline",
"label": "ഓഫ്‌ലൈൻ"
}
"ഓൺ‌ലൈൻ",
"തിരക്ക്",
"ഓഫ്‌ലൈൻ"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Druk",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Disponibilidade",
"STATUSES_LIST": [
{
"value": "online",
"label": "Disponível"
},
{
"value": "busy",
"label": "Ocupado"
},
{
"value": "offline",
"label": "Desconectado"
}
"Disponível",
"Ocupado",
"Desconectado"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Disponibilitate",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Ocupat"
},
{
"value": "offline",
"label": "Deconectat"
}
"Online",
"Ocupat",
"Deconectat"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Доступность",
"STATUSES_LIST": [
{
"value": "online",
"label": "В сети"
},
{
"value": "busy",
"label": "Занят"
},
{
"value": "offline",
"label": "Оффлайн"
}
"В сети",
"Занят",
"Оффлайн"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Availability",
"STATUSES_LIST": [
{
"value": "online",
"label": "Online"
},
{
"value": "busy",
"label": "Busy"
},
{
"value": "offline",
"label": "Offline"
}
"Online",
"Busy",
"Offline"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "Khả dụng",
"STATUSES_LIST": [
{
"value": "online",
"label": "Trực Tuyến"
},
{
"value": "busy",
"label": "Bận"
},
{
"value": "offline",
"label": "Không Trực Tuyến"
}
"Trực Tuyến",
"Bận",
"Không Trực Tuyến"
]
},
"EMAIL": {

View File

@@ -56,18 +56,9 @@
"AVAILABILITY": {
"LABEL": "有效的",
"STATUSES_LIST": [
{
"value": "online",
"label": "线的"
},
{
"value": "busy",
"label": "忙碌中"
},
{
"value": "offline",
"label": "离线的"
}
"在线的",
"忙碌中",
"线的"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "有效的",
"STATUSES_LIST": [
{
"value": "online",
"label": "线的"
},
{
"value": "busy",
"label": "忙碌中"
},
{
"value": "offline",
"label": "离线的"
}
"在线的",
"忙碌中",
"线的"
]
},
"EMAIL": {

View File

@@ -58,18 +58,9 @@
"AVAILABILITY": {
"LABEL": "有效的",
"STATUSES_LIST": [
{
"value": "online",
"label": "線上的"
},
{
"value": "busy",
"label": "忙碌中"
},
{
"value": "offline",
"label": "離線的"
}
"線上的",
"忙碌中",
"離線的"
]
},
"EMAIL": {

View File

@@ -49,21 +49,6 @@
{{ $t('PROFILE_SETTINGS.FORM.EMAIL.ERROR') }}
</span>
</label>
<label>
{{ $t('PROFILE_SETTINGS.FORM.AVAILABILITY.LABEL') }}
<select v-model="availability">
<option
v-for="status in $t(
'PROFILE_SETTINGS.FORM.AVAILABILITY.STATUSES_LIST'
)"
:key="status.key"
class="text-capitalize"
:value="status.value"
>
{{ status.label }}
</option>
</select>
</label>
</div>
</div>
<div class="profile--settings--row row">
@@ -145,7 +130,6 @@ export default {
email: '',
password: '',
passwordConfirmation: '',
availability: 'online',
isUpdating: false,
};
},
@@ -175,7 +159,6 @@ export default {
...mapGetters({
currentUser: 'getCurrentUser',
currentUserId: 'getCurrentUserID',
currentAvailabilityStatus: 'getCurrentUserAvailabilityStatus',
}),
},
watch: {
@@ -184,11 +167,6 @@ export default {
this.initializeUser();
}
},
currentAvailabilityStatus(newStatus, oldStatus) {
if (newStatus !== oldStatus) {
this.availability = newStatus;
}
},
},
mounted() {
if (this.currentUserId) {
@@ -200,7 +178,6 @@ export default {
this.name = this.currentUser.name;
this.email = this.currentUser.email;
this.avatarUrl = this.currentUser.avatar_url;
this.availability = this.currentUser.availability_status;
this.displayName = this.currentUser.display_name;
},
async updateUser() {
@@ -218,7 +195,6 @@ export default {
avatar: this.avatarFile,
password: this.password,
displayName: this.displayName,
availability: this.availability,
password_confirmation: this.passwordConfirmation,
});
this.isUpdating = false;