feat: Right click context menu action to change the priority (#6947)

* Right click context menu action to change the priority

* Review comments

* Update Index.vue

* Remove selected priority  from menu

* Code cleanup

* Update conversation.json
This commit is contained in:
Muhsin Keloth
2023-04-24 20:07:50 +05:30
committed by GitHub
parent 0874aeee2d
commit e32f3e71e4
3 changed files with 65 additions and 0 deletions

View File

@@ -125,6 +125,7 @@
@update-conversation-status="toggleConversationStatus"
@context-menu-toggle="onContextMenuToggle"
@mark-as-unread="markAsUnread"
@assign-priority="assignPriority"
/>
<div v-if="chatListLoading" class="text-center">
@@ -670,6 +671,22 @@ export default {
this.showAlert(this.$t('BULK_ACTION.ASSIGN_FAILED'));
}
},
async assignPriority(priority, conversationId = null) {
this.$store.dispatch('setCurrentChatPriority', {
priority,
conversationId,
});
this.$store
.dispatch('assignPriority', { conversationId, priority })
.then(() => {
this.showAlert(
this.$t('CONVERSATION.PRIORITY.CHANGE_PRIORITY.SUCCESSFUL', {
priority,
conversationId,
})
);
});
},
async markAsUnread(conversationId) {
try {
await this.$store.dispatch('markMessagesUnread', {

View File

@@ -109,12 +109,14 @@
<conversation-context-menu
:status="chat.status"
:inbox-id="inbox.id"
:priority="chat.priority"
:has-unread-messages="hasUnread"
@update-conversation="onUpdateConversation"
@assign-agent="onAssignAgent"
@assign-label="onAssignLabel"
@assign-team="onAssignTeam"
@mark-as-unread="markAsUnread"
@assign-priority="assignPriority"
/>
</woot-context-menu>
</div>
@@ -375,6 +377,10 @@ export default {
this.$emit('mark-as-unread', this.chat.id);
this.closeContextMenu();
},
async assignPriority(priority) {
this.$emit('assign-priority', priority, this.chat.id);
this.closeContextMenu();
},
},
};
</script>

View File

@@ -23,6 +23,14 @@
@click="snoozeConversation(option.snoozedUntil)"
/>
</menu-item-with-submenu>
<menu-item-with-submenu :option="priorityConfig">
<menu-item
v-for="(option, i) in priorityConfig.options"
:key="i"
:option="option"
@click="assignPriority(option.key)"
/>
</menu-item-with-submenu>
<menu-item-with-submenu
:option="labelMenuConfig"
:sub-menu-available="!!labels.length"
@@ -93,6 +101,10 @@ export default {
type: Number,
default: null,
},
priority: {
type: String,
default: null,
},
},
data() {
return {
@@ -140,6 +152,33 @@ export default {
},
],
},
priorityConfig: {
key: 'priority',
label: this.$t('CONVERSATION.PRIORITY.TITLE'),
icon: 'warning',
options: [
{
label: this.$t('CONVERSATION.PRIORITY.OPTIONS.NONE'),
key: null,
},
{
label: this.$t('CONVERSATION.PRIORITY.OPTIONS.URGENT'),
key: 'urgent',
},
{
label: this.$t('CONVERSATION.PRIORITY.OPTIONS.HIGH'),
key: 'high',
},
{
label: this.$t('CONVERSATION.PRIORITY.OPTIONS.MEDIUM'),
key: 'medium',
},
{
label: this.$t('CONVERSATION.PRIORITY.OPTIONS.LOW'),
key: 'low',
},
].filter(item => item.key !== this.priority),
},
labelMenuConfig: {
key: 'label',
icon: 'tag',
@@ -193,6 +232,9 @@ export default {
this.snoozeTimes[snoozedUntil] || null
);
},
assignPriority(priority) {
this.$emit('assign-priority', priority);
},
show(key) {
// If the conversation status is same as the action, then don't display the option
// i.e.: Don't show an option to resolve if the conversation is already resolved.