Skip to content
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

Validate Unique ID for All Layouts in a Layout-Set #12487

Merged
merged 9 commits into from
Mar 13, 2024

Conversation

lassopicasso
Copy link
Contributor

@lassopicasso lassopicasso commented Mar 12, 2024

Description

Refactored idExists validation to support multiple layouts. The unique ID rule now considers all layouts within a layout-set.

Related Issue(s)

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Mar 12, 2024
Copy link

codecov bot commented Mar 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.12%. Comparing base (ceadc10) to head (0638479).

❗ Current head 0638479 differs from pull request most recent head 344a69b. Consider uploading reports for the commit 344a69b to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12487      +/-   ##
==========================================
- Coverage   88.14%   88.12%   -0.03%     
==========================================
  Files        1287     1271      -16     
  Lines       18364    18324      -40     
  Branches     2253     2266      +13     
==========================================
- Hits        16187    16148      -39     
- Misses       1905     1909       +4     
+ Partials      272      267       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lassopicasso lassopicasso changed the title check all layouts in layoutset for unique id validation Validate Unique ID for All Layouts in a Layout-Set Mar 12, 2024
@lassopicasso lassopicasso marked this pull request as ready for review March 13, 2024 07:00
@mlqn mlqn self-assigned this Mar 13, 2024
Copy link
Contributor

@mlqn mlqn left a comment

Choose a reason for hiding this comment

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

Nice work! 🙂👍

@mlqn mlqn removed their assignment Mar 13, 2024
@lassopicasso lassopicasso merged commit 6906404 into main Mar 13, 2024
9 checks passed
@lassopicasso lassopicasso deleted the unique-ids-in-layoutset branch March 13, 2024 14:35
Comment on lines +119 to +132
export function idExists(id: string, formLayouts: IFormLayouts): boolean {
return Object.values(formLayouts).some((layout) => {
const idMatchesContainers =
Object.keys(layout.containers || {}).findIndex(
(key) => key.toUpperCase() === id.toUpperCase(),
) > -1;
const idMatchesComponents =
Object.keys(layout.components || {}).findIndex(
(key) => key.toUpperCase() === id.toUpperCase(),
) > -1;

return idMatchesContainers || idMatchesComponents;
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Her kan vi også bruke some i stedet for findIndex. Men ville det ikke vært ryddigere å beholde den gamle idExists og referere til den her?

export function idExists(id: string, formLayouts: IFormLayouts): boolean {
  return Object.values(formLayouts).some((layout) => idExistsInLayout(id, layout));
}

@lassopicasso

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Det var et godt forslag! Jeg skal fikse det

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TomasEng, jeg har laget en PR her: #12502

lassopicasso added a commit that referenced this pull request Mar 14, 2024
* Refactor IdExists

* With specification

* Update frontend/packages/ux-editor/src/utils/formLayoutUtils.ts

Co-authored-by: Tomas Engebretsen <tomas.engebretsen@digdir.no>

---------

Co-authored-by: Tomas Engebretsen <tomas.engebretsen@digdir.no>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update componend ID valdation to check uniqueness across all layouts in the layoutset
3 participants