mirror of
https://github.com/bitwarden/browser.git
synced 2024-09-27 04:03:00 +02:00
4e1867682f
This PR introduces a generic `DialogService` which can be used by all the clients. This allows us to decouple dialogs from the `PlatformUtilsHelper`. The `DialogService` provides a new method, `openSimpleDialog` which is the new interface for that type of dialogs. This gives us 3 different implementations: - Web: DialogService modern dialogs - Browser: SweetAlert - Desktop: Native electron based
69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { Component, OnDestroy, OnInit } from "@angular/core";
|
|
import { ActivatedRoute } from "@angular/router";
|
|
import { Subject, takeUntil } from "rxjs";
|
|
|
|
import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog";
|
|
|
|
import {
|
|
ProjectDialogComponent,
|
|
ProjectOperation,
|
|
} from "../projects/dialog/project-dialog.component";
|
|
import {
|
|
OperationType,
|
|
SecretDialogComponent,
|
|
SecretOperation,
|
|
} from "../secrets/dialog/secret-dialog.component";
|
|
import {
|
|
ServiceAccountDialogComponent,
|
|
ServiceAccountOperation,
|
|
} from "../service-accounts/dialog/service-account-dialog.component";
|
|
|
|
@Component({
|
|
selector: "sm-new-menu",
|
|
templateUrl: "./new-menu.component.html",
|
|
})
|
|
export class NewMenuComponent implements OnInit, OnDestroy {
|
|
private organizationId: string;
|
|
private destroy$: Subject<void> = new Subject<void>();
|
|
|
|
constructor(private route: ActivatedRoute, private dialogService: DialogServiceAbstraction) {}
|
|
|
|
ngOnInit() {
|
|
this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params: any) => {
|
|
this.organizationId = params.organizationId;
|
|
});
|
|
}
|
|
|
|
ngOnDestroy(): void {
|
|
this.destroy$.next();
|
|
this.destroy$.complete();
|
|
}
|
|
|
|
openSecretDialog() {
|
|
this.dialogService.open<unknown, SecretOperation>(SecretDialogComponent, {
|
|
data: {
|
|
organizationId: this.organizationId,
|
|
operation: OperationType.Add,
|
|
},
|
|
});
|
|
}
|
|
|
|
openProjectDialog() {
|
|
this.dialogService.open<unknown, ProjectOperation>(ProjectDialogComponent, {
|
|
data: {
|
|
organizationId: this.organizationId,
|
|
operation: OperationType.Add,
|
|
},
|
|
});
|
|
}
|
|
|
|
openServiceAccountDialog() {
|
|
this.dialogService.open<unknown, ServiceAccountOperation>(ServiceAccountDialogComponent, {
|
|
data: {
|
|
organizationId: this.organizationId,
|
|
operation: OperationType.Add,
|
|
},
|
|
});
|
|
}
|
|
}
|