diff --git a/.rubocop.yml b/.rubocop.yml index 00b581c0d..ac0a64665 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,7 +25,7 @@ Style/FrozenStringLiteralComment: Style/SymbolArray: Enabled: false Style/OptionalBooleanParameter: - Exclude: + Exclude: - 'app/services/email_templates/db_resolver_service.rb' - 'app/dispatchers/dispatcher.rb' Style/GlobalVars: @@ -57,6 +57,7 @@ Rails/ApplicationController: - 'app/controllers/widgets_controller.rb' - 'app/controllers/platform_controller.rb' - 'app/controllers/public_controller.rb' + - 'app/controllers/survey/responses_controller.rb' Style/ClassAndModuleChildren: EnforcedStyle: compact Exclude: @@ -79,7 +80,7 @@ Style/GuardClause: - 'app/models/message.rb' - 'db/migrate/20190819005836_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb' Metrics/AbcSize: - Exclude: + Exclude: - 'app/controllers/concerns/auth_helper.rb' - 'db/migrate/20190819005836_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb' - 'db/migrate/20161123131628_devise_token_auth_create_users.rb' @@ -108,7 +109,7 @@ Rails/BulkChangeTable: - 'db/migrate/20191027054756_create_contact_inboxes.rb' - 'db/migrate/20191130164019_add_template_type_to_messages.rb' - 'db/migrate/20210425093724_convert_integration_hook_settings_field.rb' -Rails/UniqueValidationWithoutIndex: +Rails/UniqueValidationWithoutIndex: Exclude: - 'app/models/channel/twitter_profile.rb' - 'app/models/webhook.rb' diff --git a/app/controllers/survey/responses_controller.rb b/app/controllers/survey/responses_controller.rb new file mode 100644 index 000000000..8bbd0fe88 --- /dev/null +++ b/app/controllers/survey/responses_controller.rb @@ -0,0 +1,10 @@ +class Survey::ResponsesController < ActionController::Base + before_action :set_global_config + def show; end + + private + + def set_global_config + @global_config = GlobalConfig.get('LOGO_THUMBNAIL', 'BRAND_NAME', 'WIDGET_BRAND_URL') + end +end diff --git a/app/javascript/packs/survey.js b/app/javascript/packs/survey.js new file mode 100644 index 000000000..3c65f8b82 --- /dev/null +++ b/app/javascript/packs/survey.js @@ -0,0 +1,25 @@ +import Vue from 'vue'; +import Vuelidate from 'vuelidate'; +import VueI18n from 'vue-i18n'; +import App from '../survey/App.vue'; +import i18n from '../survey/i18n'; + +Vue.use(VueI18n); +Vue.use(Vuelidate); + +const i18nConfig = new VueI18n({ + locale: 'en', + messages: i18n, +}); + +// Event Bus +window.bus = new Vue(); + +Vue.config.productionTip = false; + +window.onload = () => { + window.WOOT_SURVEY = new Vue({ + i18n: i18nConfig, + render: h => h(App), + }).$mount('#app'); +}; diff --git a/app/javascript/widget/components/Branding.vue b/app/javascript/shared/components/Branding.vue similarity index 88% rename from app/javascript/widget/components/Branding.vue rename to app/javascript/shared/components/Branding.vue index aacf825d3..6a284a6bd 100644 --- a/app/javascript/widget/components/Branding.vue +++ b/app/javascript/shared/components/Branding.vue @@ -16,21 +16,28 @@ - diff --git a/app/javascript/survey/App.vue b/app/javascript/survey/App.vue new file mode 100755 index 000000000..076ca9fe7 --- /dev/null +++ b/app/javascript/survey/App.vue @@ -0,0 +1,20 @@ + + + + + diff --git a/app/javascript/survey/assets/scss/woot.scss b/app/javascript/survey/assets/scss/woot.scss new file mode 100755 index 000000000..5c7a4a213 --- /dev/null +++ b/app/javascript/survey/assets/scss/woot.scss @@ -0,0 +1,21 @@ +@import 'tailwindcss/base'; +@import 'tailwindcss/components'; +@import 'tailwindcss/utilities'; +@import 'widget/assets/scss/reset'; +@import 'widget/assets/scss/variables'; +@import 'widget/assets/scss/buttons'; +@import 'widget/assets/scss/mixins'; +@import 'widget/assets/scss/forms'; +@import 'shared/assets/fonts/widget_fonts'; + +html, +body { + font-family: $font-family; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + height: 100%; +} + +.woot-survey-wrap { + height: 100%; +} diff --git a/app/javascript/survey/components/Rating.vue b/app/javascript/survey/components/Rating.vue new file mode 100644 index 000000000..22f7d2cb7 --- /dev/null +++ b/app/javascript/survey/components/Rating.vue @@ -0,0 +1,73 @@ + + + + + diff --git a/app/javascript/survey/i18n/index.js b/app/javascript/survey/i18n/index.js new file mode 100644 index 000000000..8475d9f20 --- /dev/null +++ b/app/javascript/survey/i18n/index.js @@ -0,0 +1,5 @@ +import { default as en } from './locale/en.json'; + +export default { + en, +}; diff --git a/app/javascript/survey/i18n/locale/en.json b/app/javascript/survey/i18n/locale/en.json new file mode 100644 index 000000000..72107e5be --- /dev/null +++ b/app/javascript/survey/i18n/locale/en.json @@ -0,0 +1,15 @@ +{ + "SURVEY": { + "DESCRIPTION": "Dear customer 👋 , please take a few moments to complete the feedback about the conversation.", + "RATING": { + "LABEL": "Rate your conversation", + "SUCCESS_MESSAGE": "Thank you for submitting the rating" + }, + "FEEDBACK": { + "LABEL": "Do you have any thoughts you'd like to share?", + "PLACEHOLDER": "Your feedback (optional)", + "BUTTON_TEXT": "Submit feedback" + } + }, + "POWERED_BY": "Powered by Chatwoot" +} diff --git a/app/javascript/survey/views/Response.vue b/app/javascript/survey/views/Response.vue new file mode 100644 index 000000000..ff4d95fff --- /dev/null +++ b/app/javascript/survey/views/Response.vue @@ -0,0 +1,64 @@ + + + + + diff --git a/app/javascript/widget/views/Home.vue b/app/javascript/widget/views/Home.vue index c8d89cbe2..1e46f6a21 100755 --- a/app/javascript/widget/views/Home.vue +++ b/app/javascript/widget/views/Home.vue @@ -69,7 +69,7 @@ + <%= javascript_pack_tag 'survey' %> + <%= stylesheet_pack_tag 'survey' %> + + +
+ <%= yield %> + + diff --git a/config/routes.rb b/config/routes.rb index e118ca0bb..99251c754 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -20,6 +20,9 @@ Rails.application.routes.draw do get '/app/accounts/:account_id/settings/inboxes/new/:inbox_id/agents', to: 'dashboard#index', as: 'app_twitter_inbox_agents' resource :widget, only: [:show] + namespace :survey do + resources :responses, only: [:show] + end end get '/api', to: 'api#index' diff --git a/config/webpack/resolve.js b/config/webpack/resolve.js index 8ff805de9..ce17c0db4 100644 --- a/config/webpack/resolve.js +++ b/config/webpack/resolve.js @@ -6,6 +6,7 @@ const resolve = { vue$: 'vue/dist/vue.common.js', dashboard: path.resolve('./app/javascript/dashboard'), widget: path.resolve('./app/javascript/widget'), + survey: path.resolve('./app/javascript/survey'), assets: path.resolve('./app/javascript/dashboard/assets'), components: path.resolve('./app/javascript/dashboard/components'), './iconfont.eot': 'vue-easytable/libs/font/iconfont.eot', diff --git a/spec/controllers/service/responses_controller_spec.rb b/spec/controllers/service/responses_controller_spec.rb new file mode 100644 index 000000000..a576a1c19 --- /dev/null +++ b/spec/controllers/service/responses_controller_spec.rb @@ -0,0 +1,16 @@ +require 'rails_helper' + +describe '/survey/response', type: :request do + describe 'GET survey/responses/{uuid}' do + it 'renders the page correctly when called' do + conversation = create(:conversation) + get survey_response_url(id: conversation.uuid) + expect(response).to be_successful + end + + it 'returns 404 when called with invalid conversation uuid' do + get survey_response_url(id: '') + expect(response.status).to eq(404) + end + end +end diff --git a/tailwind.config.js b/tailwind.config.js index 9d76f14ee..c4e5aa8c1 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -4,6 +4,7 @@ module.exports = { purge: [ './app/javascript/widget/**/*.vue', './app/javascript/shared/**/*.vue', + './app/javascript/survey/**/*.vue', ], future: { removeDeprecatedGapUtilities: true,