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

UISAUTHCOM-43: Fix capabilities from unselected application sometimes shown as assigned for a role after editing. #65

Merged
merged 6 commits into from
Jan 31, 2025

Conversation

aidynoJ
Copy link
Contributor

@aidynoJ aidynoJ commented Jan 29, 2025

Purpose

Refs UISAUTHCOM-43

Approach

Changed hooks receives a list of the selected applications as argument,
and we retrieve the capabilities ONLY for the selected applications.
The user will then be able to select from the provided capabilities.
useEffect handles the situation where the user changes the selected applications, causing new capabilities/sets to be retrieved.
However, previously selected capabilities may no longer be present in the new list of selected application capabilities/sets.
It filters them by checking whether the selected capability/set is included in the new list of capabilities/sets.
It iterates over selectedCapabilitiesMap, disabledCapabilities, and if any of them are not in the new list of capabilities/sets,
they are removed.
Example,
const selectedCapabilitiesMap = { id1: true, id2: true }, disabledCapabilities = { id3: true }, checkedAppCaps = { id1: true };
1. Since checkedAppCaps does not include id2, it is removed from selectedCapabilitiesMap.
2. Since checkedAppCaps does not include id3, it is removed from disabledCapabilities

Pre-Merge Checklist

Before merging this PR, please go through the following list and take appropriate actions.

  • I've added appropriate record to the CHANGELOG.md
  • Does this PR meet or exceed the expected quality standards?
    • Code coverage on new code is 80% or greater
    • Duplications on new code is 3% or less
    • There are no major code smells or security issues
  • Does this introduce breaking changes?
    • If any API-related changes - okapi interfaces and permissions are reviewed/changed correspondingly
    • There are no breaking changes in this PR.

If there are breaking changes, please STOP and consider the following:

  • What other modules will these changes impact?
  • Do JIRAs exist to update the impacted modules?
    • If not, please create them
    • Do they contain the appropriate level of detail? Which endpoints/schemas changed, etc.
    • Do they have all they appropriate links to blocked/related issues?
  • Are the JIRAs under active development?
    • If not, contact the project's PO and make sure they're aware of the urgency.
  • Do PRs exist for these changes?
    • If so, have they been approved?

Ideally all of the PRs involved in breaking changes would be merged in the same day to avoid breaking the folio-testing environment. Communication is paramount if that is to be achieved, especially as the number of intermodule and inter-team dependencies increase.

While it's helpful for reviewers to help identify potential problems, ensuring that it's safe to merge is ultimately the responsibility of the PR assignee.

Copy link

github-actions bot commented Jan 29, 2025

Jest Unit Test Results

  1 files  ±0   48 suites  ±0   1m 37s ⏱️ -4s
152 tests +2  151 ✅ +2  1 💤 ±0  0 ❌ ±0 
160 runs  +2  159 ✅ +2  1 💤 ±0  0 ❌ ±0 

Results for commit 5c97402. ± Comparison against base commit da154ed.

♻️ This comment has been updated with latest results.

@aidynoJ aidynoJ requested review from ryandberger and zburke January 29, 2025 16:39
Copy link
Member

@zburke zburke left a comment

Choose a reason for hiding this comment

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

The description of the bug is very clear, but I'm not totally clear on how the data flows through the components and hooks, so I don't have a great understanding of why this fix works. Can you provide more technical details either in the PR description or in comments on the code about how this fix works?

It's clear to me you have a very deep understanding of this code, which is great, but it's also worrying that I could not have come up with this fix on my own. I see how the individual functions work in a unit-testing sense, but I need a better overall sense of how things fit together. You don't have to document everything for this PR, but if you can at least describe why this fix worked, that would help a lot.

@aidynoJ
Copy link
Contributor Author

aidynoJ commented Jan 31, 2025

The description of the bug is very clear, but I'm not totally clear on how the data flows through the components and hooks, so I don't have a great understanding of why this fix works. Can you provide more technical details either in the PR description or in comments on the code about how this fix works?

It's clear to me you have a very deep understanding of this code, which is great, but it's also worrying that I could not have come up with this fix on my own. I see how the individual functions work in a unit-testing sense, but I need a better overall sense of how things fit together. You don't have to document everything for this PR, but if you can at least describe why this fix worked, that would help a lot.

Thank you for the review! I added comments for the changes. I wanted to add them before opening the PR, but I totally forgot :)

@aidynoJ aidynoJ merged commit 3df0011 into master Jan 31, 2025
15 checks passed
@aidynoJ aidynoJ deleted the UISAUTHCOM-43 branch January 31, 2025 11:14
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.

2 participants