diff --git a/e2e/toasts.spec.ts b/e2e/toasts.spec.ts index 5cbe9960..ad22ecb2 100644 --- a/e2e/toasts.spec.ts +++ b/e2e/toasts.spec.ts @@ -53,6 +53,65 @@ test('a failed first fetch of a new subscription offers Retry, which stays until await expect(page.locator('.rp-toast')).toHaveCount(0); }); +// The boxes of a toast's parts, for the layout checks below. +async function parts(toast: ReturnType) { + return toast.evaluate(toast => { + const box = (selector: string) => { + const rect = toast.querySelector(selector)?.getBoundingClientRect(); + return rect ? {top: rect.top, bottom: rect.bottom, left: rect.left, right: rect.right, middle: rect.top + rect.height / 2} : null; + }; + return { + summary: box('[slot="title"]')!, + detail: box('[slot="description"]'), + icon: box('.icon svg'), + close: box('.close')!, + foot: box('.foot'), + action: box('.action'), + more: box('.more') + }; + }); +} + +for (const width of [1280, 390]) + test(`a failure toast at ${width}px puts the error under its summary and the action on a footer row that ends where close ends`, async ({page}) => { + await page.setViewportSize({width, height: 844}); + await failingFirstFetch(page, 1); + await page.goto('/#/nodes?tab=list'); + await addSubscription(page, 'sub-w'); + const failure = page.locator('.rp-toast.negative'); + await expect(failure.locator('[slot="title"]')).toHaveText('sub-w was written to the configuration, but could not be refreshed'); + await expect(failure.locator('[slot="description"]')).toContainText('Subscription server unreachable'); + const boxes = await parts(failure); + expect(boxes.detail!.top).toBeGreaterThanOrEqual(boxes.summary.bottom); + // Icon and close sit on the first line of the summary. + for (const middle of [boxes.icon!.middle, boxes.close.middle]) expect(Math.abs(middle - (boxes.summary.top + 10))).toBeLessThanOrEqual(1); + expect(boxes.action!.top).toBeGreaterThanOrEqual(boxes.detail!.bottom); + expect(Math.abs(boxes.action!.right - boxes.close.right)).toBeLessThanOrEqual(1); + // A toast with neither an action nor a stack behind it has no footer row, and one without a detail only its summary. + await failure.getByRole('button', {name: 'Retry', exact: true}).click(); + const success = page.locator('.rp-toast.positive'); + await expect(success).toBeVisible(); + await expect(success.locator('.foot')).toHaveCount(0); + await expect(success.locator('[slot="description"]')).toHaveCount(0); + }); + +for (const width of [1280, 390]) + test(`the front toast of a stack at ${width}px puts "show all" at the start of its footer row and the action at the end`, async ({page}) => { + await page.setViewportSize({width, height: 844}); + await failingFirstFetch(page, 9); + await page.goto('/#/nodes?tab=list'); + await addSubscription(page, 'sub-s'); + await addSubscription(page, 'sub-u'); + const front = page.locator('.rp-toast:not(.background)'); + await expect(front.getByRole('button', {name: /^Show all/})).toBeVisible(); + const boxes = await parts(front); + expect(Math.abs(boxes.action!.right - boxes.close.right)).toBeLessThanOrEqual(1); + expect(Math.abs(boxes.action!.middle - boxes.more!.middle)).toBeLessThanOrEqual(1); + expect(boxes.more!.right).toBeLessThan(boxes.action!.left); + expect(boxes.more!.top).toBeGreaterThanOrEqual(boxes.detail!.bottom); + expect(Math.abs(boxes.close.middle - (boxes.summary.top + 10))).toBeLessThanOrEqual(1); + }); + test('a repeated actionable toast replaces its earlier copy', async ({page}) => { await failingFirstFetch(page, 2); await page.goto('/#/nodes?tab=list'); diff --git a/src/api/error.test.ts b/src/api/error.test.ts index 791de779..8df62cf4 100644 --- a/src/api/error.test.ts +++ b/src/api/error.test.ts @@ -1,6 +1,6 @@ import {expect, it} from 'vitest'; import {LANGS, translate} from '../i18n'; -import {ApiError, LocalError, errorText, failureNotice, withoutRequestNote} from './error'; +import {ApiError, LocalError, errorText, failureNotice, noticeText, withoutRequestNote} from './error'; it('joins a local error and its detail with the colon of the active language', () => { const error = new LocalError('ui.operationFailed', 'member refused'); @@ -9,18 +9,18 @@ it('joins a local error and its detail with the colon of the active language', ( expect(errorText(error, (key, params) => translate('en', key, params))).toBe('The operation did not succeed: member refused'); }); -it('reports an unknown operation outcome neutrally and without the failure wording around it', () => { +it('reports a failure under the summary of its action, and an unknown operation outcome neutrally on its own', () => { const t = (key: Parameters[1], params?: Parameters[2]) => translate('en', key, params); - const wrap = (error: string) => t('ov.operationError', {error}); - expect(failureNotice(new LocalError('ui.operationUnknown'), t, wrap)).toEqual({kind: 'neutral', text: t('ui.operationUnknown')}); - expect(failureNotice(new LocalError('ui.operationFailed'), t, wrap)).toEqual({kind: 'negative', text: wrap(t('ui.operationFailed'))}); + const summary = t('ov.operationError'); + expect(failureNotice(new LocalError('ui.operationUnknown'), t, summary)).toEqual({kind: 'neutral', text: t('ui.operationUnknown')}); + expect(failureNotice(new LocalError('ui.operationFailed'), t, summary)).toEqual({kind: 'negative', text: summary, detail: t('ui.operationFailed')}); + expect(noticeText(failureNotice(new Error('offline'), t, summary), t)).toBe('Could not run the operation: offline'); }); it('reports a file written but not applied without the failure wording that says it was not written', () => { const t = (key: Parameters[1], params?: Parameters[2]) => translate('en', key, params); - const wrap = (error: string) => t('ui.writeFailed', {error}); const error = new LocalError('ui.writtenNotApplied', 'Reload rejected'); - expect(failureNotice(error, t, wrap)).toEqual({kind: 'negative', text: errorText(error, t)}); + expect(failureNotice(error, t, t('ui.writeFailed'))).toEqual({kind: 'negative', text: t('ui.writtenNotApplied'), detail: 'Reload rejected'}); }); it('keeps the failed stage a backend operation names', () => { @@ -33,8 +33,7 @@ it('drops the request note from a failure in every language and leaves other bra const id = '0f8c2a4e-5b1d-4c3e-9a7f-2d6b8e1c4f90'; for (const [lang] of LANGS) { const t = (key: Parameters[1], params?: Parameters[2]) => translate(lang, key, params); - const failure = (requestId: string | null) => - t('ui.writeFailed', {error: errorText(new ApiError(502, 'test_failure', 'Upstream (proxy) unreachable', requestId), t)}); + const failure = (requestId: string | null) => errorText(new ApiError(502, 'test_failure', 'Upstream (proxy) unreachable', requestId), t); expect(failure(id)).toContain(id); expect(withoutRequestNote(failure(id))).toBe(failure(null)); } diff --git a/src/api/error.ts b/src/api/error.ts index ad80c52b..d3cda21a 100644 --- a/src/api/error.ts +++ b/src/api/error.ts @@ -68,13 +68,15 @@ export class LocalError extends Error { } } +// The backend's part of a local failure, in its words when it sent a known code. +const localDetail = (error: LocalError, t: Translator) => + error.detail ? (error.code ? backendMessage(error.code, error.detail, t, error.details) : error.detail) : undefined; + // The words for a failure: doona's own errors in the current language, the backend's message as it sent it. export function errorText(error: unknown, t: Translator): string { if (error instanceof LocalError) { - const text = t(error.key); - return error.detail - ? t('ui.valuePair', {label: text, value: error.code ? backendMessage(error.code, error.detail, t, error.details) : error.detail}) - : text; + const detail = localDetail(error, t); + return detail ? t('ui.valuePair', {label: t(error.key), value: detail}) : t(error.key); } if (error instanceof ApiError && error.text) return t(error.text.key, error.text.params); const message = @@ -87,11 +89,15 @@ export function errorText(error: unknown, t: Translator): string { const REQUEST_NOTE = /\s*[((]request_id[::][^))]*[))]/g; export const withoutRequestNote = (text: string) => text.replace(REQUEST_NOTE, ''); -// What to tell the person about a failed action, wrapped in that action's failure wording. An operation whose outcome -// is unknown did not fail: it is reported on its own, neutrally. A file written but not applied is reported on its own -// too, since the action's wording would say the write failed. -export function failureNotice(error: unknown, t: Translator, wrap: (error: string) => string) { - if (error instanceof LocalError && error.key === 'ui.operationUnknown') return {kind: 'neutral' as const, text: t(error.key)}; - if (error instanceof LocalError && error.key === 'ui.writtenNotApplied') return {kind: 'negative' as const, text: errorText(error, t)}; - return {kind: 'negative' as const, text: wrap(errorText(error, t))}; +// What to tell the person about a failed action: the action's summary, with the error as its detail. An operation +// whose outcome is unknown did not fail: it is reported on its own, neutrally. A file written but not applied is +// reported under its own summary too, since the action's would say the write failed. +export type Notice = {kind: 'neutral' | 'negative'; text: string; detail?: string}; +export function failureNotice(error: unknown, t: Translator, summary: string): Notice { + if (error instanceof LocalError && error.key === 'ui.operationUnknown') return {kind: 'neutral', text: t(error.key)}; + if (error instanceof LocalError && error.key === 'ui.writtenNotApplied') return {kind: 'negative', text: t(error.key), detail: localDetail(error, t)}; + return {kind: 'negative', text: summary, detail: errorText(error, t)}; } + +// A notice as one line, for a place that shows it inline rather than as a toast. +export const noticeText = ({text, detail}: Notice, t: Translator) => (detail ? t('ui.valuePair', {label: text, value: detail}) : text); diff --git a/src/features/activity/useMode.ts b/src/features/activity/useMode.ts index 45887c2a..d064c3cf 100644 --- a/src/features/activity/useMode.ts +++ b/src/features/activity/useMode.ts @@ -30,7 +30,7 @@ export function useMode() { toast('positive', t('act.modeApplied', {mode: t(modeLabels[submitted.mode])})); } const problem = editProblem(result, t); - if (problem) toast(problem.kind, problem.text); + if (problem) toast(problem.kind, problem.text, {detail: problem.detail}); }; return { ...view, diff --git a/src/features/config/messages.ts b/src/features/config/messages.ts index d96faa14..f093fedb 100644 --- a/src/features/config/messages.ts +++ b/src/features/config/messages.ts @@ -131,7 +131,7 @@ export const messages = defineMessages({ 'config.level.error': '錯誤', 'config.level.warning': '警告', 'config.level.info': '提示', - 'config.previewFailed': '無法產生組態:{error}' + 'config.previewFailed': '無法產生組態' }, 'zh-CN': { 'config.tabModules': '模块', @@ -263,7 +263,7 @@ export const messages = defineMessages({ 'config.level.error': '错误', 'config.level.warning': '警告', 'config.level.info': '提示', - 'config.previewFailed': '无法生成配置:{error}' + 'config.previewFailed': '无法生成配置' }, en: { 'config.tabModules': 'Modules', @@ -406,6 +406,6 @@ export const messages = defineMessages({ 'config.level.error': 'Error', 'config.level.warning': 'Warning', 'config.level.info': 'Info', - 'config.previewFailed': 'Could not generate the configuration: {error}' + 'config.previewFailed': 'Could not generate the configuration' } }); diff --git a/src/features/config/useConfigPage.ts b/src/features/config/useConfigPage.ts index 8ae40bfb..a41b0bed 100644 --- a/src/features/config/useConfigPage.ts +++ b/src/features/config/useConfigPage.ts @@ -40,7 +40,7 @@ function useConfigEditorController(refetch: () => void) { if (diagnostics) { const restart = restartRequired(diagnostics); toast('negative', restart ? t('config.writeRestart', {n: restart}) : t('ui.writeInvalid', {n: diagnostics.filter(d => d.level === 'error').length})); - } else toastFailure(editor.error, t, error => t('ui.writeFailed', {error})); + } else toastFailure(editor.error, t, t('ui.writeFailed')); }, [editor.error, diagnostics, t]); return {...editor, diagnostics}; } diff --git a/src/features/config/useWizard.ts b/src/features/config/useWizard.ts index ce382332..cfb3ed76 100644 --- a/src/features/config/useWizard.ts +++ b/src/features/config/useWizard.ts @@ -68,7 +68,7 @@ export function useWizard({main, editor, onDone}: {main: ConfigSource; editor: C const apply = async () => { if (busy || !valid) return; if (preview.error) { - toast('negative', t('config.previewFailed', {error: errorText(preview.error, t)})); + toast('negative', t('config.previewFailed'), {detail: errorText(preview.error, t)}); return; } const result = await editor.apply(origin, text); diff --git a/src/features/connections/messages.ts b/src/features/connections/messages.ts index 3f48aae3..bb03eff5 100644 --- a/src/features/connections/messages.ts +++ b/src/features/connections/messages.ts @@ -40,7 +40,7 @@ export const messages = defineMessages({ 'conn.export': '匯出 CSV', 'conn.closed': '已關閉 {name}', 'conn.notClosable': '此連線不由使用者空間持有,無法關閉', - 'conn.closeFailed': '無法關閉連線:{error}', + 'conn.closeFailed': '無法關閉連線', 'conn.notInSnapshot': '目前清單未包含此連線。', 'conn.ungrouped': '不分組', 'conn.groupCount': '{name}({n})', @@ -123,7 +123,7 @@ export const messages = defineMessages({ 'conn.export': '导出 CSV', 'conn.closed': '已关闭 {name}', 'conn.notClosable': '此连接不由用户空间持有,无法关闭', - 'conn.closeFailed': '无法关闭连接:{error}', + 'conn.closeFailed': '无法关闭连接', 'conn.notInSnapshot': '当前列表未包含此连接。', 'conn.ungrouped': '不分组', 'conn.groupCount': '{name}({n})', @@ -211,7 +211,7 @@ export const messages = defineMessages({ 'conn.export': 'Export CSV', 'conn.closed': 'Closed {name}', 'conn.notClosable': 'This connection is not owned by the userspace datapath and cannot be closed', - 'conn.closeFailed': 'Could not close the connection: {error}', + 'conn.closeFailed': 'Could not close the connection', 'conn.notInSnapshot': 'This connection is not in the current list.', 'conn.ungrouped': 'None', 'conn.groupCount': '{name} ({n})', diff --git a/src/features/connections/useConnectionsPage.ts b/src/features/connections/useConnectionsPage.ts index 907ef3b7..009a383f 100644 --- a/src/features/connections/useConnectionsPage.ts +++ b/src/features/connections/useConnectionsPage.ts @@ -121,10 +121,8 @@ export function useConnectionsPage({go, query}: PageProps) { if (new URLSearchParams(latest.current).get('id') === id) select(null); toast('positive', t('conn.closed', {name: model.detail.title})); } catch (error) { - toast( - 'negative', - error instanceof ApiError && error.code === 'state_conflict' ? t('conn.notClosable') : t('conn.closeFailed', {error: errorText(error, t)}) - ); + if (error instanceof ApiError && error.code === 'state_conflict') toast('negative', t('conn.notClosable')); + else toast('negative', t('conn.closeFailed'), {detail: errorText(error, t)}); } }; const closeAll = async () => { @@ -135,7 +133,7 @@ export function useConnectionsPage({go, query}: PageProps) { select(null); toast(closedAllTone(tally), t('conn.closedAll', {closed: tally.closed, skipped: tally.skipped})); } catch (error) { - return t('conn.closeFailed', {error: errorText(error, t)}); + return t('ui.valuePair', {label: t('conn.closeFailed'), value: errorText(error, t)}); } }; // Picking the chosen device or rule again lifts it, as does an empty value (the menu's "all" entry). diff --git a/src/features/dns/messages.ts b/src/features/dns/messages.ts index 9b303d14..d4c99f68 100644 --- a/src/features/dns/messages.ts +++ b/src/features/dns/messages.ts @@ -26,7 +26,7 @@ export const messages = defineMessages({ 'dns.chart.sample': '已載入:{n} 筆,未命中快取:{uncached} 筆,送往上游:{upstream} 筆', 'dns.queryFailed': '無法查詢:{error}', 'dns.deleted': '已刪除 {n} 筆快取項目', - 'dns.deleteFailed': '無法刪除快取項目:{error}', + 'dns.deleteFailed': '無法刪除快取項目', 'dns.flushed': '快取已清除,符合:{matched},已刪除:{deleted}', 'dns.flushFailed': '無法清除快取:{error}', 'dns.allTypes': '所有支援類型', @@ -106,7 +106,7 @@ export const messages = defineMessages({ 'dns.chart.sample': '已加载:{n} 条,未命中缓存:{uncached} 条,发往上游:{upstream} 条', 'dns.queryFailed': '无法查询:{error}', 'dns.deleted': '已删除 {n} 条缓存项', - 'dns.deleteFailed': '无法删除缓存项:{error}', + 'dns.deleteFailed': '无法删除缓存项', 'dns.flushed': '缓存已清除,匹配:{matched},已删除:{deleted}', 'dns.flushFailed': '无法清除缓存:{error}', 'dns.allTypes': '所有支持类型', @@ -189,7 +189,7 @@ export const messages = defineMessages({ one: 'Deleted {n} cache entry', other: 'Deleted {n} cache entries' }, - 'dns.deleteFailed': 'Could not delete the cache entry: {error}', + 'dns.deleteFailed': 'Could not delete the cache entry', 'dns.flushed': 'Cache cleared, matched: {matched}, deleted: {deleted}', 'dns.flushFailed': 'Could not clear the cache: {error}', 'dns.allTypes': 'All supported types', diff --git a/src/features/dns/useDns.ts b/src/features/dns/useDns.ts index 25345095..36ce3399 100644 --- a/src/features/dns/useDns.ts +++ b/src/features/dns/useDns.ts @@ -83,7 +83,7 @@ export function useDnsCacheTab(domain: string) { (id: string) => void removeEntry(id).then( result => result && toast('positive', t('dns.deleted', {n: result.deleted})), - error => toast('negative', t('dns.deleteFailed', {error: errorText(error, t)})) + error => toast('negative', t('dns.deleteFailed'), {detail: errorText(error, t)}) ), [removeEntry, t] ); diff --git a/src/features/nodes/messages.ts b/src/features/nodes/messages.ts index cd38553a..65c6e5bf 100644 --- a/src/features/nodes/messages.ts +++ b/src/features/nodes/messages.ts @@ -34,7 +34,7 @@ export const messages = defineMessages({ 'nodes.cacheHelp': '保留最近一次取得的內容,啟動時無需連網即可載入。', 'nodes.added': '{name} 已新增', 'nodes.addedRefreshed': '{name} 已新增並重新整理,{n} 個節點', - 'nodes.addedRefreshFailed': '{name} 已寫入組態,但無法重新整理:{error}', + 'nodes.addedRefreshFailed': '{name} 已寫入組態,但無法重新整理', 'nodes.remove': '移除 {name}', 'nodes.removeProviderTitle': '移除來源 {name}', 'nodes.removeProviderHelp': '從主組態刪除此來源及其節點,並重載。', @@ -87,9 +87,9 @@ export const messages = defineMessages({ 'nodes.latency': '延遲', 'nodes.groups': '所屬群組', 'nodes.empty': '此來源沒有節點', - 'nodes.refreshFailed': '無法重新整理 {name}:{error}', + 'nodes.refreshFailed': '無法重新整理 {name}', 'nodes.refreshedDegraded': '{name}:節點已套用,但執行期處於降級狀態', - 'nodes.probeError': '無法測試 {name}:{error}' + 'nodes.probeError': '無法測試 {name}' }, 'zh-CN': { 'nodes.latency.lowest': '最低', @@ -124,7 +124,7 @@ export const messages = defineMessages({ 'nodes.cacheHelp': '保留最近一次获取的内容,启动时无需联网即可加载。', 'nodes.added': '{name} 已添加', 'nodes.addedRefreshed': '{name} 已添加并刷新,{n} 个节点', - 'nodes.addedRefreshFailed': '{name} 已写入配置,但无法刷新:{error}', + 'nodes.addedRefreshFailed': '{name} 已写入配置,但无法刷新', 'nodes.remove': '移除 {name}', 'nodes.removeProviderTitle': '移除来源 {name}', 'nodes.removeProviderHelp': '从主配置删除此来源及其节点,并重载。', @@ -177,9 +177,9 @@ export const messages = defineMessages({ 'nodes.latency': '延迟', 'nodes.groups': '所属组', 'nodes.empty': '此来源暂无节点', - 'nodes.refreshFailed': '无法刷新 {name}:{error}', + 'nodes.refreshFailed': '无法刷新 {name}', 'nodes.refreshedDegraded': '{name}:节点已应用,但运行时处于降级状态', - 'nodes.probeError': '无法测试 {name}:{error}' + 'nodes.probeError': '无法测试 {name}' }, en: { 'nodes.latency.lowest': 'Lowest', @@ -215,7 +215,7 @@ export const messages = defineMessages({ 'nodes.cacheHelp': 'Keeps the last fetched copy so it loads at startup without the network.', 'nodes.added': '{name} added', 'nodes.addedRefreshed': {one: '{name} added and refreshed, {n} node', other: '{name} added and refreshed, {n} nodes'}, - 'nodes.addedRefreshFailed': '{name} was written to the configuration, but could not be refreshed: {error}', + 'nodes.addedRefreshFailed': '{name} was written to the configuration, but could not be refreshed', 'nodes.remove': 'Remove {name}', 'nodes.removeProviderTitle': 'Remove source {name}', 'nodes.removeProviderHelp': 'Deletes this source and its nodes from the main configuration and reloads.', @@ -268,8 +268,8 @@ export const messages = defineMessages({ 'nodes.latency': 'Latency', 'nodes.groups': 'Groups', 'nodes.empty': 'This source has no nodes', - 'nodes.refreshFailed': 'Could not refresh {name}: {error}', + 'nodes.refreshFailed': 'Could not refresh {name}', 'nodes.refreshedDegraded': '{name}: nodes applied, but the runtime is degraded', - 'nodes.probeError': 'Could not test {name}: {error}' + 'nodes.probeError': 'Could not test {name}' } }); diff --git a/src/features/nodes/useNodeTable.ts b/src/features/nodes/useNodeTable.ts index 92cd3deb..b5ba9b4f 100644 --- a/src/features/nodes/useNodeTable.ts +++ b/src/features/nodes/useNodeTable.ts @@ -84,7 +84,7 @@ export function useNodeTable(input: NodeTableInput) { const {kind, text} = probeToast(result, node.id, node.name, t); toast(kind, text); }, - error => toastFailure(error, t, error => t('nodes.probeError', {name: node.name, error})) + error => toastFailure(error, t, t('nodes.probeError', {name: node.name})) ), menu: () => [ ...entries diff --git a/src/features/nodes/useNodesPage.ts b/src/features/nodes/useNodesPage.ts index 33262a7d..a8f3e3fa 100644 --- a/src/features/nodes/useNodesPage.ts +++ b/src/features/nodes/useNodesPage.ts @@ -15,7 +15,7 @@ import {useProviderTable} from './useProviderTable'; import {useNodeTable} from './useNodeTable'; import {useDraftGuard} from '../../shell/draft'; import {isSubscriptionUrl} from '../../dae/setup'; -import {errorText} from '../../api/error'; +import {errorText, noticeText} from '../../api/error'; import {pickTab, tabQuery} from '../../shell/route'; import {offered} from '../../api/capabilities'; @@ -75,7 +75,7 @@ export function useNodesPage({go, query}: PageProps) { void apply(text => addNamesToGroup(text, group, [node.name])).then(result => { if (result.kind === 'ok') toast('positive', t('nodes.joined', {name: node.name, group})); const problem = editProblem(result, t); - if (problem) toast(problem.kind, problem.text); + if (problem) toast(problem.kind, problem.text, {detail: problem.detail}); }); }, [apply, t] @@ -113,8 +113,7 @@ export function useNodesPage({go, query}: PageProps) { if ('degraded' in result) toast('info', t('nodes.refreshedDegraded', {name})); else toast('positive', t('nodes.addedRefreshed', {name, n: formatNumber(result.node_count, locale)})); }, - error => - toastFailure(error, t, error => t('nodes.addedRefreshFailed', {name, error}), {label: t('ui.retry'), onAction: fetchAdded, closeOnAction: true}) + error => toastFailure(error, t, t('nodes.addedRefreshFailed', {name}), {label: t('ui.retry'), onAction: fetchAdded, closeOnAction: true}) ); fetchAdded(); return; @@ -134,7 +133,7 @@ export function useNodesPage({go, query}: PageProps) { ]) ); const problem = editProblem(result, t); - if (problem) refuse(problem.text); + if (problem) refuse(noticeText(problem, t)); if (result.kind !== 'ok') return; toast('positive', t('nodes.joined', {name: node, group})); } else if (dialog.kind === 'removeProvider') { diff --git a/src/features/nodes/useProviderTable.ts b/src/features/nodes/useProviderTable.ts index d3e58bee..392d4fed 100644 --- a/src/features/nodes/useProviderTable.ts +++ b/src/features/nodes/useProviderTable.ts @@ -39,7 +39,7 @@ export function useProviderTable(input: ProviderTableInput) { if ('degraded' in result) toast('info', t('nodes.refreshedDegraded', {name: item.name})); else toast('positive', t('nodes.refreshed', {name: item.name, n: formatNumber(result.node_count, locale)})); }, - error => toastFailure(error, t, error => t('nodes.refreshFailed', {name: item.name, error})) + error => toastFailure(error, t, t('nodes.refreshFailed', {name: item.name})) ), removable: input.canManage && (item.kind === 'subscription' || item.kind === 'file'), remove: () => { @@ -53,7 +53,7 @@ export function useProviderTable(input: ProviderTableInput) { .then(result => { if (result.kind === 'ok') toast('positive', t('nodes.intervalSet', {name: item.name, interval: intervalText(seconds, locale, t)})); const problem = editProblem(result, t); - if (problem) toast(problem.kind, problem.text); + if (problem) toast(problem.kind, problem.text, {detail: problem.detail}); }); } })); diff --git a/src/features/overview/messages.ts b/src/features/overview/messages.ts index b8d709c2..7672a453 100644 --- a/src/features/overview/messages.ts +++ b/src/features/overview/messages.ts @@ -96,7 +96,7 @@ export const messages = defineMessages({ 'ov.unavailable': '此後端不提供該項資料', 'ov.unknown': '未知', 'ov.operationResult': '{action}:{status}({id})', - 'ov.operationError': '無法執行操作:{error}' + 'ov.operationError': '無法執行操作' }, 'zh-CN': { 'ov.v.ebpf': 'eBPF', @@ -193,7 +193,7 @@ export const messages = defineMessages({ 'ov.unavailable': '此后端不提供该项数据', 'ov.unknown': '未知', 'ov.operationResult': '{action}:{status}({id})', - 'ov.operationError': '无法执行操作:{error}' + 'ov.operationError': '无法执行操作' }, en: { 'ov.v.ebpf': 'eBPF', @@ -290,6 +290,6 @@ export const messages = defineMessages({ 'ov.unavailable': 'This backend does not provide this data', 'ov.unknown': 'Unknown', 'ov.operationResult': '{action}: {status} ({id})', - 'ov.operationError': 'Could not run the operation: {error}' + 'ov.operationError': 'Could not run the operation' } }); diff --git a/src/features/policies/usePolicyEdit.ts b/src/features/policies/usePolicyEdit.ts index 8b81c183..9726cc55 100644 --- a/src/features/policies/usePolicyEdit.ts +++ b/src/features/policies/usePolicyEdit.ts @@ -5,7 +5,7 @@ import {editProblem, type MainSourceEdit} from '../../store/mainSource'; import type {ConfigSource} from '../../api/model'; import {toast} from '../../ui/ui'; import {useDraftGuard} from '../../shell/draft'; -import {errorText} from '../../api/error'; +import {errorText, noticeText} from '../../api/error'; import {groupEditSafe} from '../shared/policyText'; export type PolicyEditView = { title: string; @@ -57,8 +57,8 @@ export function usePolicyEdit(name: string, source: MainSourceEdit, entry: Group const problem = editProblem(result, t); // A refusal after the dialog closed has nowhere inline to go. if (problem) { - if (open) refuse(problem.text); - else toast(problem.kind, problem.text); + if (open) refuse(noticeText(problem, t)); + else toast(problem.kind, problem.text, {detail: problem.detail}); } }); }; diff --git a/src/features/rules/messages.ts b/src/features/rules/messages.ts index 76599ab3..b84873a4 100644 --- a/src/features/rules/messages.ts +++ b/src/features/rules/messages.ts @@ -100,7 +100,7 @@ export const messages = defineMessages({ 'rule.dictionaryEmpty': '沒有路由規則', 'rule.dnsHeading': 'DNS:{name}', 'rule.droppedUnknown': '遺失記錄數未知', - 'rule.traceFailed': '無法執行追蹤:{error}' + 'rule.traceFailed': '無法執行追蹤' }, 'zh-CN': { 'rule.dictionaryCaption': '{n} 条规则,代次 {generation}', @@ -201,7 +201,7 @@ export const messages = defineMessages({ 'rule.dictionaryEmpty': '暂无路由规则', 'rule.dnsHeading': 'DNS:{name}', 'rule.droppedUnknown': '丢失记录数未知', - 'rule.traceFailed': '无法执行追踪:{error}' + 'rule.traceFailed': '无法执行追踪' }, en: { 'rule.dictionaryCaption': {one: '{n} rule, generation {generation}', other: '{n} rules, generation {generation}'}, @@ -307,6 +307,6 @@ export const messages = defineMessages({ 'rule.dictionaryEmpty': 'No routing rules', 'rule.dnsHeading': 'DNS: {name}', 'rule.droppedUnknown': 'Dropped record count unknown', - 'rule.traceFailed': 'Could not run the trace: {error}' + 'rule.traceFailed': 'Could not run the trace' } }); diff --git a/src/features/rules/useRoutingTrace.ts b/src/features/rules/useRoutingTrace.ts index d9ef67dc..792d8830 100644 --- a/src/features/rules/useRoutingTrace.ts +++ b/src/features/rules/useRoutingTrace.ts @@ -52,7 +52,7 @@ export function useRoutingTrace({form, setForm, advanced, setAdvanced}: ReturnTy const [accepted, setResult] = useState<{response: RoutingTraceResponse; input: RoutingTraceRequest['input']} | null>(null); const {busy, error, run} = useAction<'trace'>(); const problem = error ?? capabilities.error; - const report = useEffectEvent((error: Error) => toast('negative', t('rule.traceFailed', {error: errorText(error, t)}))); + const report = useEffectEvent((error: Error) => toast('negative', t('rule.traceFailed'), {detail: errorText(error, t)})); useEffect(() => { if (problem) report(problem); }, [problem]); @@ -143,7 +143,7 @@ export function useRoutingTrace({form, setForm, advanced, setAdvanced}: ReturnTy const {kind, text} = probeToast(result, id, node.name, t); toast(kind, text); } catch (error) { - toastFailure(error, t, error => t('nodes.probeError', {name: node.name, error})); + toastFailure(error, t, t('nodes.probeError', {name: node.name})); } }; return { diff --git a/src/features/rules/useRuleList.ts b/src/features/rules/useRuleList.ts index 704184c1..65c6c9ff 100644 --- a/src/features/rules/useRuleList.ts +++ b/src/features/rules/useRuleList.ts @@ -72,7 +72,7 @@ export function useRuleList({go, query}: PageProps) { rules.refetch(); }; const editor = useConfigEditor(retry); - const report = useEffectEvent((error: Error) => toastFailure(error, t, error => t('ui.writeFailed', {error}))); + const report = useEffectEvent((error: Error) => toastFailure(error, t, t('ui.writeFailed'))); useEffect(() => { if (editor.error) report(editor.error); }, [editor.error]); diff --git a/src/features/settings/messages.ts b/src/features/settings/messages.ts index 35aed41a..15464787 100644 --- a/src/features/settings/messages.ts +++ b/src/features/settings/messages.ts @@ -22,7 +22,7 @@ export const messages = defineMessages({ 'settings.hideToken': '隱藏 Token', 'settings.test': '測試連線', 'settings.signOut': '登出', - 'settings.signOutFailed': '無法登出:{error}', + 'settings.signOutFailed': '無法登出', 'settings.testing': '正在測試連線…', 'settings.save': '儲存', 'settings.saveHelp': '儲存後會重新載入頁面,套用設定檔。', @@ -85,7 +85,7 @@ export const messages = defineMessages({ 'settings.refreshAll': '重新整理全部訂閱({n})', 'settings.refreshedAll': '已重新整理 {n} 筆訂閱,共 {total} 筆', 'settings.refreshedDegraded': '節點已套用,但執行期處於降級狀態', - 'settings.refreshedAllFailed': '已重新整理 {n} 筆訂閱,共 {total} 筆;{failed} 筆失敗:{error}', + 'settings.refreshedAllFailed': '已重新整理 {n} 筆訂閱,共 {total} 筆;{failed} 筆失敗', 'settings.geodata': '地理資料', 'settings.geodataNote': '規則中 geosite 與 geoip 使用的資料檔案。更新操作會從來源下載檔案,驗證後取代現有檔案並重載。', 'settings.geodataUpdate': '更新', @@ -129,7 +129,7 @@ export const messages = defineMessages({ 'settings.geodataSaved': '地理資料來源已儲存,將在下次自動更新時下載', 'settings.geodataAutoSaved': '自動更新設定已儲存', 'settings.geodataRouteSaved': '下載路由已儲存', - 'settings.geodataSaveFailed': '無法儲存地理資料設定:{error}', + 'settings.geodataSaveFailed': '無法儲存地理資料設定', 'settings.geodataStatus': '狀態', 'settings.geodataUpdateNow': '立即更新', 'settings.geodataLastUpdated': '上次更新', @@ -143,10 +143,10 @@ export const messages = defineMessages({ 'settings.installHintMac': '若要安裝,請在選單列選擇「檔案」>「加入 Dock 中」。', 'settings.installed': '已安裝', 'settings.apiMajor': '後端 API 主版本為 {major},本面板依 API 主版本 1 的契約實作;欄位可能不相容。', - 'settings.installFailed': '無法安裝:{error}', - 'settings.runtimeFailed': '無法套用後端選項:{error}', - 'settings.refreshAllFailed': '無法重新整理訂閱:{error}', - 'settings.geodataFailed': '無法更新地理資料:{error}' + 'settings.installFailed': '無法安裝', + 'settings.runtimeFailed': '無法套用後端選項', + 'settings.refreshAllFailed': '無法重新整理訂閱', + 'settings.geodataFailed': '無法更新地理資料' }, 'zh-CN': { 'nav.settings': '设置', @@ -169,7 +169,7 @@ export const messages = defineMessages({ 'settings.hideToken': '隐藏 Token', 'settings.test': '测试连接', 'settings.signOut': '退出登录', - 'settings.signOutFailed': '无法退出登录:{error}', + 'settings.signOutFailed': '无法退出登录', 'settings.testing': '正在测试连接…', 'settings.save': '保存', 'settings.saveHelp': '保存后会重新加载页面,应用连接方案。', @@ -232,7 +232,7 @@ export const messages = defineMessages({ 'settings.refreshAll': '刷新全部订阅({n})', 'settings.refreshedAll': '已刷新 {n} 条订阅,共 {total} 条', 'settings.refreshedDegraded': '节点已应用,但运行时处于降级状态', - 'settings.refreshedAllFailed': '已刷新 {n} 条订阅,共 {total} 条;{failed} 条失败:{error}', + 'settings.refreshedAllFailed': '已刷新 {n} 条订阅,共 {total} 条;{failed} 条失败', 'settings.geodata': '地理数据', 'settings.geodataNote': '规则中 geosite 与 geoip 使用的数据文件。更新操作会从来源下载文件,校验后替换现有文件并重载。', 'settings.geodataUpdate': '更新', @@ -276,7 +276,7 @@ export const messages = defineMessages({ 'settings.geodataSaved': '地理数据来源已保存,将在下次自动更新时下载', 'settings.geodataAutoSaved': '自动更新设置已保存', 'settings.geodataRouteSaved': '下载路由已保存', - 'settings.geodataSaveFailed': '无法保存地理数据设置:{error}', + 'settings.geodataSaveFailed': '无法保存地理数据设置', 'settings.geodataStatus': '状态', 'settings.geodataUpdateNow': '立即更新', 'settings.geodataLastUpdated': '上次更新', @@ -290,10 +290,10 @@ export const messages = defineMessages({ 'settings.installHintMac': '如需安装,请从菜单栏中选取“文件”>“添加到程序坞”。', 'settings.installed': '已安装', 'settings.apiMajor': '后端 API 主版本为 {major},本面板按 API 主版本 1 的契约实现;字段可能不兼容。', - 'settings.installFailed': '无法安装:{error}', - 'settings.runtimeFailed': '无法应用后端选项:{error}', - 'settings.refreshAllFailed': '无法刷新订阅:{error}', - 'settings.geodataFailed': '无法更新地理数据:{error}' + 'settings.installFailed': '无法安装', + 'settings.runtimeFailed': '无法应用后端选项', + 'settings.refreshAllFailed': '无法刷新订阅', + 'settings.geodataFailed': '无法更新地理数据' }, en: { 'nav.settings': 'Settings', @@ -316,7 +316,7 @@ export const messages = defineMessages({ 'settings.hideToken': 'Hide token', 'settings.test': 'Test connection', 'settings.signOut': 'Sign out', - 'settings.signOutFailed': 'Could not sign out: {error}', + 'settings.signOutFailed': 'Could not sign out', 'settings.testing': 'Testing connection…', 'settings.save': 'Save', 'settings.saveHelp': 'Saving reloads the page to apply the profile.', @@ -382,7 +382,7 @@ export const messages = defineMessages({ 'settings.refreshAll': {one: 'Refresh subscription ({n})', other: 'Refresh all subscriptions ({n})'}, 'settings.refreshedAll': 'Subscriptions refreshed: {n} of {total}', 'settings.refreshedDegraded': 'Nodes applied, but the runtime is degraded', - 'settings.refreshedAllFailed': 'Subscriptions refreshed: {n} of {total}; {failed} failed: {error}', + 'settings.refreshedAllFailed': 'Subscriptions refreshed: {n} of {total}; {failed} failed', 'settings.geodata': 'Geodata', 'settings.geodataNote': 'The data files used by geosite and geoip rules. Updating downloads and verifies the files from their sources, replaces the existing files and reloads the configuration.', @@ -427,7 +427,7 @@ export const messages = defineMessages({ 'settings.geodataSaved': 'Geodata sources saved; they download at the next automatic update', 'settings.geodataAutoSaved': 'Automatic update settings saved', 'settings.geodataRouteSaved': 'Download route saved', - 'settings.geodataSaveFailed': 'Could not save the geodata settings: {error}', + 'settings.geodataSaveFailed': 'Could not save the geodata settings', 'settings.geodataStatus': 'Status', 'settings.geodataUpdateNow': 'Update now', 'settings.geodataLastUpdated': 'Last updated', @@ -441,9 +441,9 @@ export const messages = defineMessages({ 'settings.installHintMac': 'To install, choose File > Add to Dock from the menu bar.', 'settings.installed': 'Installed', 'settings.apiMajor': 'The backend uses API major version {major}. This panel implements the contract for major version 1, so fields may be incompatible.', - 'settings.installFailed': 'Could not install: {error}', - 'settings.runtimeFailed': 'Could not apply backend options: {error}', - 'settings.refreshAllFailed': 'Could not refresh subscriptions: {error}', - 'settings.geodataFailed': 'Could not update geodata: {error}' + 'settings.installFailed': 'Could not install', + 'settings.runtimeFailed': 'Could not apply backend options', + 'settings.refreshAllFailed': 'Could not refresh subscriptions', + 'settings.geodataFailed': 'Could not update geodata' } }); diff --git a/src/features/settings/useBackendActions.ts b/src/features/settings/useBackendActions.ts index 72f46e3f..2f8e7812 100644 --- a/src/features/settings/useBackendActions.ts +++ b/src/features/settings/useBackendActions.ts @@ -50,15 +50,12 @@ export function useBackendActions() { // Undefined: the batch was cancelled (the page was left), so there is nothing to report. if (done === undefined) return; const counts = {n: done, total: subscriptions.length}; - toast( - done === subscriptions.length ? 'positive' : done ? 'info' : 'negative', - failures.length - ? t('settings.refreshedAllFailed', {...counts, failed: failures.length, error: errorText(failures[0], t)}) - : t('settings.refreshedAll', counts) - ); + const kind = done === subscriptions.length ? 'positive' : done ? 'info' : 'negative'; + if (failures.length) toast(kind, t('settings.refreshedAllFailed', {...counts, failed: failures.length}), {detail: errorText(failures[0], t)}); + else toast(kind, t('settings.refreshedAll', counts)); if (degraded) toast('info', t('settings.refreshedDegraded')); }, - error => toast('negative', t('settings.refreshAllFailed', {error: errorText(error, t)})) + error => toast('negative', t('settings.refreshAllFailed'), {detail: errorText(error, t)}) ); }; const closeAll = () => @@ -66,7 +63,7 @@ export function useBackendActions() { tally => { if (tally) toast(closedAllTone(tally), t('conn.closedAll', {closed: tally.closed, skipped: tally.skipped})); }, - error => t('conn.closeFailed', {error: errorText(error, t)}) + error => t('ui.valuePair', {label: t('conn.closeFailed'), value: errorText(error, t)}) ); return { runtimeError: runtime.error, @@ -120,7 +117,7 @@ export function useBackendActions() { result => { if (result) toast('positive', t('settings.geodataUpdated')); }, - error => toast('negative', t('settings.geodataFailed', {error: errorText(error, t)})) + error => toast('negative', t('settings.geodataFailed'), {detail: errorText(error, t)}) ) }; } diff --git a/src/features/settings/useGeodataSettings.ts b/src/features/settings/useGeodataSettings.ts index de01201c..5f1770b4 100644 --- a/src/features/settings/useGeodataSettings.ts +++ b/src/features/settings/useGeodataSettings.ts @@ -54,7 +54,7 @@ export function useGeodataSettings() { result => { if (result) toast('positive', t('settings.geodataUpdated')); }, - (error: unknown) => toast('negative', t('settings.geodataFailed', {error: errorText(error, t)})) + (error: unknown) => toast('negative', t('settings.geodataFailed'), {detail: errorText(error, t)}) ); // Resolves true once stored; a URL change then starts the update and leaves its outcome to the status row. // One save at a time: a second press while one is in flight, or while an update runs, does nothing. @@ -76,7 +76,7 @@ export function useGeodataSettings() { (error: unknown) => { inflight.current = false; setPending(null); - toast('negative', t('settings.geodataSaveFailed', {error: errorText(error, t)})); + toast('negative', t('settings.geodataSaveFailed'), {detail: errorText(error, t)}); return false; } ); diff --git a/src/features/settings/useRuntimeSettingsForm.ts b/src/features/settings/useRuntimeSettingsForm.ts index bd6afe2c..bb461afb 100644 --- a/src/features/settings/useRuntimeSettingsForm.ts +++ b/src/features/settings/useRuntimeSettingsForm.ts @@ -80,7 +80,7 @@ export function useRuntimeSettingsForm() { setDraft(current => (current === submitted ? null : current)); toast('positive', t('settings.runtimeSaved')); }, - (error: unknown) => toast('negative', t('settings.runtimeFailed', {error: errorText(error, t)})) + (error: unknown) => toast('negative', t('settings.runtimeFailed'), {detail: errorText(error, t)}) ); }; return { diff --git a/src/features/settings/useSignOut.ts b/src/features/settings/useSignOut.ts index d1b4d922..ef92bead 100644 --- a/src/features/settings/useSignOut.ts +++ b/src/features/settings/useSignOut.ts @@ -25,7 +25,7 @@ export function useSignOut() { } catch (error) { // The session stays usable on the backend, so it is kept here too rather than silently orphaned. setBusy(false); - toast('negative', t('settings.signOutFailed', {error: errorText(error, t)})); + toast('negative', t('settings.signOutFailed'), {detail: errorText(error, t)}); return; } clearSession(); diff --git a/src/features/shared/pending.ts b/src/features/shared/pending.ts index 72ed041c..93fae362 100644 --- a/src/features/shared/pending.ts +++ b/src/features/shared/pending.ts @@ -1,5 +1,5 @@ import type {ConfigDiagnostic, ConfigSource} from '../../api/model'; -import {ApiError, failureNotice} from '../../api/error'; +import {ApiError, failureNotice, noticeText} from '../../api/error'; import {backendMessage} from '../../i18n/backend'; import type {Translator} from '../../i18n'; import type {PendingFailure, PendingRule} from '../../store'; @@ -36,7 +36,7 @@ export function ruleFailure(error: unknown, diagnostics: ConfigDiagnostic[] | nu const found = diagnostics ?? (error instanceof ApiError && error.status === 422 ? ((error.details as {diagnostics?: ConfigDiagnostic[]} | null)?.diagnostics ?? null) : null); - if (!found) return {text: failureNotice(error, t, error => t('ui.writeFailed', {error})).text, lines: []}; + if (!found) return {text: noticeText(failureNotice(error, t, t('ui.writeFailed')), t), lines: []}; const errors = found.filter(item => item.level === 'error').length; const restart = restartRequired(found); return { diff --git a/src/features/shared/useLifecycle.ts b/src/features/shared/useLifecycle.ts index b2408175..c7a51b9a 100644 --- a/src/features/shared/useLifecycle.ts +++ b/src/features/shared/useLifecycle.ts @@ -15,7 +15,7 @@ export function useLifecycle(runtime: Runtime | undefined, capabilities: Capabil result => { if (result) toast('positive', t('ov.operationResult', {action: t(operationLabels[kind]), status: t('ov.succeeded'), id: result.operation_id})); }, - error => toastFailure(error, t, error => t('ov.operationError', {error})) + error => toastFailure(error, t, t('ov.operationError')) ); return {canRun: operations.canRun, busy: operations.busy, run, actions: lifecycleActions(operations.canRun, operations.busy, run, t)}; } diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index d8b6cad3..2c7ab6e8 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -200,7 +200,7 @@ export const messages = { 'config.level.error': 'Error', 'config.level.warning': 'Warning', 'config.level.info': 'Info', - 'config.previewFailed': 'Could not generate the configuration: {error}', + 'config.previewFailed': 'Could not generate the configuration', 'conn.tab.traffic': 'Traffic', 'conn.tab.list': 'Connections', 'conn.chart.busiest': 'Heaviest connection', @@ -244,7 +244,7 @@ export const messages = { 'conn.export': 'Export CSV', 'conn.closed': 'Closed {name}', 'conn.notClosable': 'This connection is not owned by the userspace datapath and cannot be closed', - 'conn.closeFailed': 'Could not close the connection: {error}', + 'conn.closeFailed': 'Could not close the connection', 'conn.notInSnapshot': 'This connection is not in the current list.', 'conn.ungrouped': 'None', 'conn.groupCount': '{name} ({n})', @@ -312,7 +312,7 @@ export const messages = { 'dns.chart.sample': 'Loaded: {n}, uncached: {uncached}, sent upstream: {upstream}', 'dns.queryFailed': 'Could not run the query: {error}', 'dns.deleted': {one: 'Deleted {n} cache entry', other: 'Deleted {n} cache entries'}, - 'dns.deleteFailed': 'Could not delete the cache entry: {error}', + 'dns.deleteFailed': 'Could not delete the cache entry', 'dns.flushed': 'Cache cleared, matched: {matched}, deleted: {deleted}', 'dns.flushFailed': 'Could not clear the cache: {error}', 'dns.allTypes': 'All supported types', @@ -459,7 +459,7 @@ export const messages = { 'nodes.cacheHelp': 'Keeps the last fetched copy so it loads at startup without the network.', 'nodes.added': '{name} added', 'nodes.addedRefreshed': {one: '{name} added and refreshed, {n} node', other: '{name} added and refreshed, {n} nodes'}, - 'nodes.addedRefreshFailed': '{name} was written to the configuration, but could not be refreshed: {error}', + 'nodes.addedRefreshFailed': '{name} was written to the configuration, but could not be refreshed', 'nodes.remove': 'Remove {name}', 'nodes.removeProviderTitle': 'Remove source {name}', 'nodes.removeProviderHelp': 'Deletes this source and its nodes from the main configuration and reloads.', @@ -512,9 +512,9 @@ export const messages = { 'nodes.latency': 'Latency', 'nodes.groups': 'Groups', 'nodes.empty': 'This source has no nodes', - 'nodes.refreshFailed': 'Could not refresh {name}: {error}', + 'nodes.refreshFailed': 'Could not refresh {name}', 'nodes.refreshedDegraded': '{name}: nodes applied, but the runtime is degraded', - 'nodes.probeError': 'Could not test {name}: {error}', + 'nodes.probeError': 'Could not test {name}', 'ov.v.ebpf': 'eBPF', 'ov.v.userspace': 'Userspace', 'ov.v.mock': 'Mock', @@ -609,7 +609,7 @@ export const messages = { 'ov.unavailable': 'This backend does not provide this data', 'ov.unknown': 'Unknown', 'ov.operationResult': '{action}: {status} ({id})', - 'ov.operationError': 'Could not run the operation: {error}', + 'ov.operationError': 'Could not run the operation', 'arrange.drag': 'Drag {name}', 'arrange.dropInto': 'Drop into group {group}', 'arrange.ruleSelectsMore': {one: 'Currently selects: {names} and {n} more', other: 'Currently selects: {names} and {n} more'}, @@ -967,7 +967,7 @@ export const messages = { 'rule.dictionaryEmpty': 'No routing rules', 'rule.dnsHeading': 'DNS: {name}', 'rule.droppedUnknown': 'Dropped record count unknown', - 'rule.traceFailed': 'Could not run the trace: {error}', + 'rule.traceFailed': 'Could not run the trace', 'nav.settings': 'Settings', 'settings.backend': 'Backend', 'settings.profile': 'Profile', @@ -988,7 +988,7 @@ export const messages = { 'settings.hideToken': 'Hide token', 'settings.test': 'Test connection', 'settings.signOut': 'Sign out', - 'settings.signOutFailed': 'Could not sign out: {error}', + 'settings.signOutFailed': 'Could not sign out', 'settings.testing': 'Testing connection…', 'settings.save': 'Save', 'settings.saveHelp': 'Saving reloads the page to apply the profile.', @@ -1053,7 +1053,7 @@ export const messages = { 'settings.refreshAll': {one: 'Refresh subscription ({n})', other: 'Refresh all subscriptions ({n})'}, 'settings.refreshedAll': 'Subscriptions refreshed: {n} of {total}', 'settings.refreshedDegraded': 'Nodes applied, but the runtime is degraded', - 'settings.refreshedAllFailed': 'Subscriptions refreshed: {n} of {total}; {failed} failed: {error}', + 'settings.refreshedAllFailed': 'Subscriptions refreshed: {n} of {total}; {failed} failed', 'settings.geodata': 'Geodata', 'settings.geodataNote': 'The data files used by geosite and geoip rules. Updating downloads and verifies the files from their sources, replaces the existing files and reloads the configuration.', @@ -1098,7 +1098,7 @@ export const messages = { 'settings.geodataSaved': 'Geodata sources saved; they download at the next automatic update', 'settings.geodataAutoSaved': 'Automatic update settings saved', 'settings.geodataRouteSaved': 'Download route saved', - 'settings.geodataSaveFailed': 'Could not save the geodata settings: {error}', + 'settings.geodataSaveFailed': 'Could not save the geodata settings', 'settings.geodataStatus': 'Status', 'settings.geodataUpdateNow': 'Update now', 'settings.geodataLastUpdated': 'Last updated', @@ -1112,10 +1112,10 @@ export const messages = { 'settings.installHintMac': 'To install, choose File > Add to Dock from the menu bar.', 'settings.installed': 'Installed', 'settings.apiMajor': 'The backend uses API major version {major}. This panel implements the contract for major version 1, so fields may be incompatible.', - 'settings.installFailed': 'Could not install: {error}', - 'settings.runtimeFailed': 'Could not apply backend options: {error}', - 'settings.refreshAllFailed': 'Could not refresh subscriptions: {error}', - 'settings.geodataFailed': 'Could not update geodata: {error}', + 'settings.installFailed': 'Could not install', + 'settings.runtimeFailed': 'Could not apply backend options', + 'settings.refreshAllFailed': 'Could not refresh subscriptions', + 'settings.geodataFailed': 'Could not update geodata', 'shell.langUnavailable': 'Could not switch to {name}: the interface text did not load.', 'shell.searchUnavailable': 'Could not open search: it did not load.', 'shell.shortcuts': 'Keyboard shortcuts', @@ -1353,7 +1353,7 @@ export const messages = { 'ui.refreshed': 'Data refreshed.', 'ui.newBuild': 'A new version is ready; reload the page to use it.', 'ui.reloadPage': 'Reload', - 'ui.refreshFailed': 'Could not refresh data: {error}', + 'ui.refreshFailed': 'Could not refresh data', 'ui.saved': 'Settings saved.', 'ui.state': 'State', 'ui.actions': 'Actions', @@ -1412,5 +1412,5 @@ export const messages = { 'toast.showAllCount': 'Show all ({n})', 'ui.device': 'Device', 'ui.writeInvalid': {one: 'Validation found {n} error; nothing written', other: 'Validation found {n} errors; nothing written'}, - 'ui.writeFailed': 'Could not write the configuration: {error}' + 'ui.writeFailed': 'Could not write the configuration' } satisfies Record; diff --git a/src/i18n/locales/zh-CN.ts b/src/i18n/locales/zh-CN.ts index b0147e6f..2be24543 100644 --- a/src/i18n/locales/zh-CN.ts +++ b/src/i18n/locales/zh-CN.ts @@ -189,7 +189,7 @@ export const messages = { 'config.level.error': '错误', 'config.level.warning': '警告', 'config.level.info': '提示', - 'config.previewFailed': '无法生成配置:{error}', + 'config.previewFailed': '无法生成配置', 'conn.tab.traffic': '流量', 'conn.tab.list': '连接', 'conn.chart.busiest': '最高流量连接', @@ -228,7 +228,7 @@ export const messages = { 'conn.export': '导出 CSV', 'conn.closed': '已关闭 {name}', 'conn.notClosable': '此连接不由用户空间持有,无法关闭', - 'conn.closeFailed': '无法关闭连接:{error}', + 'conn.closeFailed': '无法关闭连接', 'conn.notInSnapshot': '当前列表未包含此连接。', 'conn.ungrouped': '不分组', 'conn.groupCount': '{name}({n})', @@ -295,7 +295,7 @@ export const messages = { 'dns.chart.sample': '已加载:{n} 条,未命中缓存:{uncached} 条,发往上游:{upstream} 条', 'dns.queryFailed': '无法查询:{error}', 'dns.deleted': '已删除 {n} 条缓存项', - 'dns.deleteFailed': '无法删除缓存项:{error}', + 'dns.deleteFailed': '无法删除缓存项', 'dns.flushed': '缓存已清除,匹配:{matched},已删除:{deleted}', 'dns.flushFailed': '无法清除缓存:{error}', 'dns.allTypes': '所有支持类型', @@ -441,7 +441,7 @@ export const messages = { 'nodes.cacheHelp': '保留最近一次获取的内容,启动时无需联网即可加载。', 'nodes.added': '{name} 已添加', 'nodes.addedRefreshed': '{name} 已添加并刷新,{n} 个节点', - 'nodes.addedRefreshFailed': '{name} 已写入配置,但无法刷新:{error}', + 'nodes.addedRefreshFailed': '{name} 已写入配置,但无法刷新', 'nodes.remove': '移除 {name}', 'nodes.removeProviderTitle': '移除来源 {name}', 'nodes.removeProviderHelp': '从主配置删除此来源及其节点,并重载。', @@ -494,9 +494,9 @@ export const messages = { 'nodes.latency': '延迟', 'nodes.groups': '所属组', 'nodes.empty': '此来源暂无节点', - 'nodes.refreshFailed': '无法刷新 {name}:{error}', + 'nodes.refreshFailed': '无法刷新 {name}', 'nodes.refreshedDegraded': '{name}:节点已应用,但运行时处于降级状态', - 'nodes.probeError': '无法测试 {name}:{error}', + 'nodes.probeError': '无法测试 {name}', 'ov.v.ebpf': 'eBPF', 'ov.v.userspace': '用户空间', 'ov.v.mock': '模拟', @@ -591,7 +591,7 @@ export const messages = { 'ov.unavailable': '此后端不提供该项数据', 'ov.unknown': '未知', 'ov.operationResult': '{action}:{status}({id})', - 'ov.operationError': '无法执行操作:{error}', + 'ov.operationError': '无法执行操作', 'arrange.drag': '拖动 {name}', 'arrange.dropInto': '拖放到组 {group}', 'arrange.ruleSelectsMore': '当前选入:{names},另有 {n} 个', @@ -942,7 +942,7 @@ export const messages = { 'rule.dictionaryEmpty': '暂无路由规则', 'rule.dnsHeading': 'DNS:{name}', 'rule.droppedUnknown': '丢失记录数未知', - 'rule.traceFailed': '无法执行追踪:{error}', + 'rule.traceFailed': '无法执行追踪', 'nav.settings': '设置', 'settings.backend': '后端', 'settings.profile': '连接方案', @@ -963,7 +963,7 @@ export const messages = { 'settings.hideToken': '隐藏 Token', 'settings.test': '测试连接', 'settings.signOut': '退出登录', - 'settings.signOutFailed': '无法退出登录:{error}', + 'settings.signOutFailed': '无法退出登录', 'settings.testing': '正在测试连接…', 'settings.save': '保存', 'settings.saveHelp': '保存后会重新加载页面,应用连接方案。', @@ -1026,7 +1026,7 @@ export const messages = { 'settings.refreshAll': '刷新全部订阅({n})', 'settings.refreshedAll': '已刷新 {n} 条订阅,共 {total} 条', 'settings.refreshedDegraded': '节点已应用,但运行时处于降级状态', - 'settings.refreshedAllFailed': '已刷新 {n} 条订阅,共 {total} 条;{failed} 条失败:{error}', + 'settings.refreshedAllFailed': '已刷新 {n} 条订阅,共 {total} 条;{failed} 条失败', 'settings.geodata': '地理数据', 'settings.geodataNote': '规则中 geosite 与 geoip 使用的数据文件。更新操作会从来源下载文件,校验后替换现有文件并重载。', 'settings.geodataUpdate': '更新', @@ -1070,7 +1070,7 @@ export const messages = { 'settings.geodataSaved': '地理数据来源已保存,将在下次自动更新时下载', 'settings.geodataAutoSaved': '自动更新设置已保存', 'settings.geodataRouteSaved': '下载路由已保存', - 'settings.geodataSaveFailed': '无法保存地理数据设置:{error}', + 'settings.geodataSaveFailed': '无法保存地理数据设置', 'settings.geodataStatus': '状态', 'settings.geodataUpdateNow': '立即更新', 'settings.geodataLastUpdated': '上次更新', @@ -1084,10 +1084,10 @@ export const messages = { 'settings.installHintMac': '如需安装,请从菜单栏中选取“文件”>“添加到程序坞”。', 'settings.installed': '已安装', 'settings.apiMajor': '后端 API 主版本为 {major},本面板按 API 主版本 1 的契约实现;字段可能不兼容。', - 'settings.installFailed': '无法安装:{error}', - 'settings.runtimeFailed': '无法应用后端选项:{error}', - 'settings.refreshAllFailed': '无法刷新订阅:{error}', - 'settings.geodataFailed': '无法更新地理数据:{error}', + 'settings.installFailed': '无法安装', + 'settings.runtimeFailed': '无法应用后端选项', + 'settings.refreshAllFailed': '无法刷新订阅', + 'settings.geodataFailed': '无法更新地理数据', 'shell.langUnavailable': '无法切换至{name}:界面文字加载失败。', 'shell.searchUnavailable': '无法打开搜索:搜索功能加载失败。', 'shell.shortcuts': '键盘快捷键', @@ -1324,7 +1324,7 @@ export const messages = { 'ui.refreshed': '数据已刷新。', 'ui.newBuild': '新版本已就绪,重新加载页面后生效。', 'ui.reloadPage': '重新加载', - 'ui.refreshFailed': '无法刷新数据:{error}', + 'ui.refreshFailed': '无法刷新数据', 'ui.saved': '设置已保存。', 'ui.state': '状态', 'ui.actions': '操作', @@ -1382,5 +1382,5 @@ export const messages = { 'toast.showAllCount': '显示全部({n})', 'ui.device': '设备', 'ui.writeInvalid': '校验发现 {n} 个错误,未写入', - 'ui.writeFailed': '无法写入配置:{error}' + 'ui.writeFailed': '无法写入配置' } satisfies Record; diff --git a/src/i18n/locales/zh-TW.ts b/src/i18n/locales/zh-TW.ts index eaf939ee..2b2ef6df 100644 --- a/src/i18n/locales/zh-TW.ts +++ b/src/i18n/locales/zh-TW.ts @@ -188,7 +188,7 @@ export const messages = { 'config.level.error': '錯誤', 'config.level.warning': '警告', 'config.level.info': '提示', - 'config.previewFailed': '無法產生組態:{error}', + 'config.previewFailed': '無法產生組態', 'conn.tab.traffic': '流量', 'conn.tab.list': '連線', 'conn.chart.busiest': '最高流量連線', @@ -227,7 +227,7 @@ export const messages = { 'conn.export': '匯出 CSV', 'conn.closed': '已關閉 {name}', 'conn.notClosable': '此連線不由使用者空間持有,無法關閉', - 'conn.closeFailed': '無法關閉連線:{error}', + 'conn.closeFailed': '無法關閉連線', 'conn.notInSnapshot': '目前清單未包含此連線。', 'conn.ungrouped': '不分組', 'conn.groupCount': '{name}({n})', @@ -294,7 +294,7 @@ export const messages = { 'dns.chart.sample': '已載入:{n} 筆,未命中快取:{uncached} 筆,送往上游:{upstream} 筆', 'dns.queryFailed': '無法查詢:{error}', 'dns.deleted': '已刪除 {n} 筆快取項目', - 'dns.deleteFailed': '無法刪除快取項目:{error}', + 'dns.deleteFailed': '無法刪除快取項目', 'dns.flushed': '快取已清除,符合:{matched},已刪除:{deleted}', 'dns.flushFailed': '無法清除快取:{error}', 'dns.allTypes': '所有支援類型', @@ -440,7 +440,7 @@ export const messages = { 'nodes.cacheHelp': '保留最近一次取得的內容,啟動時無需連網即可載入。', 'nodes.added': '{name} 已新增', 'nodes.addedRefreshed': '{name} 已新增並重新整理,{n} 個節點', - 'nodes.addedRefreshFailed': '{name} 已寫入組態,但無法重新整理:{error}', + 'nodes.addedRefreshFailed': '{name} 已寫入組態,但無法重新整理', 'nodes.remove': '移除 {name}', 'nodes.removeProviderTitle': '移除來源 {name}', 'nodes.removeProviderHelp': '從主組態刪除此來源及其節點,並重載。', @@ -493,9 +493,9 @@ export const messages = { 'nodes.latency': '延遲', 'nodes.groups': '所屬群組', 'nodes.empty': '此來源沒有節點', - 'nodes.refreshFailed': '無法重新整理 {name}:{error}', + 'nodes.refreshFailed': '無法重新整理 {name}', 'nodes.refreshedDegraded': '{name}:節點已套用,但執行期處於降級狀態', - 'nodes.probeError': '無法測試 {name}:{error}', + 'nodes.probeError': '無法測試 {name}', 'ov.v.ebpf': 'eBPF', 'ov.v.userspace': '使用者空間', 'ov.v.mock': '模擬', @@ -590,7 +590,7 @@ export const messages = { 'ov.unavailable': '此後端不提供該項資料', 'ov.unknown': '未知', 'ov.operationResult': '{action}:{status}({id})', - 'ov.operationError': '無法執行操作:{error}', + 'ov.operationError': '無法執行操作', 'arrange.drag': '拖曳 {name}', 'arrange.dropInto': '拖放到群組 {group}', 'arrange.ruleSelectsMore': '目前選入:{names},另有 {n} 個', @@ -941,7 +941,7 @@ export const messages = { 'rule.dictionaryEmpty': '沒有路由規則', 'rule.dnsHeading': 'DNS:{name}', 'rule.droppedUnknown': '遺失記錄數未知', - 'rule.traceFailed': '無法執行追蹤:{error}', + 'rule.traceFailed': '無法執行追蹤', 'nav.settings': '設定', 'settings.backend': '後端', 'settings.profile': '設定檔', @@ -962,7 +962,7 @@ export const messages = { 'settings.hideToken': '隱藏 Token', 'settings.test': '測試連線', 'settings.signOut': '登出', - 'settings.signOutFailed': '無法登出:{error}', + 'settings.signOutFailed': '無法登出', 'settings.testing': '正在測試連線…', 'settings.save': '儲存', 'settings.saveHelp': '儲存後會重新載入頁面,套用設定檔。', @@ -1025,7 +1025,7 @@ export const messages = { 'settings.refreshAll': '重新整理全部訂閱({n})', 'settings.refreshedAll': '已重新整理 {n} 筆訂閱,共 {total} 筆', 'settings.refreshedDegraded': '節點已套用,但執行期處於降級狀態', - 'settings.refreshedAllFailed': '已重新整理 {n} 筆訂閱,共 {total} 筆;{failed} 筆失敗:{error}', + 'settings.refreshedAllFailed': '已重新整理 {n} 筆訂閱,共 {total} 筆;{failed} 筆失敗', 'settings.geodata': '地理資料', 'settings.geodataNote': '規則中 geosite 與 geoip 使用的資料檔案。更新操作會從來源下載檔案,驗證後取代現有檔案並重載。', 'settings.geodataUpdate': '更新', @@ -1069,7 +1069,7 @@ export const messages = { 'settings.geodataSaved': '地理資料來源已儲存,將在下次自動更新時下載', 'settings.geodataAutoSaved': '自動更新設定已儲存', 'settings.geodataRouteSaved': '下載路由已儲存', - 'settings.geodataSaveFailed': '無法儲存地理資料設定:{error}', + 'settings.geodataSaveFailed': '無法儲存地理資料設定', 'settings.geodataStatus': '狀態', 'settings.geodataUpdateNow': '立即更新', 'settings.geodataLastUpdated': '上次更新', @@ -1083,10 +1083,10 @@ export const messages = { 'settings.installHintMac': '若要安裝,請在選單列選擇「檔案」>「加入 Dock 中」。', 'settings.installed': '已安裝', 'settings.apiMajor': '後端 API 主版本為 {major},本面板依 API 主版本 1 的契約實作;欄位可能不相容。', - 'settings.installFailed': '無法安裝:{error}', - 'settings.runtimeFailed': '無法套用後端選項:{error}', - 'settings.refreshAllFailed': '無法重新整理訂閱:{error}', - 'settings.geodataFailed': '無法更新地理資料:{error}', + 'settings.installFailed': '無法安裝', + 'settings.runtimeFailed': '無法套用後端選項', + 'settings.refreshAllFailed': '無法重新整理訂閱', + 'settings.geodataFailed': '無法更新地理資料', 'shell.shortcuts': '鍵盤快捷鍵', 'shell.langUnavailable': '無法切換至{name}:介面文字載入失敗。', 'shell.searchUnavailable': '無法開啟搜尋:搜尋功能載入失敗。', @@ -1323,7 +1323,7 @@ export const messages = { 'ui.refreshed': '資料已重新整理。', 'ui.newBuild': '新版本已就緒,重新載入頁面後生效。', 'ui.reloadPage': '重新載入', - 'ui.refreshFailed': '無法重新整理資料:{error}', + 'ui.refreshFailed': '無法重新整理資料', 'ui.saved': '設定已儲存。', 'ui.state': '狀態', 'ui.actions': '操作', @@ -1381,6 +1381,6 @@ export const messages = { 'toast.showAllCount': '顯示全部({n})', 'ui.device': '裝置', 'ui.writeInvalid': '驗證發現 {n} 個錯誤,未寫入', - 'ui.writeFailed': '無法寫入組態:{error}' + 'ui.writeFailed': '無法寫入組態' } satisfies Record; export type Key = keyof typeof messages; diff --git a/src/shell/install.ts b/src/shell/install.ts index 2b85f056..a5e27d1c 100644 --- a/src/shell/install.ts +++ b/src/shell/install.ts @@ -52,7 +52,7 @@ export function useInstallOffer(): (() => Promise) | null { await offer.prompt(); return (await offer.userChoice).outcome === 'accepted'; } catch (error) { - toast('negative', t('settings.installFailed', {error: errorText(error, t)})); + toast('negative', t('settings.installFailed'), {detail: errorText(error, t)}); return false; } }; diff --git a/src/shell/useShell.ts b/src/shell/useShell.ts index 3b1e6430..11c8de90 100644 --- a/src/shell/useShell.ts +++ b/src/shell/useShell.ts @@ -38,7 +38,8 @@ export function useShell(settings: Settings, route: string): ShellModel { const outcomes = await refetchAll(); // A resource unsubscribed by navigating away mid-refresh did not fail. const failure = outcomes.flatMap(outcome => (outcome.ok || outcome.error.name === 'AbortError' ? [] : [outcome.error]))[0]; - toast(failure ? 'negative' : 'positive', failure ? t('ui.refreshFailed', {error: errorText(failure, t)}) : t('ui.refreshed')); + if (failure) toast('negative', t('ui.refreshFailed'), {detail: errorText(failure, t)}); + else toast('positive', t('ui.refreshed')); } finally { refreshLock.current = false; setSpinning(false); diff --git a/src/store/mainSource.test.ts b/src/store/mainSource.test.ts index 8e7211f5..b95f75a4 100644 --- a/src/store/mainSource.test.ts +++ b/src/store/mainSource.test.ts @@ -5,12 +5,16 @@ import {LocalError} from '../api/error'; const t: Translator = (key, params) => translate('en', key, params); -it('reports every refused main-source write with one validation message and one failure prefix', () => { +it('reports every refused main-source write with one validation message and one failure summary', () => { expect(editProblem({kind: 'invalid', errors: 2}, t)).toEqual({kind: 'negative', text: 'Validation found 2 errors; nothing written'}); - expect(editProblem({kind: 'failed', error: new Error('offline')}, t)).toEqual({kind: 'negative', text: 'Could not write the configuration: offline'}); - // An unknown outcome is not a failure, so it gets neither the failure prefix nor the failure tone. + expect(editProblem({kind: 'failed', error: new Error('offline')}, t)).toEqual({ + kind: 'negative', + text: 'Could not write the configuration', + detail: 'offline' + }); + // An unknown outcome is not a failure, so it gets neither the failure summary nor the failure tone. expect(editProblem({kind: 'failed', error: new LocalError('ui.operationUnknown')}, t)).toEqual({kind: 'neutral', text: t('ui.operationUnknown')}); - // A file written but not applied is not a failed write, so it does not get the write-failure prefix. + // A file written but not applied is not a failed write, so it does not get the write-failure summary. expect(editProblem({kind: 'failed', error: new LocalError('ui.writtenNotApplied')}, t)).toEqual({kind: 'negative', text: t('ui.writtenNotApplied')}); expect(editProblem({kind: 'ok'}, t)).toBeNull(); }); diff --git a/src/store/mainSource.ts b/src/store/mainSource.ts index 3485e5a2..492785c6 100644 --- a/src/store/mainSource.ts +++ b/src/store/mainSource.ts @@ -2,7 +2,7 @@ import {useCallback, useMemo} from 'react'; import {useCapabilities} from './runtime'; import {useConfig, useConfigEditor, useSourceComplete} from './config'; import type {ConfigSource} from '../api/model'; -import {LocalError, failureNotice} from '../api/error'; +import {LocalError, failureNotice, type Notice} from '../api/error'; import type {Translator} from '../i18n'; import {offered} from '../api/capabilities'; @@ -21,11 +21,11 @@ export type EditResult = {kind: 'ok'} | {kind: 'invalid'; errors: number} | {kin // What to tell the person about an edit that did not land; null when it was written or cancelled. An unknown // operation outcome is not a failure, so it reads neutrally. -export const editProblem = (result: EditResult, t: Translator): {kind: 'neutral' | 'negative'; text: string} | null => +export const editProblem = (result: EditResult, t: Translator): Notice | null => result.kind === 'invalid' ? {kind: 'negative', text: t('ui.writeInvalid', {n: result.errors})} : result.kind === 'failed' - ? failureNotice(result.error, t, error => t('ui.writeFailed', {error})) + ? failureNotice(result.error, t, t('ui.writeFailed')) : null; export function useMainSourceEdit(): MainSourceEdit { diff --git a/src/ui/Feedback.tsx b/src/ui/Feedback.tsx index 22f4c5c2..180f9e92 100644 --- a/src/ui/Feedback.tsx +++ b/src/ui/Feedback.tsx @@ -168,10 +168,11 @@ export const toast = (kind: ToastKind, fullText: string, {detail: fullDetail, ac ); queued.set(id, key); }; -// A failed action's toast; `wrap` words the failure. An unknown operation outcome is shown on its own, neutrally. -export const toastFailure = (error: unknown, t: Translator, wrap: (error: string) => string, action?: ToastAction) => { - const notice = failureNotice(error, t, wrap); - toast(notice.kind, notice.text, {action}); +// A failed action's toast: its summary, with the error as the detail. An unknown operation outcome is shown on its own, +// neutrally. +export const toastFailure = (error: unknown, t: Translator, summary: string, action?: ToastAction) => { + const notice = failureNotice(error, t, summary); + toast(notice.kind, notice.text, {detail: notice.detail, action}); }; const TOAST_ICON = {positive: CheckmarkCircle, negative: AlertTriangle, info: InfoCircle, neutral: null}; // S2's ToastContainer placements: the edge the toasts stack from, then an optional end alignment. diff --git a/src/ui/messages.ts b/src/ui/messages.ts index 769a9f7a..f02d27f2 100644 --- a/src/ui/messages.ts +++ b/src/ui/messages.ts @@ -98,7 +98,7 @@ export const messages = defineMessages({ 'ui.refreshed': '資料已重新整理。', 'ui.newBuild': '新版本已就緒,重新載入頁面後生效。', 'ui.reloadPage': '重新載入', - 'ui.refreshFailed': '無法重新整理資料:{error}', + 'ui.refreshFailed': '無法重新整理資料', 'ui.saved': '設定已儲存。', 'ui.state': '狀態', 'ui.actions': '操作', @@ -156,7 +156,7 @@ export const messages = defineMessages({ 'toast.showAllCount': '顯示全部({n})', 'ui.device': '裝置', 'ui.writeInvalid': '驗證發現 {n} 個錯誤,未寫入', - 'ui.writeFailed': '無法寫入組態:{error}' + 'ui.writeFailed': '無法寫入組態' }, 'zh-CN': { 'ui.separator': ',', @@ -255,7 +255,7 @@ export const messages = defineMessages({ 'ui.refreshed': '数据已刷新。', 'ui.newBuild': '新版本已就绪,重新加载页面后生效。', 'ui.reloadPage': '重新加载', - 'ui.refreshFailed': '无法刷新数据:{error}', + 'ui.refreshFailed': '无法刷新数据', 'ui.saved': '设置已保存。', 'ui.state': '状态', 'ui.actions': '操作', @@ -313,7 +313,7 @@ export const messages = defineMessages({ 'toast.showAllCount': '显示全部({n})', 'ui.device': '设备', 'ui.writeInvalid': '校验发现 {n} 个错误,未写入', - 'ui.writeFailed': '无法写入配置:{error}' + 'ui.writeFailed': '无法写入配置' }, en: { 'ui.separator': ', ', @@ -413,7 +413,7 @@ export const messages = defineMessages({ 'ui.refreshed': 'Data refreshed.', 'ui.newBuild': 'A new version is ready; reload the page to use it.', 'ui.reloadPage': 'Reload', - 'ui.refreshFailed': 'Could not refresh data: {error}', + 'ui.refreshFailed': 'Could not refresh data', 'ui.saved': 'Settings saved.', 'ui.state': 'State', 'ui.actions': 'Actions', @@ -472,6 +472,6 @@ export const messages = defineMessages({ 'toast.showAllCount': 'Show all ({n})', 'ui.device': 'Device', 'ui.writeInvalid': {one: 'Validation found {n} error; nothing written', other: 'Validation found {n} errors; nothing written'}, - 'ui.writeFailed': 'Could not write the configuration: {error}' + 'ui.writeFailed': 'Could not write the configuration' } });