From e62ffc547174ea8aa03f8b1c63f668e26e64a699 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 04:14:43 +0000 Subject: [PATCH] fix(core): a list bulk Delete with refused records says why The bulk branch of recordDelete.run settled every delete, counted the rejections and toasted "N deleted, M failed", dropping each refusal's reason, which the one-record toast shows as its description. The summary keeps its counts; its description now lists the reasons: one line per distinct reason in the order handed in, led by the names of the records it refused (up to three, then +N), at most three reasons and then "And N more". An external datasource's refusal reads as the read-only sentence, as the one-record toast reads it. A refusal with no message adds no line, so a batch with no reason keeps the bare count. Two keys join every locale pack (no counted noun, so no plural family); the name/reason join is allowlisted as a format string. Claude-Session: https://claude.ai/code/session_01L6bhgUuauSMJu1nVSQRQri Co-authored-by: Claude --- .../37758-bulk-delete-refusal-reasons.md | 12 +++ .../actions/__tests__/recordDelete.test.ts | 94 ++++++++++++++++++ ui/packages/core/src/actions/recordDelete.ts | 98 +++++++++++++++++-- .../untranslated-identity-4376.test.ts | 1 + ui/packages/i18n/src/locales/ar.ts | 2 + ui/packages/i18n/src/locales/de.ts | 2 + ui/packages/i18n/src/locales/en.ts | 2 + ui/packages/i18n/src/locales/es.ts | 2 + ui/packages/i18n/src/locales/fr.ts | 2 + ui/packages/i18n/src/locales/ja.ts | 2 + ui/packages/i18n/src/locales/ko.ts | 2 + ui/packages/i18n/src/locales/pt-BR.ts | 2 + ui/packages/i18n/src/locales/ru.ts | 2 + ui/packages/i18n/src/locales/zh-Hans.ts | 2 + ui/packages/i18n/src/locales/zh-Hant.ts | 2 + ui/packages/plugin-view/src/ObjectView.tsx | 2 + .../ObjectView.gridDelete-10383.test.tsx | 7 +- 17 files changed, 227 insertions(+), 9 deletions(-) create mode 100644 .changeset/37758-bulk-delete-refusal-reasons.md diff --git a/.changeset/37758-bulk-delete-refusal-reasons.md b/.changeset/37758-bulk-delete-refusal-reasons.md new file mode 100644 index 00000000000..310fe70bb9b --- /dev/null +++ b/.changeset/37758-bulk-delete-refusal-reasons.md @@ -0,0 +1,12 @@ +--- +'@object-ui/core': patch +'@object-ui/i18n': patch +'@object-ui/plugin-view': patch +--- + +fix(core): a list bulk Delete with refused records says why, not only "0 deleted, 4 failed" + +Clause-②: no +Metadata-protocol: none + +The built-in bulk Delete deletes each selected record and reports one summary toast. When records were refused (a restrict delete, a lock, a permission), the toast gave only the two counts and dropped each refusal's reason, which the one-record Delete shows. The summary keeps its counts, and its description now lists the reasons: one line per distinct reason, led by the names of the records it refused (up to three names, then `+N`), at most three reasons and then "And N more". An external datasource's refusal reads as the read-only sentence, as the one-record toast reads it. A refusal with no message adds no line, so a batch with no reason keeps the bare count. The one-record toast is unchanged. Two keys are added to every locale pack: `objectActions.bulkDeleteRefusedNamed` and `objectActions.bulkDeleteMoreReasons`. diff --git a/ui/packages/core/src/actions/__tests__/recordDelete.test.ts b/ui/packages/core/src/actions/__tests__/recordDelete.test.ts index 68ba90876c6..574de6f3e33 100644 --- a/ui/packages/core/src/actions/__tests__/recordDelete.test.ts +++ b/ui/packages/core/src/actions/__tests__/recordDelete.test.ts @@ -190,12 +190,106 @@ describe('recordDelete.run — several records', () => { expect(toast.error).toHaveBeenCalledTimes(1); expect(toast.error).toHaveBeenCalledWith( 'objectActions.bulkDeletePartial {"succeeded":1,"failed":1}', + { description: 'refused b' }, ); expect(toast.success).not.toHaveBeenCalled(); expect(res).toEqual({ success: false }); }); }); +/** + * objectstack-ai/objectstack#37758 — a batch with refusals said only + * "0 deleted, 4 failed": each refusal's reason (the server's localized + * sentence, which the one-record toast shows) was dropped. The summary title + * keeps its counts; the description gives the reasons, one line per distinct + * reason, led by the names of the records it refused. + */ +describe('recordDelete.run — a batch with refusals names the reasons (objectstack#37758)', () => { + const EVENT = { name: 'crm_event', label: 'Event', nameField: 'name', fields: { name: { type: 'text' } } }; + const RESTRICT = 'This event is still referenced by attendee records. Delete or reassign them first.'; + + /** A data source that refuses the ids in `refusals` with the error given there. */ + function refusing(refusals: Record, objectDef: unknown = EVENT) { + const h = harness(); + h.dataSource.delete.mockImplementation(async (_resource: string, id: string) => { + if (id in refusals) throw refusals[id]; + return true; + }); + return { ...h, deps: { ...h.deps, objectDef } }; + } + + const ev = (id: string, name?: string) => (name ? { id, name } : { id }); + + it('an all-refused batch for one reason reads as that reason, with the records it refused', async () => { + const c = refusing({ e1: new Error(RESTRICT), e2: new Error(RESTRICT), e3: new Error(RESTRICT), e4: new Error(RESTRICT) }); + await recordDelete.run(c.deps, { + params: { records: [ev('e1', 'Kickoff'), ev('e2', 'Review'), ev('e3', 'Launch'), ev('e4', 'Retro')] }, + }); + + expect(c.toast.error).toHaveBeenCalledTimes(1); + expect(c.toast.error).toHaveBeenCalledWith('objectActions.bulkDeletePartial {"succeeded":0,"failed":4}', { + description: `objectActions.bulkDeleteRefusedNamed {"names":"Kickoff, Review, Launch +1","reason":"${RESTRICT}"}`, + }); + }); + + it('a mixed batch: one line per distinct reason, in the order handed in; the deleted record is not named', async () => { + const c = refusing({ e2: new Error(RESTRICT), e3: new Error('Record is locked'), e4: new Error(RESTRICT) }); + await recordDelete.run(c.deps, { + params: { records: [ev('e1', 'Kickoff'), ev('e2', 'Review'), ev('e3', 'Launch'), ev('e4', 'Retro')] }, + }); + + expect(c.toast.error).toHaveBeenCalledWith('objectActions.bulkDeletePartial {"succeeded":1,"failed":3}', { + description: [ + `objectActions.bulkDeleteRefusedNamed {"names":"Review, Retro","reason":"${RESTRICT}"}`, + 'objectActions.bulkDeleteRefusedNamed {"names":"Launch","reason":"Record is locked"}', + ].join('\n'), + }); + }); + + it('records with no name: the reason reads alone, since the title already counts them', async () => { + const c = refusing({ x1: new Error(RESTRICT), x2: new Error(RESTRICT) }, undefined); + await recordDelete.run(c.deps, { params: { records: [{ id: 'x1' }, { id: 'x2' }] } }); + + expect(c.toast.error).toHaveBeenCalledWith('objectActions.bulkDeletePartial {"succeeded":0,"failed":2}', { + description: RESTRICT, + }); + }); + + it('past three reasons the rest are counted, not listed', async () => { + const c = refusing({ a: new Error('r1'), b: new Error('r2'), c: new Error('r3'), d: new Error('r4'), e: new Error('r5') }, undefined); + await recordDelete.run(c.deps, { params: { records: ['a', 'b', 'c', 'd', 'e'].map((id) => ({ id })) } }); + + expect(c.toast.error).toHaveBeenCalledWith('objectActions.bulkDeletePartial {"succeeded":0,"failed":5}', { + description: ['r1', 'r2', 'r3', 'objectActions.bulkDeleteMoreReasons {"more":2}'].join('\n'), + }); + }); + + it("an external datasource's refusal reads as the read-only sentence, as the one-record toast reads it", async () => { + const external = Object.assign(new Error('EXTERNAL_WRITE_FORBIDDEN: datasource flags …'), { code: 'EXTERNAL_WRITE_FORBIDDEN' }); + const c = refusing({ a: external, b: external }, undefined); + await recordDelete.run(c.deps, { params: { records: [{ id: 'a' }, { id: 'b' }] } }); + + expect(c.toast.error).toHaveBeenCalledWith('objectActions.bulkDeletePartial {"succeeded":0,"failed":2}', { + description: 'form.readOnlyExternalSource', + }); + }); + + it('CONTROL — refusals that carry no message keep the bare count toast, with no description', async () => { + const c = refusing({ a: new Error(''), b: { status: 500 } }, undefined); + await recordDelete.run(c.deps, { params: { records: [{ id: 'a' }, { id: 'b' }] } }); + + expect(c.toast.error).toHaveBeenCalledTimes(1); + expect(c.toast.error).toHaveBeenCalledWith('objectActions.bulkDeletePartial {"succeeded":0,"failed":2}'); + }); + + it('CONTROL — the one-record refusal toast is unchanged', async () => { + const c = refusing({ e1: new Error(RESTRICT) }); + await recordDelete.run(c.deps, { params: { record: ev('e1', 'Kickoff') }, recordId: 'e1' }); + + expect(c.toast.error).toHaveBeenCalledWith('objectActions.deleteFailed {"label":"Lead"}', { description: RESTRICT }); + }); +}); + /** * objectstack-ai/objectstack#27823 — the delete is permanent and the success diff --git a/ui/packages/core/src/actions/recordDelete.ts b/ui/packages/core/src/actions/recordDelete.ts index 1283125320a..6efb59176bd 100644 --- a/ui/packages/core/src/actions/recordDelete.ts +++ b/ui/packages/core/src/actions/recordDelete.ts @@ -183,6 +183,80 @@ function nameOf(objectDef: unknown, record: Row | null | undefined): string { return resolved && !(id !== null && id !== undefined && resolved === `Record #${id}`) ? resolved : ''; } +/** + * The text a refused delete gives the user: the external-datasource refusal + * reads as the read-only sentence (as the one-record toast reads it), any + * other error as its message. + */ +function refusalText(deps: Pick, err: unknown): string { + if (isExternalWriteRefusal(err)) { + return deps.t('form.readOnlyExternalSource', { defaultValue: READ_ONLY_EXTERNAL_SOURCE_EN }); + } + const message = err instanceof Error ? err.message : typeof err === 'string' ? err : ''; + return message.trim(); +} + +/** At most this many reasons are listed under a batch summary; the rest are counted. */ +const MAX_REFUSAL_LINES = 3; +/** At most this many record names lead one reason's line; the rest are counted. */ +const MAX_REFUSAL_NAMES = 3; + +/** + * The description under a batch summary that had refusals + * (objectstack-ai/objectstack#37758): one line per distinct reason, in the + * order the records were handed in, led by the names of the records it + * refused (up to {@link MAX_REFUSAL_NAMES}, then `+N`). A reason whose records + * have no name reads alone; the summary title already counts them. A refusal + * with no message adds no line, so a batch that carries no reason at all keeps + * the bare count, as before. No line carries a counted noun, so no locale needs + * a plural family for it. + */ +function refusalSummary( + deps: Pick, + refused: Array<{ record: Row; err: unknown }>, +): string | undefined { + const groups = new Map(); + for (const { record, err } of refused) { + const reason = refusalText(deps, err); + if (!reason) continue; + const rows = groups.get(reason); + if (rows) rows.push(record); + else groups.set(reason, [record]); + } + if (groups.size === 0) return undefined; + const lines: string[] = []; + for (const [reason, rows] of groups) { + if (lines.length === MAX_REFUSAL_LINES) break; + const names = rows.map((row) => nameOf(deps.objectDef, row)).filter(Boolean); + if (names.length === 0) { + lines.push(reason); + continue; + } + const shown = names.slice(0, MAX_REFUSAL_NAMES).join(', '); + const unnamed = rows.length - Math.min(names.length, MAX_REFUSAL_NAMES); + const who = unnamed > 0 ? `${shown} +${unnamed}` : shown; + lines.push( + deps.t('objectActions.bulkDeleteRefusedNamed', { + names: who, + reason, + defaultValue: `${who}: ${reason}`, + }), + ); + } + const rest = groups.size - lines.length; + if (rest > 0) { + lines.push( + // `more`, not `count`: a `count` option sends i18next looking for a + // plural family this noun-free sentence does not have. + deps.t('objectActions.bulkDeleteMoreReasons', { + more: rest, + defaultValue: `And ${rest} more`, + }), + ); + } + return lines.join('\n'); +} + /** * The record-delete core: `confirmText` is the question to ask before deleting * one record, `run` performs the delete (one record, or several settled @@ -355,7 +429,10 @@ export const recordDelete = Object.freeze({ const results = await Promise.allSettled( records.map((r) => dataSource.delete(objectName, r.id as string)), ); - const failed = results.filter((r) => r.status === 'rejected').length; + const refused = results.flatMap((r, i) => + r.status === 'rejected' ? [{ record: records[i], err: r.reason as unknown }] : [], + ); + const failed = refused.length; const succeeded = results.length - failed; onRefresh?.(); if (failed === 0) { @@ -370,13 +447,18 @@ export const recordDelete = Object.freeze({ // post-execution hook adds a second, generic success toast. return { success: true, reload: true, silent: true }; } - toast.error( - t('objectActions.bulkDeletePartial', { - succeeded, - failed, - defaultValue: `${succeeded} deleted, ${failed} failed`, - }), - ); + // objectstack-ai/objectstack#37758 — the counts alone told the user + // nothing to act on; each refusal's own reason (the server's localized + // sentence, e.g. a restrict delete's "referenced by N records") goes in + // the description, grouped. A batch with no reason keeps the bare count. + const description = refusalSummary(deps, refused); + const summary = t('objectActions.bulkDeletePartial', { + succeeded, + failed, + defaultValue: `${succeeded} deleted, ${failed} failed`, + }); + if (description) toast.error(summary, { description }); + else toast.error(summary); // The summary above is authoritative; returning WITHOUT `error` keeps the // runner from toasting the failure a second time. return { success: false }; diff --git a/ui/packages/i18n/src/__tests__/untranslated-identity-4376.test.ts b/ui/packages/i18n/src/__tests__/untranslated-identity-4376.test.ts index b634ea3d9da..e9d64e61a9e 100644 --- a/ui/packages/i18n/src/__tests__/untranslated-identity-4376.test.ts +++ b/ui/packages/i18n/src/__tests__/untranslated-identity-4376.test.ts @@ -127,6 +127,7 @@ const LEGITIMATE_IDENTITIES: Record = { // `appTileOpenedLine-12601.test.ts`, not an omission. 'home.appOpened': 'Tile last-opened line — the bare `{{time}}` hole where no verb fits the tile.', 'detail.fieldChangeLabel': 'Activity field-change line label — the field hole and a separator, no prose; zh-Hans, zh-Hant and ja set a fullwidth colon, fr its space-before-colon, ko/ru/ar keep `:` as their punctuation (objectstack#36290).', + 'objectActions.bulkDeleteRefusedNamed': 'Bulk delete refusal line — the record-names hole, a separator and the server\'s reason hole, no prose; zh-Hans, zh-Hant and ja set a fullwidth colon, fr its space-before-colon, ko/ru/ar keep `:` as their punctuation (objectstack#37758).', 'console.firstRunChecklist.pill.count': 'Sidebar 「Get started」 pill count — the done and total holes joined by a slash, a format string with no word to translate (objectstack#36739).', 'console.changeOwner.failure': 'Change Owner report row — the row id and the server\'s own sentence joined by a colon, a format string with no word to translate; zh-Hans and fr use their own colon (objectstack#35403).', 'grid.import.scopeEntry': 'Import Wizard scope entry — the column label and the row\'s cell in quotes, a format string with no word to translate; de, es, fr, ja, ru and ar use their own quotes, zh-Hans, zh-Hant and ko keep the straight quotes their `grid.import.*` lines use (objectstack#36794).', diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index d76b51e0051..6bdb0a84aa6 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -4303,6 +4303,8 @@ const ar = { bulkDeleteSuccess_many: "تم حذف {{count}} من سجلات {{label}}", bulkDeleteSuccess_other: "تم حذف {{count}} من سجلات {{label}}", bulkDeletePartial: "تم حذف {{succeeded}}، فشل {{failed}}", + bulkDeleteRefusedNamed: "{{names}}: {{reason}}", + bulkDeleteMoreReasons: "و{{more}} أخرى", }, objectViewActions: { renameFailed: "تعذر إعادة تسمية العرض", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 400a7730b93..1b95c3d9bd1 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -3953,6 +3953,8 @@ const de = { bulkDeleteSuccess_one: "{{count}} {{label}}-Datensatz gelöscht", bulkDeleteSuccess_other: "{{count}} {{label}}-Datensätze gelöscht", bulkDeletePartial: "{{succeeded}} gelöscht, {{failed}} fehlgeschlagen", + bulkDeleteRefusedNamed: "{{names}}: {{reason}}", + bulkDeleteMoreReasons: "Und {{more}} weitere", }, objectViewActions: { renameFailed: "Ansicht konnte nicht umbenannt werden", diff --git a/ui/packages/i18n/src/locales/en.ts b/ui/packages/i18n/src/locales/en.ts index aa8d66a85c4..1db2d040b54 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -4925,6 +4925,8 @@ const en = { bulkDeleteSuccess_one: 'Deleted {{count}} {{label}} record', bulkDeleteSuccess_other: 'Deleted {{count}} {{label}} records', bulkDeletePartial: '{{succeeded}} deleted, {{failed}} failed', + bulkDeleteRefusedNamed: '{{names}}: {{reason}}', + bulkDeleteMoreReasons: 'And {{more}} more', }, objectViewActions: { renameFailed: 'Failed to rename view', diff --git a/ui/packages/i18n/src/locales/es.ts b/ui/packages/i18n/src/locales/es.ts index 8f8b81b0e62..7c3a93b9093 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -4041,6 +4041,8 @@ const es = { bulkDeleteSuccess_many: "{{count}} de registros de {{label}} eliminados", bulkDeleteSuccess_other: "{{count}} registros de {{label}} eliminados", bulkDeletePartial: "{{succeeded}} eliminados, {{failed}} fallidos", + bulkDeleteRefusedNamed: "{{names}}: {{reason}}", + bulkDeleteMoreReasons: "Y {{more}} más", }, objectViewActions: { renameFailed: "No se pudo renombrar la vista", diff --git a/ui/packages/i18n/src/locales/fr.ts b/ui/packages/i18n/src/locales/fr.ts index 25ff10cd9e6..96e8da1497d 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -4037,6 +4037,8 @@ const fr = { bulkDeleteSuccess_many: "{{count}} d'enregistrements {{label}} supprimés", bulkDeleteSuccess_other: "{{count}} enregistrements {{label}} supprimés", bulkDeletePartial: "{{succeeded}} supprimé(s), {{failed}} échoué(s)", + bulkDeleteRefusedNamed: "{{names}} : {{reason}}", + bulkDeleteMoreReasons: "Et {{more}} de plus", }, objectViewActions: { renameFailed: "Impossible de renommer la vue", diff --git a/ui/packages/i18n/src/locales/ja.ts b/ui/packages/i18n/src/locales/ja.ts index 5a876d529d9..0bef592571e 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -3955,6 +3955,8 @@ const ja = { bulkDeleteSuccess_one: "{{count}} 件の {{label}} レコードを削除しました", bulkDeleteSuccess_other: "{{count}} 件の {{label}} レコードを削除しました", bulkDeletePartial: "{{succeeded}} 件削除、{{failed}} 件失敗", + bulkDeleteRefusedNamed: "{{names}}:{{reason}}", + bulkDeleteMoreReasons: "ほか {{more}} 件の理由", }, objectViewActions: { renameFailed: "ビューの名前変更に失敗しました", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index d9b7e9c5a56..df56125157e 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -3952,6 +3952,8 @@ const ko = { bulkDeleteSuccess_one: "{{count}}개의 {{label}} 레코드 삭제됨", bulkDeleteSuccess_other: "{{count}}개의 {{label}} 레코드 삭제됨", bulkDeletePartial: "{{succeeded}}개 삭제됨, {{failed}}개 실패", + bulkDeleteRefusedNamed: "{{names}}: {{reason}}", + bulkDeleteMoreReasons: "외 {{more}}개 이유", }, objectViewActions: { renameFailed: "보기 이름 변경 실패", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 4f51bc5d37a..b1c6172420e 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -4036,6 +4036,8 @@ const pt = { bulkDeleteSuccess_many: "{{count}} de registros de {{label}} excluídos", bulkDeleteSuccess_other: "{{count}} registros de {{label}} excluídos", bulkDeletePartial: "{{succeeded}} excluídos, {{failed}} com falha", + bulkDeleteRefusedNamed: "{{names}}: {{reason}}", + bulkDeleteMoreReasons: "E mais {{more}}", }, objectViewActions: { renameFailed: "Não foi possível renomear a exibição", diff --git a/ui/packages/i18n/src/locales/ru.ts b/ui/packages/i18n/src/locales/ru.ts index 28cfa66eb78..b7bee79ea44 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -4138,6 +4138,8 @@ const ru = { bulkDeleteSuccess_many: "Удалено {{count}} записей {{label}}", bulkDeleteSuccess_other: "Удалено {{count}} записи {{label}}", bulkDeletePartial: "{{succeeded}} удалено, {{failed}} не удалось", + bulkDeleteRefusedNamed: "{{names}}: {{reason}}", + bulkDeleteMoreReasons: "И ещё {{more}}", }, objectViewActions: { renameFailed: "Не удалось переименовать представление", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index 1f4c19a8ecd..7bdda2e75eb 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -4291,6 +4291,8 @@ const zh = { bulkDeleteSuccess_one: '已删除 {{count}} 条 {{label}} 记录', bulkDeleteSuccess_other: '已删除 {{count}} 条 {{label}} 记录', bulkDeletePartial: '成功 {{succeeded}} 条,失败 {{failed}} 条', + bulkDeleteRefusedNamed: '{{names}}:{{reason}}', + bulkDeleteMoreReasons: '另有 {{more}} 个原因', }, objectViewActions: { renameFailed: '重命名视图失败', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 075f457f569..a3d273b0fa9 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -4291,6 +4291,8 @@ const zhHant = { bulkDeleteSuccess_one: '已刪除 {{count}} 條 {{label}} 記錄', bulkDeleteSuccess_other: '已刪除 {{count}} 條 {{label}} 記錄', bulkDeletePartial: '成功 {{succeeded}} 條,失敗 {{failed}} 條', + bulkDeleteRefusedNamed: '{{names}}:{{reason}}', + bulkDeleteMoreReasons: '另有 {{more}} 個原因', }, objectViewActions: { renameFailed: '重新命名檢視失敗', diff --git a/ui/packages/plugin-view/src/ObjectView.tsx b/ui/packages/plugin-view/src/ObjectView.tsx index c6e2bc63af2..8a4dc718ea3 100644 --- a/ui/packages/plugin-view/src/ObjectView.tsx +++ b/ui/packages/plugin-view/src/ObjectView.tsx @@ -692,6 +692,8 @@ const VIEW_DEFAULT_TRANSLATIONS: Record = { 'objectActions.bulkDeleteSuccess_one': 'Deleted {{count}} {{label}} record', 'objectActions.bulkDeleteSuccess_other': 'Deleted {{count}} {{label}} records', 'objectActions.bulkDeletePartial': '{{succeeded}} deleted, {{failed}} failed', + 'objectActions.bulkDeleteRefusedNamed': '{{names}}: {{reason}}', + 'objectActions.bulkDeleteMoreReasons': 'And {{more}} more', }; const useObjectViewTranslation = createSafeTranslation( diff --git a/ui/packages/plugin-view/src/__tests__/ObjectView.gridDelete-10383.test.tsx b/ui/packages/plugin-view/src/__tests__/ObjectView.gridDelete-10383.test.tsx index b0104804882..da1c8de2429 100644 --- a/ui/packages/plugin-view/src/__tests__/ObjectView.gridDelete-10383.test.tsx +++ b/ui/packages/plugin-view/src/__tests__/ObjectView.gridDelete-10383.test.tsx @@ -316,7 +316,12 @@ describe('objectui#10383 — bulk Delete on the registered object-view path', () fireEvent.click(await screen.findByTestId('bulk-action-delete')); await userEvent.click(within(await confirmDialog()).getByRole('button', { name: 'Delete' })); - await waitFor(() => expect(errorSpy).toHaveBeenCalledWith('1 deleted, 1 failed')); + // objectstack#37758: the refusal's own reason rides under the counts. + await waitFor(() => + expect(errorSpy).toHaveBeenCalledWith('1 deleted, 1 failed', { + description: expect.stringContaining('refused r2'), + }), + ); expect(ds.delete).toHaveBeenCalledTimes(2); await waitFor(() => expect(screen.queryByText('Alice')).not.toBeInTheDocument()); expect(screen.getByText('Bob')).toBeInTheDocument();