1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00
Files
browser/bitwarden_license/bit-web/src/app/secrets-manager/secrets/secrets.component.ts
cd-bitwarden c0810c96cc Adding UUID under the secret name on secrets list (#5773)
* adding UUID under the secret name on secrets list

* thomas' suggested changes

* Adding small attribute to bitbutton

* Copying a secret will work on all pages now that show secrets
2023-08-04 20:18:17 +00:00

104 lines
2.9 KiB
TypeScript

import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { combineLatestWith, Observable, startWith, switchMap } from "rxjs";
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SecretListView } from "../models/view/secret-list.view";
import { SecretsListComponent } from "../shared/secrets-list.component";
import {
SecretDeleteDialogComponent,
SecretDeleteOperation,
} from "./dialog/secret-delete.component";
import {
OperationType,
SecretDialogComponent,
SecretOperation,
} from "./dialog/secret-dialog.component";
import { SecretService } from "./secret.service";
@Component({
selector: "sm-secrets",
templateUrl: "./secrets.component.html",
})
export class SecretsComponent implements OnInit {
protected secrets$: Observable<SecretListView[]>;
protected search: string;
private organizationId: string;
constructor(
private route: ActivatedRoute,
private secretService: SecretService,
private dialogService: DialogServiceAbstraction,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService
) {}
ngOnInit() {
this.secrets$ = this.secretService.secret$.pipe(
startWith(null),
combineLatestWith(this.route.params),
switchMap(async ([_, params]) => {
this.organizationId = params.organizationId;
return await this.getSecrets();
})
);
if (this.route.snapshot.queryParams.search) {
this.search = this.route.snapshot.queryParams.search;
}
}
private async getSecrets(): Promise<SecretListView[]> {
return await this.secretService.getSecrets(this.organizationId);
}
openEditSecret(secretId: string) {
this.dialogService.open<unknown, SecretOperation>(SecretDialogComponent, {
data: {
organizationId: this.organizationId,
operation: OperationType.Edit,
secretId: secretId,
},
});
}
openDeleteSecret(event: SecretListView[]) {
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
data: {
secrets: event,
},
});
}
openNewSecretDialog() {
this.dialogService.open<unknown, SecretOperation>(SecretDialogComponent, {
data: {
organizationId: this.organizationId,
operation: OperationType.Add,
},
});
}
copySecretName(name: string) {
SecretsListComponent.copySecretName(name, this.platformUtilsService, this.i18nService);
}
copySecretValue(id: string) {
SecretsListComponent.copySecretValue(
id,
this.platformUtilsService,
this.i18nService,
this.secretService
);
}
copySecretUuid(id: string) {
SecretsListComponent.copySecretUuid(id, this.platformUtilsService, this.i18nService);
}
}