Skip to content

NIFI-15182: Fixed adding/removing user to multiple groups not saving…#10910

Open
Freedom9339 wants to merge 1 commit intoapache:mainfrom
Freedom9339:NIFI-15182
Open

NIFI-15182: Fixed adding/removing user to multiple groups not saving…#10910
Freedom9339 wants to merge 1 commit intoapache:mainfrom
Freedom9339:NIFI-15182

Conversation

@Freedom9339
Copy link
Contributor

… to all groups.

Summary

NIFI-15182: There was an issue where if multiple groups were selected to add a user to, the update would sometimes fail on all groups, and the operation would have to be repeated to add the user to all desired groups. This also happened when deleting a user from multiple groups. This change fixes this issue.

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

@pvillard31 pvillard31 added the ui Pull requests for work relating to the user interface label Feb 17, 2026
Copy link
Contributor

@mcgilman mcgilman left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @Freedom9339! Noted a few things below.

Also, could you add some test coverage for the changed effects? The existing spec file covers loadTenants scenarios, but the effects modified in this PR (updateUserGroup$, awaitUpdateUserGroupsForCreateUser$, awaitUpdateUserGroupsForUpdateUser$, updateUserSuccess$) don't have tests yet.

In particular, a test for updateUserGroup$ verifying that multiple concurrent actions all complete their HTTP requests would help guard against regression — the original switchMap → mergeMap fix is subtle enough that it could be accidentally reverted without a test catching it.

ofType(UserListingActions.updateUserGroup),
map((action) => action.request),
switchMap((request) =>
mergeMap((request) =>
Copy link
Contributor

Choose a reason for hiding this comment

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

The switchMap → mergeMap change in updateUserGroup$ correctly addresses the root cause. Thanks for catching this.

Comment on lines +267 to +268
// @ts-ignore
const expectedCount = createUserResponse.userGroupUpdate.userGroups?.length || 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

You can avoid the @ts-ignore here by extending the optional chaining one level up — this lets the compiler handle the nullability without suppressing other potential errors:

const expectedCount = createUserResponse.userGroupUpdate?.userGroups?.length ?? 0;

// @ts-ignore
const addedCount = updateUserResponse.userGroupUpdate.userGroupsAdded?.length || 0;
// @ts-ignore
const removedCount = updateUserResponse.userGroupUpdate.userGroupsRemoved?.length || 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same pattern here:

const addedCount = updateUserResponse.userGroupUpdate?.userGroupsAdded?.length ?? 0;
const removedCount = updateUserResponse.userGroupUpdate?.userGroupsRemoved?.length ?? 0;

return of(UserListingActions.updateUserComplete());
} else {
return userGroupUpdates;
return from(userGroupUpdates);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good change wrapping in from() here. It makes the intent clearer. Would you mind doing the same in createUserSuccess$ (line 234)? It still returns the raw array there. Both work, but it'd be nice to keep them consistent.

return userGroupUpdates;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui Pull requests for work relating to the user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants