Copy the Chatwoot (v4.14.0) frontend runnable subset into frontend/ for customization: - app/javascript/ (Vue SPA: dashboard, widget, sdk, portal, superadmin) - app/views/ (ERB templates for vite-plugin-ruby entrypoint resolution) - app/helpers/, app/assets/ (Rails view helpers, static assets) - enterprise/ (Enterprise edition frontend overlay) - config/vite.json, vite.config.ts, bin/vite (Vite-Rails toolchain) - package.json, pnpm-lock.yaml, tailwind/postcss/eslint configs - Gemfile, Gemfile.lock (vite_rails gem for bin/vite binstub) Excluded Rails backend: controllers, models, services, jobs, mailers, policies, db, lib, spec, public, node_modules. Update references to the new frontend location: - .gitignore: exclude frontend build artifacts (node_modules, tmp, packs), keep frontend/bin/ and frontend/vendor/ via negation - backend/scripts/parity_frontend_smoke.sh: CHATWOOT_DIR default reference/chatwoot -> ../frontend - backend/scripts/parity_frontend_browser_smoke.mjs: same default update - AGENTS.md: add frontend section with Rails/Vite coupling notes - README: architecture tree includes frontend/
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
import types from '../mutation-types';
|
|
|
|
import { REPLY_EDITOR_MODES } from 'dashboard/components/widgets/WootWriter/constants';
|
|
import { LocalStorage } from 'shared/helpers/localStorage';
|
|
import { LOCAL_STORAGE_KEYS } from 'dashboard/constants/localStorage';
|
|
|
|
const state = {
|
|
records: LocalStorage.get(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES) || {},
|
|
replyEditorMode: REPLY_EDITOR_MODES.REPLY,
|
|
};
|
|
|
|
export const getters = {
|
|
get: _state => key => {
|
|
return _state.records[key] || '';
|
|
},
|
|
getReplyEditorMode: _state => _state.replyEditorMode,
|
|
};
|
|
|
|
export const actions = {
|
|
set: async ({ commit }, { key, message }) => {
|
|
commit(types.SET_DRAFT_MESSAGES, { key, message });
|
|
},
|
|
delete: ({ commit }, { key }) => {
|
|
commit(types.SET_DRAFT_MESSAGES, { key });
|
|
},
|
|
setReplyEditorMode: ({ commit }, { mode }) => {
|
|
commit(types.SET_REPLY_EDITOR_MODE, { mode });
|
|
},
|
|
};
|
|
|
|
export const mutations = {
|
|
[types.SET_DRAFT_MESSAGES]($state, { key, message }) {
|
|
$state.records = {
|
|
...$state.records,
|
|
[key]: message,
|
|
};
|
|
LocalStorage.set(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES, $state.records);
|
|
},
|
|
[types.REMOVE_DRAFT_MESSAGES]($state, { key }) {
|
|
const { [key]: draftToBeRemoved, ...updatedRecords } = $state.records;
|
|
$state.records = updatedRecords;
|
|
LocalStorage.set(LOCAL_STORAGE_KEYS.DRAFT_MESSAGES, $state.records);
|
|
},
|
|
[types.SET_REPLY_EDITOR_MODE]($state, { mode }) {
|
|
$state.replyEditorMode = mode;
|
|
},
|
|
};
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state,
|
|
getters,
|
|
actions,
|
|
mutations,
|
|
};
|