fix(macros): add explicit remove assignment actions
This commit is contained in:
@@ -111,7 +111,7 @@ describe('useMacros', () => {
|
||||
useStoreGetters.mockReturnValue({
|
||||
'labels/getLabels': { value: mockLabels },
|
||||
'teams/getTeams': { value: mockTeams },
|
||||
'agents/getAgents': { value: mockAgents },
|
||||
'agents/getVerifiedAgents': { value: mockAgents },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -129,7 +129,10 @@ describe('useMacros', () => {
|
||||
it('returns teams with "None" option for assign_team and teams only for send_email_to_team', () => {
|
||||
const { getMacroDropdownValues } = useMacros();
|
||||
const assignTeamResult = getMacroDropdownValues('assign_team');
|
||||
expect(assignTeamResult[0]).toEqual({ id: 'nil', name: 'AUTOMATION.NONE_OPTION' });
|
||||
expect(assignTeamResult[0]).toEqual({
|
||||
id: 'nil',
|
||||
name: 'AUTOMATION.NONE_OPTION',
|
||||
});
|
||||
expect(assignTeamResult.slice(1)).toEqual(mockTeams);
|
||||
expect(getMacroDropdownValues('send_email_to_team')).toEqual(mockTeams);
|
||||
});
|
||||
@@ -170,7 +173,7 @@ describe('useMacros', () => {
|
||||
useStoreGetters.mockReturnValue({
|
||||
'labels/getLabels': { value: [] },
|
||||
'teams/getTeams': { value: [] },
|
||||
'agents/getAgents': { value: [] },
|
||||
'agents/getVerifiedAgents': { value: [] },
|
||||
});
|
||||
|
||||
const { getMacroDropdownValues } = useMacros();
|
||||
|
||||
@@ -13,7 +13,12 @@ export const useMacros = () => {
|
||||
|
||||
const labels = computed(() => getters['labels/getLabels'].value);
|
||||
const teams = computed(() => getters['teams/getTeams'].value);
|
||||
const agents = computed(() => getters['agents/getAgents'].value);
|
||||
const agents = computed(() => getters['agents/getVerifiedAgents'].value);
|
||||
|
||||
const withNoneOption = options => [
|
||||
{ id: 'nil', name: t('AUTOMATION.NONE_OPTION') },
|
||||
...(options || []),
|
||||
];
|
||||
|
||||
/**
|
||||
* Get dropdown values based on the specified type
|
||||
@@ -23,15 +28,12 @@ export const useMacros = () => {
|
||||
const getMacroDropdownValues = type => {
|
||||
switch (type) {
|
||||
case 'assign_team':
|
||||
return [
|
||||
{ id: 'nil', name: t('AUTOMATION.NONE_OPTION') },
|
||||
...teams.value,
|
||||
];
|
||||
return withNoneOption(teams.value);
|
||||
case 'send_email_to_team':
|
||||
return teams.value;
|
||||
case 'assign_agent':
|
||||
return [
|
||||
{ id: 'nil', name: t('AUTOMATION.NONE_OPTION') },
|
||||
...withNoneOption(),
|
||||
{ id: 'self', name: 'Self' },
|
||||
...agents.value,
|
||||
];
|
||||
|
||||
@@ -45,6 +45,10 @@ describe('#resolveTeamIds', () => {
|
||||
const resolvedTeams = '⚙️ sales team, 🤷♂️ fayaz';
|
||||
expect(resolveTeamIds(teams, [1, 2])).toEqual(resolvedTeams);
|
||||
});
|
||||
|
||||
it('resolves nil as None', () => {
|
||||
expect(resolveTeamIds(teams, ['nil'])).toEqual('None');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#resolveLabels', () => {
|
||||
@@ -59,6 +63,10 @@ describe('#resolveAgents', () => {
|
||||
const resolvedAgents = 'John Doe';
|
||||
expect(resolveAgents(agents, [1])).toEqual(resolvedAgents);
|
||||
});
|
||||
|
||||
it('resolves nil and self values', () => {
|
||||
expect(resolveAgents(agents, ['nil', 'self'])).toEqual('None, Self');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getFileName', () => {
|
||||
|
||||
@@ -125,6 +125,7 @@ const validateSingleAction = action => {
|
||||
'mute_conversation',
|
||||
'snooze_conversation',
|
||||
'resolve_conversation',
|
||||
'remove_assigned_agent',
|
||||
'remove_assigned_team',
|
||||
'open_conversation',
|
||||
];
|
||||
|
||||
@@ -137,6 +137,8 @@
|
||||
"ACTIONS": {
|
||||
"ASSIGN_AGENT": "Assign to Agent",
|
||||
"ASSIGN_TEAM": "Assign a Team",
|
||||
"REMOVE_ASSIGNED_AGENT": "Remove Assigned Agent",
|
||||
"REMOVE_ASSIGNED_TEAM": "Remove Assigned Team",
|
||||
"ADD_LABEL": "Add a Label",
|
||||
"REMOVE_LABEL": "Remove a Label",
|
||||
"SEND_EMAIL_TO_TEAM": "Send an Email to Team",
|
||||
|
||||
@@ -89,6 +89,7 @@
|
||||
"ASSIGN_AGENT": "Assign an Agent",
|
||||
"ADD_LABEL": "Add a Label",
|
||||
"REMOVE_LABEL": "Remove a Label",
|
||||
"REMOVE_ASSIGNED_AGENT": "Remove Assigned Agent",
|
||||
"REMOVE_ASSIGNED_TEAM": "Remove Assigned Team",
|
||||
"SEND_EMAIL_TRANSCRIPT": "Send an Email Transcript",
|
||||
"MUTE_CONVERSATION": "Mute Conversation",
|
||||
|
||||
@@ -25,6 +25,7 @@ const getActionValue = (key, params) => {
|
||||
add_label: resolveLabels(labels.value, params),
|
||||
remove_label: resolveLabels(labels.value, params),
|
||||
assign_agent: resolveAgents(agents.value, params),
|
||||
remove_assigned_agent: null,
|
||||
mute_conversation: null,
|
||||
snooze_conversation: null,
|
||||
resolve_conversation: null,
|
||||
|
||||
@@ -78,6 +78,14 @@ export const AUTOMATIONS = {
|
||||
key: 'assign_team',
|
||||
name: 'ASSIGN_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
name: 'REMOVE_ASSIGNED_AGENT',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
name: 'REMOVE_ASSIGNED_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'add_label',
|
||||
name: 'ADD_LABEL',
|
||||
@@ -196,6 +204,14 @@ export const AUTOMATIONS = {
|
||||
key: 'assign_team',
|
||||
name: 'ASSIGN_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
name: 'REMOVE_ASSIGNED_AGENT',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
name: 'REMOVE_ASSIGNED_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'assign_agent',
|
||||
name: 'ASSIGN_AGENT',
|
||||
@@ -318,6 +334,14 @@ export const AUTOMATIONS = {
|
||||
key: 'assign_team',
|
||||
name: 'ASSIGN_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
name: 'REMOVE_ASSIGNED_AGENT',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
name: 'REMOVE_ASSIGNED_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'assign_agent',
|
||||
name: 'ASSIGN_AGENT',
|
||||
@@ -434,6 +458,14 @@ export const AUTOMATIONS = {
|
||||
key: 'assign_team',
|
||||
name: 'ASSIGN_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
name: 'REMOVE_ASSIGNED_AGENT',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
name: 'REMOVE_ASSIGNED_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'assign_agent',
|
||||
name: 'ASSIGN_AGENT',
|
||||
@@ -546,6 +578,14 @@ export const AUTOMATIONS = {
|
||||
key: 'assign_team',
|
||||
name: 'ASSIGN_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
name: 'REMOVE_ASSIGNED_AGENT',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
name: 'REMOVE_ASSIGNED_TEAM',
|
||||
},
|
||||
{
|
||||
key: 'send_email_to_team',
|
||||
name: 'SEND_EMAIL_TO_TEAM',
|
||||
@@ -604,6 +644,16 @@ export const AUTOMATION_ACTION_TYPES = [
|
||||
label: 'ASSIGN_TEAM',
|
||||
inputType: 'search_select',
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
label: 'REMOVE_ASSIGNED_AGENT',
|
||||
inputType: null,
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
label: 'REMOVE_ASSIGNED_TEAM',
|
||||
inputType: null,
|
||||
},
|
||||
{
|
||||
key: 'add_label',
|
||||
label: 'ADD_LABEL',
|
||||
|
||||
@@ -58,7 +58,9 @@ const formatMacro = macroData => {
|
||||
),
|
||||
message: action.action_params[0].message,
|
||||
};
|
||||
} else actionParams = [...action.action_params];
|
||||
} else {
|
||||
actionParams = [...action.action_params];
|
||||
}
|
||||
}
|
||||
return {
|
||||
...action,
|
||||
|
||||
@@ -19,8 +19,11 @@ export const MACRO_ACTION_TYPES = [
|
||||
label: 'REMOVE_LABEL',
|
||||
inputType: 'multi_select',
|
||||
},
|
||||
// @deprecated: Use assign_team with 'None' option instead
|
||||
// Kept for backward compatibility
|
||||
{
|
||||
key: 'remove_assigned_agent',
|
||||
label: 'REMOVE_ASSIGNED_AGENT',
|
||||
inputType: null,
|
||||
},
|
||||
{
|
||||
key: 'remove_assigned_team',
|
||||
label: 'REMOVE_ASSIGNED_TEAM',
|
||||
|
||||
Reference in New Issue
Block a user