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

Editor: Fix error when creating new record #1061

Merged
merged 9 commits into from
Dec 19, 2024
Merged

Editor: Fix error when creating new record #1061

merged 9 commits into from
Dec 19, 2024

Conversation

tkohr
Copy link
Collaborator

@tkohr tkohr commented Dec 11, 2024

Description

The goal of this PR is to fix the error when creating a new record. The same exception sometimes occurs when editing fields of a draft. A first commit ensures errors displayed via the notifications.service still to be logged to the console.

The actual error is caused by the fact that the EditRecordResolver is called even when routing to /create. This happens due to the navigate['edit'] calls within the component. Both navigations have been removed:

  • 07dcd58 does not seem essential, but maybe I've missed something. Creating a new record now stays on /create. => This prevents the exception when creating a new record.
  • a97b566 does not seem to be used anymore, since we've replaced the uniqueIdentifier with the resourceIdentifier in the form. => This prevents the exception when editing fields of a draft.

Note to reproduce: The issue occurs on the first access to /create after app reload. It starts with the second access to /create or accessing /create after /edit.

Screenshots

image

Quality Assurance Checklist

  • Commit history is devoid of any merge commits and readable to facilitate reviews
  • If new logic ⚙️ is introduced: unit tests were added
  • If new user stories 🤏 are introduced: E2E tests were added
  • If new UI components 🕹️ are introduced: corresponding stories in Storybook were created
  • If breaking changes 🪚 are introduced: add the breaking change label
  • If bugs 🐞 are fixed: add the backport <release branch> label
  • The documentation website 📚 has received the love it deserves

Copy link
Contributor

github-actions bot commented Dec 11, 2024

Affected libs: feature-editor, feature-notifications, feature-search, feature-router, feature-map, feature-record,
Affected apps: metadata-editor, datafeeder, demo, datahub, webcomponents, map-viewer, search,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

Copy link
Contributor

github-actions bot commented Dec 11, 2024

📷 Screenshots are here!

since this provokes calling the edit-record.resolver which needs a metadata xml too early and results in an exception
note: bug ccould be reproduced from any second access to /create
…fier changes

this causes exceptions when modifying fields in a draft.
it does not seem to be used anymore, since the uniqueIdentifier has been replaced by the resourceIdentifier
@tkohr tkohr marked this pull request as ready for review December 12, 2024 15:33
@coveralls
Copy link

coveralls commented Dec 12, 2024

Coverage Status

coverage: 83.9% (+2.1%) from 81.764%
when pulling ace56df on me-fix-create
into a63d6d0 on main.

@jahow
Copy link
Collaborator

jahow commented Dec 17, 2024

I'm not sure that this fix is the right way forward; the automatic redirection from /create to /edit/TEMP-ID-XXX was made so that refreshing the page was not going to create a new record but instead leave the user on the same draft.

Maybe if it's just a timing issue a different fix could be found? I'm taking a look right now

@tkohr
Copy link
Collaborator Author

tkohr commented Dec 17, 2024

Thanks for the feedback @jahow! I didn't think of reloading the app on create, good catch!

I've noticed that the reverted subscribe that is not yet added to the component's subscriptions still causes the error when editing draft records, so I also wrapped it into a subscription.add(). Also added some UTs for the subscriptions. I'll let you have a final look before merging.

Copy link
Collaborator

@jahow jahow left a comment

Choose a reason for hiding this comment

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

Thank you! I just saw two new things that should be addressed, sorry 😬 I'll approve the PR and let you merge when you think it's done :)

@tkohr tkohr merged commit 8bec1c9 into main Dec 19, 2024
14 checks passed
@tkohr tkohr deleted the me-fix-create branch December 19, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants