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/
100 lines
2.4 KiB
JavaScript
100 lines
2.4 KiB
JavaScript
import types from '../../mutation-types';
|
|
import * as Sentry from '@sentry/vue';
|
|
|
|
export const mutations = {
|
|
[types.SET_CONTACT_UI_FLAG]($state, data) {
|
|
$state.uiFlags = {
|
|
...$state.uiFlags,
|
|
...data,
|
|
};
|
|
},
|
|
|
|
[types.CLEAR_CONTACTS]: $state => {
|
|
$state.records = {};
|
|
$state.sortOrder = [];
|
|
},
|
|
|
|
[types.SET_CONTACT_META]: ($state, data) => {
|
|
const { count, current_page: currentPage, has_more: hasMore } = data;
|
|
$state.meta.count = count;
|
|
$state.meta.currentPage = currentPage;
|
|
if (hasMore !== undefined) {
|
|
$state.meta.hasMore = hasMore;
|
|
}
|
|
},
|
|
|
|
[types.APPEND_CONTACTS]: ($state, data) => {
|
|
data.forEach(contact => {
|
|
$state.records[contact.id] = {
|
|
...($state.records[contact.id] || {}),
|
|
...contact,
|
|
};
|
|
if (!$state.sortOrder.includes(contact.id)) {
|
|
$state.sortOrder.push(contact.id);
|
|
}
|
|
});
|
|
},
|
|
|
|
[types.SET_CONTACTS]: ($state, data) => {
|
|
const sortOrder = data.map(contact => {
|
|
$state.records[contact.id] = {
|
|
...($state.records[contact.id] || {}),
|
|
...contact,
|
|
};
|
|
return contact.id;
|
|
});
|
|
$state.sortOrder = sortOrder;
|
|
},
|
|
|
|
[types.SET_CONTACT_ITEM]: ($state, data) => {
|
|
$state.records[data.id] = {
|
|
...($state.records[data.id] || {}),
|
|
...data,
|
|
};
|
|
|
|
if (!$state.sortOrder.includes(data.id)) {
|
|
$state.sortOrder.push(data.id);
|
|
}
|
|
},
|
|
|
|
[types.EDIT_CONTACT]: ($state, data) => {
|
|
$state.records[data.id] = data;
|
|
},
|
|
|
|
[types.DELETE_CONTACT]: ($state, id) => {
|
|
const index = $state.sortOrder.findIndex(item => item === id);
|
|
$state.sortOrder.splice(index, 1);
|
|
delete $state.records[id];
|
|
},
|
|
|
|
[types.UPDATE_CONTACTS_PRESENCE]: ($state, data) => {
|
|
Object.values($state.records).forEach(element => {
|
|
let availabilityStatus;
|
|
try {
|
|
availabilityStatus = data[element.id];
|
|
} catch (error) {
|
|
Sentry.setContext('contact is undefined', {
|
|
records: $state.records,
|
|
data: data,
|
|
});
|
|
Sentry.captureException(error);
|
|
|
|
return;
|
|
}
|
|
if (availabilityStatus) {
|
|
$state.records[element.id].availability_status = availabilityStatus;
|
|
} else {
|
|
$state.records[element.id].availability_status = null;
|
|
}
|
|
});
|
|
},
|
|
|
|
[types.SET_CONTACT_FILTERS](_state, data) {
|
|
_state.appliedFilters = data;
|
|
},
|
|
|
|
[types.CLEAR_CONTACT_FILTERS](_state) {
|
|
_state.appliedFilters = [];
|
|
},
|
|
};
|