Skip to content

Commit

Permalink
[SM-660] move sm-no-items to CL (#5059)
Browse files Browse the repository at this point in the history
* refactor: move sm-no-items to CL

* update and run prettier

* apply code review
  • Loading branch information
willmartian committed Apr 7, 2023
1 parent 2ad739b commit 36de1c8
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 26 deletions.
Expand Up @@ -2,7 +2,7 @@
<i class="bwi bwi-spinner bwi-spin bwi-3x"></i>
</div>

<sm-no-items *ngIf="tokens?.length == 0">
<bit-no-items *ngIf="tokens?.length == 0">
<ng-container slot="title">{{ "accessTokensNoItemsTitle" | i18n }}</ng-container>
<ng-container slot="description">{{ "accessTokensNoItemsDesc" | i18n }}</ng-container>
<button
Expand All @@ -15,7 +15,7 @@
<i class="bwi bwi-plus" aria-hidden="true"></i>
{{ "newAccessToken" | i18n }}
</button>
</sm-no-items>
</bit-no-items>

<bit-table *ngIf="tokens?.length >= 1">
<ng-container header>
Expand Down
Expand Up @@ -2,7 +2,7 @@
<i class="bwi bwi-spinner bwi-spin bwi-3x"></i>
</div>

<sm-no-items *ngIf="serviceAccounts?.length == 0">
<bit-no-items *ngIf="serviceAccounts?.length == 0">
<ng-container slot="title">{{ "serviceAccountsNoItemsTitle" | i18n }}</ng-container>
<ng-container slot="description">{{ "serviceAccountsNoItemsMessage" | i18n }}</ng-container>
<button
Expand All @@ -15,7 +15,7 @@
<i class="bwi bwi-plus" aria-hidden="true"></i>
{{ "newServiceAccount" | i18n }}
</button>
</sm-no-items>
</bit-no-items>

<bit-table *ngIf="serviceAccounts?.length >= 1" [dataSource]="dataSource">
<ng-container header>
Expand Down

This file was deleted.

Expand Up @@ -2,7 +2,7 @@
<i class="bwi bwi-spinner bwi-spin bwi-3x"></i>
</div>

<sm-no-items *ngIf="projects?.length == 0">
<bit-no-items *ngIf="projects?.length == 0">
<ng-container slot="title">{{ "projectsNoItemsTitle" | i18n }}</ng-container>
<ng-container slot="description">{{ "projectsNoItemsMessage" | i18n }}</ng-container>
<button
Expand All @@ -15,7 +15,7 @@
<i class="bwi bwi-plus" aria-hidden="true"></i>
{{ "newProject" | i18n }}
</button>
</sm-no-items>
</bit-no-items>

<bit-table *ngIf="projects?.length >= 1" [dataSource]="dataSource">
<ng-container header>
Expand Down
Expand Up @@ -3,11 +3,11 @@
</div>

<ng-container *ngIf="secrets?.length == 0">
<sm-no-items *ngIf="trash">
<bit-no-items *ngIf="trash">
<ng-container slot="title">{{ "secretsNoItemsTitle" | i18n }}</ng-container>
<ng-container slot="description">{{ "secretsTrashNoItemsMessage" | i18n }}</ng-container>
</sm-no-items>
<sm-no-items *ngIf="!trash">
</bit-no-items>
<bit-no-items *ngIf="!trash">
<ng-container slot="title">{{ "secretsNoItemsTitle" | i18n }}</ng-container>
<ng-container slot="description">{{ "secretsNoItemsMessage" | i18n }}</ng-container>
<button
Expand All @@ -20,7 +20,7 @@
<i class="bwi bwi-plus" aria-hidden="true"></i>
{{ "newSecret" | i18n }}
</button>
</sm-no-items>
</bit-no-items>
</ng-container>

<bit-table *ngIf="secrets?.length >= 1" [dataSource]="dataSource">
Expand Down
@@ -1,6 +1,6 @@
import { NgModule } from "@angular/core";

import { MultiSelectModule } from "@bitwarden/components";
import { MultiSelectModule, NoItemsModule } from "@bitwarden/components";
import { CoreOrganizationModule } from "@bitwarden/web-vault/app/admin-console/organizations/core";
import { ProductSwitcherModule } from "@bitwarden/web-vault/app/layouts/product-switcher/product-switcher.module";
import { SharedModule } from "@bitwarden/web-vault/app/shared";
Expand All @@ -10,19 +10,24 @@ import { AccessRemovalDialogComponent } from "./access-policies/dialogs/access-r
import { BulkStatusDialogComponent } from "./dialogs/bulk-status-dialog.component";
import { HeaderComponent } from "./header.component";
import { NewMenuComponent } from "./new-menu.component";
import { NoItemsComponent } from "./no-items.component";
import { ProjectsListComponent } from "./projects-list.component";
import { SecretsListComponent } from "./secrets-list.component";

@NgModule({
imports: [SharedModule, ProductSwitcherModule, MultiSelectModule, CoreOrganizationModule],
imports: [
SharedModule,
ProductSwitcherModule,
MultiSelectModule,
CoreOrganizationModule,
NoItemsModule,
],
exports: [
SharedModule,
NoItemsModule,
AccessRemovalDialogComponent,
BulkStatusDialogComponent,
HeaderComponent,
NewMenuComponent,
NoItemsComponent,
ProjectsListComponent,
SecretsListComponent,
AccessSelectorComponent,
Expand All @@ -32,7 +37,6 @@ import { SecretsListComponent } from "./secrets-list.component";
BulkStatusDialogComponent,
HeaderComponent,
NewMenuComponent,
NoItemsComponent,
ProjectsListComponent,
SecretsListComponent,
AccessSelectorComponent,
Expand Down
1 change: 1 addition & 0 deletions libs/components/src/index.ts
Expand Up @@ -16,6 +16,7 @@ export * from "./link";
export * from "./menu";
export * from "./multi-select";
export * from "./navigation";
export * from "./no-items";
export * from "./progress";
export * from "./radio-button";
export * from "./table";
Expand Down
1 change: 1 addition & 0 deletions libs/components/src/no-items/index.ts
@@ -0,0 +1 @@
export * from "./no-items.module";
14 changes: 14 additions & 0 deletions libs/components/src/no-items/no-items.component.ts
@@ -0,0 +1,14 @@
import { Component } from "@angular/core";

import { Icons } from "..";

/**
* Component for displaying a message when there are no items to display. Expects title, description and button slots.
*/
@Component({
selector: "bit-no-items",
templateUrl: "./no-items.component.html",
})
export class NoItemsComponent {
protected icon = Icons.Search;
}
13 changes: 13 additions & 0 deletions libs/components/src/no-items/no-items.module.ts
@@ -0,0 +1,13 @@
import { CommonModule } from "@angular/common";
import { NgModule } from "@angular/core";

import { IconModule } from "../icon";

import { NoItemsComponent } from "./no-items.component";

@NgModule({
imports: [CommonModule, IconModule],
exports: [NoItemsComponent],
declarations: [NoItemsComponent],
})
export class NoItemsModule {}
35 changes: 35 additions & 0 deletions libs/components/src/no-items/no-items.stories.ts
@@ -0,0 +1,35 @@
import { Meta, moduleMetadata, Story } from "@storybook/angular";

import { ButtonModule } from "../button";

import { NoItemsModule } from "./no-items.module";

export default {
title: "Component Library/No Items",
decorators: [
moduleMetadata({
imports: [ButtonModule, NoItemsModule],
}),
],
} as Meta;

const Template: Story = (args) => ({
props: args,
template: `
<bit-no-items class="tw-text-main">
<ng-container slot="title">No items found</ng-container>
<ng-container slot="description">Your description here.</ng-container>
<button
slot="button"
type="button"
bitButton
buttonType="secondary"
>
<i class="bwi bwi-plus" aria-hidden="true"></i>
New item
</button>
</bit-no-items>
`,
});

export const Default = Template.bind({});

0 comments on commit 36de1c8

Please sign in to comment.