diff --git a/.eslintrc.js b/.eslintrc.js index f3d050ab3..3c191b7b7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,17 +1,6 @@ module.exports = { - extends: [ - 'airbnb-base/legacy', - 'prettier', - 'plugin:vue/recommended', - 'plugin:storybook/recommended', - 'plugin:cypress/recommended', - ], - parserOptions: { - parser: '@babel/eslint-parser', - ecmaVersion: 2020, - sourceType: 'module', - }, - plugins: ['html', 'prettier', 'babel'], + extends: ['airbnb-base/legacy', 'prettier', 'plugin:vue/recommended'], + plugins: ['html', 'prettier'], rules: { 'prettier/prettier': ['error'], camelcase: 'off', @@ -210,13 +199,6 @@ module.exports = { 'import/extensions': ['off'], 'no-console': 'error', }, - settings: { - 'import/resolver': { - webpack: { - config: 'config/webpack/resolve.js', - }, - }, - }, env: { browser: true, node: true, diff --git a/.github/workflows/run_foss_spec.yml b/.github/workflows/run_foss_spec.yml index b0b2372ae..9382ccbf6 100644 --- a/.github/workflows/run_foss_spec.yml +++ b/.github/workflows/run_foss_spec.yml @@ -42,7 +42,9 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 with: + version: 9 ref: ${{ github.event.pull_request.head.ref }} repository: ${{ github.event.pull_request.head.repo.full_name }} @@ -53,10 +55,10 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 - cache: yarn + cache: 'pnpm' - - name: yarn - run: yarn install + - name: Install pnpm dependencies + run: pnpm i - name: Strip enterprise code run: | @@ -69,9 +71,6 @@ jobs: - name: Seed database run: bundle exec rake db:schema:load - - name: yarn check-files - run: yarn install --check-files - # Run rails tests - name: Run backend tests run: | diff --git a/.gitignore b/.gitignore index 028a97f09..5eb883db0 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,16 @@ master.key public/uploads public/packs* +public/assets/administrate* +public/assets/action*.js +public/assets/activestorage*.js +public/assets/trix* +public/assets/belongs_to*.js +public/assets/manifest*.js +public/assets/manifest*.js +public/assets/*.js.gz +public/assets/secretField* +public/assets/.sprockets-manifest-*.json # VIM files *.swp @@ -75,4 +85,8 @@ yalc.lock yarn-debug.log* .yarn-integrity -/storybook-static \ No newline at end of file +# Vite Ruby +/public/vite* +# Vite uses dotenv and suggests to ignore local-only env files. See +# https://vitejs.dev/guide/env-and-mode.html#env-files +*.local diff --git a/.husky/pre-commit b/.husky/pre-commit index adda426ad..2525dde4e 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,11 +1,11 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" +# #!/bin/sh +# . "$(dirname "$0")/_/husky.sh" -# lint js and vue files -npx --no-install lint-staged +# # lint js and vue files +# npx --no-install lint-staged -# lint only staged ruby files -git diff --name-only --cached | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs bundle exec rubocop --force-exclusion -a +# # lint only staged ruby files +# git diff --name-only --cached | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs bundle exec rubocop --force-exclusion -a -# stage rubocop changes to files -git diff --name-only --cached | xargs git add +# # stage rubocop changes to files +# git diff --name-only --cached | xargs git add diff --git a/.storybook/main.js b/.storybook/main.js deleted file mode 100644 index cb32634c2..000000000 --- a/.storybook/main.js +++ /dev/null @@ -1,56 +0,0 @@ -const path = require('path'); -const resolve = require('../config/webpack/resolve'); - -// Chatwoot's webpack.config.js -process.env.NODE_ENV = 'development'; -const custom = require('../config/webpack/environment'); - -module.exports = { - stories: [ - '../stories/**/*.stories.mdx', - '../app/javascript/**/*.stories.@(js|jsx|ts|tsx)', - ], - addons: [ - { - name: '@storybook/addon-docs', - options: { - vueDocgenOptions: { - alias: { - '@': path.resolve(__dirname, '../'), - }, - }, - }, - }, - '@storybook/addon-links', - '@storybook/addon-essentials', - { - /** - * Fix Storybook issue with PostCSS@8 - * @see https://github.com/storybookjs/storybook/issues/12668#issuecomment-773958085 - */ - name: '@storybook/addon-postcss', - options: { - postcssLoaderOptions: { - implementation: require('postcss'), - }, - }, - }, - ], - webpackFinal: config => { - const newConfig = { - ...config, - resolve: { - ...config.resolve, - modules: custom.resolvedModules.map(i => i.value), - }, - }; - - newConfig.module.rules.push({ - test: /\.scss$/, - use: ['style-loader', 'css-loader', 'postcss-loader', 'sass-loader'], - include: path.resolve(__dirname, '../app/javascript'), - }); - - return newConfig; - }, -}; diff --git a/.storybook/preview.js b/.storybook/preview.js deleted file mode 100644 index 7c046d51a..000000000 --- a/.storybook/preview.js +++ /dev/null @@ -1,46 +0,0 @@ -import { addDecorator } from '@storybook/vue'; -import Vue from 'vue'; -import Vuex from 'vuex'; -import VueI18n from 'vue-i18n'; -import Multiselect from 'vue-multiselect'; -import VueDOMPurifyHTML from 'vue-dompurify-html'; -import FluentIcon from 'shared/components/FluentIcon/DashboardIcon'; - -import WootUiKit from '../app/javascript/dashboard/components'; -import i18n from '../app/javascript/dashboard/i18n'; -import { domPurifyConfig } from 'shared/helpers/HTMLSanitizer'; - -import '../app/javascript/dashboard/assets/scss/storybook.scss'; - -Vue.use(VueI18n); -Vue.use(WootUiKit); -Vue.use(Vuex); -Vue.use(VueDOMPurifyHTML, domPurifyConfig); - -Vue.component('multiselect', Multiselect); -Vue.component('fluent-icon', FluentIcon); - -const store = new Vuex.Store({}); -const i18nConfig = new VueI18n({ - locale: 'en', - messages: i18n, -}); - -addDecorator(() => ({ - template: '', - i18n: i18nConfig, - store, - beforeCreate: function () { - this.$root._i18n = this.$i18n; - }, -})); - -export const parameters = { - actions: { argTypesRegex: '^on[A-Z].*' }, - controls: { - matchers: { - color: /(background|color)$/i, - date: /Date$/, - }, - }, -}; diff --git a/Gemfile b/Gemfile index ec57da193..2e1e3ec14 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,7 @@ gem 'activerecord-import' gem 'dotenv-rails', '>= 3.0.0' gem 'foreman' gem 'puma' -gem 'webpacker' +gem 'vite_rails' # metrics on heroku gem 'barnes' @@ -204,8 +204,6 @@ group :development do end group :test do - # Cypress in rails. - gem 'cypress-on-rails' # fast cleaning of database gem 'database_cleaner' # mock http calls diff --git a/Gemfile.lock b/Gemfile.lock index 75fbd2e4f..f54a20aaa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,8 +178,6 @@ GEM csv (3.3.0) csv-safe (3.3.1) csv (~> 3.0) - cypress-on-rails (1.16.0) - rack database_cleaner (2.0.2) database_cleaner-active_record (>= 2, < 3) database_cleaner-active_record (2.1.0) @@ -222,6 +220,7 @@ GEM railties (>= 6.1) down (5.4.0) addressable (~> 2.8) + dry-cli (1.1.0) ecma-re-validator (0.4.0) regexp_parser (~> 2.2) elastic-apm (4.6.2) @@ -496,14 +495,14 @@ GEM newrelic_rpm (9.6.0) base64 nio4r (2.7.3) - nokogiri (1.16.6) + nokogiri (1.16.7) mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.16.6-arm64-darwin) + nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.6-x86_64-darwin) + nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) + nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) oauth (1.1.0) oauth-tty (~> 1.0, >= 1.0.1) @@ -557,7 +556,7 @@ GEM pundit (2.3.0) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.8.0) + racc (1.8.1) rack (2.2.9) rack-attack (6.7.0) rack (>= 1.0, < 4) @@ -570,7 +569,7 @@ GEM rack-protection (3.2.0) base64 (>= 0.1.0) rack (~> 2.2, >= 2.2.4) - rack-proxy (0.7.6) + rack-proxy (0.7.7) rack rack-test (2.1.0) rack (>= 1.3) @@ -709,7 +708,6 @@ GEM activerecord (>= 4) activesupport (>= 4) selectize-rails (0.12.6) - semantic_range (3.0.0) sentry-rails (5.19.0) railties (>= 5.0) sentry-ruby (~> 5.19.0) @@ -800,6 +798,13 @@ GEM activemodel (>= 3.2) mail (~> 2.5) version_gem (1.1.4) + vite_rails (3.0.17) + railties (>= 5.1, < 8) + vite_ruby (~> 3.0, >= 3.2.2) + vite_ruby (3.8.0) + dry-cli (>= 0.7, < 2) + rack-proxy (~> 0.6, >= 0.6.1) + zeitwerk (~> 2.2) warden (1.2.9) rack (>= 2.0.9) web-console (4.2.1) @@ -814,11 +819,6 @@ GEM addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webpacker (5.4.4) - activesupport (>= 5.2) - rack-proxy (>= 0.6.1) - railties (>= 5.2) - semantic_range (>= 2.3.0) webrick (1.8.2) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) @@ -827,7 +827,7 @@ GEM working_hours (1.4.1) activesupport (>= 3.2) tzinfo - zeitwerk (2.6.16) + zeitwerk (2.6.17) PLATFORMS arm64-darwin-20 @@ -862,7 +862,6 @@ DEPENDENCIES climate_control commonmarker csv-safe - cypress-on-rails database_cleaner ddtrace debug (~> 1.8) @@ -960,10 +959,10 @@ DEPENDENCIES tzinfo-data uglifier valid_email2 + vite_rails web-console (>= 4.2.1) web-push (>= 3.0.1) webmock - webpacker wisper (= 2.0.0) working_hours diff --git a/Procfile.dev b/Procfile.dev index 73c2af7e8..651b84edd 100644 --- a/Procfile.dev +++ b/Procfile.dev @@ -1,4 +1,4 @@ backend: bin/rails s -p 3000 -frontend: export NODE_OPTIONS=--openssl-legacy-provider && bin/webpack-dev-server # https://github.com/mperham/sidekiq/issues/3090#issuecomment-389748695 worker: dotenv bundle exec sidekiq -C config/sidekiq.yml +vite: bin/vite dev diff --git a/Procfile.test b/Procfile.test index 1770cdbc6..f7ac060ba 100644 --- a/Procfile.test +++ b/Procfile.test @@ -1,3 +1,3 @@ backend: RAILS_ENV=test bin/rails s -p 5050 -frontend: export NODE_OPTIONS=--openssl-legacy-provider && bin/webpack-dev-server +vite: bin/vite dev worker: RAILS_ENV=test dotenv bundle exec sidekiq -C config/sidekiq.yml diff --git a/README.md b/README.md index 152660fb7..3cddf3fb3 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ +## 🚨 Note: This branch is unstable. For the stable branch's source code, please use version 3.x + + Chat dashboard dark mode Chat dashboard ___ -# Chatwoot +# Chatwoot Customer engagement suite, an open-source alternative to Intercom, Zendesk, Salesforce Service Cloud etc.

@@ -98,7 +101,7 @@ Chatwoot now supports 1-Click deployment to DigitalOcean as a kubernetes app. ### Other deployment options -For other supported options, checkout our [deployment page](https://chatwoot.com/deploy). +For other supported options, checkout our [deployment page](https://chatwoot.com/deploy). ## Security diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js index 2cc9549bc..00c9417ba 100644 --- a/app/assets/config/manifest.js +++ b/app/assets/config/manifest.js @@ -2,5 +2,4 @@ //= link administrate/application.css //= link administrate/application.js //= link administrate-field-active_storage/application.css -//= link dashboardChart.js //= link secretField.js diff --git a/app/assets/javascripts/dashboardChart.js b/app/assets/javascripts/dashboardChart.js deleted file mode 100644 index 46f278b80..000000000 --- a/app/assets/javascripts/dashboardChart.js +++ /dev/null @@ -1,55 +0,0 @@ -// eslint-disable-next-line -function prepareData(data) { - var labels = []; - var dataSet = []; - data.forEach(item => { - labels.push(item[0]); - dataSet.push(item[1]); - }); - return { labels, dataSet }; -} - -function getChartOptions() { - var fontFamily = - 'PlusJakarta,-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif'; - return { - responsive: true, - legend: { labels: { fontFamily } }, - scales: { - xAxes: [ - { - barPercentage: 1.26, - ticks: { fontFamily }, - gridLines: { display: false }, - }, - ], - yAxes: [ - { - ticks: { fontFamily }, - gridLines: { display: false }, - }, - ], - }, - }; -} - -// eslint-disable-next-line -function drawSuperAdminDashboard(data) { - var ctx = document.getElementById('dashboard-chart').getContext('2d'); - var chartData = prepareData(data); - // eslint-disable-next-line - new Chart(ctx, { - type: 'bar', - data: { - labels: chartData.labels, - datasets: [ - { - label: 'Conversations', - data: chartData.dataSet, - backgroundColor: '#1f93ff', - }, - ], - }, - options: getChartOptions(), - }); -} diff --git a/app/assets/stylesheets/administrate/utilities/_variables.scss b/app/assets/stylesheets/administrate/utilities/_variables.scss index 3a1129c41..9123667e2 100644 --- a/app/assets/stylesheets/administrate/utilities/_variables.scss +++ b/app/assets/stylesheets/administrate/utilities/_variables.scss @@ -86,8 +86,5 @@ $swift-ease-out-duration: .4s !default; $swift-ease-out-timing-function: cubic-bezier(.25, .8, .25, 1) !default; $swift-ease-out: all $swift-ease-out-duration $swift-ease-out-timing-function !default; -// Ionicons -$ionicons-font-path: '~ionicons/fonts'; - // Transitions $transition-ease-in: all 0.250s ease-in; diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 332f1528f..6ddaab73b 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -72,7 +72,7 @@ class DashboardController < ActionController::Base @application_pack = if request.path.include?('/auth') || request.path.include?('/login') 'v3app' else - 'application' + 'dashboard' end end diff --git a/app/javascript/dashboard/App.vue b/app/javascript/dashboard/App.vue index da169d61f..977f8565c 100644 --- a/app/javascript/dashboard/App.vue +++ b/app/javascript/dashboard/App.vue @@ -1,6 +1,5 @@ @@ -34,7 +36,7 @@ export default {