-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Revamp notification and audio preferences (#9312)
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
- Loading branch information
Showing
13 changed files
with
794 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
app/javascript/dashboard/routes/dashboard/settings/personal/AudioAlertCondition.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<template> | ||
<div> | ||
<label | ||
class="flex justify-between pb-1 text-sm font-medium leading-6 text-ash-900" | ||
> | ||
{{ label }} | ||
</label> | ||
<div class="flex flex-col gap-4"> | ||
<div | ||
v-for="item in items" | ||
:key="item.id" | ||
class="flex flex-row items-start gap-2" | ||
> | ||
<CheckBox | ||
:is-checked="item.model" | ||
:value="item.value" | ||
@update="onChange" | ||
/> | ||
<label class="text-sm font-normal text-ash-900"> | ||
{{ item.label }} | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
<script setup> | ||
import CheckBox from 'v3/components/Form/CheckBox.vue'; | ||
defineProps({ | ||
label: { | ||
type: String, | ||
required: true, | ||
}, | ||
items: { | ||
type: Array, | ||
required: true, | ||
}, | ||
}); | ||
const emit = defineEmits(['change']); | ||
const onChange = (id, value) => { | ||
emit('change', id, value); | ||
}; | ||
</script> |
66 changes: 66 additions & 0 deletions
66
app/javascript/dashboard/routes/dashboard/settings/personal/AudioAlertEvent.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<template> | ||
<div> | ||
<label | ||
class="flex justify-between pb-1 text-sm font-medium leading-6 text-ash-900" | ||
> | ||
{{ label }} | ||
</label> | ||
<div | ||
class="flex flex-row justify-between h-10 max-w-xl p-2 border border-solid rounded-xl border-ash-200" | ||
> | ||
<div | ||
v-for="option in alertEvents" | ||
:key="option.value" | ||
class="flex flex-row items-center justify-center gap-2 px-4 border-r border-ash-200 grow last:border-r-0" | ||
> | ||
<input | ||
:id="`radio-${option.value}`" | ||
v-model="selectedValue" | ||
class="shadow cursor-pointer grid place-items-center border-2 border-ash-200 appearance-none rounded-full w-4 h-4 checked:bg-primary-600 before:content-[''] before:bg-primary-600 before:border-4 before:rounded-full before:border-ash-25 checked:before:w-[14px] checked:before:h-[14px] checked:border checked:border-primary-600" | ||
type="radio" | ||
:value="option.value" | ||
/> | ||
<label | ||
:for="`radio-${option.value}`" | ||
class="text-sm font-medium" | ||
:class=" | ||
selectedValue === option.value ? 'text-ash-900' : 'text-ash-800' | ||
" | ||
> | ||
{{ | ||
$t( | ||
`PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.ALERT_TYPES.${option.label.toUpperCase()}` | ||
) | ||
}} | ||
</label> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
import { computed } from 'vue'; | ||
import { ALERT_EVENTS } from './constants'; | ||
const props = defineProps({ | ||
label: { | ||
type: String, | ||
default: '', | ||
}, | ||
value: { | ||
type: String, | ||
default: 'all', | ||
}, | ||
}); | ||
const alertEvents = ALERT_EVENTS; | ||
const emit = defineEmits(['update']); | ||
const selectedValue = computed({ | ||
get: () => props.value, | ||
set: value => { | ||
emit('update', value); | ||
}, | ||
}); | ||
</script> |
56 changes: 56 additions & 0 deletions
56
app/javascript/dashboard/routes/dashboard/settings/personal/AudioAlertTone.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<template> | ||
<form-select | ||
v-model="selectedValue" | ||
name="alertTone" | ||
spacing="compact" | ||
:value="selectedValue" | ||
:options="alertTones" | ||
:label="label" | ||
class="max-w-xl" | ||
> | ||
<option | ||
v-for="tone in alertTones" | ||
:key="tone.label" | ||
:value="tone.value" | ||
:selected="tone.value === selectedValue" | ||
> | ||
{{ tone.label }} | ||
</option> | ||
</form-select> | ||
</template> | ||
<script setup> | ||
import { computed } from 'vue'; | ||
import FormSelect from 'v3/components/Form/Select.vue'; | ||
const props = defineProps({ | ||
value: { | ||
type: String, | ||
required: true, | ||
validator: value => ['ding', 'bell'].includes(value), | ||
}, | ||
label: { | ||
type: String, | ||
default: '', | ||
}, | ||
}); | ||
const alertTones = computed(() => [ | ||
{ | ||
value: 'ding', | ||
label: 'Ding', | ||
}, | ||
{ | ||
value: 'bell', | ||
label: 'Bell', | ||
}, | ||
]); | ||
const emit = defineEmits(['change']); | ||
const selectedValue = computed({ | ||
get: () => props.value, | ||
set: value => { | ||
emit('change', value); | ||
}, | ||
}); | ||
</script> |
128 changes: 128 additions & 0 deletions
128
app/javascript/dashboard/routes/dashboard/settings/personal/AudioNotifications.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
<template> | ||
<div id="profile-settings-notifications" class="flex flex-col gap-6"> | ||
<audio-alert-tone | ||
:value="alertTone" | ||
:label=" | ||
$t( | ||
'PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.DEFAULT_TONE.TITLE' | ||
) | ||
" | ||
@change="handleAudioToneChange" | ||
/> | ||
|
||
<audio-alert-event | ||
:label=" | ||
$t('PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.ALERT_TYPE.TITLE') | ||
" | ||
:value="audioAlert" | ||
@update="handAudioAlertChange" | ||
/> | ||
|
||
<audio-alert-condition | ||
:items="audioAlertConditions" | ||
:label=" | ||
$t('PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.CONDITIONS.TITLE') | ||
" | ||
@change="handleAudioAlertConditions" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { mapGetters } from 'vuex'; | ||
import alertMixin from 'shared/mixins/alertMixin'; | ||
import configMixin from 'shared/mixins/configMixin'; | ||
import uiSettingsMixin from 'dashboard/mixins/uiSettings'; | ||
import AudioAlertTone from './AudioAlertTone.vue'; | ||
import AudioAlertEvent from './AudioAlertEvent.vue'; | ||
import AudioAlertCondition from './AudioAlertCondition.vue'; | ||
export default { | ||
components: { | ||
AudioAlertEvent, | ||
AudioAlertTone, | ||
AudioAlertCondition, | ||
}, | ||
mixins: [alertMixin, configMixin, uiSettingsMixin], | ||
data() { | ||
return { | ||
audioAlert: '', | ||
playAudioWhenTabIsInactive: false, | ||
alertIfUnreadConversationExist: false, | ||
alertTone: 'ding', | ||
audioAlertConditions: [], | ||
}; | ||
}, | ||
computed: { | ||
...mapGetters({ | ||
accountId: 'getCurrentAccountId', | ||
uiSettings: 'getUISettings', | ||
}), | ||
}, | ||
watch: { | ||
uiSettings(value) { | ||
this.notificationUISettings(value); | ||
}, | ||
}, | ||
mounted() { | ||
this.notificationUISettings(this.uiSettings); | ||
this.$store.dispatch('userNotificationSettings/get'); | ||
}, | ||
methods: { | ||
notificationUISettings(uiSettings) { | ||
const { | ||
enable_audio_alerts: audioAlert = '', | ||
always_play_audio_alert: alwaysPlayAudioAlert, | ||
alert_if_unread_assigned_conversation_exist: | ||
alertIfUnreadConversationExist, | ||
notification_tone: alertTone, | ||
} = uiSettings; | ||
this.audioAlert = audioAlert; | ||
this.playAudioWhenTabIsInactive = !alwaysPlayAudioAlert; | ||
this.alertIfUnreadConversationExist = alertIfUnreadConversationExist; | ||
this.audioAlertConditions = [ | ||
{ | ||
id: 'audio1', | ||
label: this.$t( | ||
'PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.CONDITIONS.CONDITION_ONE' | ||
), | ||
model: this.playAudioWhenTabIsInactive, | ||
value: 'tab_is_inactive', | ||
}, | ||
{ | ||
id: 'audio2', | ||
label: this.$t( | ||
'PROFILE_SETTINGS.FORM.AUDIO_NOTIFICATIONS_SECTION.CONDITIONS.CONDITION_TWO' | ||
), | ||
model: this.alertIfUnreadConversationExist, | ||
value: 'conversations_are_read', | ||
}, | ||
]; | ||
this.alertTone = alertTone || 'ding'; | ||
}, | ||
handAudioAlertChange(value) { | ||
this.audioAlert = value; | ||
this.updateUISettings({ | ||
enable_audio_alerts: this.audioAlert, | ||
}); | ||
this.showAlert(this.$t('PROFILE_SETTINGS.FORM.API.UPDATE_SUCCESS')); | ||
}, | ||
handleAudioAlertConditions(id, value) { | ||
if (id === 'tab_is_inactive') { | ||
this.updateUISettings({ | ||
always_play_audio_alert: !value, | ||
}); | ||
} else if (id === 'conversations_are_read') { | ||
this.updateUISettings({ | ||
alert_if_unread_assigned_conversation_exist: value, | ||
}); | ||
} | ||
this.showAlert(this.$t('PROFILE_SETTINGS.FORM.API.UPDATE_SUCCESS')); | ||
}, | ||
handleAudioToneChange(value) { | ||
this.updateUISettings({ notification_tone: value }); | ||
this.showAlert(this.$t('PROFILE_SETTINGS.FORM.API.UPDATE_SUCCESS')); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.