From 25ba852b6852b99aca800d3a40bddce3e499dbef Mon Sep 17 00:00:00 2001 From: Pranav Raj S Date: Fri, 28 May 2021 19:21:16 +0530 Subject: [PATCH] chore: Adjust Chatwoot Config to deploy frontend as a separate app (#2347) --- .../dashboard/assets/scss/_woot.scss | 1 - .../components/widgets/InboxListItem.vue | 16 ++++---- .../components/widgets/WootWriter/Editor.vue | 1 + app/javascript/dashboard/constants.js | 5 +-- app/javascript/dashboard/helper/APIHelper.js | 9 ++--- .../dashboard/helper/actionCable.js | 3 +- .../dashboard/routes/auth/Confirmation.vue | 38 ++++++++++--------- .../dashboard/routes/auth/PasswordEdit.vue | 7 ++-- .../dashboard/routes/auth/ResetPassword.vue | 2 - .../dashboard/routes/auth/Signup.vue | 3 +- .../dashboard/settings/canned/EditCanned.vue | 1 - .../dashboard/settings/integrations/New.vue | 1 - app/javascript/dashboard/routes/index.js | 14 +++---- app/javascript/dashboard/routes/index.spec.js | 4 -- .../dashboard/store/modules/auth.js | 3 +- .../helpers/BaseActionCableConnector.js | 5 ++- 16 files changed, 53 insertions(+), 60 deletions(-) diff --git a/app/javascript/dashboard/assets/scss/_woot.scss b/app/javascript/dashboard/assets/scss/_woot.scss index 7ecec198b..1712e256e 100644 --- a/app/javascript/dashboard/assets/scss/_woot.scss +++ b/app/javascript/dashboard/assets/scss/_woot.scss @@ -46,5 +46,4 @@ @import 'plugins/multiselect'; @import 'plugins/dropdown'; -@import '@chatwoot/prosemirror-schema/src/woot-editor.css'; @import '~shared/assets/stylesheets/ionicons'; diff --git a/app/javascript/dashboard/components/widgets/InboxListItem.vue b/app/javascript/dashboard/components/widgets/InboxListItem.vue index 413fec00c..5bfdacdda 100644 --- a/app/javascript/dashboard/components/widgets/InboxListItem.vue +++ b/app/javascript/dashboard/components/widgets/InboxListItem.vue @@ -1,21 +1,23 @@ diff --git a/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue b/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue index bbb1d4e82..ba26ef177 100644 --- a/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue +++ b/app/javascript/dashboard/components/widgets/WootWriter/Editor.vue @@ -28,6 +28,7 @@ import TagAgents from '../conversation/TagAgents.vue'; import { EditorState } from 'prosemirror-state'; import { defaultMarkdownParser } from 'prosemirror-markdown'; import { wootWriterSetup } from '@chatwoot/prosemirror-schema'; +import '@chatwoot/prosemirror-schema/src/woot-editor.css'; const createState = (content, placeholder, plugins = []) => { return EditorState.create({ diff --git a/app/javascript/dashboard/constants.js b/app/javascript/dashboard/constants.js index 9a00775bf..34f4b9845 100644 --- a/app/javascript/dashboard/constants.js +++ b/app/javascript/dashboard/constants.js @@ -1,8 +1,4 @@ export default { - APP_BASE_URL: '/', - get apiURL() { - return `${this.APP_BASE_URL}/`; - }, GRAVATAR_URL: 'https://www.gravatar.com/avatar/', ASSIGNEE_TYPE: { ME: 'me', @@ -15,3 +11,4 @@ export default { BOT: 'bot', }, }; +export const DEFAULT_REDIRECT_URL = '/app/'; diff --git a/app/javascript/dashboard/helper/APIHelper.js b/app/javascript/dashboard/helper/APIHelper.js index 03e902259..5dcb34f97 100644 --- a/app/javascript/dashboard/helper/APIHelper.js +++ b/app/javascript/dashboard/helper/APIHelper.js @@ -1,14 +1,11 @@ /* eslint no-console: 0 */ -import constants from '../constants'; import Auth from '../api/auth'; -const parseErrorCode = error => { - return Promise.reject(error); -}; +const parseErrorCode = error => Promise.reject(error); export default axios => { - const wootApi = axios.create(); - wootApi.defaults.baseURL = constants.apiURL; + const { apiHost = '' } = window.chatwootConfig || {}; + const wootApi = axios.create({ baseURL: `${apiHost}/` }); // Add Auth Headers to requests if logged in if (Auth.isLoggedIn()) { const { diff --git a/app/javascript/dashboard/helper/actionCable.js b/app/javascript/dashboard/helper/actionCable.js index 6103ee915..afddb1e88 100644 --- a/app/javascript/dashboard/helper/actionCable.js +++ b/app/javascript/dashboard/helper/actionCable.js @@ -4,7 +4,8 @@ import { newMessageNotification } from 'shared/helpers/AudioNotificationHelper'; class ActionCableConnector extends BaseActionCableConnector { constructor(app, pubsubToken) { - super(app, pubsubToken); + const { websocketURL = '' } = window.chatwootConfig || {}; + super(app, pubsubToken, websocketURL); this.CancelTyping = []; this.events = { 'message.created': this.onMessageCreated, diff --git a/app/javascript/dashboard/routes/auth/Confirmation.vue b/app/javascript/dashboard/routes/auth/Confirmation.vue index ff41375a6..db439af03 100644 --- a/app/javascript/dashboard/routes/auth/Confirmation.vue +++ b/app/javascript/dashboard/routes/auth/Confirmation.vue @@ -2,31 +2,35 @@ diff --git a/app/javascript/dashboard/routes/auth/PasswordEdit.vue b/app/javascript/dashboard/routes/auth/PasswordEdit.vue index 698c3f792..4549528a0 100644 --- a/app/javascript/dashboard/routes/auth/PasswordEdit.vue +++ b/app/javascript/dashboard/routes/auth/PasswordEdit.vue @@ -46,12 +46,11 @@