diff --git a/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json b/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json
index 71a334d87..7721cc3e6 100644
--- a/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json
+++ b/app/javascript/dashboard/i18n/locale/en/cannedMgmt.json
@@ -1,15 +1,20 @@
{
"CANNED_MGMT": {
"HEADER": "Canned Responses",
+ "LEARN_MORE": "Learn more about canned responses",
+ "DESCRIPTION": "Canned Responses are pre-written reply templates that help you quickly respond to a conversation. Agents can type the '/' character followed by the shortcode to insert a canned response during a conversation. ",
"HEADER_BTN_TXT": "Add canned response",
"LOADING": "Fetching canned responses...",
"SEARCH_404": "There are no items matching this query.",
- "SIDEBAR_TXT": "
Canned Responses
Canned Responses are pre-written reply templates that help you quickly respond to a conversation. To insert a canned response during a chat, agents can type a short code preceded by a '/' character.
You can manage your canned responses from this page or create new ones using the \"Add canned response\" button.
Open the Canned Responses handbook in another tab for a helping hand.
Also, check out the all-new Canned Responses Library .
",
"LIST": {
"404": "There are no canned responses available in this account.",
"TITLE": "Manage canned responses",
"DESC": "Canned Responses are predefined reply templates which can be used to quickly send out replies to conversations.",
- "TABLE_HEADER": ["Short code", "Content", "Actions"]
+ "TABLE_HEADER": [
+ "Short code",
+ "Content",
+ "Actions"
+ ]
},
"ADD": {
"TITLE": "Add canned response",
diff --git a/app/javascript/dashboard/routes/dashboard/settings/canned/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/canned/Index.vue
index 80a50a095..d3fc54596 100644
--- a/app/javascript/dashboard/routes/dashboard/settings/canned/Index.vue
+++ b/app/javascript/dashboard/routes/dashboard/settings/canned/Index.vue
@@ -1,238 +1,222 @@
-
-
- {{ $t('CANNED_MGMT.HEADER_BTN_TXT') }}
-
-
-
-
-
-
+
- {{ $t('CANNED_MGMT.LIST.404') }}
-
-
+ {{ $t('CANNED_MGMT.HEADER_BTN_TXT') }}
+
+
+
-
-
-
-
+
+
+ {{ $t('CANNED_MGMT.LIST.404') }}
+
+
+
+
+
+ {{ thHeader }}
+
+
+
-
+
{{ thHeader }}
-
-
-
-
- {{ thHeader }}
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
-
- {{ cannedItem.short_code }}
-
-
-
- {{ cannedItem.content }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ {{ cannedItem.short_code }}
+
+
+ {{ cannedItem.content }}
+
+
+
+
+
+
+
+
-
+
-
-
import('../Wrapper.vue');
+const SettingsWrapper = () => import('../SettingsWrapper.vue');
const CannedHome = () => import('./Index.vue');
export default {
routes: [
{
path: frontendURL('accounts/:accountId/settings/canned-response'),
- component: SettingsContent,
- props: {
- headerTitle: 'CANNED_MGMT.HEADER',
- icon: 'chat-multiple',
- showNewButton: false,
- },
+ component: SettingsWrapper,
children: [
{
path: '',
diff --git a/app/javascript/dashboard/store/modules/cannedResponse.js b/app/javascript/dashboard/store/modules/cannedResponse.js
index 7b24d1171..568150392 100644
--- a/app/javascript/dashboard/store/modules/cannedResponse.js
+++ b/app/javascript/dashboard/store/modules/cannedResponse.js
@@ -18,6 +18,15 @@ const getters = {
getCannedResponses(_state) {
return _state.records;
},
+ getSortedCannedResponses(_state) {
+ return sortOrder =>
+ [..._state.records].sort((a, b) => {
+ if (sortOrder === 'asc') {
+ return a.short_code.localeCompare(b.short_code);
+ }
+ return b.short_code.localeCompare(a.short_code);
+ });
+ },
getUIFlags(_state) {
return _state.uiFlags;
},
diff --git a/app/javascript/dashboard/store/modules/specs/cannedResponses/getters.spec.js b/app/javascript/dashboard/store/modules/specs/cannedResponses/getters.spec.js
new file mode 100644
index 000000000..7a80aed8c
--- /dev/null
+++ b/app/javascript/dashboard/store/modules/specs/cannedResponses/getters.spec.js
@@ -0,0 +1,43 @@
+import CannedResponses from '../../cannedResponse';
+
+const CANNED_RESPONSES = [
+ { short_code: 'hello', content: 'Hi ' },
+ { short_code: 'ask', content: 'Ask questions' },
+ { short_code: 'greet', content: 'Good morning' },
+];
+
+const getters = CannedResponses.getters;
+
+describe('#getCannedResponses', () => {
+ it('returns canned responses', () => {
+ const state = { records: CANNED_RESPONSES };
+ expect(getters.getCannedResponses(state)).toEqual(CANNED_RESPONSES);
+ });
+});
+
+describe('#getSortedCannedResponses', () => {
+ it('returns sort canned responses in ascending order', () => {
+ const state = { records: CANNED_RESPONSES };
+ expect(getters.getSortedCannedResponses(state)('asc')).toEqual([
+ CANNED_RESPONSES[1],
+ CANNED_RESPONSES[2],
+ CANNED_RESPONSES[0],
+ ]);
+ });
+
+ it('returns sort canned responses in descending order', () => {
+ const state = { records: CANNED_RESPONSES };
+ expect(getters.getSortedCannedResponses(state)('desc')).toEqual([
+ CANNED_RESPONSES[0],
+ CANNED_RESPONSES[2],
+ CANNED_RESPONSES[1],
+ ]);
+ });
+});
+
+describe('#getUIFlags', () => {
+ it('returns uiFlags', () => {
+ const state = { uiFlags: { isFetching: true } };
+ expect(getters.getUIFlags(state)).toEqual({ isFetching: true });
+ });
+});