diff --git a/.changeset/39439-recycle-bin-delete-toast.md b/.changeset/39439-recycle-bin-delete-toast.md new file mode 100644 index 00000000000..db94775461e --- /dev/null +++ b/.changeset/39439-recycle-bin-delete-toast.md @@ -0,0 +1,17 @@ +--- +'@object-ui/core': patch +'@object-ui/app-shell': patch +'@object-ui/i18n': patch +--- + +fix(core, app-shell): the delete toast says the record went to the recycle bin; a position's Add holder leaves out people who already hold it + +Clause-②: no +Metadata-protocol: none + +Who sees it: anyone who deletes one record from a list or a record page, and an administrator adding holders to a position in Setup. + +- **Deleting one record now says where it went.** When the delete's answer carries a recycle-bin entry, the success toast reads `Lead "Ada" moved to the recycle bin` (and its translation in every built-in language) instead of `Lead "Ada" deleted`, for every caller. Before, only a person allowed to restore their own deletes learned anything, through the toast's Undo. Undo is unchanged: it is still offered only to that person. A delete whose answer carries no entry (a platform object, a deployment without a recycle bin, a data source that answers none) keeps the old toast, word for word. The confirm question is not changed, and the toast names no restore-until date, which the delete's answer does not carry. +- **`recordDelete.run` and the record page now always pass `onRecycleBinEntry` to `DataSource.delete`** for a one-record delete, not only when Undo can be offered. The ObjectStack adapter sends the same request either way; an adapter whose backend has no recycle bin never calls it. A batch delete is unchanged. +- Two new keys, `objectActions.movedToRecycleBinNamed` and `objectActions.movedToRecycleBin`, are in every built-in language pack; a host with no translations reads the English sentence. +- **Setup → position → Add holder offers only people who do not hold the position yet**; the picker's title says holders are not listed, and when every member already holds it the picker stays closed and says so. It is the same shape a permission set's Add user takes. diff --git a/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.deleteDialog-11695.test.tsx b/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.deleteDialog-11695.test.tsx index b049e3ea089..6ec79d01058 100644 --- a/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.deleteDialog-11695.test.tsx +++ b/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.deleteDialog-11695.test.tsx @@ -60,6 +60,7 @@ type Pack = { deleteConfirm: string; deleteConfirmQuestion: string; deletedNamed: string; + movedToRecycleBinNamed: string; restoredNamed: string; restoreFailed: string; deleteConfirmTitle: string; @@ -158,7 +159,7 @@ describe.each(['en', 'zh'] as const)('console list Delete in %s (objectui#11695) expect(dataSource.delete).not.toHaveBeenCalled(); fireEvent.click(confirm); - await waitFor(() => expect(dataSource.delete).toHaveBeenCalledWith('crm_product', 'p1')); + await waitFor(() => expect(dataSource.delete).toHaveBeenCalledWith('crm_product', 'p1', { onRecycleBinEntry: expect.any(Function) })); }); it('a selection counts the batch in the title, with the same destructive Delete', async () => { @@ -252,13 +253,14 @@ const MAY_NOT_RESTORE = grants({ crm_product: { allowRead: true, allowDelete: tr describe.each(['en', 'zh'] as const)('console list Delete undo in %s (objectstack#30239)', (language) => { const pack = PACKS[language]; const deleted = fill(pack.objectActions.deletedNamed, { label: 'Product', name: 'QA Widget 0' }); + const recycled = fill(pack.objectActions.movedToRecycleBinNamed, { label: 'Product', name: 'QA Widget 0' }); it('round trip: Undo restores the entry the delete wrote, never re-creates, and names the record', async () => { const dataSource = mountBin(language, MAY_RESTORE, { entryId: 'rb1' }); await confirmRowDelete(pack); await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); const [message, data] = (toast.success as any).mock.calls[0]; - expect(message).toBe(deleted); + expect(message).toBe(recycled); expect(data.action.label).toBe(pack.actions.undo); data.action.onClick(); @@ -285,12 +287,12 @@ describe.each(['en', 'zh'] as const)('console list Delete undo in %s (objectstac }); }); - it('control: without allowRestoreOwnDeleted the toast is today\'s, and no entry id is asked for', async () => { + it('without allowRestoreOwnDeleted no Undo is offered (objectstack#39439: the toast still says where the record went)', async () => { const dataSource = mountBin(language, MAY_NOT_RESTORE, { entryId: 'rb1' }); await confirmRowDelete(pack); await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); - expect((toast.success as any).mock.calls[0]).toEqual([deleted]); - expect(dataSource.delete.mock.calls).toEqual([['crm_product', 'p1']]); + expect((toast.success as any).mock.calls[0]).toEqual([recycled]); + expect(dataSource.delete.mock.calls).toEqual([['crm_product', 'p1', { onRecycleBinEntry: expect.any(Function) }]]); }); it('control: an answer with no recycle-bin entry keeps today\'s toast', async () => { @@ -300,3 +302,48 @@ describe.each(['en', 'zh'] as const)('console list Delete undo in %s (objectstac expect((toast.success as any).mock.calls[0]).toEqual([deleted]); }); }); + +/** + * objectstack#39439 item 11 — the console list's one-record Delete, on the + * real chain and the shipped packs: the toast says the record went to the + * recycle bin whenever the delete's answer carries an entry, whoever deletes; + * Undo stays with a holder of `allowRestoreOwnDeleted`; an answer with none + * keeps today's toast byte for byte. The recycle-bin sentence is the pack's + * own row, distinct from today's, so a host that dropped it reads red. + */ +describe.each(['en', 'zh'] as const)('the list delete toast names the recycle bin in %s (objectstack#39439)', (language) => { + const pack = PACKS[language]; + const deleted = fill(pack.objectActions.deletedNamed, { label: 'Product', name: 'QA Widget 0' }); + const recycled = fill(pack.objectActions.movedToRecycleBinNamed, { label: 'Product', name: 'QA Widget 0' }); + + it('the two sentences differ, so the pins below can tell them apart', () => { + expect(recycled).not.toBe(deleted); + }); + + it('a caller who may not restore reads the recycle-bin sentence, with no Undo', async () => { + mountBin(language, MAY_NOT_RESTORE, { entryId: 'rb1' }); + await confirmRowDelete(pack); + await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); + expect((toast.success as any).mock.calls[0]).toEqual([recycled]); + }); + + it('a caller who may restore reads the same sentence, with Undo', async () => { + mountBin(language, MAY_RESTORE, { entryId: 'rb1' }); + await confirmRowDelete(pack); + await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); + const [message, data] = (toast.success as any).mock.calls[0]; + expect(message).toBe(recycled); + expect(data.action.label).toBe(pack.actions.undo); + }); + + it('CONTROL: an answer with no entry keeps today\'s toast byte for byte, for either caller', async () => { + for (const permissions of [MAY_NOT_RESTORE, MAY_RESTORE]) { + mountBin(language, permissions, {}); + await confirmRowDelete(pack); + await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); + expect((toast.success as any).mock.calls[0]).toEqual([deleted]); + cleanup(); + vi.clearAllMocks(); + } + }); +}); diff --git a/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.test.tsx b/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.test.tsx index c46b71dd76b..e44a02ca8e8 100644 --- a/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.test.tsx +++ b/ui/packages/app-shell/src/hooks/__tests__/useObjectActions.test.tsx @@ -176,7 +176,7 @@ describe('useObjectActions — the delete confirmation names what it deletes (ob confirmText: 'objectActions.deleteConfirmButton', destructive: true, }); - expect(dataSource.delete).toHaveBeenCalledWith('crm_product', 'p1'); + expect(dataSource.delete).toHaveBeenCalledWith('crm_product', 'p1', { onRecycleBinEntry: expect.any(Function) }); }); it('a batch: asks ONCE for all of them with the counting title, then deletes each', async () => { diff --git a/ui/packages/app-shell/src/views/RecordDetailView.deleteConfirmDialog-11001.test.tsx b/ui/packages/app-shell/src/views/RecordDetailView.deleteConfirmDialog-11001.test.tsx index 04fdadb3d12..262093495ac 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.deleteConfirmDialog-11001.test.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.deleteConfirmDialog-11001.test.tsx @@ -95,6 +95,7 @@ type Pack = { deleteConfirmTitle: string; deleteConfirmButton: string; deletedNamed: string; + movedToRecycleBinNamed: string; deleteSuccess: string; }; console: { objectView: { bulkDeleteConfirm: string } }; @@ -287,7 +288,7 @@ describe('record page Delete asks through the in-app confirm dialog (objectui#11 fireEvent.click(within(dialog).getByRole('button', { name: EN.objectActions.deleteConfirmButton })); await waitFor(() => expect(dataSource.delete).toHaveBeenCalledTimes(1)); - expect(dataSource.delete).toHaveBeenCalledWith(OBJECT_NAME, RECORD_ID); + expect(dataSource.delete).toHaveBeenCalledWith(OBJECT_NAME, RECORD_ID, { onRecycleBinEntry: expect.any(Function) }); await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); // objectstack-ai/objectstack#27823 — the toast names the deleted record the // way the confirm title did, not a generic "Record deleted". @@ -333,7 +334,7 @@ describe('record page Delete names the record in zh too (objectui#11695)', () => expect(confirm.className).toContain('bg-destructive'); fireEvent.click(confirm); - await waitFor(() => expect(dataSource.delete).toHaveBeenCalledWith(OBJECT_NAME, RECORD_ID)); + await waitFor(() => expect(dataSource.delete).toHaveBeenCalledWith(OBJECT_NAME, RECORD_ID, { onRecycleBinEntry: expect.any(Function) })); }); }); @@ -352,7 +353,7 @@ describe('record page Delete never re-reads the deleted record', () => { const dialog = await screen.findByRole('alertdialog'); fireEvent.click(within(dialog).getByRole('button', { name: EN.objectActions.deleteConfirmButton })); - await waitFor(() => expect(dataSource.delete).toHaveBeenCalledWith(OBJECT_NAME, RECORD_ID)); + await waitFor(() => expect(dataSource.delete).toHaveBeenCalledWith(OBJECT_NAME, RECORD_ID, { onRecycleBinEntry: expect.any(Function) })); await waitFor(() => expect(currentPath()).toBe(`/${OBJECT_NAME}`)); await act(async () => { for (let i = 0; i < 5; i++) await new Promise((resolve) => setTimeout(resolve, 0)); @@ -372,3 +373,43 @@ describe('record page Delete never re-reads the deleted record', () => { expect(currentPath()).toBe(START_PATH); }); }); + +/** + * objectstack#39439 item 11 — the record page's own delete call asks for the + * recycle-bin entry id whoever deletes, and the toast says the record went to + * the recycle bin when the answer carries one. This caller cannot restore (the + * data source offers no restore), so no Undo rides on it; an answer with no + * entry keeps today's toast byte for byte. + */ +describe('record page Delete says the record went to the recycle bin (objectstack#39439)', () => { + const ASK = { onRecycleBinEntry: expect.any(Function) }; + async function deleteFromHeader(dataSource: ReturnType) { + await mountRecordPage('en', dataSource); + await chooseHeaderDelete(); + const dialog = await screen.findByRole('alertdialog'); + fireEvent.click(within(dialog).getByRole('button', { name: EN.objectActions.deleteConfirmButton })); + await waitFor(() => expect(toast.success).toHaveBeenCalledTimes(1)); + } + + it('an answer with an entry reads the recycle-bin sentence, with no Undo for a caller who cannot restore', async () => { + const dataSource = makeDataSource(); + dataSource.delete = vi.fn(async (_r: string, _id: string, o?: { onRecycleBinEntry?: (id: string) => void }) => { + o?.onRecycleBinEntry?.('rb1'); + return true; + }); + await deleteFromHeader(dataSource); + expect(dataSource.delete.mock.calls).toEqual([[OBJECT_NAME, RECORD_ID, ASK]]); + expect((toast.success as any).mock.calls[0]).toEqual([ + fill(EN.objectActions.movedToRecycleBinNamed, { label: 'Call', name: 'Intro call' }), + ]); + }); + + it('CONTROL: an answer with no entry keeps today\'s toast byte for byte', async () => { + const dataSource = makeDataSource(); + await deleteFromHeader(dataSource); + expect(dataSource.delete.mock.calls).toEqual([[OBJECT_NAME, RECORD_ID, ASK]]); + expect((toast.success as any).mock.calls[0]).toEqual([ + fill(EN.objectActions.deletedNamed, { label: 'Call', name: 'Intro call' }), + ]); + }); +}); diff --git a/ui/packages/app-shell/src/views/RecordDetailView.tsx b/ui/packages/app-shell/src/views/RecordDetailView.tsx index 8de759feea8..6070a8a50ee 100644 --- a/ui/packages/app-shell/src/views/RecordDetailView.tsx +++ b/ui/packages/app-shell/src/views/RecordDetailView.tsx @@ -4482,23 +4482,21 @@ export function RecordDetailView({ dataSource, objects, onEdit, objectNameOverri destructive: true, })) ) return; - // ADR-0148 — the toast offers Undo when the delete wrote a - // recycle-bin entry and the caller may restore its own deletes on - // the object; the undo restores the entry and comes back here. + // ADR-0148 — the delete always asks for the recycle-bin entry id: + // when one arrives the toast says the record went to the recycle + // bin, for every caller, and offers Undo when the caller may also + // restore its own deletes on the object; the undo restores the + // entry and comes back here. const restore = recycleBinRestoreOf(dataSource, objectName!, perms.effectiveObjects); const baseAppUrl = appName ? `/apps/${appName}` : ''; const recordUrl = `${location.pathname}${location.search}`; try { let entryId: string | undefined; - if (restore) { - await dataSource.delete(objectName!, pureRecordId!, { - onRecycleBinEntry: (id: string) => { - entryId = id; - }, - }); - } else { - await dataSource.delete(objectName!, pureRecordId!); - } + await dataSource.delete(objectName!, pureRecordId!, { + onRecycleBinEntry: (id: string) => { + entryId = id; + }, + }); recordDelete.successToast( { ...deleteDeps, diff --git a/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.confirmAndMembers-13337.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.confirmAndMembers-13337.test.tsx index 601a51fc40b..59592c5882a 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.confirmAndMembers-13337.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.confirmAndMembers-13337.test.tsx @@ -21,6 +21,7 @@ import { render, screen, waitFor, fireEvent, cleanup, within } from '@testing-li interface PickerProps { open: boolean; + title?: string; baseFilter?: unknown; onSelectRecords: (records: any[]) => void; } @@ -39,7 +40,7 @@ vi.mock('@object-ui/auth', async (importOriginal) => ({ useAuth: () => ({ activeOrganization: auth.activeOrganization }), })); -const assignments = [{ id: 'up_1', user_id: 'u_1', position: 'auditor' }]; +let assignments = [{ id: 'up_1', user_id: 'u_1', position: 'auditor' }]; const users = [{ id: 'u_1', name: 'Ada Auditor', email: 'ada@example.com' }]; /** `u_9` (QA Csv) was removed from `org_1`: no membership row names them there. */ let members: Array<{ id: string; user_id: string; organization_id: string }> = []; @@ -83,6 +84,7 @@ beforeEach(() => { auth.activeOrganization = { id: 'org_1' }; registered.objects = [{ name: 'sys_user_position' }, { name: 'sys_member' }]; membershipRead = null; + assignments = [{ id: 'up_1', user_id: 'u_1', position: 'auditor' }]; members = [ { id: 'm_1', user_id: 'u_1', organization_id: 'org_1' }, { id: 'm_3', user_id: 'u_3', organization_id: 'org_1' }, @@ -126,7 +128,8 @@ describe("the holder picker offers the organization's members only (objectui#133 expect(memberReads()).toEqual([ ['sys_member', { $filter: { organization_id: 'org_1' }, $top: 500, $skip: 0 }], ]); - expect(picker!.baseFilter).toEqual({ id: { $in: ['u_1', 'u_3'] } }); + // `u_1` already holds the position, so it is left out too (objectstack#39439). + expect(picker!.baseFilter).toEqual({ id: { $in: ['u_3'] } }); }); it('reads every page of the membership', async () => { @@ -135,7 +138,8 @@ describe("the holder picker offers the organization's members only (objectui#133 fireEvent.click(screen.getByRole('button', { name: 'Add holder' })); await waitFor(() => expect(picker?.open).toBe(true)); expect(memberReads().map(([, q]) => (q as { $skip: number }).$skip)).toEqual([0, 500]); - expect((picker!.baseFilter as { id: { $in: string[] } }).id.$in).toHaveLength(501); + // Every member but the holder `u_1` (objectstack#39439). + expect((picker!.baseFilter as { id: { $in: string[] } }).id.$in).toHaveLength(500); }); it("a refused membership read is said in the server's words and the picker stays shut", async () => { @@ -162,7 +166,8 @@ describe("the holder picker offers the organization's members only (objectui#133 await mount(); fireEvent.click(screen.getByRole('button', { name: 'Add holder' })); await waitFor(() => expect(picker?.open).toBe(true)); - expect(picker!.baseFilter).toBeUndefined(); + // Unfiltered by membership; only the holders are left out (objectstack#39439). + expect(picker!.baseFilter).toEqual({ id: { $nin: ['u_1'] } }); expect(memberReads()).toHaveLength(0); }); @@ -171,7 +176,46 @@ describe("the holder picker offers the organization's members only (objectui#133 await mount(); fireEvent.click(screen.getByRole('button', { name: 'Add holder' })); await waitFor(() => expect(picker?.open).toBe(true)); - expect(picker!.baseFilter).toBeUndefined(); + // Unfiltered by membership; only the holders are left out (objectstack#39439). + expect(picker!.baseFilter).toEqual({ id: { $nin: ['u_1'] } }); expect(memberReads()).toHaveLength(0); }); }); + +/** + * objectstack#39439 — the same shape as a permission set's Add user: Add skips + * a current holder, so the picker no longer offers one. Its title says holders + * are not listed; when every member already holds the position it stays shut + * and says so. With no holder there is nothing to leave out. + */ +describe('the holder picker leaves out people who already hold the position (objectstack#39439)', () => { + it("offers the organization's members who do not hold it, and its title says holders are left out", async () => { + await mount(); + fireEvent.click(screen.getByRole('button', { name: 'Add holder' })); + await waitFor(() => expect(picker?.open).toBe(true)); + expect(picker!.baseFilter).toEqual({ id: { $in: ['u_3'] } }); + expect(picker!.title).toBe( + 'Select organization members to assign this position to (people who already hold it are not listed)', + ); + }); + + it('when every member already holds the position, the picker stays shut and says why', async () => { + members = [{ id: 'm_1', user_id: 'u_1', organization_id: 'org_1' }]; + await mount(); + fireEvent.click(screen.getByRole('button', { name: 'Add holder' })); + expect(await screen.findByRole('alert')).toHaveTextContent( + 'Every member of this organization already holds this position.', + ); + expect(picker?.open).toBe(false); + }); + + it('CONTROL: with no holder and no membership to judge, the picker opens unfiltered', async () => { + assignments = []; + registered.objects = [{ name: 'sys_user_position' }]; + render(); + await waitFor(() => expect(screen.getByText('Nobody holds this position yet.')).toBeInTheDocument()); + fireEvent.click(screen.getByRole('button', { name: 'Add holder' })); + await waitFor(() => expect(picker?.open).toBe(true)); + expect(picker!.baseFilter).toBeUndefined(); + }); +}); diff --git a/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.tsx b/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.tsx index 69224cfe57b..60df77cb525 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PositionHoldersSection.tsx @@ -39,6 +39,12 @@ * be refused. Where that refusal judges nothing — no active organization (the * row is stored with none) or a composition that registers no `sys_member` — * the picker keeps its whole list, as the server does. + * + * Either way it leaves out the people who already hold the position + * (objectstack#39439, the shape `AssignedUsersSection` follows): Add skips a + * holder, so offering one offered a pick that does nothing. The picker's title + * says they are not listed, and when every member already holds the position + * it stays shut and says so. */ import * as React from 'react'; @@ -98,6 +104,13 @@ const personLabel = (u: any): string => const PICKER_NAME_FIELD = 'name'; const PICKER_EMAIL_FIELD = 'email'; +/** + * The add picker's hard filter: the organization's members who do not hold the + * position yet, or — where the server judges no membership — everyone but the + * holders (`$nin`). `undefined` when there is nothing to leave out. + */ +type PickerFilter = MemberFilter | { id: { $nin: string[] } }; + /** * The server's own sentence out of a refused call, or `''` when it gave none. * Read through `@object-ui/react`'s shared reader, the one place the adapters' @@ -118,10 +131,11 @@ function useCopy() { remove: '移除', empty: '此岗位还没有成员。', loading: '加载中…', - pickTitle: '选择要分配此岗位的组织成员', + pickTitle: '选择要分配此岗位的组织成员(已担任此岗位的人不在列表中)', nameColumn: '姓名', emailColumn: '邮箱', noMembers: '本组织还没有可分配的成员。', + allMembersHold: '本组织的成员都已担任此岗位。', membersFailed: '无法读取本组织的成员。', removeTitle: (who: string) => `将 ${who} 从此岗位移除?`, removeBody: (who: string) => @@ -137,10 +151,11 @@ function useCopy() { remove: 'Remove', empty: 'Nobody holds this position yet.', loading: 'Loading…', - pickTitle: 'Select organization members to assign this position to', + pickTitle: 'Select organization members to assign this position to (people who already hold it are not listed)', nameColumn: 'Name', emailColumn: 'Email', noMembers: 'This organization has no members to assign yet.', + allMembersHold: 'Every member of this organization already holds this position.', membersFailed: 'Could not read the members of this organization.', removeTitle: (who: string) => `Remove ${who} from this position?`, removeBody: (who: string) => @@ -173,11 +188,13 @@ export function PositionHoldersSection({ name }: PositionHoldersSectionProps): R /** The holder whose Remove is being confirmed, or `null` while no confirm is open. */ const [pendingRemove, setPendingRemove] = React.useState(null); /** - * The picker's hard filter: the active organization's members, by user id, - * or `undefined` where the server judges no membership (see the module note). - * Read when the picker opens, so a member added or removed since is counted. + * The picker's hard filter: the active organization's members who do not + * hold the position yet, by user id, or — where the server judges no + * membership (see the module note) — everyone but the holders + * ({@link PickerFilter}). Read when the picker opens, so a member added or + * removed since is counted. */ - const [memberFilter, setMemberFilter] = React.useState(undefined); + const [memberFilter, setMemberFilter] = React.useState(undefined); const [openingPicker, setOpeningPicker] = React.useState(false); const activeOrganizationId = useAuth().activeOrganization?.id ?? null; @@ -294,8 +311,12 @@ export function PositionHoldersSection({ name }: PositionHoldersSectionProps): R */ const openPicker = React.useCallback(async () => { setError(null); + // The picker offers only people who do not hold the position yet: a + // holder is one the add skips, so listing them offered a pick that does + // nothing. + const holders = [...held]; if (!memberOrganization) { - setMemberFilter(undefined); + setMemberFilter(holders.length > 0 ? { id: { $nin: holders } } : undefined); setPickerOpen(true); return; } @@ -306,14 +327,19 @@ export function PositionHoldersSection({ name }: PositionHoldersSectionProps): R setError(c.noMembers); return; } - setMemberFilter({ id: { $in: ids } }); + const offered = ids.filter((id) => !held.has(id)); + if (offered.length === 0) { + setError(c.allMembersHold); + return; + } + setMemberFilter({ id: { $in: offered } }); setPickerOpen(true); } catch (err) { setError(refusalSentence(err) || c.membersFailed); } finally { setOpeningPicker(false); } - }, [adapter, memberOrganization, c]); + }, [adapter, memberOrganization, held, c]); const removeHolder = React.useCallback( async (assignmentId: string) => { diff --git a/ui/packages/core/src/actions/__tests__/recordDelete.test.ts b/ui/packages/core/src/actions/__tests__/recordDelete.test.ts index 574de6f3e33..6f8be88423d 100644 --- a/ui/packages/core/src/actions/__tests__/recordDelete.test.ts +++ b/ui/packages/core/src/actions/__tests__/recordDelete.test.ts @@ -119,7 +119,7 @@ describe('recordDelete.run — one record', () => { const res = await recordDelete.run(deps, { params: { recordId: 'l1' } }); expect(dataSource.delete).toHaveBeenCalledTimes(1); - expect(dataSource.delete).toHaveBeenCalledWith('crm_lead', 'l1'); + expect(dataSource.delete).toHaveBeenCalledWith('crm_lead', 'l1', { onRecycleBinEntry: expect.any(Function) }); expect(onRefresh).toHaveBeenCalledTimes(1); expect(toast.success).toHaveBeenCalledWith('objectActions.deleteSuccess {"label":"Lead"}'); expect(toast.error).not.toHaveBeenCalled(); @@ -141,15 +141,15 @@ describe('recordDelete.run — one record', () => { it('reads the id off `params.record`, then a single `params.records` entry, then the legacy top-level `recordId`', async () => { const a = harness(); await recordDelete.run(a.deps, { params: { record: { id: 'from-record' } } }); - expect(a.dataSource.delete).toHaveBeenCalledWith('crm_lead', 'from-record'); + expect(a.dataSource.delete).toHaveBeenCalledWith('crm_lead', 'from-record', { onRecycleBinEntry: expect.any(Function) }); const b = harness(); await recordDelete.run(b.deps, { params: { records: [{ id: 'only-one' }] } }); - expect(b.dataSource.delete).toHaveBeenCalledWith('crm_lead', 'only-one'); + expect(b.dataSource.delete).toHaveBeenCalledWith('crm_lead', 'only-one', { onRecycleBinEntry: expect.any(Function) }); const c = harness(); await recordDelete.run(c.deps, { recordId: 'legacy' }); - expect(c.dataSource.delete).toHaveBeenCalledWith('crm_lead', 'legacy'); + expect(c.dataSource.delete).toHaveBeenCalledWith('crm_lead', 'legacy', { onRecycleBinEntry: expect.any(Function) }); }); it('with no id at all, deletes nothing and returns the `error` for the runner to report', async () => { @@ -399,7 +399,7 @@ describe('recordDelete and the recycle bin (objectstack#30239)', () => { expect(toast.success).toHaveBeenCalledTimes(1); const [message, data] = toast.success.mock.calls[0]; - expect(message).toBe('objectActions.deletedNamed {"label":"Lead","name":"Ada"}'); + expect(message).toBe('objectActions.movedToRecycleBinNamed {"label":"Lead","name":"Ada"}'); expect(data.action.label).toBe('actions.undo'); expect(restore).not.toHaveBeenCalled(); @@ -443,16 +443,96 @@ describe('recordDelete and the recycle bin (objectstack#30239)', () => { expect(toast.success.mock.calls).toEqual([['objectActions.deletedNamed {"label":"Lead","name":"Ada"}']]); }); - it('control: a host with no restore deletes exactly as before and offers no Undo', async () => { - const { deps, dataSource, toast } = binHarness({ entryId: 'rb1', withRestore: false }); - await recordDelete.run(deps, ROW); - expect(dataSource.delete.mock.calls).toEqual([['crm_lead', 'l1']]); - expect(toast.success.mock.calls).toEqual([['objectActions.deletedNamed {"label":"Lead","name":"Ada"}']]); - }); - it('control: a batch keeps its summary toast with no Undo', async () => { const { deps, toast } = binHarness({ entryId: 'rb1' }); await recordDelete.run(deps, { params: { records: [{ id: 'a' }, { id: 'b' }] } }); expect(toast.success.mock.calls).toEqual([['objectActions.bulkDeleteSuccess {"count":2,"label":"Lead"}']]); }); }); + +/** + * objectstack#39439 item 11 — the toast is where a person learns the record was + * kept (ADR-0148 D4). Every one-record delete asks for the entry id; when the + * answer carries one the toast says the record went to the recycle bin, for + * every caller, and only a host that passed `restore` adds Undo. An answer with + * none keeps today's toast byte for byte: absent means nothing was kept. + */ +describe('the one-record delete toast says the record went to the recycle bin (objectstack#39439)', () => { + function deps39439(opts: { entryId?: string; withRestore: boolean; objectName?: string }) { + const dataSource = { + delete: vi.fn(async (_resource: string, _id: string, o?: { onRecycleBinEntry?: (id: string) => void }) => { + if (opts.entryId) o?.onRecycleBinEntry?.(opts.entryId); + return true; + }), + }; + const toast = { success: vi.fn(), error: vi.fn() }; + const restore = vi.fn(async () => ({})); + return { + dataSource, + toast, + restore, + deps: { + objectName: opts.objectName ?? 'crm_lead', + label: 'Lead', + t, + dataSource, + toast, + onRefresh: vi.fn(), + ...(opts.withRestore ? { restore } : {}), + }, + }; + } + const ASK = { onRecycleBinEntry: expect.any(Function) }; + const NAMED = { params: { recordId: 'l1', record: { id: 'l1', name: 'Ada' } } }; + + it('a caller who may not restore is still asked for the entry, and told the record went to the recycle bin, with no Undo', async () => { + const { deps, dataSource, toast } = deps39439({ entryId: 'rb1', withRestore: false }); + await recordDelete.run(deps, NAMED); + expect(dataSource.delete.mock.calls).toEqual([['crm_lead', 'l1', ASK]]); + expect(toast.success.mock.calls).toEqual([['objectActions.movedToRecycleBinNamed {"label":"Lead","name":"Ada"}']]); + }); + + it('a caller who may restore reads the same sentence, with Undo', async () => { + const { deps, toast } = deps39439({ entryId: 'rb1', withRestore: true }); + await recordDelete.run(deps, NAMED); + expect(toast.success).toHaveBeenCalledTimes(1); + const [message, data] = toast.success.mock.calls[0]; + expect(message).toBe('objectActions.movedToRecycleBinNamed {"label":"Lead","name":"Ada"}'); + expect(data.action.label).toBe('actions.undo'); + }); + + it('a record with nothing nameable reads by the object label', async () => { + const { deps, toast } = deps39439({ entryId: 'rb1', withRestore: false }); + await recordDelete.run(deps, { params: { recordId: 'l1' } }); + expect(toast.success.mock.calls).toEqual([['objectActions.movedToRecycleBin {"label":"Lead"}']]); + }); + + it('CONTROL: an answer with no entry keeps today\'s toast byte for byte, for either caller', async () => { + for (const withRestore of [false, true]) { + const { deps, dataSource, toast } = deps39439({ entryId: undefined, withRestore }); + await recordDelete.run(deps, NAMED); + expect(dataSource.delete.mock.calls).toEqual([['crm_lead', 'l1', ASK]]); + expect(toast.success.mock.calls).toEqual([['objectActions.deletedNamed {"label":"Lead","name":"Ada"}']]); + } + }); + + it('CONTROL: a batch keeps its summary toast and asks for no entry', async () => { + const { deps, dataSource, toast } = deps39439({ entryId: 'rb1', withRestore: true }); + await recordDelete.run(deps, { params: { records: [{ id: 'a' }, { id: 'b' }] } }); + expect(dataSource.delete.mock.calls).toEqual([['crm_lead', 'a'], ['crm_lead', 'b']]); + expect(toast.success.mock.calls).toEqual([['objectActions.bulkDeleteSuccess {"count":2,"label":"Lead"}']]); + }); + + it('a host with no translation still reads an English sentence (the inline default)', async () => { + const bare = (key: string, o?: Record) => + typeof o?.defaultValue === 'string' + ? o.defaultValue.replace(/\{\{(\w+)\}\}/g, (_m, k: string) => String(o[k])) + : key; + const named = deps39439({ entryId: 'rb1', withRestore: false }); + await recordDelete.run({ ...named.deps, t: bare }, NAMED); + expect(named.toast.success.mock.calls).toEqual([['Lead "Ada" moved to the recycle bin']]); + const nameless = deps39439({ entryId: 'rb1', withRestore: false }); + await recordDelete.run({ ...nameless.deps, t: bare }, { params: { recordId: 'l1' } }); + expect(nameless.toast.success.mock.calls).toEqual([['Lead moved to the recycle bin']]); + }); +}); diff --git a/ui/packages/core/src/actions/recordDelete.ts b/ui/packages/core/src/actions/recordDelete.ts index 2d9ddc235fe..3b1ac779c6c 100644 --- a/ui/packages/core/src/actions/recordDelete.ts +++ b/ui/packages/core/src/actions/recordDelete.ts @@ -56,12 +56,20 @@ * * The success toast names the deleted record by the same resolver * ({@link recordDelete}.successText), the counterpart of the record-save - * toasts; a record with nothing nameable keeps the object-label toast. When - * the delete wrote an entry AND the host passed `restore` (it does only for a - * caller holding `allowRestoreOwnDeleted` on the object, the spec's - * `objectPermissionGrants`), the toast carries an Undo action that restores - * that entry: a restore, never a re-create. Without either, the toast is - * today's, byte for byte. A batch keeps its summary toast with no Undo. + * toasts; a record with nothing nameable keeps the object-label toast. + * + * The toast is where a person learns the record was kept (ADR-0148 D4): a + * one-record delete always asks for the entry id, and when the answer carries + * one the toast says the record went to the recycle bin + * ({@link recycledText}), for every caller. An answer with none + * (a platform object, a composition with no recycle bin, an adapter whose + * backend has none) keeps the plain toast, byte for byte: absent means nothing + * was kept. The toast names no restore-until date, which the answer does not + * carry. When the delete wrote an entry AND the host passed `restore` (it does + * only for a caller holding `allowRestoreOwnDeleted` on the object, the spec's + * `objectPermissionGrants`), the toast also carries an Undo action that + * restores that entry: a restore, never a re-create. A batch keeps its summary + * toast with no Undo. * * ## The confirmation names what the delete cascades into (objectstack#28472) * @@ -129,7 +137,8 @@ interface RecordDeleteDeps { * `dataSource.restoreRecycleBinEntry` bound to the object. Pass it ONLY when * the caller may restore its own deletes on the object * (`objectPermissionGrants(perm, 'allowRestoreOwnDeleted')`): without it no - * Undo is offered, and the delete is asked for no entry id. + * Undo is offered. The entry id is asked for either way; the toast says the + * record went to the recycle bin whenever one arrives. */ restore?: (entryId: string) => Promise; /** Labels for a refused restore's sentence; each falls back to the machine name. */ @@ -183,6 +192,27 @@ function nameOf(objectDef: unknown, record: Row | null | undefined): string { return resolved && !(id !== null && id !== undefined && resolved === `Record #${id}`) ? resolved : ''; } +/** + * The success toast for ONE deleted record whose delete wrote a recycle-bin + * entry: it says the record went to the recycle bin, named as + * {@link recordDelete}.successText names it. It names no restore-until date: + * the delete's answer carries none. + */ +function recycledText( + deps: Pick, + record: Row | null | undefined, +): string { + const { t, label } = deps; + const name = nameOf(deps.objectDef, record); + return name + ? t('objectActions.movedToRecycleBinNamed', { + label, + name, + defaultValue: '{{label}} "{{name}}" moved to the recycle bin', + }) + : t('objectActions.movedToRecycleBin', { label, defaultValue: '{{label}} moved to the recycle bin' }); +} + /** * 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 @@ -365,11 +395,11 @@ export const recordDelete = Object.freeze({ }, /** - * The success toast for ONE deleted record: {@link recordDelete}.successText, - * plus an Undo action when the delete wrote a recycle-bin entry and the host - * passed `restore`. Without both it is exactly today's toast — one argument, - * no action. `onRestored` runs after a successful undo (the record page - * navigates back to the record). + * The success toast for ONE deleted record. With no recycle-bin entry it is + * exactly {@link recordDelete}.successText — one argument, no action. With + * one it is {@link recycledText}, plus an Undo action when the + * host passed `restore`. `onRestored` runs after a successful undo (the + * record page navigates back to the record). */ successToast( deps: Pick, @@ -377,9 +407,13 @@ export const recordDelete = Object.freeze({ entryId: string | undefined, onRestored?: () => void, ): void { - const message = recordDelete.successText(deps, record); + if (!entryId) { + deps.toast.success(recordDelete.successText(deps, record)); + return; + } + const message = recycledText(deps, record); const restore = deps.restore; - if (!entryId || !restore) { + if (!restore) { deps.toast.success(message); return; } @@ -484,18 +518,15 @@ export const recordDelete = Object.freeze({ if (!recordId) return { success: false, error: t('objectActions.noRecordId') }; try { - // The entry id is asked for only when an Undo can be offered, so a - // host that cannot restore deletes exactly as before. + // The entry id is asked for on every one-record delete: whether the + // record was kept is the answer's fact, and the toast says so for every + // caller. The callback changes nothing the adapter sends. let entryId: string | undefined; - if (deps.restore) { - await dataSource.delete(objectName, recordId as string, { - onRecycleBinEntry: (id) => { - entryId = id; - }, - }); - } else { - await dataSource.delete(objectName, recordId as string); - } + await dataSource.delete(objectName, recordId as string, { + onRecycleBinEntry: (id) => { + entryId = id; + }, + }); onRefresh?.(); recordDelete.successToast(deps, record, entryId); return { success: true, reload: true, silent: true }; diff --git a/ui/packages/i18n/src/locales/ar.ts b/ui/packages/i18n/src/locales/ar.ts index 799d7334c5c..4cfe8d04fda 100644 --- a/ui/packages/i18n/src/locales/ar.ts +++ b/ui/packages/i18n/src/locales/ar.ts @@ -4481,6 +4481,11 @@ const ar = { bulkDeletePartial: "تم حذف {{succeeded}}، فشل {{failed}}", bulkDeleteRefusedNamed: "{{names}}: {{reason}}", bulkDeleteMoreReasons: "و{{more}} أخرى", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: 'تم نقل {{label}} "{{name}}" إلى سلة المحذوفات', + movedToRecycleBin: 'تم نقل {{label}} إلى سلة المحذوفات', }, objectViewActions: { renameFailed: "تعذر إعادة تسمية العرض", diff --git a/ui/packages/i18n/src/locales/de.ts b/ui/packages/i18n/src/locales/de.ts index 22fdd9a4bdf..fbd74c85c0e 100644 --- a/ui/packages/i18n/src/locales/de.ts +++ b/ui/packages/i18n/src/locales/de.ts @@ -4123,6 +4123,11 @@ const de = { bulkDeletePartial: "{{succeeded}} gelöscht, {{failed}} fehlgeschlagen", bulkDeleteRefusedNamed: "{{names}}: {{reason}}", bulkDeleteMoreReasons: "Und {{more}} weitere", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: "{{label}} „{{name}}“ in den Papierkorb verschoben", + movedToRecycleBin: "{{label}} in den Papierkorb verschoben", }, 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 72819ed34c4..1f4ded8e557 100644 --- a/ui/packages/i18n/src/locales/en.ts +++ b/ui/packages/i18n/src/locales/en.ts @@ -5109,6 +5109,11 @@ const en = { bulkDeletePartial: '{{succeeded}} deleted, {{failed}} failed', bulkDeleteRefusedNamed: '{{names}}: {{reason}}', bulkDeleteMoreReasons: 'And {{more}} more', + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}} "{{name}}" moved to the recycle bin', + movedToRecycleBin: '{{label}} moved to the recycle bin', }, 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 fe0f67789ec..89f630ba37c 100644 --- a/ui/packages/i18n/src/locales/es.ts +++ b/ui/packages/i18n/src/locales/es.ts @@ -4213,6 +4213,11 @@ const es = { bulkDeletePartial: "{{succeeded}} eliminados, {{failed}} fallidos", bulkDeleteRefusedNamed: "{{names}}: {{reason}}", bulkDeleteMoreReasons: "Y {{more}} más", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}} "{{name}}" movido a la papelera', + movedToRecycleBin: '{{label}} movido a la papelera', }, 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 0b36606f1b1..07b101e577b 100644 --- a/ui/packages/i18n/src/locales/fr.ts +++ b/ui/packages/i18n/src/locales/fr.ts @@ -4209,6 +4209,11 @@ const fr = { bulkDeletePartial: "{{succeeded}} supprimé(s), {{failed}} échoué(s)", bulkDeleteRefusedNamed: "{{names}} : {{reason}}", bulkDeleteMoreReasons: "Et {{more}} de plus", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}} "{{name}}" déplacé dans la corbeille', + movedToRecycleBin: '{{label}} déplacé dans la corbeille', }, 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 2446bb32555..1fdde0f41b2 100644 --- a/ui/packages/i18n/src/locales/ja.ts +++ b/ui/packages/i18n/src/locales/ja.ts @@ -4125,6 +4125,11 @@ const ja = { bulkDeletePartial: "{{succeeded}} 件削除、{{failed}} 件失敗", bulkDeleteRefusedNamed: "{{names}}:{{reason}}", bulkDeleteMoreReasons: "ほか {{more}} 件の理由", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: "{{label}}「{{name}}」をごみ箱に移動しました", + movedToRecycleBin: "{{label}} をごみ箱に移動しました", }, objectViewActions: { renameFailed: "ビューの名前変更に失敗しました", diff --git a/ui/packages/i18n/src/locales/ko.ts b/ui/packages/i18n/src/locales/ko.ts index 774ccfe54c0..48924e9984b 100644 --- a/ui/packages/i18n/src/locales/ko.ts +++ b/ui/packages/i18n/src/locales/ko.ts @@ -4122,6 +4122,11 @@ const ko = { bulkDeletePartial: "{{succeeded}}개 삭제됨, {{failed}}개 실패", bulkDeleteRefusedNamed: "{{names}}: {{reason}}", bulkDeleteMoreReasons: "외 {{more}}개 이유", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}} "{{name}}"을(를) 휴지통으로 이동됨', + movedToRecycleBin: '{{label}}을(를) 휴지통으로 이동됨', }, objectViewActions: { renameFailed: "보기 이름 변경 실패", diff --git a/ui/packages/i18n/src/locales/pt-BR.ts b/ui/packages/i18n/src/locales/pt-BR.ts index 0792604de06..6f2396fda84 100644 --- a/ui/packages/i18n/src/locales/pt-BR.ts +++ b/ui/packages/i18n/src/locales/pt-BR.ts @@ -4208,6 +4208,11 @@ const pt = { bulkDeletePartial: "{{succeeded}} excluídos, {{failed}} com falha", bulkDeleteRefusedNamed: "{{names}}: {{reason}}", bulkDeleteMoreReasons: "E mais {{more}}", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}} "{{name}}" movido para a lixeira', + movedToRecycleBin: '{{label}} movido para a lixeira', }, 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 481a918c4a9..2d5c6b7cfb5 100644 --- a/ui/packages/i18n/src/locales/ru.ts +++ b/ui/packages/i18n/src/locales/ru.ts @@ -4312,6 +4312,11 @@ const ru = { bulkDeletePartial: "{{succeeded}} удалено, {{failed}} не удалось", bulkDeleteRefusedNamed: "{{names}}: {{reason}}", bulkDeleteMoreReasons: "И ещё {{more}}", + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}} "{{name}}" перемещён в корзину', + movedToRecycleBin: '{{label}} перемещён в корзину', }, objectViewActions: { renameFailed: "Не удалось переименовать представление", diff --git a/ui/packages/i18n/src/locales/zh-Hans.ts b/ui/packages/i18n/src/locales/zh-Hans.ts index f36cd301670..5c8d4415c47 100644 --- a/ui/packages/i18n/src/locales/zh-Hans.ts +++ b/ui/packages/i18n/src/locales/zh-Hans.ts @@ -4470,6 +4470,11 @@ const zh = { bulkDeletePartial: '成功 {{succeeded}} 条,失败 {{failed}} 条', bulkDeleteRefusedNamed: '{{names}}:{{reason}}', bulkDeleteMoreReasons: '另有 {{more}} 个原因', + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}}“{{name}}”已移入回收站', + movedToRecycleBin: '{{label}} 已移入回收站', }, objectViewActions: { renameFailed: '重命名视图失败', diff --git a/ui/packages/i18n/src/locales/zh-Hant.ts b/ui/packages/i18n/src/locales/zh-Hant.ts index 764dd11e1bd..5c26ed7578e 100644 --- a/ui/packages/i18n/src/locales/zh-Hant.ts +++ b/ui/packages/i18n/src/locales/zh-Hant.ts @@ -4470,6 +4470,11 @@ const zhHant = { bulkDeletePartial: '成功 {{succeeded}} 條,失敗 {{failed}} 條', bulkDeleteRefusedNamed: '{{names}}:{{reason}}', bulkDeleteMoreReasons: '另有 {{more}} 個原因', + // ADR-0148 D4 — the one-record delete toast when the delete's answer + // carries a recycle-bin entry: the record was kept. No entry keeps + // `deletedNamed` / `deleteSuccess` above. + movedToRecycleBinNamed: '{{label}}“{{name}}”已移入回收站', + movedToRecycleBin: '{{label}} 已移入回收站', }, objectViewActions: { renameFailed: '重新命名檢視失敗', 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 da1c8de2429..24c3fbf55b0 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 @@ -240,7 +240,7 @@ describe('objectui#10383 — row Delete on the registered object-view path', () await userEvent.click(within(dialog).getByRole('button', { name: 'Delete' })); await waitFor(() => expect(ds.delete).toHaveBeenCalledTimes(1)); - expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1'); + expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1', { onRecycleBinEntry: expect.any(Function) }); await waitFor(() => expect(screen.queryByText('Alice')).not.toBeInTheDocument()); expect(screen.getByText('Bob')).toBeInTheDocument(); expect(successSpy).toHaveBeenCalledWith('Test object "Alice" deleted'); @@ -271,7 +271,7 @@ describe('objectui#10383 — row Delete on the registered object-view path', () await userEvent.click(within(await confirmDialog()).getByRole('button', { name: 'Delete' })); await waitFor(() => expect(errorSpy).toHaveBeenCalledTimes(1)); - expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1'); + expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1', { onRecycleBinEntry: expect.any(Function) }); expect(errorSpy).toHaveBeenCalledWith('Failed to delete Test object', { description: 'refused r1' }); expect(successSpy).not.toHaveBeenCalled(); expect(screen.getByText('Alice')).toBeInTheDocument(); @@ -401,6 +401,6 @@ describe('objectui#11695 — the row Delete names the row in zh', () => { expect(confirm.className).toContain('bg-destructive'); await userEvent.click(confirm); - await waitFor(() => expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1')); + await waitFor(() => expect(ds.delete).toHaveBeenCalledWith(OBJECT, 'r1', { onRecycleBinEntry: expect.any(Function) })); }); }); diff --git a/ui/packages/plugin-view/src/__tests__/ObjectView.refreshInPlace-10035.test.tsx b/ui/packages/plugin-view/src/__tests__/ObjectView.refreshInPlace-10035.test.tsx index f80634c4dc7..9a23058a3c9 100644 --- a/ui/packages/plugin-view/src/__tests__/ObjectView.refreshInPlace-10035.test.tsx +++ b/ui/packages/plugin-view/src/__tests__/ObjectView.refreshInPlace-10035.test.tsx @@ -270,7 +270,7 @@ describe('ObjectView keeps a self-fetching view mounted and tells the bus instea fireEvent.click(buttons[buttons.length - 1]); }); - await waitFor(() => expect(ds.delete).toHaveBeenCalledWith('task', '1')); + await waitFor(() => expect(ds.delete).toHaveBeenCalledWith('task', '1', { onRecycleBinEntry: expect.any(Function) })); await waitFor(() => expect( view().dataset.rows,