diff --git a/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx b/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx index 3090d287ec..d23ce5679e 100644 --- a/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx +++ b/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.test.tsx @@ -18,7 +18,7 @@ describe('RepeatingGroupTableSummary', () => { jest.restoreAllMocks(); }); - const layoutWithHidden = (hidden: NodeId[]): ILayoutCollection => ({ + const layoutWithHidden = (hidden: NodeId[], editButton?: boolean): ILayoutCollection => ({ FormPage1: { data: { layout: [ @@ -32,6 +32,11 @@ describe('RepeatingGroupTableSummary', () => { children: ['input1', 'input2', 'input3'], maxCount: 3, hidden: hidden.includes('repeating-group'), + ...(editButton !== undefined && { + edit: { + editButton, + }, + }), }, { id: 'input1', @@ -140,6 +145,16 @@ describe('RepeatingGroupTableSummary', () => { ); }); + test('should not render edit button when edit.editButton is false', async () => { + await render({ layout: layoutWithHidden([], false) }); + expect(screen.queryByRole('button', { name: /endre/i })).not.toBeInTheDocument(); + }); + + test('should render edit button when edit.editButton is true', async () => { + await render({ layout: layoutWithHidden([], true) }); + expect(screen.getByRole('button', { name: /endre/i })).toBeInTheDocument(); + }); + type IRenderProps = { navigate?: jest.Mock; layout?: ILayoutCollection; diff --git a/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx b/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx index 4f18040108..2fe7f8f9d4 100644 --- a/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx +++ b/src/layout/RepeatingGroup/Summary2/RepeatingGroupTableSummary/RepeatingGroupTableSummary.tsx @@ -140,6 +140,9 @@ function DataRow({ row, baseComponentId, pdfModeActive, columnSettings }: DataRo const layoutLookups = useLayoutLookups(); const ids = useTableComponentIds(baseComponentId); const children = RepGroupHooks.useChildIds(baseComponentId); + const rowWithExpressions = RepGroupHooks.useRowWithExpressions(baseComponentId, { uuid: row?.uuid ?? '' }); + const editRow = rowWithExpressions?.edit; + const hiddenEditButton = editRow?.editButton === false; const visibleIds = ids.filter((id) => columnSettings[id]?.hidden !== true); if (!row) { @@ -161,17 +164,20 @@ function DataRow({ row, baseComponentId, pdfModeActive, columnSettings }: DataRo /> ), )} - {!pdfModeActive && ( -