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-12049] Remove usage of ActiveUserState from folder service #11880

Merged
merged 32 commits into from
Jan 2, 2025

Conversation

gbubemismith
Copy link
Member

@gbubemismith gbubemismith commented Nov 6, 2024

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-12049

📔 Objective

ActiveUserState is being deprecated. Remove usage from folderService and require userId to be passed.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

…tate

Added extra test cases for encrypted folder and decrypted folders

Updated derived state to use decrypt with key

This comment has been minimized.

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 43.06220% with 119 lines in your changes missing coverage. Please review.

Project coverage is 33.73%. Comparing base (b966019) to head (4b0a42f).
Report is 1 commits behind head on main.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...common/src/vault/services/folder/folder.service.ts 73.07% 12 Missing and 2 partials ⚠️
.../src/vault/components/folder-add-edit.component.ts 0.00% 9 Missing ⚠️
...wser/src/vault/popup/settings/folders.component.ts 0.00% 8 Missing ⚠️
apps/cli/src/vault/create.command.ts 0.00% 7 Missing ⚠️
...ault/vault-filter/services/vault-filter.service.ts 0.00% 7 Missing ⚠️
libs/common/src/platform/sync/core-sync.service.ts 0.00% 7 Missing ⚠️
apps/cli/src/commands/edit.command.ts 0.00% 6 Missing ⚠️
apps/cli/src/commands/get.command.ts 0.00% 6 Missing ⚠️
apps/cli/src/vault/delete.command.ts 0.00% 6 Missing ⚠️
...ogs/bulk-move-dialog/bulk-move-dialog.component.ts 0.00% 6 Missing ⚠️
... and 17 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11880      +/-   ##
==========================================
- Coverage   33.73%   33.73%   -0.01%     
==========================================
  Files        2918     2918              
  Lines       90929    91001      +72     
  Branches    17185    17201      +16     
==========================================
+ Hits        30679    30696      +17     
- Misses      57857    57905      +48     
- Partials     2393     2400       +7     

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

return [];
}

const decryptFolderPromises = folders.map((f) => f.decryptWithKey(userKey, encryptService));
Copy link
Member Author

Choose a reason for hiding this comment

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

ℹ️ @bitwarden/team-platform-dev changed folder decryption to use decryptWithKey instead of the decrypt method.


folders$(userId$: Observable<UserId>): Observable<Folder[]> {
return userId$.pipe(
takeWhile((userId) => userId != null),
Copy link
Member Author

@gbubemismith gbubemismith Nov 8, 2024

Choose a reason for hiding this comment

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

ℹ️ takeWhile operator to stop folder state observations when userId becomes invalid (during logout)

@gbubemismith gbubemismith marked this pull request as ready for review November 8, 2024 17:52
@gbubemismith gbubemismith requested review from a team as code owners November 8, 2024 17:52
this.folderViews$ = this.decryptedFoldersState.state$;
folderViews$(userId$: Observable<UserId>): Observable<FolderView[]> {
return userId$.pipe(
takeWhile((userId) => userId != null),
Copy link
Member Author

@gbubemismith gbubemismith Nov 8, 2024

Choose a reason for hiding this comment

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

ℹ️ takeWhile operator to stop folder state observations when userId becomes invalid (during logout)

audreyality
audreyality previously approved these changes Nov 12, 2024
Copy link
Member

@shane-melton shane-melton left a comment

Choose a reason for hiding this comment

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

Nice work on this so far!

I mostly just left a couple thoughts/comments on my concern with mixing Observable<UserId> and UserId arguments to the FolderService. They're not hard change requests, but I think it something we should consider / discuss further.

Also, I do think we'll need to introduce the same UserId requirement to the FolderApiService to ensure we are always using the same userId throughout a submission.

jprusik
jprusik previously approved these changes Dec 23, 2024
Copy link
Member

@shane-melton shane-melton left a comment

Choose a reason for hiding this comment

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

Looks good! But we do need to make Justin's suggested change.

shane-melton
shane-melton previously approved these changes Dec 23, 2024
audreyality

This comment was marked as outdated.

@gbubemismith gbubemismith merged commit 10c8a21 into main Jan 2, 2025
165 checks passed
@gbubemismith gbubemismith deleted the vault/PM-12049 branch January 2, 2025 22:16
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.

10 participants