1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

[SM-611] Fix edit dialog & overview secrets refresh (#4951)

* Fix edit dialog

* Have secrets list refresh during project deletion

* Fix input required for init edit

* Fixing delete prompt for edit dialog
This commit is contained in:
Thomas Avery 2023-03-07 17:59:52 -06:00 committed by GitHub
parent 85cd419d5c
commit 720b61076a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 7 deletions

View File

@ -116,7 +116,11 @@ export class OverviewComponent implements OnInit, OnDestroy {
share() share()
); );
const secrets$ = combineLatest([orgId$, this.secretService.secret$.pipe(startWith(null))]).pipe( const secrets$ = combineLatest([
orgId$,
this.secretService.secret$.pipe(startWith(null)),
this.projectService.project$.pipe(startWith(null)),
]).pipe(
switchMap(([orgId]) => this.secretService.getSecrets(orgId)), switchMap(([orgId]) => this.secretService.getSecrets(orgId)),
share() share()
); );

View File

@ -46,7 +46,7 @@ export class SecretDeleteDialogComponent {
if (bulkResponses.find((response) => response.errorMessage)) { if (bulkResponses.find((response) => response.errorMessage)) {
this.openBulkStatusDialog(bulkResponses.filter((response) => response.errorMessage)); this.openBulkStatusDialog(bulkResponses.filter((response) => response.errorMessage));
this.dialogRef.close(); this.dialogRef.close(true);
return; return;
} }
@ -54,7 +54,7 @@ export class SecretDeleteDialogComponent {
this.data.secrets.length === 1 ? "softDeleteSuccessToast" : "softDeletesSuccessToast"; this.data.secrets.length === 1 ? "softDeleteSuccessToast" : "softDeletesSuccessToast";
this.platformUtilsService.showToast("success", null, this.i18nService.t(message)); this.platformUtilsService.showToast("success", null, this.i18nService.t(message));
this.dialogRef.close(); this.dialogRef.close(true);
}; };
openBulkStatusDialog(bulkStatusResults: BulkOperationStatus[]) { openBulkStatusDialog(bulkStatusResults: BulkOperationStatus[]) {
@ -62,7 +62,7 @@ export class SecretDeleteDialogComponent {
data: { data: {
title: "deleteSecrets", title: "deleteSecrets",
subTitle: "secrets", subTitle: "secrets",
columnTitle: "secretName", columnTitle: "name",
message: "bulkDeleteSecretsErrorMessage", message: "bulkDeleteSecretsErrorMessage",
details: bulkStatusResults, details: bulkStatusResults,
}, },

View File

@ -78,7 +78,7 @@ export class SecretDialogComponent implements OnInit {
name: secret.name, name: secret.name,
value: secret.value, value: secret.value,
notes: secret.note, notes: secret.note,
project: secret.projects[0]?.id, project: secret.projects[0]?.id ?? "",
}); });
this.loading = false; this.loading = false;
} }
@ -154,12 +154,18 @@ export class SecretDialogComponent implements OnInit {
private getSecretListView() { private getSecretListView() {
const secretListViews: SecretListView[] = []; const secretListViews: SecretListView[] = [];
const emptyProjects: SecretProjectView[] = []; const emptyProjects: SecretProjectView[] = [];
const selectedProject = [this.projects.find((p) => p.id == this.formGroup.value.project)];
const secretListView = new SecretListView(); const secretListView = new SecretListView();
if (this.formGroup.value.project) {
secretListView.projects = [this.projects.find((p) => p.id == this.formGroup.value.project)];
} else {
secretListView.projects = emptyProjects;
}
secretListView.organizationId = this.data.organizationId; secretListView.organizationId = this.data.organizationId;
secretListView.id = this.data.secretId;
secretListView.name = this.formGroup.value.name; secretListView.name = this.formGroup.value.name;
secretListView.projects = selectedProject ? selectedProject : emptyProjects;
secretListViews.push(secretListView); secretListViews.push(secretListView);
return secretListViews; return secretListViews;
} }