Skip to content

Commit 5b76d7a

Browse files
committed
fix(ui): the related tab's bulk delete reads the child object's row delete grant
The batch call is a write site of its own, so the tab offers it only where the relatedRowDelete row of the affordance map allows it, beside the row delete the host hands in, and the write census names it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgTKEPqtmiK9SGpHsmW
1 parent 4e82b60 commit 5b76d7a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎ui/packages/plugin-detail/src/RelatedList.tsx‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3599,6 +3599,11 @@ export const RelatedList: React.FC<RelatedListProps> = ({
35993599
// the child object.
36003600
const tabInlineEdit = tabList
36013601
&& resolveAffordance('listInlineEdit', { objectSchema, objectName: api, perms }).allowed;
3602+
// The bulk bar's delete is one batch call to the data source, so it reads
3603+
// the child object's `relatedRowDelete` row itself, beside the row delete
3604+
// the host hands in (objectstack#35892).
3605+
const tabBulkDelete = !!onRowDelete
3606+
&& resolveAffordance('relatedRowDelete', { objectSchema, objectName: api, perms }).allowed;
36023607
const viewSchema = React.useMemo(() => {
36033608
if (schema) return schema;
36043609

@@ -3805,7 +3810,8 @@ export const RelatedList: React.FC<RelatedListProps> = ({
38053810
...(tabFindParams ? { findParams: tabFindParams } : {}),
38063811
...(objectSchema?.fields ? { objectFields: objectSchema.fields } : {}),
38073812
...(onRowEdit ? { onEdit: onRowEdit } : {}),
3808-
...(onRowDelete ? { onDelete: handleDeleteRow, onBulkDelete: handleBulkDeleteRows } : {}),
3813+
...(onRowDelete ? { onDelete: handleDeleteRow } : {}),
3814+
...(tabBulkDelete ? { onBulkDelete: handleBulkDeleteRows } : {}),
38093815
...(writeTabColumnState ? { onColumnStateChange: writeTabColumnState } : {}),
38103816
};
38113817
}
@@ -3822,7 +3828,7 @@ export const RelatedList: React.FC<RelatedListProps> = ({
38223828
...(onRowDelete ? { onDelete: handleDeleteRow } : {}),
38233829
...(writeTabColumnState ? { onColumnStateChange: writeTabColumnState } : {}),
38243830
};
3825-
}, [writeTabColumnState, enlargedGrid, windowed, total, currentPage, effectivePageSize, relatedData.length, hasMore, sortedData.length, paginatedData.length, activeSort, handleTableSort, objectSchema, onRowEdit, onRowDelete, handleDeleteRow, tabList, tabRecordCountLead, pickTabSummary, tabFindParams, handleBulkDeleteRows]);
3831+
}, [writeTabColumnState, enlargedGrid, windowed, total, currentPage, effectivePageSize, relatedData.length, hasMore, sortedData.length, paginatedData.length, activeSort, handleTableSort, objectSchema, onRowEdit, onRowDelete, handleDeleteRow, tabList, tabRecordCountLead, pickTabSummary, tabFindParams, handleBulkDeleteRows, tabBulkDelete]);
38263832

38273833
// objectstack#35601 — a stateful child (tasks) is grouped by its status on
38283834
// the related tab: open groups first, completed last (`statusGroupsOf`).

‎ui/packages/plugin-form/src/affordanceGrantMap-12082.test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -853,6 +853,10 @@ const WRITE_SITES: Record<string, WriteSite> = {
853853
// the picked rows (relatedRowEdit).
854854
'packages/plugin-detail/src/RelatedList.tsx :: RelatedList > handleAddRecords :: batch':
855855
mapped(['relatedNew', 'relatedRowEdit'], RELATED_LIST),
856+
// The related tab's bulk delete (objectstack#35892): one batch call to the
857+
// data source, offered beside the host's row delete and read here.
858+
'packages/plugin-detail/src/RelatedList.tsx :: RelatedList > handleConfirmBulkDelete :: delete':
859+
mapped(['relatedRowDelete'], RELATED_LIST),
856860
'packages/plugin-detail/src/renderers/record-related-list.tsx :: RecordRelatedListBody :: delete': {
857861
...mapped(['relatedRowDelete'], RELATED_LIST_BLOCK),
858862
note: "the FALLBACK remove (an `add` config, no host delete) reads the same row the host's delete reads, so it never puts back a delete the host withheld",

0 commit comments

Comments
 (0)