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

fix: 404 error when creating subform #13992

Merged
merged 14 commits into from
Nov 12, 2024
Merged

Conversation

lassopicasso
Copy link
Contributor

@lassopicasso lassopicasso commented Nov 6, 2024

Description

The 404 error occurred because the useCreateSubform hook was triggering the onSubformCreated callback before the new subform was saved on the backend. This caused a validation check in useSubformLayoutValidation to attempt accessing layouts for the new layout set too soon.

To address this, useCreateSubform now waits until the subform is successfully saved before calling onSubformCreated.

A spinner has also been added to indicate loading, improving the user experience, particularly for those with slower internet.

Below are videos from the two locations where users can create a subform, showing the spinner on a slow internet. @Annikenkbrathen, feel free to share any thoughts on the UX.

Video 1: Create subform in config
spinner-loading.mp4
Video 2: Create subform in subheader
spinner-loadingv2.mp4

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. frontend labels Nov 6, 2024
@lassopicasso lassopicasso changed the title Fix 404 error when creating subform fix: 404 error when creating subform Nov 6, 2024
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.21%. Comparing base (ceeaae8) to head (bb5f76c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #13992   +/-   ##
=======================================
  Coverage   95.21%   95.21%           
=======================================
  Files        1756     1756           
  Lines       22984    22990    +6     
  Branches     2681     2684    +3     
=======================================
+ Hits        21885    21891    +6     
  Misses        849      849           
  Partials      250      250           

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

@lassopicasso lassopicasso linked an issue Nov 6, 2024 that may be closed by this pull request
@lassopicasso lassopicasso marked this pull request as ready for review November 6, 2024 14:48
@Annikenkbrathen
Copy link

Great to have a spinner to indicate loading/slowness! Eventually, we’ll remove the button at the top in video 2. So we probably don’t need to make any more changes there?

In the future, the user will only be able to add a subform from the component itself.

In the first video, I can’t actually see where the subform is being added. It’s supposed to appear in the config panel, under Component ID. But maybe that hasn’t been implemented yet or isn’t part of this task either?

@lassopicasso
Copy link
Contributor Author

lassopicasso commented Nov 7, 2024

In the first video, I can’t actually see where the subform is being added. It’s supposed to appear in the config panel, under Component ID. But maybe that hasn’t been implemented yet or isn’t part of this task either?

It does appear in the config panel, but when a new subform is created, the user is automatically redirected to it. This might not be the intended behavior? If so, fixing it only requires removing one line of code (I think) 🙂 Edit: will fix it here #13999

Copy link
Contributor

@wrt95 wrt95 left a comment

Choose a reason for hiding this comment

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

Lots of great code @lassopicasso 😄 Added some comments

@lassopicasso lassopicasso requested a review from wrt95 November 8, 2024 12:12
Copy link
Contributor

@wrt95 wrt95 left a comment

Choose a reason for hiding this comment

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

Great job 🤩

@nkylstad
Copy link
Member

Tested ok, see comment in issue for details #13967 (comment)

@nkylstad nkylstad merged commit 002b6e4 into main Nov 12, 2024
10 checks passed
@nkylstad nkylstad deleted the fix-404-error-when-creating-subform branch November 12, 2024 12:45
nkylstad added a commit that referenced this pull request Nov 26, 2024
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. frontend solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

404 error received when creating a new subform
4 participants