feat: Add assign agent option in macro (#5821)
Co-authored-by: fayazara <fayazara@gmail.com>
This commit is contained in:
@@ -70,6 +70,34 @@ export const labels = [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const agents = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
account_id: 1,
|
||||||
|
availability_status: 'offline',
|
||||||
|
auto_offline: true,
|
||||||
|
confirmed: true,
|
||||||
|
email: 'john@doe.com',
|
||||||
|
available_name: 'John Doe',
|
||||||
|
name: 'John Doe',
|
||||||
|
role: 'agent',
|
||||||
|
thumbnail:
|
||||||
|
'http://localhost:3000/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBUZz09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--746506837470c1a3dd063e90211ba2386963d52f/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lJY0c1bkJqb0dSVlE2QzNKbGMybDZaVWtpRERJMU1IZ3lOVEFHT3daVSIsImV4cCI6bnVsbCwicHVyIjoidmFyaWF0aW9uIn19--e0e35266e8ed66e90c51be02408be8a022aca545/batman_90804.png',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 9,
|
||||||
|
account_id: 1,
|
||||||
|
availability_status: 'offline',
|
||||||
|
auto_offline: true,
|
||||||
|
confirmed: true,
|
||||||
|
email: 'clark@kent.com',
|
||||||
|
available_name: 'Clark Kent',
|
||||||
|
name: 'Clark Kent',
|
||||||
|
role: 'agent',
|
||||||
|
thumbnail: '',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
export const files = [
|
export const files = [
|
||||||
{
|
{
|
||||||
id: 76,
|
id: 76,
|
||||||
|
|||||||
@@ -4,9 +4,10 @@ import {
|
|||||||
resolveLabels,
|
resolveLabels,
|
||||||
resolveTeamIds,
|
resolveTeamIds,
|
||||||
getFileName,
|
getFileName,
|
||||||
|
resolveAgents,
|
||||||
} from '../../routes/dashboard/settings/macros/macroHelper';
|
} from '../../routes/dashboard/settings/macros/macroHelper';
|
||||||
import { MACRO_ACTION_TYPES } from '../../routes/dashboard/settings/macros/constants';
|
import { MACRO_ACTION_TYPES } from '../../routes/dashboard/settings/macros/constants';
|
||||||
import { teams, labels, files } from './macrosFixtures';
|
import { teams, labels, files, agents } from './macrosFixtures';
|
||||||
|
|
||||||
describe('#emptyMacro', () => {
|
describe('#emptyMacro', () => {
|
||||||
const defaultMacro = {
|
const defaultMacro = {
|
||||||
@@ -52,6 +53,13 @@ describe('#resolveLabels', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#resolveAgents', () => {
|
||||||
|
it('resolves agents names from ids and returns a joined string', () => {
|
||||||
|
const resolvedAgents = 'John Doe';
|
||||||
|
expect(resolveAgents(agents, [1])).toEqual(resolvedAgents);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('#getFileName', () => {
|
describe('#getFileName', () => {
|
||||||
it('returns the correct file name from the list of files', () => {
|
it('returns the correct file name from the list of files', () => {
|
||||||
expect(getFileName(files[0].blob_id, 'send_attachment', files)).toEqual(
|
expect(getFileName(files[0].blob_id, 'send_attachment', files)).toEqual(
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export default {
|
|||||||
case 'assign_team':
|
case 'assign_team':
|
||||||
case 'send_email_to_team':
|
case 'send_email_to_team':
|
||||||
return this.teams;
|
return this.teams;
|
||||||
|
case 'assign_best_agent':
|
||||||
|
return this.agents;
|
||||||
case 'add_label':
|
case 'add_label':
|
||||||
return this.labels.map(i => {
|
return this.labels.map(i => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { createWrapper } from '@vue/test-utils';
|
import { createWrapper } from '@vue/test-utils';
|
||||||
import macrosMixin from '../macrosMixin';
|
import macrosMixin from '../macrosMixin';
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { teams, labels } from '../../helper/specs/macrosFixtures';
|
import { teams, labels, agents } from '../../helper/specs/macrosFixtures';
|
||||||
describe('webhookMixin', () => {
|
describe('webhookMixin', () => {
|
||||||
describe('#getEventLabel', () => {
|
describe('#getEventLabel', () => {
|
||||||
it('returns correct i18n translation:', () => {
|
it('returns correct i18n translation:', () => {
|
||||||
@@ -13,6 +13,7 @@ describe('webhookMixin', () => {
|
|||||||
return {
|
return {
|
||||||
teams,
|
teams,
|
||||||
labels,
|
labels,
|
||||||
|
agents,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -35,6 +36,7 @@ describe('webhookMixin', () => {
|
|||||||
expect(wrapper.vm.getDropdownValues('assign_team')).toEqual(teams);
|
expect(wrapper.vm.getDropdownValues('assign_team')).toEqual(teams);
|
||||||
expect(wrapper.vm.getDropdownValues('send_email_to_team')).toEqual(teams);
|
expect(wrapper.vm.getDropdownValues('send_email_to_team')).toEqual(teams);
|
||||||
expect(wrapper.vm.getDropdownValues('add_label')).toEqual(resolvedLabels);
|
expect(wrapper.vm.getDropdownValues('add_label')).toEqual(resolvedLabels);
|
||||||
|
expect(wrapper.vm.getDropdownValues('assign_best_agent')).toEqual(agents);
|
||||||
expect(wrapper.vm.getDropdownValues()).toEqual([]);
|
expect(wrapper.vm.getDropdownValues()).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
resolveActionName,
|
resolveActionName,
|
||||||
resolveTeamIds,
|
resolveTeamIds,
|
||||||
resolveLabels,
|
resolveLabels,
|
||||||
|
resolveAgents,
|
||||||
} from 'dashboard/routes/dashboard/settings/macros/macroHelper';
|
} from 'dashboard/routes/dashboard/settings/macros/macroHelper';
|
||||||
import { mapGetters } from 'vuex';
|
import { mapGetters } from 'vuex';
|
||||||
|
|
||||||
@@ -40,6 +41,7 @@ export default {
|
|||||||
...mapGetters({
|
...mapGetters({
|
||||||
labels: 'labels/getLabels',
|
labels: 'labels/getLabels',
|
||||||
teams: 'teams/getTeams',
|
teams: 'teams/getTeams',
|
||||||
|
agents: 'agents/getAgents',
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -47,6 +49,7 @@ export default {
|
|||||||
const actionsMap = {
|
const actionsMap = {
|
||||||
assign_team: resolveTeamIds(this.teams, params),
|
assign_team: resolveTeamIds(this.teams, params),
|
||||||
add_label: resolveLabels(this.labels, params),
|
add_label: resolveLabels(this.labels, params),
|
||||||
|
assign_best_agent: resolveAgents(this.agents, params),
|
||||||
mute_conversation: null,
|
mute_conversation: null,
|
||||||
snooze_conversation: null,
|
snooze_conversation: null,
|
||||||
resolve_conversation: null,
|
resolve_conversation: null,
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export default {
|
|||||||
uiFlags: 'macros/getUIFlags',
|
uiFlags: 'macros/getUIFlags',
|
||||||
labels: 'labels/getLabels',
|
labels: 'labels/getLabels',
|
||||||
teams: 'teams/getTeams',
|
teams: 'teams/getTeams',
|
||||||
|
agents: 'agents/getAgents',
|
||||||
}),
|
}),
|
||||||
macroId() {
|
macroId() {
|
||||||
return this.$route.params.macroId;
|
return this.$route.params.macroId;
|
||||||
@@ -50,6 +51,7 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
$route: {
|
$route: {
|
||||||
handler() {
|
handler() {
|
||||||
|
this.fetchDropdownData();
|
||||||
if (this.$route.params.macroId) {
|
if (this.$route.params.macroId) {
|
||||||
this.fetchMacro();
|
this.fetchMacro();
|
||||||
} else {
|
} else {
|
||||||
@@ -60,11 +62,13 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchMacro() {
|
fetchDropdownData() {
|
||||||
this.mode = 'EDIT';
|
|
||||||
this.$store.dispatch('agents/get');
|
this.$store.dispatch('agents/get');
|
||||||
this.$store.dispatch('teams/get');
|
this.$store.dispatch('teams/get');
|
||||||
this.$store.dispatch('labels/get');
|
this.$store.dispatch('labels/get');
|
||||||
|
},
|
||||||
|
fetchMacro() {
|
||||||
|
this.mode = 'EDIT';
|
||||||
this.manifestMacro();
|
this.manifestMacro();
|
||||||
},
|
},
|
||||||
async manifestMacro() {
|
async manifestMacro() {
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export default {
|
|||||||
...mapGetters({
|
...mapGetters({
|
||||||
labels: 'labels/getLabels',
|
labels: 'labels/getLabels',
|
||||||
teams: 'teams/getTeams',
|
teams: 'teams/getTeams',
|
||||||
|
agents: 'agents/getAgents',
|
||||||
}),
|
}),
|
||||||
actionData: {
|
actionData: {
|
||||||
get() {
|
get() {
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ export const MACRO_ACTION_TYPES = [
|
|||||||
label: 'Assign a team',
|
label: 'Assign a team',
|
||||||
inputType: 'multi_select',
|
inputType: 'multi_select',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
key: 'assign_best_agent',
|
||||||
|
label: 'Assign an agent',
|
||||||
|
inputType: 'multi_select',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'add_label',
|
key: 'add_label',
|
||||||
label: 'Add a label',
|
label: 'Add a label',
|
||||||
|
|||||||
@@ -32,6 +32,15 @@ export const resolveLabels = (labels, ids) => {
|
|||||||
.join(', ');
|
.join(', ');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const resolveAgents = (agents, ids) => {
|
||||||
|
return ids
|
||||||
|
.map(id => {
|
||||||
|
const agent = agents.find(i => i.id === id);
|
||||||
|
return agent ? agent.name : '';
|
||||||
|
})
|
||||||
|
.join(', ');
|
||||||
|
};
|
||||||
|
|
||||||
export const getFileName = (id, actionType, files) => {
|
export const getFileName = (id, actionType, files) => {
|
||||||
if (!id || !files) return '';
|
if (!id || !files) return '';
|
||||||
if (actionType === 'send_attachment') {
|
if (actionType === 'send_attachment') {
|
||||||
|
|||||||
Reference in New Issue
Block a user