1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-02-16 01:21:48 +01:00

[PM-14190] Replace history card with item component (#11775)

This commit is contained in:
✨ Audrey ✨ 2024-10-30 09:43:18 -04:00 committed by GitHub
parent 7ce26f7aea
commit 8af0b6e380
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 25 deletions

View File

@ -1,23 +1,22 @@
<bit-card *ngFor="let credential of credentials$ | async" class="tw-mb-2"> <bit-item *ngFor="let credential of credentials$ | async">
<div class="tw-flex tw-justify-between tw-items-center"> <bit-item-content>
<div class="tw-flex tw-flex-col"> <bit-color-password class="tw-font-mono" [password]="credential.credential" />
<bit-color-password <div slot="secondary">
class="tw-font-mono" {{ credential.generationDate | date: "medium" }}
[password]="credential.credential"
></bit-color-password>
<span class="tw-text-muted" bitTypography="body1">{{
credential.generationDate | date: "medium"
}}</span>
</div> </div>
</bit-item-content>
<ng-container slot="end">
<bit-item-action>
<button <button
bitIconButton="bwi-clone"
bitSuffix
size="small"
type="button" type="button"
bitIconButton="bwi-clone"
[appCopyClick]="credential.credential" [appCopyClick]="credential.credential"
[ariaLabel]="'copyPassword' | i18n" [valueLabel]="getGeneratedValueText(credential)"
[appA11yTitle]="'copyPassword' | i18n" [appA11yTitle]="getCopyText(credential)"
showToast showToast
></button> >
</div> {{ getCopyText(credential) }}
</bit-card> </button>
</bit-item-action>
</ng-container>
</bit-item>

View File

@ -8,15 +8,18 @@ import { JslibModule } from "@bitwarden/angular/jslib.module";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service"; import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { UserId } from "@bitwarden/common/types/guid"; import { UserId } from "@bitwarden/common/types/guid";
import { import {
CardComponent,
ColorPasswordModule, ColorPasswordModule,
IconButtonModule, IconButtonModule,
ItemModule,
NoItemsModule, NoItemsModule,
SectionComponent, SectionComponent,
SectionHeaderComponent, SectionHeaderComponent,
} from "@bitwarden/components"; } from "@bitwarden/components";
import { CredentialGeneratorService } from "@bitwarden/generator-core";
import { GeneratedCredential, GeneratorHistoryService } from "@bitwarden/generator-history"; import { GeneratedCredential, GeneratorHistoryService } from "@bitwarden/generator-history";
import { GeneratorModule } from "./generator.module";
@Component({ @Component({
standalone: true, standalone: true,
selector: "bit-credential-generator-history", selector: "bit-credential-generator-history",
@ -28,9 +31,10 @@ import { GeneratedCredential, GeneratorHistoryService } from "@bitwarden/generat
NoItemsModule, NoItemsModule,
JslibModule, JslibModule,
RouterLink, RouterLink,
CardComponent, ItemModule,
SectionComponent, SectionComponent,
SectionHeaderComponent, SectionHeaderComponent,
GeneratorModule,
], ],
}) })
export class CredentialGeneratorHistoryComponent { export class CredentialGeneratorHistoryComponent {
@ -39,6 +43,7 @@ export class CredentialGeneratorHistoryComponent {
constructor( constructor(
private accountService: AccountService, private accountService: AccountService,
private generatorService: CredentialGeneratorService,
private history: GeneratorHistoryService, private history: GeneratorHistoryService,
) { ) {
this.accountService.activeAccount$ this.accountService.activeAccount$
@ -53,8 +58,18 @@ export class CredentialGeneratorHistoryComponent {
.pipe( .pipe(
takeUntilDestroyed(), takeUntilDestroyed(),
switchMap((id) => id && this.history.credentials$(id)), switchMap((id) => id && this.history.credentials$(id)),
map((credentials) => credentials), map((credentials) => credentials.filter((c) => (c.credential ?? "") !== "")),
) )
.subscribe(this.credentials$); .subscribe(this.credentials$);
} }
protected getCopyText(credential: GeneratedCredential) {
const info = this.generatorService.algorithm(credential.category);
return info.copy;
}
protected getGeneratedValueText(credential: GeneratedCredential) {
const info = this.generatorService.algorithm(credential.category);
return info.generatedValue;
}
} }