1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00

Create web specific layout

This commit is contained in:
Hinton 2024-05-16 16:44:08 +02:00
parent 07076ebf9d
commit 123c1841a4
No known key found for this signature in database
GPG Key ID: 5F7295599C5D965C
11 changed files with 114 additions and 139 deletions

View File

@ -1,9 +1,5 @@
<bit-layout variant="secondary"> <app-layout variant="secondary">
<nav <ng-container slot="sidebar" *ngIf="organization$ | async as organization">
slot="sidebar"
*ngIf="organization$ | async as organization"
class="tw-flex tw-flex-col tw-h-full"
>
<a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'adminConsole' | i18n"> <a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'adminConsole' | i18n">
<bit-icon [icon]="logo"></bit-icon> <bit-icon [icon]="logo"></bit-icon>
</a> </a>
@ -109,11 +105,7 @@
*ngIf="organization.canManageScim" *ngIf="organization.canManageScim"
></bit-nav-item> ></bit-nav-item>
</bit-nav-group> </bit-nav-group>
</ng-container>
<navigation-product-switcher class="tw-mt-auto"></navigation-product-switcher>
<app-toggle-width></app-toggle-width>
</nav>
<ng-container *ngIf="organization$ | async as organization"> <ng-container *ngIf="organization$ | async as organization">
<bit-banner <bit-banner
@ -123,10 +115,7 @@
> >
{{ "accessingUsingProvider" | i18n: organization.providerName }} {{ "accessingUsingProvider" | i18n: organization.providerName }}
</bit-banner> </bit-banner>
<app-payment-method-warnings
*ngIf="showPaymentMethodWarningBanners$ | async"
></app-payment-method-warnings>
</ng-container> </ng-container>
<router-outlet></router-outlet> <router-outlet></router-outlet>
</bit-layout> </app-layout>

View File

@ -18,15 +18,11 @@ import {
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { PolicyType } from "@bitwarden/common/admin-console/enums"; import { PolicyType } from "@bitwarden/common/admin-console/enums";
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { BannerModule, IconModule, LayoutComponent, NavigationModule } from "@bitwarden/components"; import { BannerModule, IconModule, NavigationModule } from "@bitwarden/components";
import { PaymentMethodWarningsModule } from "../../../billing/shared";
import { OrgSwitcherComponent } from "../../../layouts/org-switcher/org-switcher.component"; import { OrgSwitcherComponent } from "../../../layouts/org-switcher/org-switcher.component";
import { ProductSwitcherModule } from "../../../layouts/product-switcher/product-switcher.module"; import { WebLayoutComponent } from "../../../layouts/web-layout.component";
import { ToggleWidthComponent } from "../../../layouts/toggle-width.component";
import { AdminConsoleLogo } from "../../icons/admin-console-logo"; import { AdminConsoleLogo } from "../../icons/admin-console-logo";
@Component({ @Component({
@ -37,14 +33,11 @@ import { AdminConsoleLogo } from "../../icons/admin-console-logo";
CommonModule, CommonModule,
RouterModule, RouterModule,
JslibModule, JslibModule,
LayoutComponent, WebLayoutComponent,
IconModule, IconModule,
NavigationModule, NavigationModule,
OrgSwitcherComponent, OrgSwitcherComponent,
BannerModule, BannerModule,
PaymentMethodWarningsModule,
ToggleWidthComponent,
ProductSwitcherModule,
], ],
}) })
export class OrganizationLayoutComponent implements OnInit, OnDestroy { export class OrganizationLayoutComponent implements OnInit, OnDestroy {
@ -58,15 +51,10 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
private _destroy = new Subject<void>(); private _destroy = new Subject<void>();
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
FeatureFlag.ShowPaymentMethodWarningBanners,
);
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService,
private configService: ConfigService,
private policyService: PolicyService, private policyService: PolicyService,
) {} ) {}

View File

@ -1,5 +1,5 @@
<bit-layout> <app-layout>
<nav slot="sidebar" class="tw-flex tw-flex-col tw-h-full"> <ng-container slot="sidebar">
<a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'passwordManager' | i18n"> <a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'passwordManager' | i18n">
<bit-icon [icon]="logo"></bit-icon> <bit-icon [icon]="logo"></bit-icon>
</a> </a>
@ -32,13 +32,7 @@
*ngIf="hasFamilySponsorshipAvailable$ | async" *ngIf="hasFamilySponsorshipAvailable$ | async"
></bit-nav-item> ></bit-nav-item>
</bit-nav-group> </bit-nav-group>
</ng-container>
<navigation-product-switcher class="tw-mt-auto"></navigation-product-switcher>
<app-toggle-width></app-toggle-width>
</nav>
<app-payment-method-warnings
*ngIf="showPaymentMethodWarningBanners$ | async"
></app-payment-method-warnings>
<router-outlet></router-outlet> <router-outlet></router-outlet>
</bit-layout> </app-layout>

View File

@ -7,17 +7,12 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service"; import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction"; import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { IconModule, LayoutComponent, NavigationModule } from "@bitwarden/components"; import { IconModule, NavigationModule } from "@bitwarden/components";
import { PaymentMethodWarningsModule } from "../billing/shared";
import { PasswordManagerLogo } from "./password-manager-logo"; import { PasswordManagerLogo } from "./password-manager-logo";
import { ProductSwitcherModule } from "./product-switcher/product-switcher.module"; import { WebLayoutComponent } from "./web-layout.component";
import { ToggleWidthComponent } from "./toggle-width.component";
@Component({ @Component({
selector: "app-user-layout", selector: "app-user-layout",
@ -27,12 +22,9 @@ import { ToggleWidthComponent } from "./toggle-width.component";
CommonModule, CommonModule,
RouterModule, RouterModule,
JslibModule, JslibModule,
LayoutComponent, WebLayoutComponent,
IconModule, IconModule,
NavigationModule, NavigationModule,
PaymentMethodWarningsModule,
ToggleWidthComponent,
ProductSwitcherModule,
], ],
}) })
export class UserLayoutComponent implements OnInit { export class UserLayoutComponent implements OnInit {
@ -40,16 +32,11 @@ export class UserLayoutComponent implements OnInit {
protected hasFamilySponsorshipAvailable$: Observable<boolean>; protected hasFamilySponsorshipAvailable$: Observable<boolean>;
protected showSubscription$: Observable<boolean>; protected showSubscription$: Observable<boolean>;
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
FeatureFlag.ShowPaymentMethodWarningBanners,
);
constructor( constructor(
private platformUtilsService: PlatformUtilsService, private platformUtilsService: PlatformUtilsService,
private organizationService: OrganizationService, private organizationService: OrganizationService,
private apiService: ApiService, private apiService: ApiService,
private syncService: SyncService, private syncService: SyncService,
private configService: ConfigService,
private billingAccountProfileStateService: BillingAccountProfileStateService, private billingAccountProfileStateService: BillingAccountProfileStateService,
) {} ) {}

View File

@ -0,0 +1,14 @@
<bit-layout [variant]="variant">
<nav slot="sidebar" class="tw-flex tw-flex-col tw-h-full">
<ng-content select="[slot=sidebar]"></ng-content>
<navigation-product-switcher class="tw-mt-auto"></navigation-product-switcher>
<app-toggle-width></app-toggle-width>
</nav>
<app-payment-method-warnings
*ngIf="showPaymentMethodWarningBanners$ | async"
></app-payment-method-warnings>
<ng-content></ng-content>
</bit-layout>

View File

@ -0,0 +1,33 @@
import { CommonModule } from "@angular/common";
import { Component, Input } from "@angular/core";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { LayoutComponent, LayoutVariant } from "@bitwarden/components";
import { PaymentMethodWarningsModule } from "../billing/shared";
import { ProductSwitcherModule } from "./product-switcher/product-switcher.module";
import { ToggleWidthComponent } from "./toggle-width.component";
@Component({
selector: "app-layout",
templateUrl: "web-layout.component.html",
standalone: true,
imports: [
CommonModule,
LayoutComponent,
ProductSwitcherModule,
ToggleWidthComponent,
PaymentMethodWarningsModule,
],
})
export class WebLayoutComponent {
@Input() variant: LayoutVariant = "primary";
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
FeatureFlag.ShowPaymentMethodWarningBanners,
);
constructor(private configService: ConfigService) {}
}

View File

@ -1,5 +1,5 @@
<bit-layout variant="secondary"> <app-layout variant="secondary">
<nav slot="sidebar" *ngIf="provider$ | async as provider" class="tw-flex tw-flex-col tw-h-full"> <ng-container slot="sidebar" *ngIf="provider$ | async as provider">
<a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'providerPortal' | i18n"> <a routerLink="." class="tw-m-5 tw-mt-7 tw-block" [appA11yTitle]="'providerPortal' | i18n">
<bit-icon [icon]="logo"></bit-icon> <bit-icon [icon]="logo"></bit-icon>
</a> </a>
@ -40,13 +40,7 @@
route="settings" route="settings"
*ngIf="showSettingsTab(provider)" *ngIf="showSettingsTab(provider)"
></bit-nav-item> ></bit-nav-item>
</ng-container>
<navigation-product-switcher class="tw-mt-auto"></navigation-product-switcher>
<app-toggle-width></app-toggle-width>
</nav>
<app-payment-method-warnings
*ngIf="showPaymentMethodWarningBanners$ | async"
></app-payment-method-warnings>
<router-outlet></router-outlet> <router-outlet></router-outlet>
</bit-layout> </app-layout>

View File

@ -8,13 +8,10 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service"; import { ProviderService } from "@bitwarden/common/admin-console/abstractions/provider.service";
import { Provider } from "@bitwarden/common/admin-console/models/domain/provider"; import { Provider } from "@bitwarden/common/admin-console/models/domain/provider";
import { canAccessBilling } from "@bitwarden/common/billing/abstractions/provider-billing.service.abstraction"; 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 { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
import { IconModule, LayoutComponent, NavigationModule } from "@bitwarden/components"; import { IconModule, NavigationModule } from "@bitwarden/components";
import { ProviderPortalLogo } from "@bitwarden/web-vault/app/admin-console/icons/provider-portal-logo"; import { ProviderPortalLogo } from "@bitwarden/web-vault/app/admin-console/icons/provider-portal-logo";
import { PaymentMethodWarningsModule } from "@bitwarden/web-vault/app/billing/shared"; import { WebLayoutComponent } from "@bitwarden/web-vault/app/layouts/web-layout.component";
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({ @Component({
selector: "providers-layout", selector: "providers-layout",
@ -24,12 +21,9 @@ import { ToggleWidthComponent } from "@bitwarden/web-vault/app/layouts/toggle-wi
CommonModule, CommonModule,
RouterModule, RouterModule,
JslibModule, JslibModule,
LayoutComponent, WebLayoutComponent,
IconModule, IconModule,
NavigationModule, NavigationModule,
PaymentMethodWarningsModule,
ToggleWidthComponent,
ProductSwitcherModule,
], ],
}) })
export class ProvidersLayoutComponent implements OnInit, OnDestroy { export class ProvidersLayoutComponent implements OnInit, OnDestroy {
@ -39,10 +33,6 @@ export class ProvidersLayoutComponent implements OnInit, OnDestroy {
protected provider$: Observable<Provider>; protected provider$: Observable<Provider>;
protected canAccessBilling$: Observable<boolean>; protected canAccessBilling$: Observable<boolean>;
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
FeatureFlag.ShowPaymentMethodWarningBanners,
);
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
private providerService: ProviderService, private providerService: ProviderService,

View File

@ -1,4 +1,4 @@
<bit-layout> <app-layout>
<router-outlet slot="sidebar" name="sidebar"></router-outlet> <router-outlet slot="sidebar" name="sidebar"></router-outlet>
<router-outlet></router-outlet> <router-outlet></router-outlet>
</bit-layout> </app-layout>

View File

@ -1,23 +1,15 @@
import { NgModule } from "@angular/core"; import { NgModule } from "@angular/core";
import { LayoutComponent as BitLayoutComponent, NavigationModule } from "@bitwarden/components"; import { NavigationModule } from "@bitwarden/components";
import { OrgSwitcherComponent } from "@bitwarden/web-vault/app/layouts/org-switcher/org-switcher.component"; import { OrgSwitcherComponent } from "@bitwarden/web-vault/app/layouts/org-switcher/org-switcher.component";
import { ProductSwitcherModule } from "@bitwarden/web-vault/app/layouts/product-switcher/product-switcher.module"; import { WebLayoutComponent } from "@bitwarden/web-vault/app/layouts/web-layout.component";
import { ToggleWidthComponent } from "@bitwarden/web-vault/app/layouts/toggle-width.component";
import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module"; import { SharedModule } from "@bitwarden/web-vault/app/shared/shared.module";
import { LayoutComponent } from "./layout.component"; import { LayoutComponent } from "./layout.component";
import { NavigationComponent } from "./navigation.component"; import { NavigationComponent } from "./navigation.component";
@NgModule({ @NgModule({
imports: [ imports: [SharedModule, NavigationModule, WebLayoutComponent, OrgSwitcherComponent],
SharedModule,
NavigationModule,
BitLayoutComponent,
OrgSwitcherComponent,
ToggleWidthComponent,
ProductSwitcherModule,
],
declarations: [LayoutComponent, NavigationComponent], declarations: [LayoutComponent, NavigationComponent],
}) })
export class LayoutModule {} export class LayoutModule {}

View File

@ -1,54 +1,48 @@
<nav class="tw-flex tw-flex-col tw-h-full"> <a routerLink="." class="tw-m-5 tw-mt-7 tw-block">
<a routerLink="." class="tw-m-5 tw-mt-7 tw-block"> <bit-icon [icon]="logo"></bit-icon>
<bit-icon [icon]="logo"></bit-icon> </a>
</a>
<org-switcher [filter]="orgFilter" [hideNewButton]="true"></org-switcher> <org-switcher [filter]="orgFilter" [hideNewButton]="true"></org-switcher>
<bit-nav-item
icon="bwi-collection"
[text]="'projects' | i18n"
route="projects"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
icon="bwi-key"
[text]="'secrets' | i18n"
route="secrets"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
icon="bwi-wrench"
[text]="'machineAccounts' | i18n"
route="machine-accounts"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
icon="bwi-providers"
[text]="'integrations' | i18n"
route="integrations"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
icon="bwi-trash"
[text]="'trash' | i18n"
route="trash"
[relativeTo]="route.parent"
*ngIf="isAdmin$ | async"
></bit-nav-item>
<bit-nav-group icon="bwi-cog" [text]="'settings' | i18n" *ngIf="isAdmin$ | async">
<bit-nav-item <bit-nav-item
icon="bwi-collection" [text]="'importData' | i18n"
[text]="'projects' | i18n" route="settings/import"
route="projects"
[relativeTo]="route.parent" [relativeTo]="route.parent"
></bit-nav-item> ></bit-nav-item>
<bit-nav-item <bit-nav-item
icon="bwi-key" [text]="'exportData' | i18n"
[text]="'secrets' | i18n" route="settings/export"
route="secrets"
[relativeTo]="route.parent" [relativeTo]="route.parent"
></bit-nav-item> ></bit-nav-item>
<bit-nav-item </bit-nav-group>
icon="bwi-wrench"
[text]="'machineAccounts' | i18n"
route="machine-accounts"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
icon="bwi-providers"
[text]="'integrations' | i18n"
route="integrations"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
icon="bwi-trash"
[text]="'trash' | i18n"
route="trash"
[relativeTo]="route.parent"
*ngIf="isAdmin$ | async"
></bit-nav-item>
<bit-nav-group icon="bwi-cog" [text]="'settings' | i18n" *ngIf="isAdmin$ | async">
<bit-nav-item
[text]="'importData' | i18n"
route="settings/import"
[relativeTo]="route.parent"
></bit-nav-item>
<bit-nav-item
[text]="'exportData' | i18n"
route="settings/export"
[relativeTo]="route.parent"
></bit-nav-item>
</bit-nav-group>
<navigation-product-switcher class="tw-mt-auto"></navigation-product-switcher>
<app-toggle-width></app-toggle-width>
</nav>