diff --git a/app/controllers/api/v1/accounts/inboxes_controller.rb b/app/controllers/api/v1/accounts/inboxes_controller.rb index d99180588..630f93e0d 100644 --- a/app/controllers/api/v1/accounts/inboxes_controller.rb +++ b/app/controllers/api/v1/accounts/inboxes_controller.rb @@ -6,15 +6,15 @@ class Api::V1::Accounts::InboxesController < Api::BaseController @inboxes = policy_scope(current_account.inboxes) end + def update + @inbox.update(inbox_update_params) + end + def destroy @inbox.destroy head :ok end - def update - @inbox.update(inbox_update_params) - end - private def fetch_inbox diff --git a/app/javascript/dashboard/helper/scriptGenerator.js b/app/javascript/dashboard/helper/scriptGenerator.js index bfb900718..5a278d30a 100644 --- a/app/javascript/dashboard/helper/scriptGenerator.js +++ b/app/javascript/dashboard/helper/scriptGenerator.js @@ -1,20 +1,3 @@ -export const createWebsiteWidgetScript = websiteToken => ` - -`; - export const createMessengerScript = pageId => ` diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue index 7bce9e6f9..447bd5438 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/Settings.vue @@ -22,7 +22,7 @@ :sub-title="$t('INBOX_MGMT.SETTINGS_POPUP.MESSENGER_SUB_HEAD')" > - +
@@ -81,10 +85,7 @@ /* eslint no-console: 0 */ /* global bus */ import { mapGetters } from 'vuex'; -import { - createWebsiteWidgetScript, - createMessengerScript, -} from 'dashboard/helper/scriptGenerator'; +import { createMessengerScript } from 'dashboard/helper/scriptGenerator'; import { Compact } from 'vue-color'; import SettingsFormHeader from '../../../../components/SettingsFormHeader.vue'; @@ -112,9 +113,6 @@ export default { inbox() { return this.$store.getters['inboxes/getInbox'](this.currentInboxId); }, - webWidgetScript() { - return createWebsiteWidgetScript(this.inbox.website_token); - }, messengerScript() { return createMessengerScript(this.inbox.page_id); }, @@ -196,9 +194,13 @@ export default { enable_auto_assignment: this.autoAssignment, }, }); - this.showAlert(this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE')); + this.showAlert( + this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE') + ); } catch (error) { - this.showAlert(this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE')); + this.showAlert( + this.$t('INBOX_MGMT.EDIT.API.AUTO_ASSIGNMENT_SUCCESS_MESSAGE') + ); } }, getWidgetColor() { diff --git a/app/javascript/packs/sdk.js b/app/javascript/packs/sdk.js index 11f485b7a..650bd1816 100755 --- a/app/javascript/packs/sdk.js +++ b/app/javascript/packs/sdk.js @@ -213,7 +213,6 @@ const IFrameHelper = { }); }, toggleCloseButton: () => { - console.log(window.matchMedia('(max-width: 668px)')); if (window.matchMedia('(max-width: 668px)').matches) { IFrameHelper.sendMessage('toggle-close-button', { showClose: true }); } else { diff --git a/app/models/channel/web_widget.rb b/app/models/channel/web_widget.rb index 97b16eef2..68fe67ae8 100644 --- a/app/models/channel/web_widget.rb +++ b/app/models/channel/web_widget.rb @@ -31,6 +31,23 @@ class Channel::WebWidget < ApplicationRecord 'Website' end + def web_widget_script + "" + end + def create_contact_inbox ActiveRecord::Base.transaction do contact = inbox.account.contacts.create!(name: ::Haikunator.haikunate(1000)) diff --git a/app/views/api/v1/accounts/inboxes/index.json.jbuilder b/app/views/api/v1/accounts/inboxes/index.json.jbuilder index 3256f04cd..6dab70ff7 100644 --- a/app/views/api/v1/accounts/inboxes/index.json.jbuilder +++ b/app/views/api/v1/accounts/inboxes/index.json.jbuilder @@ -9,5 +9,6 @@ json.payload do json.widget_color inbox.channel.try(:widget_color) json.website_token inbox.channel.try(:website_token) json.enable_auto_assignment inbox.enable_auto_assignment + json.web_widget_script inbox.channel.try(:web_widget_script) end end diff --git a/app/views/api/v1/accounts/widget/inboxes/create.json.jbuilder b/app/views/api/v1/accounts/widget/inboxes/create.json.jbuilder index ac444ba48..fc5260605 100644 --- a/app/views/api/v1/accounts/widget/inboxes/create.json.jbuilder +++ b/app/views/api/v1/accounts/widget/inboxes/create.json.jbuilder @@ -4,3 +4,4 @@ json.name @inbox.name json.channel_type @inbox.channel_type json.website_token @inbox.channel.try(:website_token) json.widget_color @inbox.channel.try(:widget_color) +json.web_widget_script @inbox.channel.try(:web_widget_script) diff --git a/app/views/api/v1/accounts/widget/inboxes/update.json.jbuilder b/app/views/api/v1/accounts/widget/inboxes/update.json.jbuilder index e43655f60..3fb1bf4a2 100644 --- a/app/views/api/v1/accounts/widget/inboxes/update.json.jbuilder +++ b/app/views/api/v1/accounts/widget/inboxes/update.json.jbuilder @@ -4,3 +4,4 @@ json.name @inbox.name json.channel_type @inbox.channel_type json.website_token @inbox.channel.website_token json.widget_color @inbox.channel.widget_color +json.web_widget_script @inbox.channel.try(:web_widget_script) diff --git a/swagger/definitions/resource/inbox.yml b/swagger/definitions/resource/inbox.yml index 9575bebfe..375f3be4f 100644 --- a/swagger/definitions/resource/inbox.yml +++ b/swagger/definitions/resource/inbox.yml @@ -18,3 +18,6 @@ properties: enable_auto_assignment: type: boolean description: The flag which shows whether Auto Assignment is enabled or not + web_widget_script: + type: string + description: Script used to load the website widget diff --git a/swagger/swagger.json b/swagger/swagger.json index ac28523b0..049a1b21e 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -930,6 +930,10 @@ "enable_auto_assignment": { "type": "boolean", "description": "The flag which shows whether Auto Assignment is enabled or not" + }, + "web_widget_script": { + "type": "string", + "description": "Script used to load the website widget" } } },