diff --git a/app/javascript/dashboard/api/macros.js b/app/javascript/dashboard/api/macros.js index b275dec3a..d515b7b52 100644 --- a/app/javascript/dashboard/api/macros.js +++ b/app/javascript/dashboard/api/macros.js @@ -1,9 +1,20 @@ +/* global axios */ import ApiClient from './ApiClient'; class MacrosAPI extends ApiClient { constructor() { super('macros', { accountScoped: true }); } + + getSingleMacro(macroId) { + return axios.get(`${this.url}/${macroId}`); + } + + executeMacro({ macroId, conversationIds }) { + return axios.post(`${this.url}/${macroId}/execute`, { + conversation_ids: conversationIds, + }); + } } export default new MacrosAPI(); diff --git a/app/javascript/dashboard/components/layout/config/sidebarItems/settings.js b/app/javascript/dashboard/components/layout/config/sidebarItems/settings.js index a2a57b218..d4f304c73 100644 --- a/app/javascript/dashboard/components/layout/config/sidebarItems/settings.js +++ b/app/javascript/dashboard/components/layout/config/sidebarItems/settings.js @@ -34,6 +34,7 @@ const settings = accountId => ({ 'automation_list', 'macros_wrapper', 'macros_new', + 'macros_edit', ], menuItems: [ { diff --git a/app/javascript/dashboard/i18n/locale/en/conversation.json b/app/javascript/dashboard/i18n/locale/en/conversation.json index 39857520f..6182c6f01 100644 --- a/app/javascript/dashboard/i18n/locale/en/conversation.json +++ b/app/javascript/dashboard/i18n/locale/en/conversation.json @@ -207,7 +207,8 @@ "CONVERSATION_LABELS": "Conversation Labels", "CONVERSATION_INFO": "Conversation Information", "CONTACT_ATTRIBUTES": "Contact Attributes", - "PREVIOUS_CONVERSATION": "Previous Conversations" + "PREVIOUS_CONVERSATION": "Previous Conversations", + "MACROS": "Macros" } }, "CONVERSATION_CUSTOM_ATTRIBUTES": { diff --git a/app/javascript/dashboard/i18n/locale/en/macros.json b/app/javascript/dashboard/i18n/locale/en/macros.json index 359b912d7..f6ee277e3 100644 --- a/app/javascript/dashboard/i18n/locale/en/macros.json +++ b/app/javascript/dashboard/i18n/locale/en/macros.json @@ -5,6 +5,8 @@ "HEADER_BTN_TXT_SAVE": "Save macro", "LOADING": "Fetching macros", "SIDEBAR_TXT": "
Macros
Macros help you run a series of actions and tasks. They're a list of instructions which tell chatwoot how to execute based on the order which you define them.
Please refer to the docs to read more about macros in detail.
", + "ERROR": "Something went wrong. Please try again", + "ORDER_INFO": "Macros will run in the order you add yout actions. You can rearrange them by dragging them by the handle beside each action.", "ADD": { "TITLE": "Add new Macro", "SUBMIT": "Create", @@ -12,8 +14,8 @@ "FORM": { "NAME": { "LABEL": "Macro name", - "PLACEHOLDER": "Enter macro name", - "ERROR": "Name is required" + "PLACEHOLDER": "Enter a name for your macro", + "ERROR": "Please enter a macro name" }, "DESC": { "LABEL": "Description", @@ -30,7 +32,7 @@ "ACTION_BUTTON_LABEL": "Add Action", "API": { "SUCCESS_MESSAGE": "Macro added successfully", - "ERROR_MESSAGE": "Could not able to create macro, Please try again later" + "ERROR_MESSAGE": "Unable to create macro, Please try again later" } }, "LIST": { @@ -66,13 +68,6 @@ "ERROR_MESSAGE": "Could not update Macro, Please try again later" } }, - "CLONE": { - "TOOLTIP": "Clone", - "API": { - "SUCCESS_MESSAGE": "Macro cloned successfully", - "ERROR_MESSAGE": "Could not clone Macro, Please try again later" - } - }, "FORM": { "EDIT": "Edit", "CREATE": "Create", @@ -80,32 +75,30 @@ "CANCEL": "Cancel", "RESET_MESSAGE": "Changing event type will reset the conditions and events you have added below" }, - "CONDITION": { - "DELETE_MESSAGE": "You need to have atleast one condition to save" - }, "ACTION": { "DELETE_MESSAGE": "You need to have atleast one action to save", "TEAM_MESSAGE_INPUT_PLACEHOLDER": "Enter your message here", "TEAM_DROPDOWN_PLACEHOLDER": "Select teams" }, - "TOGGLE": { - "ACTIVATION_TITLE": "Activate Macro", - "DEACTIVATION_TITLE": "Deactivate Macro", - "ACTIVATION_DESCRIPTION": "This action will activate the Macro '{macroName}'. Are you sure you want to proceed?", - "DEACTIVATION_DESCRIPTION": "This action will deactivate the Macro '{macroName}'. Are you sure you want to proceed?", - "ACTIVATION_SUCCESFUL": "Macro Activated Successfully", - "DEACTIVATION_SUCCESFUL": "Macro Deactivated Successfully", - "ACTIVATION_ERROR": "Could not Activate Macro, Please try again later", - "DEACTIVATION_ERROR": "Could not Deactivate Macro, Please try again later", - "CONFIRMATION_LABEL": "Yes", - "CANCEL_LABEL": "No" + "EDITOR": { + "START_FLOW": "Start Flow", + "END_FLOW": "End Flow", + "VISIBILITY": { + "LABEL": "Macro Visibility", + "GLOBAL": { + "LABEL": "Global", + "DESCRIPTION": "This macro is available globally for all agents in this account." + }, + "PERSONAL": { + "LABEL": "Personal", + "DESCRIPTION": "This macro will be personal to you and not be available to others." + } + } }, - "ATTACHMENT": { - "UPLOAD_ERROR": "Could not upload attachment, Please try again", - "LABEL_IDLE": "Upload Attachment", - "LABEL_UPLOADING": "Uploading...", - "LABEL_UPLOADED": "Succesfully Uploaded", - "LABEL_UPLOAD_FAILED": "Upload Failed" + "EXECUTE": { + "BUTTON_TOOLTIP": "Execute", + "PREVIEW": "Preview Macro", + "EXECUTED_SUCCESFULLY": "Macro executed successfully" } } } diff --git a/app/javascript/dashboard/mixins/uiSettings.js b/app/javascript/dashboard/mixins/uiSettings.js index e265975e1..4e129c130 100644 --- a/app/javascript/dashboard/mixins/uiSettings.js +++ b/app/javascript/dashboard/mixins/uiSettings.js @@ -4,6 +4,7 @@ export const DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER = [ { name: 'conversation_info' }, { name: 'contact_attributes' }, { name: 'previous_conversation' }, + { name: 'macros' }, ]; export const DEFAULT_CONTACT_SIDEBAR_ITEMS_ORDER = [ { name: 'contact_attributes' }, @@ -16,8 +17,8 @@ export default { uiSettings: 'getUISettings', }), conversationSidebarItemsOrder() { - const { conversation_sidebar_items_order: itemsOrder } = this.uiSettings; - return itemsOrder || DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER; + // const { conversation_sidebar_items_order: itemsOrder } = this.uiSettings; + return DEFAULT_CONVERSATION_SIDEBAR_ITEMS_ORDER; }, contactSidebarItemsOrder() { const { contact_sidebar_items_order: itemsOrder } = this.uiSettings; diff --git a/app/javascript/dashboard/routes/dashboard/conversation/ContactPanel.vue b/app/javascript/dashboard/routes/dashboard/conversation/ContactPanel.vue index 4405ed2ad..34171b9a3 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/ContactPanel.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/ContactPanel.vue @@ -93,6 +93,16 @@ /> +{{ macro.name }}
+{{ action.actionName }}
+{{ action.actionValue }}
+