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

Migrate existing organizations state from StateServiceStateProvider #7895

Merged
merged 33 commits into from Mar 18, 2024

Conversation

addisonbeck
Copy link
Contributor

@addisonbeck addisonbeck commented Feb 9, 2024

Type of change

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

Objective

This PR migrates OrganizationService over to StateProvider.

‼️ Attention non Admin Console teams:
The changes to your files here are a result of making two methods in OrganizationService async. In most cases, this
just involves adding an await. In a few select cases this involves swapping to an observable that is exposed from
OrganizationService that accomplishes the same need. In most cases all of these changes are small.
All of these changes are on the last commit: 5a114f6

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

References

@github-actions github-actions bot added the needs-qa Marks a PR as requiring QA approval label Feb 9, 2024
@addisonbeck addisonbeck force-pushed the AC-2009/migrate-organization-state branch 3 times, most recently from 3d7c188 to e848699 Compare February 9, 2024 19:11
Copy link

codecov bot commented Feb 9, 2024

Codecov Report

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

Project coverage is 26.20%. Comparing base (ca86288) to head (d2f9644).

Files Patch % Lines
...rets-manager/projects/project/project.component.ts 0.00% 7 Missing ⚠️
...ganizations/settings/two-factor-setup.component.ts 0.00% 6 Missing ⚠️
...c/app/secrets-manager/shared/new-menu.component.ts 0.00% 6 Missing ⚠️
...sole/services/organization/organization.service.ts 80.00% 3 Missing and 2 partials ⚠️
.../secrets-manager/shared/org-suspended.component.ts 0.00% 3 Missing ⚠️
libs/importer/src/components/import.component.ts 0.00% 3 Missing ⚠️
apps/browser/src/background/main.background.ts 0.00% 2 Missing ⚠️
apps/desktop/src/app/app.component.ts 0.00% 2 Missing ⚠️
.../organizations/reporting/reports-home.component.ts 0.00% 2 Missing ⚠️
apps/web/src/app/app.component.ts 0.00% 2 Missing ⚠️
... and 22 more
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7895   +/-   ##
=======================================
  Coverage   26.20%   26.20%           
=======================================
  Files        2280     2280           
  Lines       66727    66735    +8     
  Branches    12549    12550    +1     
=======================================
+ Hits        17483    17489    +6     
- Misses      47881    47883    +2     
  Partials     1363     1363           

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

@bitwarden-bot
Copy link

bitwarden-bot commented Feb 9, 2024

Logo
Checkmarx One – Scan Summary & Details25ceb7aa-26da-48db-8216-4e6673958871

No New Or Fixed Issues Found

@addisonbeck addisonbeck force-pushed the AC-2009/migrate-organization-state branch from e848699 to f08a24e Compare February 9, 2024 21:51
@addisonbeck addisonbeck marked this pull request as ready for review February 9, 2024 21:51
@addisonbeck addisonbeck requested review from a team as code owners February 9, 2024 21:51
@addisonbeck addisonbeck force-pushed the AC-2009/migrate-organization-state branch 3 times, most recently from 3de2b40 to b7d5776 Compare February 12, 2024 16:35
Copy link
Member

@justindbaur justindbaur left a comment

Choose a reason for hiding this comment

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

I understand the desire for smaller PR's but I don't like that this will cause there to be 2 places the data is saved. The migration will delete it from the state service location but then if someone uses the application it will get saved there again. To finish this off you'd need another migration just deleting the data.

@addisonbeck
Copy link
Contributor Author

addisonbeck commented Feb 12, 2024

@justindbaur that makes sense. It is important to me to make incremental steps here for several reasons. Is there any good way for me to "queue" up a migration so that the migration can be written and tested without being implemented yet? I had thought of just removing it from the migration list & renaming the file without a number. Then applying the migration would just involve numbering the migration and adding it to the list. The still seems a little complicated though, so I'm wondering if you've got any better ideas?

@justindbaur
Copy link
Member

@addisonbeck There is no way to queue up a migration, moving the backing location of your data is kind of an all or nothing move. If you're trying to keep things small you can delete some of the type assertions in here: https://github.com/bitwarden/clients/pull/7895/files#diff-397e257f75aaf8565e7025b97bbf6d6c0830fb174aceaa38522097a74422f2dcR54-R103

If the properties aren't referenced in the migration code they don't really contribute, what's is most important are the types for the account object shape leading up to your data. Then your data can be represented with an unknown.

Then, if you use the same observable names that the state service ones use you can switch over their backing data right now. Then you can have another 1 or 2 PR's that rename those observables to the new name if you want and one for deleting the state service methods and account property.

With those changes I think this PR would actually be slightly smaller.

@addisonbeck
Copy link
Contributor Author

Renaming the exposed methods & observables separately is a good idea. I'll go that route, thanks!

@addisonbeck addisonbeck marked this pull request as draft February 14, 2024 22:58
@addisonbeck addisonbeck force-pushed the AC-2009/migrate-organization-state branch from b7d5776 to 8ba99c6 Compare February 15, 2024 00:05
@addisonbeck
Copy link
Contributor Author

@justindbaur @eliykat This ended up getting bigger since many of OrganizationService's methods were made async. Would y'all mind giving it a review before I open it up to teams to review the changes to OrganizationService callers?

@addisonbeck addisonbeck force-pushed the AC-2009/migrate-organization-state branch 5 times, most recently from d7d26e8 to 2df3c1a Compare February 15, 2024 01:44
Copy link
Member

@eliykat eliykat left a comment

Choose a reason for hiding this comment

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

Looking good overall!

eliykat
eliykat previously approved these changes Mar 14, 2024
justindbaur
justindbaur previously approved these changes Mar 14, 2024
cyprain-okeke
cyprain-okeke previously approved these changes Mar 15, 2024
Jingo88
Jingo88 previously approved these changes Mar 15, 2024
justindbaur
justindbaur previously approved these changes Mar 15, 2024
@addisonbeck addisonbeck force-pushed the AC-2009/migrate-organization-state branch from e6fb4f9 to d2f9644 Compare March 15, 2024 22:19
Copy link
Member

@coltonhurst coltonhurst left a comment

Choose a reason for hiding this comment

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

SM files look good

@addisonbeck addisonbeck merged commit c7abdb9 into main Mar 18, 2024
59 of 60 checks passed
@addisonbeck addisonbeck deleted the AC-2009/migrate-organization-state branch March 18, 2024 16:58
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

8 participants