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

[PM-7883] Fix Collection Dialog Component #9088

Merged
merged 4 commits into from May 14, 2024

Conversation

shane-melton
Copy link
Member

@shane-melton shane-melton commented May 8, 2024

Type of change

- [X] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other

Objective

The Collection Dialog component had some ambiguous/outdated logic surrounding the nested collection dropdown that wasn't being used by consuming Vault components properly. Users should only be able to nest a collection they CanManage under other collections that they have CanManage access to. This should always be the default behavior for the Individual Vault and only apply to Org Vault when the user does not have permission to edit any collection (depends on V1 flag and collection management setting).

Code changes

Filtering Nested Collections

The collectionIds dialog param would filter the available collections to nest based on what was passed in via the parent Vault component. Instead of having each Vault determine what collections to filter, I moved that logic internal to the dialog as it now has all that information available due to bitwarden/server#3793.

To accomplish this, I opted to introduce a new limitNestedCollections option that would be responsible for applying the filtering. This is always set to true for the Individual Vault and only true for the Org Vault when the user does not have permission to edit any collection (depends on V1 flag and collection management setting).

Service and API request Cleanup

We have normally needed to marry up collection sync data with the admin collection data in order to determine the acting users permissions for a given collection. However, now that its available directly from the admin endpoints I was able to remove the additional calls to the collectionService and the extra collectionAdminService call for the specific collection.

Dealing with Restricted/Deleted Parent Collections

Normally, if an existing parent collection was not found in the list of all collections, it was presumed the collection was deleted and it was marked as so in the dropdown (with a (deleted) suffix). Unfortunately, we can no longer always assume this because a non-admin user may simply not have access to the parent collection.

Logic was added to better determine if the existing parent collection was deleted versus just hidden/unknown. If hidden/unknown, a fake parent option is added to the list of nest options to prevent the user from inadvertently overwriting the parent assignment.

Before you submit

  • Please add unit tests where it makes sense to do so (encouraged but not required)
  • If this change requires a documentation update - notify the documentation team
  • If this change has particular deployment requirements - notify the DevOps team
  • Ensure that all UI additions follow WCAG AA requirements

- Add new limitNestedCollections option
- Remove redundant calls to collectionService and collectionAdminService
- Adjust deleted parent logic to account for users that cannot ViewAllCollections
@shane-melton shane-melton requested a review from a team as a code owner May 8, 2024 17:09
@github-actions github-actions bot added the needs-qa Marks a PR as requiring QA approval label May 8, 2024
@shane-melton shane-melton requested a review from Jingo88 May 8, 2024 17:09
Copy link

codecov bot commented May 8, 2024

Codecov Report

Attention: Patch coverage is 0% with 17 lines in your changes are missing coverage. Please review.

Project coverage is 27.79%. Comparing base (7f91e84) to head (3fb7ed3).

Files Patch % Lines
...s/collection-dialog/collection-dialog.component.ts 0.00% 16 Missing ⚠️
.../src/app/vault/individual-vault/vault.component.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9088   +/-   ##
=======================================
  Coverage   27.78%   27.79%           
=======================================
  Files        2422     2422           
  Lines       70235    70233    -2     
  Branches    13097    13096    -1     
=======================================
+ Hits        19518    19521    +3     
+ Misses      49197    49192    -5     
  Partials     1520     1520           

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

Copy link
Contributor

github-actions bot commented May 8, 2024

Logo
Checkmarx One – Scan Summary & Detailsc0278527-a55c-4edb-a783-a8b7d4a6df57

No New Or Fixed Issues Found

@shane-melton shane-melton marked this pull request as draft May 8, 2024 18:23
@shane-melton shane-melton marked this pull request as ready for review May 8, 2024 18:30
Jingo88
Jingo88 previously approved these changes May 8, 2024
@shane-melton shane-melton removed the needs-qa Marks a PR as requiring QA approval label May 14, 2024
@shane-melton shane-melton merged commit b4f4818 into main May 14, 2024
33 of 35 checks passed
@shane-melton shane-melton deleted the vault/pm-7883/fix-nest-collection-options branch May 14, 2024 15:24
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.

None yet

2 participants