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

Refactoring updateRepeatingGroups #1198

Merged
merged 6 commits into from
May 26, 2023

Conversation

olemartinorg
Copy link
Contributor

@olemartinorg olemartinorg commented May 25, 2023

Description

This PR includes some refactoring to make #1175 easier to implement with a compatibility layer on top. Instead of updateRepeatingGroups in formLayoutSaga doing two things (both adding and removing a row from the repeating group state), this splits the two apart into separate actions (repGroupAddRow and repGroupDeleteRow).

The reason behind this change is to prepare for a cleaner interface in the future where we store this metadata about repeating groups inside the data model (for instance, the index state should be derived from the data model itself, as it is essentially the length of the repeating groups array). To make this change more cleanly, we should prepare our existing code for the changes to come.

Sadly, the diffs here on github are pretty useless for this change, as most of this is just moving around code with automated 'extract to function', moving functions into other folders, indentation changes, etc. Sorry!

Related Issue(s)

Verification/QA

  • Manual functionality testing
    • I have tested these changes manually
    • Creator of the original issue (or service owner) has been contacted for manual testing (or will be contacted when released in alpha)
    • No testing done/necessary
  • Automated tests
    • Unit test(s) have been added/updated
    • Cypress E2E test(s) have been added/updated
    • No automatic tests are needed here (no functional changes/additions)
    • I want someone to help me make some tests
  • UU/WCAG (follow these guidelines until we have our own)
    • I have tested with a screen reader/keyboard navigation/automated wcag validator
    • No testing done/necessary (no DOM/visual changes)
    • I want someone to help me perform accessibility testing
  • User documentation @ altinn-studio-docs
    • Has been added/updated
    • No functionality has been changed/added, so no documentation is needed
    • I will do that later/have created an issue
  • Changes/additions to component properties
    • Changes are reflected in both src/layout/layout.d.ts and layout.schema.v1.json, and these are all backwards-compatible
    • No changes made
  • Support in Altinn Studio
    • Issue(s) created for support in Studio
    • This change/feature does not require any changes to Altinn Studio
  • Sprint board
    • The original issue (or this PR itself) has been added to the Team Apps project and to the current sprint board
    • I don't have permissions to do that, please help me out
  • Labels
    • I have added a kind/* label to this PR for proper release notes grouping
    • I don't have permissions to add labels, please help me out

Ole Martin Handeland added 5 commits May 25, 2023 14:26
….ts (it contained functions for not just the form layout, but repeating groups and file uploaders)
…s for adding and removing rows. Also adding separate rejection actions for them all.
… editIndex to undefined.

When these two sagas (delete row + add row) used the same function, the `index` parameter passed in was _only_ set when deleting a row (used for indicating which row to delete, but new rows are always added at the end). The thinking here was probably to set the edit index to the new row index, so I changed the code to fix that, but some tests are now failing because it is expected that the calling code handles updating the editing index (and does it conditionally).
@olemartinorg olemartinorg added the kind/other Pull requests containing chores/repo structure/other changes label May 25, 2023
@olemartinorg olemartinorg self-assigned this May 25, 2023
Copy link
Member

@bjosttveit bjosttveit left a comment

Choose a reason for hiding this comment

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

Nice! did not read through the diff, just make the tests pass and you are good to go

…ingGroups runs, not just the first time (fixes Likert test)
@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 18 Code Smells

32.4% 32.4% Coverage
5.9% 5.9% Duplication

@olemartinorg olemartinorg merged commit b29a094 into main May 26, 2023
@olemartinorg olemartinorg deleted the chore/refactor-update-repeating-groups-saga branch May 26, 2023 14:08
@bjosttveit bjosttveit mentioned this pull request Jun 6, 2023
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/other Pull requests containing chores/repo structure/other changes
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants