Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
41a0358628 | ||
|
|
7c9b8344ca | ||
|
|
02e2191fa6 | ||
|
|
edd0d58c39 | ||
|
|
d2f5b5f976 | ||
|
|
cb2fa4da45 | ||
|
|
d1039d4866 | ||
|
|
2717bd1024 | ||
|
|
b36dfb79db |
@@ -0,0 +1,11 @@
|
||||
// /* global axios */
|
||||
|
||||
import ApiClient from './ApiClient';
|
||||
|
||||
class SlaAPI extends ApiClient {
|
||||
constructor() {
|
||||
super('sla_policies', { accountScoped: true });
|
||||
}
|
||||
}
|
||||
|
||||
export default new SlaAPI();
|
||||
@@ -39,6 +39,7 @@ const settings = accountId => ({
|
||||
'settings_teams_finish',
|
||||
'settings_teams_list',
|
||||
'settings_teams_new',
|
||||
'sla_list',
|
||||
],
|
||||
menuItems: [
|
||||
{
|
||||
@@ -158,6 +159,15 @@ const settings = accountId => ({
|
||||
featureFlag: FEATURE_FLAGS.AUDIT_LOGS,
|
||||
beta: true,
|
||||
},
|
||||
{
|
||||
icon: 'key',
|
||||
label: 'SLA',
|
||||
hasSubMenu: false,
|
||||
toState: frontendURL(`accounts/${accountId}/settings/sla/list`),
|
||||
toStateName: 'sla_list',
|
||||
featureFlag: FEATURE_FLAGS.SLA,
|
||||
beta: true,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
@@ -111,3 +111,9 @@ export const INBOX_EVENTS = Object.freeze({
|
||||
DELETE_NOTIFICATION: 'Deleted notification',
|
||||
DELETE_ALL_NOTIFICATIONS: 'Deleted all notifications',
|
||||
});
|
||||
|
||||
export const SLA_EVENTS = Object.freeze({
|
||||
CREATE: 'Created an SLA',
|
||||
UPDATE: 'Updated an SLA',
|
||||
DELETED: 'Deleted an SLA',
|
||||
});
|
||||
|
||||
@@ -29,6 +29,7 @@ import settings from './settings.json';
|
||||
import signup from './signup.json';
|
||||
import teamsSettings from './teamsSettings.json';
|
||||
import whatsappTemplates from './whatsappTemplates.json';
|
||||
import sla from './sla.json';
|
||||
import inbox from './inbox.json';
|
||||
|
||||
export default {
|
||||
@@ -61,6 +62,7 @@ export default {
|
||||
...setNewPassword,
|
||||
...settings,
|
||||
...signup,
|
||||
...sla,
|
||||
...teamsSettings,
|
||||
...whatsappTemplates,
|
||||
...inbox,
|
||||
|
||||
@@ -238,6 +238,7 @@
|
||||
"REPORTS_INBOX": "Inbox",
|
||||
"REPORTS_TEAM": "Team",
|
||||
"SET_AVAILABILITY_TITLE": "Set yourself as",
|
||||
"SLA": "SLA",
|
||||
"BETA": "Beta",
|
||||
"REPORTS_OVERVIEW": "Overview",
|
||||
"FACEBOOK_REAUTHORIZE": "Your Facebook connection has expired, please reconnect your Facebook page to continue services",
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
{
|
||||
"SLA": {
|
||||
"HEADER": "SLA",
|
||||
"HEADER_BTN_TXT": "Add sla",
|
||||
"LOADING": "Fetching slas",
|
||||
"SEARCH_404": "There are no items matching this query",
|
||||
"SIDEBAR_TXT": "<p><b>SLA</b> <p>Think of Service Level Agreements (SLAs) like friendly promises between a service provider and a customer.</p> <p> These promises set clear expectations for things like how quickly the team will respond to issues, making sure you always get a reliable and top-notch experience!</p>",
|
||||
"LIST": {
|
||||
"404": "There are no slas available in this account.",
|
||||
"TITLE": "Manage slas",
|
||||
"DESC": "SLAs: Friendly promises for great service!",
|
||||
"TABLE_HEADER": ["Name", "Description", "FRT", "NRT", "RT", "Business Hours"]
|
||||
},
|
||||
"FORM": {
|
||||
"NAME": {
|
||||
"LABEL": "SLA Name",
|
||||
"PLACEHOLDER": "SLA Name",
|
||||
"REQUIRED_ERROR": "SLA name is required",
|
||||
"MINIMUM_LENGTH_ERROR": "Minimum length 2 is required",
|
||||
"VALID_ERROR": "Only Alphabets, Numbers, Hyphen and Underscore are allowed"
|
||||
},
|
||||
"DESCRIPTION": {
|
||||
"LABEL": "Description",
|
||||
"PLACEHOLDER": "SLA Description"
|
||||
},
|
||||
"FIRST_RESPONSE_TIME": {
|
||||
"LABEL": "First Response Time",
|
||||
"PLACEHOLDER": "First Response Time"
|
||||
},
|
||||
"NEXT_RESPONSE_TIME": {
|
||||
"LABEL": "Next Response Time",
|
||||
"PLACEHOLDER": "Next Response Time"
|
||||
},
|
||||
"RESOLUTION_TIME": {
|
||||
"LABEL": "Resolution Time",
|
||||
"PLACEHOLDER": "Resolution Time"
|
||||
},
|
||||
"BUSINESS_HOURS": {
|
||||
"LABEL": "Business Hours",
|
||||
"PLACEHOLDER": "Business Hours"
|
||||
},
|
||||
"EDIT": "Edit",
|
||||
"CREATE": "Create",
|
||||
"DELETE": "Delete",
|
||||
"CANCEL": "Cancel"
|
||||
},
|
||||
"SUGGESTIONS": {
|
||||
"TOOLTIP": {
|
||||
"SINGLE_SUGGESTION": "Add sla to conversation",
|
||||
"MULTIPLE_SUGGESTION": "Select this sla",
|
||||
"DESELECT": "Deselect sla",
|
||||
"DISMISS": "Dismiss suggestion"
|
||||
},
|
||||
"POWERED_BY": "Chatwoot AI",
|
||||
"DISMISS": "Dismiss",
|
||||
"ADD_SELECTED_SLAS": "Add selected slas",
|
||||
"ADD_SELECTED_SLA": "Add selected sla",
|
||||
"ADD_ALL_SLAS": "Add all slas"
|
||||
},
|
||||
"ADD": {
|
||||
"TITLE": "Add SLA",
|
||||
"DESC": "SLAs: Friendly promises for great service!",
|
||||
"API": {
|
||||
"SUCCESS_MESSAGE": "SLA added successfully",
|
||||
"ERROR_MESSAGE": "There was an error, please try again"
|
||||
}
|
||||
},
|
||||
"EDIT": {
|
||||
"TITLE": "Edit SLA",
|
||||
"API": {
|
||||
"SUCCESS_MESSAGE": "SLA updated successfully",
|
||||
"ERROR_MESSAGE": "There was an error, please try again"
|
||||
}
|
||||
},
|
||||
"DELETE": {
|
||||
"BUTTON_TEXT": "Delete",
|
||||
"API": {
|
||||
"SUCCESS_MESSAGE": "SLA deleted successfully",
|
||||
"ERROR_MESSAGE": "There was an error, please try again"
|
||||
},
|
||||
"CONFIRM": {
|
||||
"TITLE": "Confirm Deletion",
|
||||
"MESSAGE": "Are you sure to delete ",
|
||||
"YES": "Yes, Delete ",
|
||||
"NO": "No, Keep "
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ import macros from './macros/macros.routes';
|
||||
import profile from './profile/profile.routes';
|
||||
import reports from './reports/reports.routes';
|
||||
import store from '../../../store';
|
||||
import sla from './sla/sla.routes';
|
||||
import teams from './teams/teams.routes';
|
||||
|
||||
export default {
|
||||
@@ -47,6 +48,7 @@ export default {
|
||||
...macros.routes,
|
||||
...profile.routes,
|
||||
...reports.routes,
|
||||
...sla.routes,
|
||||
...teams.routes,
|
||||
],
|
||||
};
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div class="h-auto overflow-auto flex flex-col">
|
||||
<woot-modal-header
|
||||
:header-title="$t('SLA.ADD.TITLE')"
|
||||
:header-content="$t('SLA.ADD.DESC')"
|
||||
/>
|
||||
<form class="mx-0 flex flex-wrap" @submit.prevent="addSLA">
|
||||
<woot-input
|
||||
v-model.trim="name"
|
||||
:class="{ error: $v.name.$error }"
|
||||
class="w-full sla-name--input"
|
||||
:label="$t('SLA.FORM.NAME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.NAME.PLACEHOLDER')"
|
||||
:error="getSlaNameErrorMessage"
|
||||
data-testid="sla-name"
|
||||
@input="$v.name.$touch"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="description"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.DESCRIPTION.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.DESCRIPTION.PLACEHOLDER')"
|
||||
data-testid="sla-description"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="firstResponseTimeThreshold"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.FIRST_RESPONSE_TIME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.FIRST_RESPONSE_TIME.PLACEHOLDER')"
|
||||
data-testid="sla-firstResponseTimeThreshold"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="nextResponseTimeThreshold"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.NEXT_RESPONSE_TIME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.NEXT_RESPONSE_TIME.PLACEHOLDER')"
|
||||
data-testid="sla-nextResponseTimeThreshold"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="resolutionTimeThreshold"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.RESOLUTION_TIME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.RESOLUTION_TIME.PLACEHOLDER')"
|
||||
data-testid="sla-resolutionTimeThreshold"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="onlyDuringBusinessHours"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.BUSINESS_HOURS.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.BUSINESS_HOURS.PLACEHOLDER')"
|
||||
data-testid="sla-onlyDuringBusinessHours"
|
||||
/>
|
||||
|
||||
<div class="flex justify-end items-center py-2 px-0 gap-2 w-full">
|
||||
<woot-button
|
||||
:is-disabled="$v.name.$invalid || uiFlags.isCreating"
|
||||
:is-loading="uiFlags.isCreating"
|
||||
data-testid="sla-submit"
|
||||
>
|
||||
{{ $t('SLA.FORM.CREATE') }}
|
||||
</woot-button>
|
||||
<woot-button class="button clear" @click.prevent="onClose">
|
||||
{{ $t('SLA.FORM.CANCEL') }}
|
||||
</woot-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import validationMixin from './validationMixin';
|
||||
import { mapGetters } from 'vuex';
|
||||
import validations from './validations';
|
||||
|
||||
export default {
|
||||
mixins: [alertMixin, validationMixin],
|
||||
props: {},
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
description: '',
|
||||
firstResponseTimeThreshold: '',
|
||||
nextResponseTimeThreshold: '',
|
||||
resolutionTimeThreshold: '',
|
||||
onlyDuringBusinessHours: '',
|
||||
showOnSidebar: true,
|
||||
};
|
||||
},
|
||||
validations,
|
||||
computed: {
|
||||
...mapGetters({
|
||||
uiFlags: 'sla/getUIFlags',
|
||||
}),
|
||||
},
|
||||
mounted() {},
|
||||
methods: {
|
||||
onClose() {
|
||||
this.$emit('close');
|
||||
},
|
||||
async addSLA() {
|
||||
try {
|
||||
await this.$store.dispatch('sla/create', {
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
first_response_time_threshold: this.firstResponseTimeThreshold,
|
||||
next_response_time_threshold: this.nextResponseTimeThreshold,
|
||||
resolution_time_threshold: this.resolutionTimeThreshold,
|
||||
only_during_business_hours: this.onlyDuringBusinessHours,
|
||||
});
|
||||
this.showAlert(this.$t('SLA.ADD.API.SUCCESS_MESSAGE'));
|
||||
this.onClose();
|
||||
} catch (error) {
|
||||
const errorMessage =
|
||||
error.message || this.$t('SLA.ADD.API.ERROR_MESSAGE');
|
||||
this.showAlert(errorMessage);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<div class="h-auto overflow-auto flex flex-col">
|
||||
<woot-modal-header :header-title="pageTitle" />
|
||||
<form class="mx-0 flex flex-wrap" @submit.prevent="editSLA">
|
||||
<woot-input
|
||||
v-model.trim="name"
|
||||
:class="{ error: $v.name.$error }"
|
||||
class="w-full sla-name--input"
|
||||
:sla="$t('SLA.FORM.NAME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.NAME.PLACEHOLDER')"
|
||||
:error="getSlaNameErrorMessage"
|
||||
@input="$v.name.$touch"
|
||||
/>
|
||||
<woot-input
|
||||
v-model.trim="description"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.DESCRIPTION.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.DESCRIPTION.PLACEHOLDER')"
|
||||
data-testid="sla-description"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="firstResponseTimeThreshold"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.FIRST_RESPONSE_TIME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.FIRST_RESPONSE_TIME.PLACEHOLDER')"
|
||||
data-testid="sla-firstResponseTimeThreshold"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="nextResponseTimeThreshold"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.NEXT_RESPONSE_TIME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.NEXT_RESPONSE_TIME.PLACEHOLDER')"
|
||||
data-testid="sla-nextResponseTimeThreshold"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="resolutionTimeThreshold"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.RESOLUTION_TIME.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.RESOLUTION_TIME.PLACEHOLDER')"
|
||||
data-testid="sla-resolutionTimeThreshold"
|
||||
/>
|
||||
|
||||
<woot-input
|
||||
v-model.trim="onlyDuringBusinessHours"
|
||||
class="w-full"
|
||||
:label="$t('SLA.FORM.BUSINESS_HOURS.LABEL')"
|
||||
:placeholder="$t('SLA.FORM.BUSINESS_HOURS.PLACEHOLDER')"
|
||||
data-testid="sla-onlyDuringBusinessHours"
|
||||
/>
|
||||
|
||||
<div class="flex justify-end items-center py-2 px-0 gap-2 w-full">
|
||||
<woot-button
|
||||
:is-disabled="$v.name.$invalid || uiFlags.isUpdating"
|
||||
:is-loading="uiFlags.isUpdating"
|
||||
>
|
||||
{{ $t('SLA.FORM.EDIT') }}
|
||||
</woot-button>
|
||||
<woot-button class="button clear" @click.prevent="onClose">
|
||||
{{ $t('SLA.FORM.CANCEL') }}
|
||||
</woot-button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
import validationMixin from './validationMixin';
|
||||
import validations from './validations';
|
||||
|
||||
export default {
|
||||
mixins: [alertMixin, validationMixin],
|
||||
props: {
|
||||
selectedResponse: {
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
name: '',
|
||||
description: '',
|
||||
firstResponseTimeThreshold: '',
|
||||
nextResponseTimeThreshold: '',
|
||||
resolutionTimeThreshold: '',
|
||||
onlyDuringBusinessHours: '',
|
||||
};
|
||||
},
|
||||
validations,
|
||||
computed: {
|
||||
...mapGetters({
|
||||
uiFlags: 'sla/getUIFlags',
|
||||
}),
|
||||
pageTitle() {
|
||||
return `${this.$t('SLA.EDIT.TITLE')} - ${this.selectedResponse.name}`;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.setFormValues();
|
||||
},
|
||||
methods: {
|
||||
onClose() {
|
||||
this.$emit('close');
|
||||
},
|
||||
setFormValues() {
|
||||
this.name = this.selectedResponse.name;
|
||||
this.description = this.selectedResponse.description;
|
||||
this.firstResponseTimeThreshold =
|
||||
this.selectedResponse.first_response_time_threshold;
|
||||
this.nextResponseTimeThreshold =
|
||||
this.selectedResponse.next_response_time_threshold;
|
||||
this.resolutionTimeThreshold =
|
||||
this.selectedResponse.resolution_time_threshold;
|
||||
this.onlyDuringBusinessHours =
|
||||
this.selectedResponse.only_during_business_hours.toString();
|
||||
},
|
||||
editSLA() {
|
||||
this.$store
|
||||
.dispatch('sla/update', {
|
||||
id: this.selectedResponse.id,
|
||||
name: this.name,
|
||||
description: this.description,
|
||||
first_response_time_threshold: this.firstResponseTimeThreshold,
|
||||
next_response_time_threshold: this.nextResponseTimeThreshold,
|
||||
resolution_time_threshold: this.resolutionTimeThreshold,
|
||||
only_during_business_hours: this.onlyDuringBusinessHours,
|
||||
})
|
||||
.then(() => {
|
||||
this.showAlert(this.$t('SLA.EDIT.API.SUCCESS_MESSAGE'));
|
||||
setTimeout(() => this.onClose(), 10);
|
||||
})
|
||||
.catch(() => {
|
||||
this.showAlert(this.$t('SLA.EDIT.API.ERROR_MESSAGE'));
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,216 @@
|
||||
<template>
|
||||
<div class="flex-1 overflow-auto p-4">
|
||||
<woot-button
|
||||
color-scheme="success"
|
||||
class-names="button--fixed-top"
|
||||
icon="add-circle"
|
||||
@click="openAddPopup"
|
||||
>
|
||||
{{ $t('SLA.HEADER_BTN_TXT') }}
|
||||
</woot-button>
|
||||
<div class="flex flex-row gap-4">
|
||||
<div class="w-[60%]">
|
||||
<p
|
||||
v-if="!uiFlags.isFetching && !records.length"
|
||||
class="flex h-full items-center flex-col justify-center"
|
||||
>
|
||||
{{ $t('SLA.LIST.404') }}
|
||||
</p>
|
||||
<woot-loading-state
|
||||
v-if="uiFlags.isFetching"
|
||||
:message="$t('SLA.LOADING')"
|
||||
/>
|
||||
<table v-if="!uiFlags.isFetching && records.length" class="woot-table">
|
||||
<thead>
|
||||
<th v-for="thHeader in $t('SLA.LIST.TABLE_HEADER')" :key="thHeader">
|
||||
{{ thHeader }}
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="sla in records" :key="sla.title">
|
||||
<td class="sla-title">
|
||||
<span class="overflow-hidden whitespace-nowrap text-ellipsis">{{
|
||||
sla.name
|
||||
}}</span>
|
||||
</td>
|
||||
<td>{{ sla.description }}</td>
|
||||
<td>
|
||||
<div class="sla-color--container">
|
||||
<span
|
||||
class="sla-color--display"
|
||||
:style="{ backgroundColor: sla.color }"
|
||||
/>
|
||||
{{ sla.first_response_time_threshold }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sla-color--container">
|
||||
<span
|
||||
class="sla-color--display"
|
||||
:style="{ backgroundColor: sla.color }"
|
||||
/>
|
||||
{{ sla.next_response_time_threshold }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sla-color--container">
|
||||
<span
|
||||
class="sla-color--display"
|
||||
:style="{ backgroundColor: sla.color }"
|
||||
/>
|
||||
{{ sla.resolution_time_threshold }}
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="sla-color--container">
|
||||
<span
|
||||
class="sla-color--display"
|
||||
:style="{ backgroundColor: sla.color }"
|
||||
/>
|
||||
{{ sla.only_during_business_hours }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="button-wrapper">
|
||||
<woot-button
|
||||
v-tooltip.top="$t('SLA.FORM.EDIT')"
|
||||
variant="smooth"
|
||||
size="tiny"
|
||||
color-scheme="secondary"
|
||||
class-names="grey-btn"
|
||||
:is-loading="loading[sla.id]"
|
||||
icon="edit"
|
||||
@click="openEditPopup(sla)"
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="w-[34%]">
|
||||
<span v-dompurify-html="$t('SLA.SIDEBAR_TXT')" />
|
||||
</div>
|
||||
</div>
|
||||
<woot-modal :show.sync="showAddPopup" :on-close="hideAddPopup">
|
||||
<add-SLA @close="hideAddPopup" />
|
||||
</woot-modal>
|
||||
|
||||
<woot-modal :show.sync="showEditPopup" :on-close="hideEditPopup">
|
||||
<edit-SLA :selected-response="selectedResponse" @close="hideEditPopup" />
|
||||
</woot-modal>
|
||||
|
||||
<woot-delete-modal
|
||||
:show.sync="showDeleteConfirmationPopup"
|
||||
:on-close="closeDeletePopup"
|
||||
:on-confirm="confirmDeletion"
|
||||
:title="$t('SLA.DELETE.CONFIRM.TITLE')"
|
||||
:message="$t('SLA.DELETE.CONFIRM.MESSAGE')"
|
||||
:message-value="deleteMessage"
|
||||
:confirm-text="deleteConfirmText"
|
||||
:reject-text="deleteRejectText"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { mapGetters } from 'vuex';
|
||||
|
||||
import AddSLA from './AddSLA.vue';
|
||||
import EditSLA from './EditSLA.vue';
|
||||
import alertMixin from 'shared/mixins/alertMixin';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
AddSLA,
|
||||
EditSLA,
|
||||
},
|
||||
mixins: [alertMixin],
|
||||
data() {
|
||||
return {
|
||||
loading: {},
|
||||
showAddPopup: false,
|
||||
showEditPopup: false,
|
||||
showDeleteConfirmationPopup: false,
|
||||
selectedResponse: {},
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
records: 'sla/getSLA',
|
||||
uiFlags: 'sla/getUIFlags',
|
||||
}),
|
||||
// Delete Modal
|
||||
deleteConfirmText() {
|
||||
return this.$t('SLA.DELETE.CONFIRM.YES');
|
||||
},
|
||||
deleteRejectText() {
|
||||
return this.$t('SLA.DELETE.CONFIRM.NO');
|
||||
},
|
||||
deleteMessage() {
|
||||
return ` ${this.selectedResponse.title}?`;
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.$store.dispatch('sla/get');
|
||||
},
|
||||
methods: {
|
||||
openAddPopup() {
|
||||
this.showAddPopup = true;
|
||||
},
|
||||
hideAddPopup() {
|
||||
this.showAddPopup = false;
|
||||
},
|
||||
|
||||
openEditPopup(response) {
|
||||
this.showEditPopup = true;
|
||||
this.selectedResponse = response;
|
||||
},
|
||||
hideEditPopup() {
|
||||
this.showEditPopup = false;
|
||||
},
|
||||
|
||||
openDeletePopup(response) {
|
||||
this.showDeleteConfirmationPopup = true;
|
||||
this.selectedResponse = response;
|
||||
},
|
||||
closeDeletePopup() {
|
||||
this.showDeleteConfirmationPopup = false;
|
||||
},
|
||||
|
||||
confirmDeletion() {
|
||||
this.loading[this.selectedResponse.id] = true;
|
||||
this.closeDeletePopup();
|
||||
this.deletesla(this.selectedResponse.id);
|
||||
},
|
||||
deletesla(id) {
|
||||
this.$store
|
||||
.dispatch('slas/delete', id)
|
||||
.then(() => {
|
||||
this.showAlert(this.$t('SLA.DELETE.API.SUCCESS_MESSAGE'));
|
||||
})
|
||||
.catch(() => {
|
||||
this.showAlert(this.$t('SLA.DELETE.API.ERROR_MESSAGE'));
|
||||
})
|
||||
.finally(() => {
|
||||
this.loading[this.selectedResponse.id] = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@import '~dashboard/assets/scss/variables';
|
||||
|
||||
.sla-color--container {
|
||||
@apply flex items-center;
|
||||
}
|
||||
|
||||
.sla-color--display {
|
||||
@apply rounded h-4 w-4 mr-1 rtl:mr-0 rtl:ml-1 border border-solid border-slate-50 dark:border-slate-700;
|
||||
}
|
||||
.sla-title {
|
||||
span {
|
||||
@apply inline-block;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,32 @@
|
||||
import { frontendURL } from '../../../../helper/URLHelper';
|
||||
|
||||
const SettingsContent = () => import('../Wrapper.vue');
|
||||
const Index = () => import('./Index.vue');
|
||||
|
||||
export default {
|
||||
routes: [
|
||||
{
|
||||
path: frontendURL('accounts/:accountId/settings/sla'),
|
||||
component: SettingsContent,
|
||||
props: {
|
||||
headerTitle: 'SLA.HEADER',
|
||||
icon: 'tag',
|
||||
showNewButton: true,
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'sla_wrapper',
|
||||
roles: ['administrator'],
|
||||
redirect: 'list',
|
||||
},
|
||||
{
|
||||
path: 'list',
|
||||
name: 'sla_list',
|
||||
roles: ['administrator'],
|
||||
component: Index,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,72 @@
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils';
|
||||
import VueI18n from 'vue-i18n';
|
||||
import Vuelidate from 'vuelidate';
|
||||
|
||||
import validationMixin from '../validationMixin';
|
||||
import validations from '../validations';
|
||||
import i18n from 'dashboard/i18n';
|
||||
const localVue = createLocalVue();
|
||||
|
||||
localVue.use(VueI18n);
|
||||
localVue.use(Vuelidate);
|
||||
const i18nConfig = new VueI18n({
|
||||
locale: 'en',
|
||||
messages: i18n,
|
||||
});
|
||||
const Component = {
|
||||
render() {},
|
||||
title: 'TestComponent',
|
||||
mixins: [validationMixin],
|
||||
validations,
|
||||
};
|
||||
|
||||
describe('validationMixin', () => {
|
||||
it('it should return empty error message if valid label name passed', async () => {
|
||||
const wrapper = shallowMount(Component, {
|
||||
i18n: i18nConfig,
|
||||
localVue,
|
||||
data() {
|
||||
return { title: 'sales' };
|
||||
},
|
||||
});
|
||||
wrapper.vm.$v.$touch();
|
||||
expect(wrapper.vm.getLabelTitleErrorMessage).toBe('');
|
||||
});
|
||||
it('it should return label required error message if empty name is passed', async () => {
|
||||
const wrapper = shallowMount(Component, {
|
||||
i18n: i18nConfig,
|
||||
localVue,
|
||||
data() {
|
||||
return { title: '' };
|
||||
},
|
||||
});
|
||||
wrapper.vm.$v.$touch();
|
||||
expect(wrapper.vm.getLabelTitleErrorMessage).toBe('Label name is required');
|
||||
});
|
||||
it('it should return label minimum length error message if one charceter label name is passed', async () => {
|
||||
const wrapper = shallowMount(Component, {
|
||||
i18n: i18nConfig,
|
||||
localVue,
|
||||
data() {
|
||||
return { title: 's' };
|
||||
},
|
||||
});
|
||||
wrapper.vm.$v.$touch();
|
||||
expect(wrapper.vm.getLabelTitleErrorMessage).toBe(
|
||||
'Minimum length 2 is required'
|
||||
);
|
||||
});
|
||||
it('it should return invalid character error message if invalid lable name passed', async () => {
|
||||
const wrapper = shallowMount(Component, {
|
||||
i18n: i18nConfig,
|
||||
localVue,
|
||||
data() {
|
||||
return { title: 'sales enquiry' };
|
||||
},
|
||||
});
|
||||
wrapper.vm.$v.$touch();
|
||||
expect(wrapper.vm.getLabelTitleErrorMessage).toBe(
|
||||
'Only Alphabets, Numbers, Hyphen and Underscore are allowed'
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
import { validLabelCharacters } from '../validations';
|
||||
|
||||
describe('#validLabelCharacters', () => {
|
||||
it('validates the label', () => {
|
||||
expect(validLabelCharacters('')).toEqual(false);
|
||||
expect(validLabelCharacters('str str')).toEqual(false);
|
||||
expect(validLabelCharacters('str_str')).toEqual(true);
|
||||
expect(validLabelCharacters('str-str')).toEqual(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,17 @@
|
||||
export default {
|
||||
computed: {
|
||||
getSlaNameErrorMessage() {
|
||||
let errorMessage = '';
|
||||
if (!this.$v.name.$error) {
|
||||
errorMessage = '';
|
||||
} else if (!this.$v.name.required) {
|
||||
errorMessage = this.$t('SLA.FORM.NAME.REQUIRED_ERROR');
|
||||
} else if (!this.$v.name.minLength) {
|
||||
errorMessage = this.$t('SLA.FORM.NAME.MINIMUM_LENGTH_ERROR');
|
||||
} else if (!this.$v.name.validLabelCharacters) {
|
||||
errorMessage = this.$t('SLA.FORM.NAME.VALID_ERROR');
|
||||
}
|
||||
return errorMessage;
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { required, minLength } from 'vuelidate/lib/validators';
|
||||
|
||||
export default {
|
||||
name: {
|
||||
required,
|
||||
minLength: minLength(2),
|
||||
},
|
||||
};
|
||||
@@ -38,6 +38,7 @@ import macros from './modules/macros';
|
||||
import notifications from './modules/notifications';
|
||||
import portals from './modules/helpCenterPortals';
|
||||
import reports from './modules/reports';
|
||||
import sla from './modules/sla';
|
||||
import teamMembers from './modules/teamMembers';
|
||||
import teams from './modules/teams';
|
||||
import userNotificationSettings from './modules/userNotificationSettings';
|
||||
@@ -109,6 +110,7 @@ export default new Vuex.Store({
|
||||
userNotificationSettings,
|
||||
webhooks,
|
||||
draftMessages,
|
||||
sla,
|
||||
},
|
||||
plugins,
|
||||
});
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
import * as MutationHelpers from 'shared/helpers/vuex/mutationHelpers';
|
||||
import types from '../mutation-types';
|
||||
import SlaAPI from '../../api/sla';
|
||||
import AnalyticsHelper from '../../helper/AnalyticsHelper';
|
||||
import { SLA_EVENTS } from '../../helper/AnalyticsHelper/events';
|
||||
|
||||
export const state = {
|
||||
records: [],
|
||||
uiFlags: {
|
||||
isFetching: false,
|
||||
isFetchingItem: false,
|
||||
isCreating: false,
|
||||
isDeleting: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const getters = {
|
||||
getSLA(_state) {
|
||||
return _state.records;
|
||||
},
|
||||
getUIFlags(_state) {
|
||||
return _state.uiFlags;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
get: async function get({ commit }) {
|
||||
commit(types.SET_SLA_UI_FLAG, { isFetching: true });
|
||||
try {
|
||||
const response = await SlaAPI.get();
|
||||
commit(types.SET_SLA, response.data.payload);
|
||||
} catch (error) {
|
||||
// Ignore error
|
||||
} finally {
|
||||
commit(types.SET_SLA_UI_FLAG, { isFetching: false });
|
||||
}
|
||||
},
|
||||
|
||||
create: async function create({ commit }, slaObj) {
|
||||
commit(types.SET_SLA_UI_FLAG, { isCreating: true });
|
||||
try {
|
||||
const response = await SlaAPI.create(slaObj);
|
||||
AnalyticsHelper.track(SLA_EVENTS.CREATE);
|
||||
commit(types.ADD_SLA, response.data.payload);
|
||||
} catch (error) {
|
||||
const errorMessage = error?.response?.data?.message;
|
||||
throw new Error(errorMessage);
|
||||
} finally {
|
||||
commit(types.SET_SLA_UI_FLAG, { isCreating: false });
|
||||
}
|
||||
},
|
||||
|
||||
update: async function update({ commit }, { id, ...updateObj }) {
|
||||
commit(types.SET_SLA_UI_FLAG, { isUpdating: true });
|
||||
try {
|
||||
const response = await SlaAPI.update(id, updateObj);
|
||||
AnalyticsHelper.track(SLA_EVENTS.UPDATE);
|
||||
commit(types.EDIT_SLA, response.data.payload);
|
||||
} catch (error) {
|
||||
throw new Error(error);
|
||||
} finally {
|
||||
commit(types.SET_SLA_UI_FLAG, { isUpdating: false });
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const mutations = {
|
||||
[types.SET_SLA_UI_FLAG](_state, data) {
|
||||
_state.uiFlags = {
|
||||
..._state.uiFlags,
|
||||
...data,
|
||||
};
|
||||
},
|
||||
|
||||
[types.SET_SLA]: MutationHelpers.set,
|
||||
[types.ADD_SLA]: MutationHelpers.create,
|
||||
[types.EDIT_SLA]: MutationHelpers.update,
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations,
|
||||
};
|
||||
@@ -301,4 +301,11 @@ export default {
|
||||
SET_AUDIT_LOGS_UI_FLAG: 'SET_AUDIT_LOGS_UI_FLAG',
|
||||
SET_AUDIT_LOGS: 'SET_AUDIT_LOGS',
|
||||
SET_AUDIT_LOGS_META: 'SET_AUDIT_LOGS_META',
|
||||
|
||||
// SLA
|
||||
SET_SLA_UI_FLAG: 'SET_SLA_UI_FLAG',
|
||||
SET_SLA: 'SET_SLA',
|
||||
ADD_SLA: 'ADD_SLA',
|
||||
EDIT_SLA: 'EDIT_SLA',
|
||||
DELETE_SLA: 'DELETE_SLA',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user