diff --git a/.env.example b/.env.example index 81228f00a..b7ba0920d 100644 --- a/.env.example +++ b/.env.example @@ -258,4 +258,3 @@ AZURE_APP_SECRET= # contact_inboxes with no conversation older than 90 days will be removed # REMOVE_STALE_CONTACT_INBOX_JOB_STATUS=false -# CAPTAIN_API_URL=http://localhost:3001/api diff --git a/.eslintrc.js b/.eslintrc.js index 18162ee76..f3d050ab3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -27,6 +27,160 @@ module.exports = { 'import/no-unresolved': 'off', 'vue/html-indent': 'off', 'vue/multi-word-component-names': 'off', + 'vue/next-tick-style': ['error', 'callback'], + 'vue/block-order': [ + 'error', + { + order: ['script', 'template', 'style'], + }, + ], + 'vue/component-name-in-template-casing': [ + 'error', + 'PascalCase', + { + registeredComponentsOnly: true, + }, + ], + 'vue/component-options-name-casing': ['error', 'PascalCase'], + 'vue/custom-event-name-casing': ['error', 'camelCase'], + 'vue/define-emits-declaration': ['error'], + 'vue/define-macros-order': [ + 'error', + { + order: ['defineProps', 'defineEmits'], + defineExposeLast: false, + }, + ], + 'vue/define-props-declaration': ['error', 'runtime'], + 'vue/match-component-import-name': ['error'], + 'vue/no-bare-strings-in-template': [ + 'error', + { + allowlist: [ + '(', + ')', + ',', + '.', + '&', + '+', + '-', + '=', + '*', + '/', + '#', + '%', + '!', + '?', + ':', + '[', + ']', + '{', + '}', + '<', + '>', + '⌘', + '📄', + '🎉', + '💬', + '👥', + '📥', + '🔖', + '❌', + '✅', + '\u00b7', + '\u2022', + '\u2010', + '\u2013', + '\u2014', + '\u2212', + '|', + ], + attributes: { + '/.+/': [ + 'title', + 'aria-label', + 'aria-placeholder', + 'aria-roledescription', + 'aria-valuetext', + ], + input: ['placeholder'], + }, + directives: ['v-text'], + }, + ], + 'vue/no-empty-component-block': 'error', + 'vue/no-multiple-objects-in-class': 'error', + 'vue/no-root-v-if': 'warn', + 'vue/no-static-inline-styles': [ + 'error', + { + allowBinding: false, + }, + ], + 'vue/no-template-target-blank': [ + 'error', + { + allowReferrer: false, + enforceDynamicLinks: 'always', + }, + ], + 'vue/no-required-prop-with-default': [ + 'error', + { + autofix: false, + }, + ], + 'vue/no-this-in-before-route-enter': 'error', + 'vue/no-undef-components': [ + 'error', + { + ignorePatterns: [ + '^woot-', + '^fluent-', + '^multiselect', + '^router-link', + '^router-view', + '^ninja-keys', + '^FormulateForm', + '^FormulateInput', + '^highlightjs', + ], + }, + ], + 'vue/no-unused-emit-declarations': 'error', + 'vue/no-unused-refs': 'error', + 'vue/no-use-v-else-with-v-for': 'error', + 'vue/prefer-true-attribute-shorthand': 'error', + 'vue/no-useless-v-bind': [ + 'error', + { + ignoreIncludesComment: false, + ignoreStringEscape: false, + }, + ], + 'vue/no-v-text': 'error', + 'vue/padding-line-between-blocks': ['error', 'always'], + 'vue/prefer-separate-static-class': 'error', + 'vue/require-explicit-slots': 'error', + 'vue/require-macro-variable-name': [ + 'error', + { + defineProps: 'props', + defineEmits: 'emit', + defineSlots: 'slots', + useSlots: 'slots', + useAttrs: 'attrs', + }, + ], + 'vue/no-unused-properties': [ + 'error', + { + groups: ['props'], + deepData: false, + ignorePublicMembers: false, + unreferencedOptions: [], + }, + ], 'vue/max-attributes-per-line': [ 'error', { diff --git a/Gemfile.lock b/Gemfile.lock index be6a33af0..cf522bf39 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -634,7 +634,7 @@ GEM retriable (3.1.2) reverse_markdown (2.1.1) nokogiri - rexml (3.3.2) + rexml (3.3.4) strscan rspec-core (3.13.0) rspec-support (~> 3.13.0) diff --git a/app/controllers/api/v1/accounts/integrations/captain_controller.rb b/app/controllers/api/v1/accounts/integrations/captain_controller.rb new file mode 100644 index 000000000..7df0e61df --- /dev/null +++ b/app/controllers/api/v1/accounts/integrations/captain_controller.rb @@ -0,0 +1,22 @@ +class Api::V1::Accounts::Integrations::CaptainController < Api::V1::Accounts::BaseController + before_action :check_admin_authorization? + before_action :fetch_hook + + def sso_url + params_string = + "token=#{URI.encode_www_form_component(@hook['settings']['access_token'])}" \ + "&email=#{URI.encode_www_form_component(@hook['settings']['account_email'])}" \ + "&account_id=#{URI.encode_www_form_component(@hook['settings']['account_id'])}" + + installation_config = InstallationConfig.find_by(name: 'CAPTAIN_APP_URL') + + sso_url = "#{installation_config.value}/sso?#{params_string}" + render json: { sso_url: sso_url }, status: :ok + end + + private + + def fetch_hook + @hook = Current.account.hooks.find_by!(app_id: 'captain') + end +end diff --git a/app/javascript/dashboard/App.vue b/app/javascript/dashboard/App.vue index c343fbe4f..efb89f489 100644 --- a/app/javascript/dashboard/App.vue +++ b/app/javascript/dashboard/App.vue @@ -1,30 +1,3 @@ - - + + diff --git a/app/javascript/dashboard/api/integrations.js b/app/javascript/dashboard/api/integrations.js index 2b816e603..975857ce1 100644 --- a/app/javascript/dashboard/api/integrations.js +++ b/app/javascript/dashboard/api/integrations.js @@ -32,6 +32,10 @@ class IntegrationsAPI extends ApiClient { deleteHook(hookId) { return axios.delete(`${this.baseUrl()}/integrations/hooks/${hookId}`); } + + fetchCaptainURL() { + return axios.get(`${this.baseUrl()}/integrations/captain/sso_url`); + } } export default new IntegrationsAPI(); diff --git a/app/javascript/dashboard/components/Accordion/AccordionItem.vue b/app/javascript/dashboard/components/Accordion/AccordionItem.vue index 87370185d..6fc0ee0d9 100644 --- a/app/javascript/dashboard/components/Accordion/AccordionItem.vue +++ b/app/javascript/dashboard/components/Accordion/AccordionItem.vue @@ -1,35 +1,3 @@ - - + + diff --git a/app/javascript/dashboard/components/ChannelSelector.vue b/app/javascript/dashboard/components/ChannelSelector.vue index 6cff70bd3..2322edbfb 100644 --- a/app/javascript/dashboard/components/ChannelSelector.vue +++ b/app/javascript/dashboard/components/ChannelSelector.vue @@ -1,17 +1,3 @@ - - + + diff --git a/app/javascript/dashboard/components/widgets/LoadingState.vue b/app/javascript/dashboard/components/widgets/LoadingState.vue index 76aaef3eb..dfba6b43e 100644 --- a/app/javascript/dashboard/components/widgets/LoadingState.vue +++ b/app/javascript/dashboard/components/widgets/LoadingState.vue @@ -1,3 +1,11 @@ + + - diff --git a/app/javascript/dashboard/components/widgets/SettingIntroBanner.vue b/app/javascript/dashboard/components/widgets/SettingIntroBanner.vue index 9f99d5ba2..c2e6c48c3 100644 --- a/app/javascript/dashboard/components/widgets/SettingIntroBanner.vue +++ b/app/javascript/dashboard/components/widgets/SettingIntroBanner.vue @@ -1,3 +1,18 @@ + + - - diff --git a/app/javascript/dashboard/components/widgets/ShowMore.vue b/app/javascript/dashboard/components/widgets/ShowMore.vue index 980889122..c17c32e2a 100644 --- a/app/javascript/dashboard/components/widgets/ShowMore.vue +++ b/app/javascript/dashboard/components/widgets/ShowMore.vue @@ -1,15 +1,3 @@ - + + + diff --git a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue index df61e9de1..8bd1bb8df 100644 --- a/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue +++ b/app/javascript/dashboard/components/widgets/conversation/MessagesView.vue @@ -1,106 +1,8 @@ - - + + + diff --git a/app/javascript/dashboard/components/widgets/conversation/VariableList.vue b/app/javascript/dashboard/components/widgets/conversation/VariableList.vue index 48b1dcea3..66ad8965d 100644 --- a/app/javascript/dashboard/components/widgets/conversation/VariableList.vue +++ b/app/javascript/dashboard/components/widgets/conversation/VariableList.vue @@ -1,19 +1,3 @@ - - + + + + + + diff --git a/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue b/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue index 190e04fe3..21ed33b3d 100644 --- a/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue +++ b/app/javascript/dashboard/modules/contact/components/AddCustomAttribute.vue @@ -1,41 +1,3 @@ - - - + + + diff --git a/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue b/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue index 5dcfd568a..52eb6eaa5 100644 --- a/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue +++ b/app/javascript/dashboard/modules/contact/components/ContactAttribute.vue @@ -1,9 +1,47 @@ + + - - + diff --git a/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsAdvancedFilters.vue b/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsAdvancedFilters.vue index f6e00b70b..41c986d03 100644 --- a/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsAdvancedFilters.vue +++ b/app/javascript/dashboard/routes/dashboard/contacts/components/ContactsAdvancedFilters.vue @@ -1,93 +1,3 @@ - - + + + + diff --git a/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributes.vue b/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributes.vue index ae2e6c424..86ef0f91e 100644 --- a/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributes.vue +++ b/app/javascript/dashboard/routes/dashboard/conversation/customAttributes/CustomAttributes.vue @@ -1,45 +1,3 @@ - - + + + diff --git a/app/javascript/dashboard/routes/dashboard/inbox/components/InboxNameAndId.vue b/app/javascript/dashboard/routes/dashboard/inbox/components/InboxNameAndId.vue index 0b0ef03ff..3e4a9d8a9 100644 --- a/app/javascript/dashboard/routes/dashboard/inbox/components/InboxNameAndId.vue +++ b/app/javascript/dashboard/routes/dashboard/inbox/components/InboxNameAndId.vue @@ -21,6 +21,7 @@ export default { }, }; + - + + diff --git a/app/javascript/dashboard/routes/dashboard/inbox/components/MenuItem.vue b/app/javascript/dashboard/routes/dashboard/inbox/components/MenuItem.vue index cddad0d58..5019d451d 100644 --- a/app/javascript/dashboard/routes/dashboard/inbox/components/MenuItem.vue +++ b/app/javascript/dashboard/routes/dashboard/inbox/components/MenuItem.vue @@ -6,16 +6,17 @@ defineProps({ }, }); -const emits = defineEmits(['click']); +const emit = defineEmits(['click']); const onMenuItemClick = () => { - emits('click'); + emit('click'); }; +