Repository navigation
fix(roles): save works after removing a just-added access row - #544
Open
nicdavidson wants to merge 1 commit into
Open
nicdavidson wants to merge 1 commit into
nicdavidson wants to merge 1 commit into
Conversation
A service-access row added and then removed before saving stayed in the form array with access set to '', so onSubmit threw 'access.reduce is not a function' and Update did nothing. Rows that were never saved are now left out of the payload, new rows start with access: [], and the row trash button is type=button so it cannot submit the form. e2e/role-save-after-remove.spec.ts covers adding-then-removing and removing a saved row.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Reported again by a customer ("issue saving RBAC after I have deleted an item, old issue reintroduced"):
Nothing happens: there's no request, no message, and the console shows
TypeError: access.reduce is not a function.Cause
Deleting a row only hides it; the row stays in the form array.
add()started new rows withaccess: '', so whenonSubmitbuilt the payload over every row,val.access.reduce(...)threw before the request was sent. Rows loaded from the server already have an array there, which is why deleting a saved row worked. The earlier fixes (#370,8d468ae1) fixed which row gets hidden, not what the payload contains.Fix
onSubmitleaves out hidden rows that have noid. They never reached the server, so there's nothing to delete.access: [].type="button". As a plain<button>inside the role<form>it was a submit button.Tests
e2e/role-save-after-remove.spec.ts, run against a real instance:I also ran this merged with #537 (#540 is already merged into it) and current
develop. The role specs, the endpoint search/filter flow,npm run test:ci(307/307) and the e2e smoke test all pass.dist/is not rebuilt in this PR.