1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-21 16:18:28 +01:00

Move SM header into web (#6976)

This commit is contained in:
Oscar Hinton 2023-12-11 18:22:37 +01:00 committed by GitHub
parent 29841605fb
commit a40643d9d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 68 additions and 51 deletions

View File

@ -0,0 +1,14 @@
import { NgModule } from "@angular/core";
import { DynamicAvatarComponent } from "../../components/dynamic-avatar.component";
import { SharedModule } from "../../shared";
import { ProductSwitcherModule } from "../product-switcher/product-switcher.module";
import { WebHeaderComponent } from "./web-header.component";
@NgModule({
imports: [SharedModule, DynamicAvatarComponent, ProductSwitcherModule],
declarations: [WebHeaderComponent],
exports: [WebHeaderComponent],
})
export class HeaderModule {}

View File

@ -10,10 +10,10 @@ import { StateService } from "@bitwarden/common/platform/abstractions/state.serv
import { AccountProfile } from "@bitwarden/common/platform/models/domain/account"; import { AccountProfile } from "@bitwarden/common/platform/models/domain/account";
@Component({ @Component({
selector: "sm-header", selector: "app-header",
templateUrl: "./header.component.html", templateUrl: "./web-header.component.html",
}) })
export class HeaderComponent { export class WebHeaderComponent {
/** /**
* Custom title that overrides the route data `titleId` * Custom title that overrides the route data `titleId`
*/ */

View File

@ -1,3 +1,4 @@
import { CommonModule } from "@angular/common";
import { Component, Injectable, importProvidersFrom } from "@angular/core"; import { Component, Injectable, importProvidersFrom } from "@angular/core";
import { RouterModule } from "@angular/router"; import { RouterModule } from "@angular/router";
import { import {
@ -27,9 +28,9 @@ import {
TypographyModule, TypographyModule,
InputModule, InputModule,
} from "@bitwarden/components"; } from "@bitwarden/components";
import { PreloadedEnglishI18nModule } from "@bitwarden/web-vault/app/core/tests";
import { HeaderComponent } from "./header.component"; import { PreloadedEnglishI18nModule } from "../../core/tests";
import { WebHeaderComponent } from "../header/web-header.component";
@Injectable({ @Injectable({
providedIn: "root", providedIn: "root",
@ -66,6 +67,8 @@ class MockProductSwitcher {}
@Component({ @Component({
selector: "dynamic-avatar", selector: "dynamic-avatar",
template: `<bit-avatar [text]="name$ | async"></bit-avatar>`, template: `<bit-avatar [text]="name$ | async"></bit-avatar>`,
standalone: true,
imports: [CommonModule, AvatarModule],
}) })
class MockDynamicAvatar { class MockDynamicAvatar {
protected name$ = combineLatest([ protected name$ = combineLatest([
@ -81,7 +84,7 @@ class MockDynamicAvatar {
export default { export default {
title: "Web/Header", title: "Web/Header",
component: HeaderComponent, component: WebHeaderComponent,
decorators: [ decorators: [
componentWrapperDecorator( componentWrapperDecorator(
(story) => `<div class="tw-min-h-screen tw-flex-1 tw-p-6 tw-text-main">${story}</div>`, (story) => `<div class="tw-min-h-screen tw-flex-1 tw-p-6 tw-text-main">${story}</div>`,
@ -89,7 +92,6 @@ export default {
moduleMetadata({ moduleMetadata({
imports: [ imports: [
JslibModule, JslibModule,
RouterModule,
AvatarModule, AvatarModule,
BreadcrumbsModule, BreadcrumbsModule,
ButtonModule, ButtonModule,
@ -100,8 +102,9 @@ export default {
TabsModule, TabsModule,
TypographyModule, TypographyModule,
NavigationModule, NavigationModule,
MockDynamicAvatar,
], ],
declarations: [HeaderComponent, MockProductSwitcher, MockDynamicAvatar], declarations: [WebHeaderComponent, MockProductSwitcher],
providers: [ providers: [
{ provide: StateService, useClass: MockStateService }, { provide: StateService, useClass: MockStateService },
{ provide: PlatformUtilsService, useClass: MockPlatformUtilsService }, { provide: PlatformUtilsService, useClass: MockPlatformUtilsService },
@ -126,7 +129,7 @@ export default {
export const KitchenSink: Story = (args) => ({ export const KitchenSink: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="LongTitleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" icon="bwi-bug"> <app-header title="LongTitleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" icon="bwi-bug">
<bit-breadcrumbs slot="breadcrumbs"> <bit-breadcrumbs slot="breadcrumbs">
<bit-breadcrumb>Foo</bit-breadcrumb> <bit-breadcrumb>Foo</bit-breadcrumb>
<bit-breadcrumb>Bar</bit-breadcrumb> <bit-breadcrumb>Bar</bit-breadcrumb>
@ -142,75 +145,75 @@ export const KitchenSink: Story = (args) => ({
<bit-tab-link route="">Foo</bit-tab-link> <bit-tab-link route="">Foo</bit-tab-link>
<bit-tab-link route="#bar">Bar</bit-tab-link> <bit-tab-link route="#bar">Bar</bit-tab-link>
</bit-tab-nav-bar> </bit-tab-nav-bar>
</sm-header> </app-header>
`, `,
}); });
export const Basic: Story = (args) => ({ export const Basic: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="Foobar" icon="bwi-bug"></sm-header> <app-header title="Foobar" icon="bwi-bug"></app-header>
`, `,
}); });
export const WithLongTitle: Story = (args) => ({ export const WithLongTitle: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="LongTitleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" icon="bwi-bug"></sm-header> <app-header title="LongTitleeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee" icon="bwi-bug"></app-header>
`, `,
}); });
export const WithBreadcrumbs: Story = (args) => ({ export const WithBreadcrumbs: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="Foobar" icon="bwi-bug" class="tw-text-main"> <app-header title="Foobar" icon="bwi-bug" class="tw-text-main">
<bit-breadcrumbs slot="breadcrumbs"> <bit-breadcrumbs slot="breadcrumbs">
<bit-breadcrumb>Foo</bit-breadcrumb> <bit-breadcrumb>Foo</bit-breadcrumb>
<bit-breadcrumb>Bar</bit-breadcrumb> <bit-breadcrumb>Bar</bit-breadcrumb>
</bit-breadcrumbs> </bit-breadcrumbs>
</sm-header> </app-header>
`, `,
}); });
export const WithSearch: Story = (args) => ({ export const WithSearch: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="Foobar" icon="bwi-bug" class="tw-text-main"> <app-header title="Foobar" icon="bwi-bug" class="tw-text-main">
<input <input
bitInput bitInput
placeholder="Ask Jeeves" placeholder="Ask Jeeves"
type="text" type="text"
/> />
</sm-header> </app-header>
`, `,
}); });
export const WithSecondaryContent: Story = (args) => ({ export const WithSecondaryContent: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="Foobar" icon="bwi-bug" class="tw-text-main"> <app-header title="Foobar" icon="bwi-bug" class="tw-text-main">
<button bitButton slot="secondary">Click Me 🎉</button> <button bitButton slot="secondary">Click Me 🎉</button>
</sm-header> </app-header>
`, `,
}); });
export const WithTabs: Story = (args) => ({ export const WithTabs: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="Foobar" icon="bwi-bug" class="tw-text-main"> <app-header title="Foobar" icon="bwi-bug" class="tw-text-main">
<bit-tab-nav-bar slot="tabs"> <bit-tab-nav-bar slot="tabs">
<bit-tab-link route="">Foo</bit-tab-link> <bit-tab-link route="">Foo</bit-tab-link>
<bit-tab-link route="#bar">Bar</bit-tab-link> <bit-tab-link route="#bar">Bar</bit-tab-link>
</bit-tab-nav-bar> </bit-tab-nav-bar>
</sm-header> </app-header>
`, `,
}); });
export const WithCustomTitleComponent: Story = (args) => ({ export const WithCustomTitleComponent: Story = (args) => ({
props: args, props: args,
template: ` template: `
<sm-header title="Foobar" icon="bwi-bug" class="tw-text-main"> <app-header title="Foobar" icon="bwi-bug" class="tw-text-main">
<h1 slot="title" class="tw-text-3xl tw-font-semibold" style="font-family: 'Comic Sans MS'">Bitwarden</h1> <h1 slot="title" class="tw-text-3xl tw-font-semibold" style="font-family: 'Comic Sans MS'">Bitwarden</h1>
</sm-header> </app-header>
`, `,
}); });

View File

@ -1,6 +1,6 @@
<sm-header [title]="organizationName"> <app-header [title]="organizationName">
<sm-new-menu></sm-new-menu> <sm-new-menu></sm-new-menu>
</sm-header> </app-header>
<div *ngIf="!loading && view$ | async as view; else spinner"> <div *ngIf="!loading && view$ | async as view; else spinner">
<sm-onboarding [title]="'getStarted' | i18n" *ngIf="showOnboarding" (dismiss)="hideOnboarding()"> <sm-onboarding [title]="'getStarted' | i18n" *ngIf="showOnboarding" (dismiss)="hideOnboarding()">

View File

@ -1,4 +1,4 @@
<sm-header *ngIf="project$ | async as project" [title]="project.name" icon="bwi-collection"> <app-header *ngIf="project$ | async as project" [title]="project.name" icon="bwi-collection">
<bit-breadcrumbs slot="breadcrumbs"> <bit-breadcrumbs slot="breadcrumbs">
<bit-breadcrumb [route]="['..']" icon="bwi-angle-left">{{ "projects" | i18n }}</bit-breadcrumb> <bit-breadcrumb [route]="['..']" icon="bwi-angle-left">{{ "projects" | i18n }}</bit-breadcrumb>
</bit-breadcrumbs> </bit-breadcrumbs>
@ -20,5 +20,5 @@
> >
{{ "editProject" | i18n }} {{ "editProject" | i18n }}
</button> </button>
</sm-header> </app-header>
<router-outlet></router-outlet> <router-outlet></router-outlet>

View File

@ -1,11 +1,11 @@
<sm-header> <app-header>
<bit-search <bit-search
[placeholder]="'searchProjects' | i18n" [placeholder]="'searchProjects' | i18n"
[(ngModel)]="search" [(ngModel)]="search"
class="tw-w-80" class="tw-w-80"
></bit-search> ></bit-search>
<sm-new-menu></sm-new-menu> <sm-new-menu></sm-new-menu>
</sm-header> </app-header>
<sm-projects-list <sm-projects-list
(newProjectEvent)="openNewProjectDialog()" (newProjectEvent)="openNewProjectDialog()"
(editProjectEvent)="openEditProject($event)" (editProjectEvent)="openEditProject($event)"

View File

@ -1,11 +1,11 @@
<sm-header> <app-header>
<bit-search <bit-search
[placeholder]="'searchSecrets' | i18n" [placeholder]="'searchSecrets' | i18n"
[(ngModel)]="search" [(ngModel)]="search"
class="tw-w-80" class="tw-w-80"
></bit-search> ></bit-search>
<sm-new-menu></sm-new-menu> <sm-new-menu></sm-new-menu>
</sm-header> </app-header>
<sm-secrets-list <sm-secrets-list
(deleteSecretsEvent)="openDeleteSecret($event)" (deleteSecretsEvent)="openDeleteSecret($event)"
(newSecretEvent)="openNewSecretDialog()" (newSecretEvent)="openNewSecretDialog()"

View File

@ -1,4 +1,4 @@
<sm-header <app-header
*ngIf="serviceAccount$ | async as serviceAccount" *ngIf="serviceAccount$ | async as serviceAccount"
[title]="serviceAccount.name" [title]="serviceAccount.name"
icon="bwi-wrench" icon="bwi-wrench"
@ -25,5 +25,5 @@
<i class="bwi bwi-plus" aria-hidden="true"></i> <i class="bwi bwi-plus" aria-hidden="true"></i>
{{ "newAccessToken" | i18n }} {{ "newAccessToken" | i18n }}
</button> </button>
</sm-header> </app-header>
<router-outlet></router-outlet> <router-outlet></router-outlet>

View File

@ -1,11 +1,11 @@
<sm-header> <app-header>
<bit-search <bit-search
[placeholder]="'searchServiceAccounts' | i18n" [placeholder]="'searchServiceAccounts' | i18n"
[(ngModel)]="search" [(ngModel)]="search"
class="tw-w-80" class="tw-w-80"
></bit-search> ></bit-search>
<sm-new-menu></sm-new-menu> <sm-new-menu></sm-new-menu>
</sm-header> </app-header>
<sm-service-accounts-list <sm-service-accounts-list
[serviceAccounts]="serviceAccounts$ | async" [serviceAccounts]="serviceAccounts$ | async"
(newServiceAccountEvent)="openNewServiceAccountDialog()" (newServiceAccountEvent)="openNewServiceAccountDialog()"

View File

@ -1,4 +1,4 @@
<sm-header></sm-header> <app-header></app-header>
<form [formGroup]="formGroup" [bitSubmit]="submit"> <form [formGroup]="formGroup" [bitSubmit]="submit">
<div class="tw-my-4 tw-max-w-xl"> <div class="tw-my-4 tw-max-w-xl">

View File

@ -1,4 +1,4 @@
<sm-header></sm-header> <app-header></app-header>
<form [formGroup]="formGroup" [bitSubmit]="submit" class="tw-max-w-xl"> <form [formGroup]="formGroup" [bitSubmit]="submit" class="tw-max-w-xl">
<bit-form-field> <bit-form-field>

View File

@ -1,6 +1,6 @@
<sm-header [title]="organizationName$ | async"> <app-header [title]="organizationName$ | async">
<sm-new-menu></sm-new-menu> <sm-new-menu></sm-new-menu>
</sm-header> </app-header>
<bit-no-items [icon]="NoAccess"> <bit-no-items [icon]="NoAccess">
<ng-container slot="title">{{ "organizationIsDisabled" | i18n }}</ng-container> <ng-container slot="title">{{ "organizationIsDisabled" | i18n }}</ng-container>
<ng-container slot="description">{{ "secretsAccessSuspended" | i18n }}</ng-container> <ng-container slot="description">{{ "secretsAccessSuspended" | i18n }}</ng-container>

View File

@ -8,6 +8,7 @@ import {
} from "@bitwarden/components"; } from "@bitwarden/components";
import { CoreOrganizationModule } from "@bitwarden/web-vault/app/admin-console/organizations/core"; import { CoreOrganizationModule } from "@bitwarden/web-vault/app/admin-console/organizations/core";
import { DynamicAvatarComponent } from "@bitwarden/web-vault/app/components/dynamic-avatar.component"; import { DynamicAvatarComponent } from "@bitwarden/web-vault/app/components/dynamic-avatar.component";
import { HeaderModule } from "@bitwarden/web-vault/app/layouts/header/header.module";
import { ProductSwitcherModule } from "@bitwarden/web-vault/app/layouts/product-switcher/product-switcher.module"; import { ProductSwitcherModule } from "@bitwarden/web-vault/app/layouts/product-switcher/product-switcher.module";
import { SharedModule } from "@bitwarden/web-vault/app/shared"; import { SharedModule } from "@bitwarden/web-vault/app/shared";
@ -15,7 +16,6 @@ import { AccessPolicySelectorComponent } from "./access-policies/access-policy-s
import { AccessSelectorComponent } from "./access-policies/access-selector.component"; import { AccessSelectorComponent } from "./access-policies/access-selector.component";
import { BulkConfirmationDialogComponent } from "./dialogs/bulk-confirmation-dialog.component"; import { BulkConfirmationDialogComponent } from "./dialogs/bulk-confirmation-dialog.component";
import { BulkStatusDialogComponent } from "./dialogs/bulk-status-dialog.component"; import { BulkStatusDialogComponent } from "./dialogs/bulk-status-dialog.component";
import { HeaderComponent } from "./header.component";
import { NewMenuComponent } from "./new-menu.component"; import { NewMenuComponent } from "./new-menu.component";
import { OrgSuspendedComponent } from "./org-suspended.component"; import { OrgSuspendedComponent } from "./org-suspended.component";
import { ProjectsListComponent } from "./projects-list.component"; import { ProjectsListComponent } from "./projects-list.component";
@ -31,16 +31,16 @@ import { SecretsListComponent } from "./secrets-list.component";
SelectModule, SelectModule,
DynamicAvatarComponent, DynamicAvatarComponent,
SearchModule, SearchModule,
HeaderModule,
], ],
exports: [ exports: [
SharedModule,
NoItemsModule,
AccessSelectorComponent,
AccessPolicySelectorComponent, AccessPolicySelectorComponent,
BulkStatusDialogComponent, AccessSelectorComponent,
BulkConfirmationDialogComponent, BulkConfirmationDialogComponent,
HeaderComponent, BulkStatusDialogComponent,
HeaderModule,
NewMenuComponent, NewMenuComponent,
NoItemsModule,
ProjectsListComponent, ProjectsListComponent,
SearchModule, SearchModule,
SecretsListComponent, SecretsListComponent,
@ -48,15 +48,15 @@ import { SecretsListComponent } from "./secrets-list.component";
SharedModule, SharedModule,
], ],
declarations: [ declarations: [
BulkStatusDialogComponent, AccessPolicySelectorComponent,
AccessSelectorComponent,
BulkConfirmationDialogComponent, BulkConfirmationDialogComponent,
HeaderComponent, BulkStatusDialogComponent,
BulkStatusDialogComponent,
NewMenuComponent, NewMenuComponent,
OrgSuspendedComponent,
ProjectsListComponent, ProjectsListComponent,
SecretsListComponent, SecretsListComponent,
AccessSelectorComponent,
OrgSuspendedComponent,
AccessPolicySelectorComponent,
], ],
providers: [], providers: [],
bootstrap: [], bootstrap: [],

View File

@ -1,6 +1,6 @@
<sm-header> <app-header>
<sm-new-menu></sm-new-menu> <sm-new-menu></sm-new-menu>
</sm-header> </app-header>
<bit-callout type="warning" [title]="'warning' | i18n">{{ <bit-callout type="warning" [title]="'warning' | i18n">{{
"trashCleanupWarning" | i18n "trashCleanupWarning" | i18n
}}</bit-callout> }}</bit-callout>