mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
* refactor: move logic for products into a service - This is in preparation for having having the navigation menu show products based off of the same logic. * add extra small font size to tailwind config * remove absolute positioning from toggle width component - it now sits beneath the product switcher * update product switcher to have UI details that are only shown in the navigation pane * add navigation oriented product switcher * integrate navigation product switcher into secrets manager * integrate navigation product switcher into provider console * integrate navigation product switcher into user layout * integrate navigation product switcher into organizations * add translation for "switch" * hide active styles from navigation product switcher * update storybook for product switcher stories * remove unneeded full width style * use protected readonly variable instead of getter * migrate stories to CSF3 * remove double subscription to `moreProducts$` * only use wrapping div in navigation switcher story - less vertical space is taken up * update to satisfies * refactor `navigationUI` to `otherProductOverrides` * move observables to protected readonly * apply margin-top via class on the host component * remove switch text from the navigation product switcher * Allow for the active navigation switcher to be shown * remove xxs font style * remove unneeded module * remove switch from stories * remove defensive nullish coalescing * remove merge leftovers * Defect PM-7899 - show organizations product at the top of the other products list * Defect PM-7951 use attr.icon to keep the icon as an attribute after prod mode is enabled * Defect PM-7948 update path based on the current org * force active styles for navigation items (#9128) * add horizontal margin to icon --------- Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
81 lines
2.8 KiB
TypeScript
81 lines
2.8 KiB
TypeScript
import { CommonModule } from "@angular/common";
|
|
import { Component, OnDestroy, OnInit } from "@angular/core";
|
|
import { ActivatedRoute, RouterModule } from "@angular/router";
|
|
import { switchMap, Observable, Subject, filter, startWith } from "rxjs";
|
|
import { takeUntil } from "rxjs/operators";
|
|
|
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
|
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
|
|
import { Provider } from "@bitwarden/common/admin-console/models/domain/provider";
|
|
import { canAccessBilling } from "@bitwarden/common/billing/abstractions/provider-billing.service.abstraction";
|
|
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
import { IconModule, LayoutComponent, NavigationModule } from "@bitwarden/components";
|
|
import { ProviderPortalLogo } from "@bitwarden/web-vault/app/admin-console/icons/provider-portal-logo";
|
|
import { PaymentMethodWarningsModule } from "@bitwarden/web-vault/app/billing/shared";
|
|
import { ProductSwitcherModule } from "@bitwarden/web-vault/app/layouts/product-switcher/product-switcher.module";
|
|
import { ToggleWidthComponent } from "@bitwarden/web-vault/app/layouts/toggle-width.component";
|
|
|
|
@Component({
|
|
selector: "providers-layout",
|
|
templateUrl: "providers-layout.component.html",
|
|
standalone: true,
|
|
imports: [
|
|
CommonModule,
|
|
RouterModule,
|
|
JslibModule,
|
|
LayoutComponent,
|
|
IconModule,
|
|
NavigationModule,
|
|
PaymentMethodWarningsModule,
|
|
ToggleWidthComponent,
|
|
ProductSwitcherModule,
|
|
],
|
|
})
|
|
export class ProvidersLayoutComponent implements OnInit, OnDestroy {
|
|
protected readonly logo = ProviderPortalLogo;
|
|
|
|
private destroy$ = new Subject<void>();
|
|
protected provider$: Observable<Provider>;
|
|
protected canAccessBilling$: Observable<boolean>;
|
|
|
|
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
|
|
FeatureFlag.ShowPaymentMethodWarningBanners,
|
|
);
|
|
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private providerService: ProviderService,
|
|
private configService: ConfigService,
|
|
) {}
|
|
|
|
ngOnInit() {
|
|
document.body.classList.remove("layout_frontend");
|
|
|
|
this.provider$ = this.route.params.pipe(
|
|
switchMap((params) => this.providerService.get$(params.providerId)),
|
|
takeUntil(this.destroy$),
|
|
);
|
|
|
|
this.canAccessBilling$ = this.provider$.pipe(
|
|
filter((provider) => !!provider),
|
|
canAccessBilling(this.configService),
|
|
startWith(false),
|
|
takeUntil(this.destroy$),
|
|
);
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.destroy$.next();
|
|
this.destroy$.complete();
|
|
}
|
|
|
|
showManageTab(provider: Provider) {
|
|
return provider.canManageUsers || provider.canAccessEventLogs;
|
|
}
|
|
|
|
showSettingsTab(provider: Provider) {
|
|
return provider.isProviderAdmin;
|
|
}
|
|
}
|