Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('RepeatingGroupTableSummary', () => {
jest.restoreAllMocks();
});

const layoutWithHidden = (hidden: NodeId[]): ILayoutCollection => ({
const layoutWithHidden = (hidden: NodeId[], editButton?: boolean): ILayoutCollection => ({
FormPage1: {
data: {
layout: [
Expand All @@ -32,6 +32,11 @@ describe('RepeatingGroupTableSummary', () => {
children: ['input1', 'input2', 'input3'],
maxCount: 3,
hidden: hidden.includes('repeating-group'),
...(editButton !== undefined && {
edit: {
editButton,
},
}),
},
{
id: 'input1',
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -161,7 +164,7 @@ function DataRow({ row, baseComponentId, pdfModeActive, columnSettings }: DataRo
/>
),
)}
{!pdfModeActive && (
{!pdfModeActive && !hiddenEditButton && (
<Table.Cell
align='right'
className={tableClasses.buttonCell}
Expand Down