-
Notifications
You must be signed in to change notification settings - Fork 31
Support merge/col span cells horizontal in grid and hide a column #4050
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lassopicasso
wants to merge
8
commits into
main
Choose a base branch
from
support-merge/colSpan-cells-horizontal-in-grid
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
089bf51
support colSpan without expression
lassopicasso 7b7bf66
support colSpan without expression
lassopicasso dc40cec
support colSpan without expression
lassopicasso 0241acd
support colSpan with expression
lassopicasso 859546a
update colSpan and add hidden for column
JamalAlabdullah e036442
removed unused imports
JamalAlabdullah 912170e
added test
JamalAlabdullah 8b3b5f3
test lowercase
JamalAlabdullah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'); | ||
| }); | ||
| }); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: Altinn/app-frontend-react
Length of output: 513
🏁 Script executed:
Repository: Altinn/app-frontend-react
Length of output: 1091
🏁 Script executed:
Repository: Altinn/app-frontend-react
Length of output: 1074
🏁 Script executed:
Repository: Altinn/app-frontend-react
Length of output: 1126
Inconsistency with
revert.shwill break revert operations for pre-release tags.This lowercase normalization ensures
APP_FULLpasses theVERSION_REGEXvalidation (which expects[a-z0-9.\-]+for pre-release identifiers), butrevert.shdoes not apply the same normalization. When reverting a pre-release likev3.0.0-RC1:release.shnormalizes to3.0.0-rc1and publishes to that pathrevert.shkeeps it as3.0.0-RC1, which fails theVERSION_REGEXcheck, causing the script to exit with a validation errorApply the same normalization in
revert.shline 38:APP_FULL=${REVERT_TAG:1} +APP_FULL=$(echo "$APP_FULL" | tr '[:upper:]' '[:lower:]')🤖 Prompt for AI Agents
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. 👍