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
1 change: 1 addition & 0 deletions .github/scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ CURRENT_VERSION_PARTS=(${CURRENT_VERSION//./ })
APP_FULL=${CURRENT_VERSION:1}
APP_MAJOR=${CURRENT_VERSION_PARTS[0]:1}
APP_MAJOR_MINOR=${CURRENT_VERSION_PARTS[0]:1}.${CURRENT_VERSION_PARTS[1]}
APP_FULL=$(echo "$APP_FULL" | tr '[:upper:]' '[:lower:]')
Copy link
Contributor

@coderabbitai coderabbitai bot Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that revert.sh does not normalize APP_FULL to lowercase
rg -n 'APP_FULL' .github/scripts/revert.sh

Repository: Altinn/app-frontend-react

Length of output: 513


🏁 Script executed:

# Check release.sh around line 55 and VERSION_REGEX definition
sed -n '50,75p' .github/scripts/release.sh | cat -n

Repository: Altinn/app-frontend-react

Length of output: 1091


🏁 Script executed:

# Check revert.sh VERSION_REGEX definition and full context around APP_FULL assignment
sed -n '35,60p' .github/scripts/revert.sh | cat -n

Repository: Altinn/app-frontend-react

Length of output: 1074


🏁 Script executed:

# Check how REVERT_TAG is set in revert.sh
sed -n '1,40p' .github/scripts/revert.sh | cat -n

Repository: Altinn/app-frontend-react

Length of output: 1126


Inconsistency with revert.sh will break revert operations for pre-release tags.

This lowercase normalization ensures APP_FULL passes the VERSION_REGEX validation (which expects [a-z0-9.\-]+ for pre-release identifiers), but revert.sh does not apply the same normalization. When reverting a pre-release like v3.0.0-RC1:

  • release.sh normalizes to 3.0.0-rc1 and publishes to that path
  • revert.sh keeps it as 3.0.0-RC1, which fails the VERSION_REGEX check, causing the script to exit with a validation error

Apply the same normalization in revert.sh line 38:

APP_FULL=${REVERT_TAG:1}
+APP_FULL=$(echo "$APP_FULL" | tr '[:upper:]' '[:lower:]')
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/scripts/release.sh at line 55, The revert script fails validation
for pre-release tags because it doesn't lowercase APP_FULL like release.sh does;
update revert.sh to normalize APP_FULL to lowercase (e.g., APP_FULL=$(echo
"$APP_FULL" | tr '[:upper:]' '[:lower:]')) before the VERSION_REGEX check so
pre-release identifiers (like RC1 -> rc1) match the expected `[a-z0-9.\-]+`
pattern and revert logic that uses APP_FULL will behave identically to
release.sh.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will remove it . this is just temporary

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JamalAlabdullah, understood! No worries — if it's temporary, feel free to remove it when it's no longer needed. 👍


echo "Git tag: '$CURRENT_VERSION'"
echo "Full version: '$APP_FULL'"
Expand Down
31 changes: 28 additions & 3 deletions src/codegen/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,28 @@ const common = {
),
).extends(CG.common('ISelectionComponent')),

IGridColumnProperties: () =>
new CG.obj(
new CG.prop(
'colSpan',
new CG.expr(ExprVal.Number)
.optional()
.setTitle('Column span')
.setDescription('Number of columns this cell should span. Defaults to 1 if not set.'),
),
new CG.prop(
'hidden',
new CG.expr(ExprVal.Boolean)
.optional()
.setTitle('Hidden column')
.setDescription(
'Expression or boolean indicating whether this column should be hidden. Defaults to false if not set.',
),
),
)
.setTitle('Grid column properties')
.setDescription('Additional properties for columns in the Grid component'),

// Table configuration:
ITableColumnsAlignText: () =>
new CG.enum('left', 'center', 'right')
Expand Down Expand Up @@ -588,7 +610,8 @@ const common = {
new CG.obj(
new CG.prop('component', new CG.str().optional().setTitle('Component ID').setDescription('ID of the component')),
new CG.prop('columnOptions', CG.common('ITableColumnProperties').optional()),
).extends(CG.common('ITableColumnProperties')),
new CG.prop('gridColumnOptions', CG.common('IGridColumnProperties').optional()),
),
GridCellLabelFrom: () =>
new CG.obj(
new CG.prop(
Expand All @@ -598,7 +621,8 @@ const common = {
.setDescription('Set this to a component id to display the label from that component'),
),
new CG.prop('columnOptions', CG.common('ITableColumnProperties').optional()),
).extends(CG.common('ITableColumnProperties')),
new CG.prop('gridColumnOptions', CG.common('IGridColumnProperties').optional()),
),
GridCellText: () =>
new CG.obj(
new CG.prop(
Expand All @@ -607,7 +631,8 @@ const common = {
),
new CG.prop('help', new CG.str().optional().setTitle('Help').setDescription('Help text to display')),
new CG.prop('columnOptions', CG.common('ITableColumnProperties').optional()),
).extends(CG.common('ITableColumnProperties')),
new CG.prop('gridColumnOptions', CG.common('IGridColumnProperties').optional()),
),
GridCell: () =>
new CG.union(CG.common('GridComponentRef'), CG.null, CG.common('GridCellText'), CG.common('GridCellLabelFrom')),
GridRow: () =>
Expand Down
152 changes: 152 additions & 0 deletions src/layout/Grid/GridComponent.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import React from 'react';

import { screen } from '@testing-library/react';

import { RenderGrid } from 'src/layout/Grid/GridComponent';
import { renderGenericComponentTest } from 'src/test/renderWithProviders';
import type { CompExternalExact } from 'src/layout/layout';

describe('GridComponent', () => {
const render = async (hiddenValue: unknown) =>
await renderGenericComponentTest({
type: 'Grid',
renderer: (props) => <RenderGrid {...props} />,
component: {
rows: [
{
header: true,
readOnly: false,
cells: [
{ text: 'accordion.title' },
{
text: 'FormLayout',
gridColumnOptions: { hidden: hiddenValue },
},
],
},
{
header: false,
readOnly: false,
cells: [{ text: 'accordion.title' }, { text: 'FormLayout' }],
},
],
} as CompExternalExact<'Grid'>,
});

it('hides a column when header cell hidden evaluates to true', async () => {
await render(true);
const headers = screen.getAllByRole('columnheader');
expect(headers).toHaveLength(1);

const titleOccurrences = screen.getAllByText('This is a title');
expect(titleOccurrences).toHaveLength(2);
expect(screen.queryByText('This is a page title')).not.toBeInTheDocument();

const bodyCells = screen.getAllByRole('cell');
expect(bodyCells).toHaveLength(1);
expect(screen.getAllByText('This is a title')[0]).toBeInTheDocument();
});

it('does not hide a column when hidden expression is invalid for boolean', async () => {
await render(false);

const headers = screen.getAllByRole('columnheader');
expect(headers).toHaveLength(2);

const titleOccurrences = screen.getAllByText('This is a title');
expect(titleOccurrences.length).toBeGreaterThanOrEqual(1);
const pageTitleOccurrences = screen.getAllByText('This is a page title');
expect(pageTitleOccurrences.length).toBeGreaterThanOrEqual(1);
});

it('applies colSpan from text cell settings', async () => {
await renderGenericComponentTest({
type: 'Grid',
renderer: (props) => <RenderGrid {...props} />,
component: {
rows: [
{
header: true,
readOnly: false,
cells: [
{
text: 'accordion.title',
colSpan: 2,
},
{ text: 'FormLayout' },
],
},
],
} as CompExternalExact<'Grid'>,
});

const headers = screen.getAllByRole('columnheader');
expect(headers.length).toBeGreaterThanOrEqual(1);
const firstHeaderCell = headers[0];
expect(firstHeaderCell).toHaveAttribute('colspan', '2');
});

it('applies colSpan for component cells', async () => {
await renderGenericComponentTest({
type: 'Grid',
renderer: (props) => <RenderGrid {...props} />,
component: {
rows: [
{
header: false,
readOnly: false,
cells: [
{
component: 'grid-text',
gridColumnOptions: {
colSpan: 3,
},
},
],
},
],
} as CompExternalExact<'Grid'>,
queries: {
fetchLayouts: async () => ({
FormLayout: {
data: {
layout: [
{
id: 'my-test-component-id',
type: 'Grid',
rows: [
{
header: false,
readOnly: false,
cells: [
{
component: 'grid-text',
gridColumnOptions: {
colSpan: 3,
},
},
],
},
],
},
{
id: 'grid-text',
type: 'Text',
value: '',
textResourceBindings: {
title: 'accordion.title',
},
},
],
},
},
}),
},
});

const cells = screen.getAllByRole('cell');
expect(cells.length).toBeGreaterThanOrEqual(1);
const firstCell = cells[0];
expect(firstCell).toHaveAttribute('colspan', '3');
});
});
Loading
Loading