- | {{ e.name }} |
+
+ {{ e.name }}
+ |
+
diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/secrets/dialog/secret-dialog.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/secrets/dialog/secret-dialog.component.ts
index 938987b54dc..7a053255ad3 100644
--- a/bitwarden_license/bit-web/src/app/secrets-manager/secrets/dialog/secret-dialog.component.ts
+++ b/bitwarden_license/bit-web/src/app/secrets-manager/secrets/dialog/secret-dialog.component.ts
@@ -1,10 +1,11 @@
import { DialogRef, DIALOG_DATA } from "@angular/cdk/dialog";
import { Component, Inject, OnInit } from "@angular/core";
import { FormControl, FormGroup, Validators } from "@angular/forms";
-import { Subject, takeUntil } from "rxjs";
+import { lastValueFrom, Subject, takeUntil } from "rxjs";
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
+import { DialogService } from "@bitwarden/components";
import { ProjectListView } from "../../models/view/project-list.view";
import { SecretProjectView } from "../../models/view/secret-project.view";
@@ -12,6 +13,8 @@ import { SecretView } from "../../models/view/secret.view";
import { ProjectService } from "../../projects/project.service";
import { SecretService } from "../secret.service";
+import { SecretDeleteDialogComponent, SecretDeleteOperation } from "./secret-delete.component";
+
export enum OperationType {
Add,
Edit,
@@ -47,11 +50,14 @@ export class SecretDialogComponent implements OnInit {
private secretService: SecretService,
private i18nService: I18nService,
private platformUtilsService: PlatformUtilsService,
- private projectService: ProjectService
+ private projectService: ProjectService,
+ private dialogService: DialogService
) {}
async ngOnInit() {
- this.projects = await this.projectService.getProjects(this.data.organizationId);
+ this.projects = await this.projectService
+ .getProjects(this.data.organizationId)
+ .then((projects) => projects.sort((a, b) => a.name.localeCompare(b.name)));
if (this.data.operation === OperationType.Edit && this.data.secretId) {
await this.loadData();
@@ -135,6 +141,26 @@ export class SecretDialogComponent implements OnInit {
this.dialogRef.close();
};
+ get deleteButtonIsVisible(): boolean {
+ return this.data.operation === OperationType.Edit;
+ }
+
+ protected openDeleteSecretDialog() {
+ const dialogRef = this.dialogService.open(
+ SecretDeleteDialogComponent,
+ {
+ data: {
+ secretIds: [this.data.secretId],
+ },
+ }
+ );
+
+ // If the secret is deleted, chain close this dialog after the delete dialog
+ lastValueFrom(dialogRef.closed).then(
+ (closeData) => closeData !== undefined && this.dialogRef.close()
+ );
+ }
+
private async createSecret(secretView: SecretView) {
await this.secretService.create(this.data.organizationId, secretView);
this.platformUtilsService.showToast("success", null, this.i18nService.t("secretCreated"));
diff --git a/libs/components/src/dialog/dialog.service.ts b/libs/components/src/dialog/dialog.service.ts
index b65390c7e3d..fdde775f66d 100644
--- a/libs/components/src/dialog/dialog.service.ts
+++ b/libs/components/src/dialog/dialog.service.ts
@@ -33,7 +33,8 @@ export class DialogService extends Dialog implements OnDestroy {
"tw-bg-black",
"tw-bg-opacity-30",
"tw-inset-0",
- "tw-z-40",
+ // CDK dialog panels have a default z-index of 1000. Matching this allows us to easily stack dialogs.
+ "tw-z-[1000]",
];
constructor(
|