feat(ee): Add support for SLA in automation rules (#8910)

Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
Vishnu Narayanan
2024-02-22 04:15:43 +05:30
committed by GitHub
parent ae4c8d818f
commit 27ac262a26
9 changed files with 125 additions and 6 deletions

View File

@@ -129,7 +129,13 @@ export const agentList = agents => [
...(agents || []),
];
export const getActionOptions = ({ agents, teams, labels, type }) => {
export const getActionOptions = ({
agents,
teams,
labels,
slaPolicies,
type,
}) => {
const actionsMap = {
assign_agent: agentList(agents),
assign_team: teams,
@@ -137,6 +143,7 @@ export const getActionOptions = ({ agents, teams, labels, type }) => {
add_label: generateConditionOptions(labels, 'title'),
remove_label: generateConditionOptions(labels, 'title'),
change_priority: PRIORITY_CONDITION_VALUES,
add_sla: slaPolicies,
};
return actionsMap[type];
};

View File

@@ -27,6 +27,7 @@ export default {
inboxes: 'inboxes/getInboxes',
labels: 'labels/getLabels',
teams: 'teams/getTeams',
slaPolicies: 'sla/getSLA',
}),
booleanFilterOptions() {
return [
@@ -257,8 +258,15 @@ export default {
};
},
getActionDropdownValues(type) {
const { agents, labels, teams } = this;
return getActionOptions({ agents, labels, teams, languages, type });
const { agents, labels, teams, slaPolicies } = this;
return getActionOptions({
agents,
labels,
teams,
slaPolicies,
languages,
type,
});
},
manifestCustomAttributes() {
const conversationCustomAttributesRaw = this.$store.getters[

View File

@@ -144,6 +144,7 @@
</template>
<script>
import { mapGetters } from 'vuex';
import alertMixin from 'shared/mixins/alertMixin';
import automationMethodsMixin from 'dashboard/mixins/automations/methodsMixin';
import automationValidationsMixin from 'dashboard/mixins/automations/validationsMixin';
@@ -173,7 +174,6 @@ export default {
automationTypes: JSON.parse(JSON.stringify(AUTOMATIONS)),
automationRuleEvent: AUTOMATION_RULE_EVENTS[0].key,
automationRuleEvents: AUTOMATION_RULE_EVENTS,
automationActionTypes: AUTOMATION_ACTION_TYPES,
automationMutated: false,
show: true,
automation: {
@@ -202,6 +202,10 @@ export default {
};
},
computed: {
...mapGetters({
accountId: 'getCurrentAccountId',
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
}),
hasAutomationMutated() {
if (
this.automation.conditions[0].values ||
@@ -210,6 +214,12 @@ export default {
return true;
return false;
},
automationActionTypes() {
const isSLAEnabled = this.isFeatureEnabled('sla');
return isSLAEnabled
? AUTOMATION_ACTION_TYPES
: AUTOMATION_ACTION_TYPES.filter(action => action.key !== 'add_sla');
},
},
mounted() {
this.$store.dispatch('inboxes/get');
@@ -221,6 +231,11 @@ export default {
this.allCustomAttributes = this.$store.getters['attributes/getAttributes'];
this.manifestCustomAttributes();
},
methods: {
isFeatureEnabled(flag) {
return this.isFeatureEnabledonAccount(this.accountId, flag);
},
},
};
</script>
<style lang="scss" scoped>

View File

@@ -142,6 +142,7 @@
</template>
<script>
import { mapGetters } from 'vuex';
import alertMixin from 'shared/mixins/alertMixin';
import automationMethodsMixin from 'dashboard/mixins/automations/methodsMixin';
import automationValidationsMixin from 'dashboard/mixins/automations/validationsMixin';
@@ -175,7 +176,6 @@ export default {
automationTypes: JSON.parse(JSON.stringify(AUTOMATIONS)),
automationRuleEvent: AUTOMATION_RULE_EVENTS[0].key,
automationRuleEvents: AUTOMATION_RULE_EVENTS,
automationActionTypes: AUTOMATION_ACTION_TYPES,
automationMutated: false,
show: true,
automation: null,
@@ -185,6 +185,10 @@ export default {
};
},
computed: {
...mapGetters({
accountId: 'getCurrentAccountId',
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
}),
hasAutomationMutated() {
if (
this.automation.conditions[0].values ||
@@ -193,12 +197,23 @@ export default {
return true;
return false;
},
automationActionTypes() {
const isSLAEnabled = this.isFeatureEnabled('sla');
return isSLAEnabled
? AUTOMATION_ACTION_TYPES
: AUTOMATION_ACTION_TYPES.filter(action => action.key !== 'add_sla');
},
},
mounted() {
this.manifestCustomAttributes();
this.allCustomAttributes = this.$store.getters['attributes/getAttributes'];
this.formatAutomation(this.selectedResponse);
},
methods: {
isFeatureEnabled(flag) {
return this.isFeatureEnabledonAccount(this.accountId, flag);
},
},
};
</script>
<style lang="scss" scoped>

View File

@@ -153,6 +153,8 @@ export default {
...mapGetters({
records: ['automations/getAutomations'],
uiFlags: 'automations/getUIFlags',
accountId: 'getCurrentAccountId',
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
}),
// Delete Modal
deleteConfirmText() {
@@ -168,6 +170,9 @@ export default {
deleteMessage() {
return ` ${this.selectedResponse.name}?`;
},
isSLAEnabled() {
return this.isFeatureEnabledonAccount(this.accountId, 'sla');
},
},
mounted() {
this.$store.dispatch('inboxes/get');
@@ -177,6 +182,7 @@ export default {
this.$store.dispatch('labels/get');
this.$store.dispatch('campaigns/get');
this.$store.dispatch('automations/get');
if (this.isSLAEnabled) this.$store.dispatch('sla/get');
},
methods: {
openAddPopup() {

View File

@@ -611,4 +611,9 @@ export const AUTOMATION_ACTION_TYPES = [
label: 'Change Priority',
inputType: 'search_select',
},
{
key: 'add_sla',
label: 'Add SLA',
inputType: 'search_select',
},
];

View File

@@ -111,12 +111,26 @@ export default {
...mapGetters({
records: 'sla/getSLA',
uiFlags: 'sla/getUIFlags',
accountId: 'getCurrentAccountId',
isFeatureEnabledonAccount: 'accounts/isFeatureEnabledonAccount',
}),
isSLAEnabled() {
return this.isFeatureEnabledonAccount(this.accountId, 'sla');
},
},
mounted() {
this.$store.dispatch('sla/get');
this.isSLAfeatureEnabled();
},
methods: {
isSLAfeatureEnabled() {
if (!this.isSLAEnabled) {
this.$router.push({
name: 'general_settings_index',
});
} else {
this.$store.dispatch('sla/get');
}
},
openAddPopup() {
this.showAddPopup = true;
},

View File

@@ -762,3 +762,45 @@ export const expectedOutputForCustomAttributeGenerator = [
],
},
];
export const slaPolicies = [
{
id: 1,
account_id: 1,
name: 'Low',
first_response_time_threshold: 60,
next_response_time_threshold: 120,
resolution_time_threshold: 240,
created_at: '2022-01-26T08:06:39.470Z',
updated_at: '2022-01-26T08:06:39.470Z',
},
{
id: 2,
account_id: 1,
name: 'Medium',
first_response_time_threshold: 30,
next_response_time_threshold: 60,
resolution_time_threshold: 120,
created_at: '2022-01-26T08:06:39.470Z',
updated_at: '2022-01-26T08:06:39.470Z',
},
{
id: 3,
account_id: 1,
name: 'High',
first_response_time_threshold: 15,
next_response_time_threshold: 30,
resolution_time_threshold: 60,
created_at: '2022-01-26T08:06:39.470Z',
updated_at: '2022-01-26T08:06:39.470Z',
},
{
id: 4,
account_id: 1,
name: 'Urgent',
first_response_time_threshold: 5,
next_response_time_threshold: 10,
resolution_time_threshold: 20,
created_at: '2022-01-26T08:06:39.470Z',
updated_at: '2022-01-26T08:06:39.470Z',
},
];

View File

@@ -13,6 +13,7 @@ import {
inboxes,
languages,
countries,
slaPolicies,
MESSAGE_CONDITION_VALUES,
automationToSubmit,
savedAutomation,
@@ -89,6 +90,9 @@ const generateComputedProperties = () => {
countries() {
return countries;
},
slaPolicies() {
return slaPolicies;
},
MESSAGE_CONDITION_VALUES() {
return MESSAGE_CONDITION_VALUES;
},
@@ -433,6 +437,9 @@ describe('automationMethodsMixin', () => {
teams() {
return teams;
},
slaPolicies() {
return slaPolicies;
},
};
const expectedActionDropdownValues = [
{ id: 'testlabel', name: 'testlabel' },