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

[AC-1970] Add billing navigation group to provider layout #8941

Merged
merged 18 commits into from May 3, 2024

Conversation

amorask-bitwarden
Copy link
Contributor

@amorask-bitwarden amorask-bitwarden commented Apr 26, 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 adds the Billing navigation group to the provider layout when the FF enable-consolidated-billing is on and the provider's providerStatus is Billable.

It also does some minor refactoring on the fly.

Code changes

Screenshots

Screen.Recording.2024-04-26.at.1.41.06.PM.mov

@github-actions github-actions bot added the needs-qa Marks a PR as requiring QA approval label Apr 26, 2024
@amorask-bitwarden amorask-bitwarden marked this pull request as ready for review April 26, 2024 19:23
@amorask-bitwarden amorask-bitwarden requested review from a team as code owners April 26, 2024 19:23
@amorask-bitwarden amorask-bitwarden marked this pull request as draft April 26, 2024 19:27
Copy link
Contributor

github-actions bot commented Apr 26, 2024

Logo
Checkmarx One – Scan Summary & Detailsc52fa5c8-d5d3-4c7f-a240-72c86c1d076b

No New Or Fixed Issues Found

@amorask-bitwarden amorask-bitwarden marked this pull request as ready for review April 29, 2024 14:28
Copy link

codecov bot commented Apr 29, 2024

Codecov Report

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

Project coverage is 27.74%. Comparing base (debfe91) to head (09355f7).

Files Patch % Lines
...providers/guards/has-consolidated-billing.guard.ts 0.00% 16 Missing ⚠️
...in-console/providers/providers-layout.component.ts 0.00% 14 Missing ⚠️
...s/clients/manage-client-organizations.component.ts 0.00% 8 Missing ⚠️
...stractions/provider-billing.service.abstraction.ts 0.00% 8 Missing ⚠️
...min-console/providers/clients/clients.component.ts 0.00% 6 Missing ⚠️
...dmin-console/providers/providers-routing.module.ts 0.00% 3 Missing ⚠️
...license/bit-web/src/app/billing/providers/index.ts 0.00% 2 Missing ⚠️
...lling/providers/provider-subscription.component.ts 0.00% 2 Missing ⚠️
...rc/app/admin-console/providers/providers.module.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8941      +/-   ##
==========================================
- Coverage   27.75%   27.74%   -0.01%     
==========================================
  Files        2411     2415       +4     
  Lines       69874    69901      +27     
  Branches    13000    13000              
==========================================
+ Hits        19393    19394       +1     
- Misses      48967    48993      +26     
  Partials     1514     1514              

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

import { UserId } from "../../types/guid";
import { ProviderData } from "../models/data/provider.data";
import { Provider } from "../models/domain/provider";

export abstract class ProviderService {
hasConsolidatedBilling$: (id: string) => Observable<boolean>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This observable is less about moving providers to and from state, which is the scope we are trying to keep services at in this level of on admin console code, and is more about applying business logic to a returned observable to filter out unwanted data.

Would you be up for exporting this as a mapping function instead? You can find some examples of how we are doing this in organizationService here. It could be exported from this file, or I'd even say it might be better to export it from some place owned by billing so you don't have to worry about us needing to review changes.

Creating walled gardens between AC and Billing seems like a challenge, so anything we can do to isolate I think is useful to do even if just for that reason.

That said: this particular example has some variables in it that make me wonder how well it'll translate to an essentially static function. Using a feature flag is one example. If you notice or feel like these things stack up in a way that make it not worth it, just let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great suggestion! I've moved this to the provider-billing.service.abstraction file and called it canAccessBilling. It takes the configService dependency as a parameter rather than an injection since I don't actually need a full class yet. Changes here: 4d5dbb1#diff-9ebdce965c4d4d8fbb70b0ae033fdce9629dea1a7c4b16dfb40df8c8d03cb6f9

});
});

describe("get$()", () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the tests!

const configService = inject(ConfigService);
const providerService = inject(ProviderService);

const provider = await providerService.get(route.params.providerId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to use the observable get$ here instead? You'll probably still have to await it since this is a guard, and that's fine, but we are planning to remove the promise based methods on providerService soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah because I'm asyncing everything in this guard I just did firstValueFrom out of the get$ observable. Changes here: 4d5dbb1#diff-9ebdce965c4d4d8fbb70b0ae033fdce9629dea1a7c4b16dfb40df8c8d03cb6f9

@@ -104,6 +89,10 @@ export class ManageClientOrganizationsComponent extends BaseClientsComponent {
}

async load() {
this.provider = await this.providerService.get(this.providerId);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use the observable get$ here instead? We're planning to remove the promise based methods from AC's domain services soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! Missed this one initially but added it here: d8339ac

@amorask-bitwarden amorask-bitwarden merged commit 0b02d2e into main May 3, 2024
61 of 62 checks passed
@amorask-bitwarden amorask-bitwarden deleted the billing/AC-1970/provider-billing-area branch May 3, 2024 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-qa Marks a PR as requiring QA approval
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants