fix: use Deal terminology in trash

This commit is contained in:
mirivlad 2026-07-14 23:19:11 +08:00
parent c8b8045da1
commit f456287c2e
4 changed files with 26 additions and 7 deletions

View File

@ -217,7 +217,7 @@
value: state.workspace, value: state.workspace,
'data-trash-filter-workspace': '', 'data-trash-filter-workspace': '',
onChange: function (event) { state.workspace = event.target.value; render(); } onChange: function (event) { state.workspace = event.target.value; render(); }
}, [el('option', { value: '' }, [tr('ui.allWorkspaces', null, 'All workspaces')])]); }, [el('option', { value: '' }, [tr('ui.allWorkspaces', null, 'All Deals')])]);
workspaceOptions().forEach(function (workspace) { workspaceOptions().forEach(function (workspace) {
workspaceSelect.appendChild(el('option', { value: workspace }, [workspace])); workspaceSelect.appendChild(el('option', { value: workspace }, [workspace]));
}); });
@ -270,7 +270,7 @@
var list = el('div', { className: 'trash-list', 'data-trash-list': '' }); var list = el('div', { className: 'trash-list', 'data-trash-list': '' });
list.appendChild(el('div', { className: 'trash-header' }, [ list.appendChild(el('div', { className: 'trash-header' }, [
el('span', {}, [tr('ui.name', null, 'Name')]), el('span', {}, [tr('ui.name', null, 'Name')]),
el('span', {}, [tr('ui.workspace', null, 'Workspace')]), el('span', {}, [tr('ui.workspace', null, 'Deal')]),
el('span', {}, [tr('ui.originalPath', null, 'Original path')]), el('span', {}, [tr('ui.originalPath', null, 'Original path')]),
el('span', {}, [tr('ui.deleted', null, 'Deleted')]), el('span', {}, [tr('ui.deleted', null, 'Deleted')]),
el('span', {}, [tr('ui.typeSize', null, 'Type / size')]), el('span', {}, [tr('ui.typeSize', null, 'Type / size')]),

View File

@ -10,7 +10,7 @@
"ui.cannotUndo": "This cannot be undone.", "ui.cannotUndo": "This cannot be undone.",
"ui.cancel": "Cancel", "ui.cancel": "Cancel",
"ui.deleting": "Deleting...", "ui.deleting": "Deleting...",
"ui.allWorkspaces": "All workspaces", "ui.allWorkspaces": "All Deals",
"ui.allTypes": "All types", "ui.allTypes": "All types",
"ui.files": "Files", "ui.files": "Files",
"ui.folders": "Folders", "ui.folders": "Folders",
@ -22,7 +22,7 @@
"ui.total": "{count} total", "ui.total": "{count} total",
"ui.filter": "Filter name or path", "ui.filter": "Filter name or path",
"ui.refresh": "Refresh", "ui.refresh": "Refresh",
"ui.workspace": "Workspace", "ui.workspace": "Deal",
"ui.originalPath": "Original path", "ui.originalPath": "Original path",
"ui.deleted": "Deleted", "ui.deleted": "Deleted",
"ui.typeSize": "Type / size", "ui.typeSize": "Type / size",

View File

@ -10,7 +10,7 @@
"ui.cannotUndo": "Это действие нельзя отменить.", "ui.cannotUndo": "Это действие нельзя отменить.",
"ui.cancel": "Отмена", "ui.cancel": "Отмена",
"ui.deleting": "Удаление...", "ui.deleting": "Удаление...",
"ui.allWorkspaces": "Все рабочие пространства", "ui.allWorkspaces": "Все Дела",
"ui.allTypes": "Все типы", "ui.allTypes": "Все типы",
"ui.files": "Файлы", "ui.files": "Файлы",
"ui.folders": "Папки", "ui.folders": "Папки",
@ -22,7 +22,7 @@
"ui.total": "Всего: {count}", "ui.total": "Всего: {count}",
"ui.filter": "Фильтр по имени или пути", "ui.filter": "Фильтр по имени или пути",
"ui.refresh": "Обновить", "ui.refresh": "Обновить",
"ui.workspace": "Рабочее пространство", "ui.workspace": "Дело",
"ui.originalPath": "Исходный путь", "ui.originalPath": "Исходный путь",
"ui.deleted": "Удалён", "ui.deleted": "Удалён",
"ui.typeSize": "Тип / размер", "ui.typeSize": "Тип / размер",

View File

@ -5,8 +5,10 @@ const vm = require('vm');
const root = path.resolve(__dirname, '..'); const root = path.resolve(__dirname, '..');
const sourcePath = path.join(root, 'plugins', 'trash', 'frontend', 'src', 'index.js'); const sourcePath = path.join(root, 'plugins', 'trash', 'frontend', 'src', 'index.js');
const manifestPath = path.join(root, 'plugins', 'trash', 'plugin.json'); const manifestPath = path.join(root, 'plugins', 'trash', 'plugin.json');
const russianLocalePath = path.join(root, 'plugins', 'trash', 'locales', 'ru.json');
const source = fs.readFileSync(sourcePath, 'utf8'); const source = fs.readFileSync(sourcePath, 'utf8');
const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
const russianLocale = JSON.parse(fs.readFileSync(russianLocalePath, 'utf8'));
class FakeClassList { class FakeClassList {
constructor(node) { constructor(node) {
@ -159,7 +161,7 @@ function loadTrashComponent(document) {
return component; return component;
} }
function makeApi() { function makeApi(locale = null) {
let entries = [ let entries = [
{ {
trashId: 'old-project-file', trashId: 'old-project-file',
@ -194,6 +196,11 @@ function makeApi() {
return { return {
restoreCalls, restoreCalls,
deleteCalls, deleteCalls,
i18n: locale ? {
t(key, params, fallback) {
return String(locale[key] || fallback || key).replace(/\{(\w+)\}/g, (_match, name) => String((params || {})[name] ?? ''));
},
} : null,
files: { files: {
listTrash: async () => entries.slice(), listTrash: async () => entries.slice(),
restoreTrash: async (trashId, options) => { restoreTrash: async (trashId, options) => {
@ -237,6 +244,10 @@ function findByData(rootNode, name, value) {
component.mount(container, {}, api); component.mount(container, {}, api);
await flush(); await flush();
if (!container.textContent.includes('All Deals') || !container.textContent.includes('Deal')) {
throw new Error('global Trash did not use Deal terminology');
}
const latestRow = findByData(container, 'data-trash-row', 'latest-client-report'); const latestRow = findByData(container, 'data-trash-row', 'latest-client-report');
if (!latestRow || !latestRow.textContent.includes('ClientA') || !latestRow.textContent.includes('ClientA/Archive/report.pdf')) { if (!latestRow || !latestRow.textContent.includes('ClientA') || !latestRow.textContent.includes('ClientA/Archive/report.pdf')) {
throw new Error(`global Trash must render workspace and original path: ${container.textContent}`); throw new Error(`global Trash must render workspace and original path: ${container.textContent}`);
@ -298,6 +309,14 @@ function findByData(rootNode, name, value) {
} }
component.unmount(container); component.unmount(container);
const russianContainer = new FakeNode('div');
component.mount(russianContainer, {}, makeApi(russianLocale));
await flush();
if (!russianContainer.textContent.includes('Все Дела') || !russianContainer.textContent.includes('Дело')) {
throw new Error('global Trash did not localize Deal terminology');
}
component.unmount(russianContainer);
console.log('trash frontend smoke passed'); console.log('trash frontend smoke passed');
})().catch((err) => { })().catch((err) => {
console.error(err); console.error(err);