mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-02 18:17:46 +01:00
SM-631: Allow Admins to Create and Edit Unassigned Secrets (#5052)
* SM-631: Allow admins to edit and create unassigned secrets * SM-631: Fix OrganizationService import and refactor project selection logic in getSecretView
This commit is contained in:
parent
c3e87a55d6
commit
8d34bc9ad9
@ -5,6 +5,7 @@ import { lastValueFrom, Subject } from "rxjs";
|
|||||||
|
|
||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
|
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
|
||||||
import { DialogService } from "@bitwarden/components";
|
import { DialogService } from "@bitwarden/components";
|
||||||
|
|
||||||
import { ProjectListView } from "../../models/view/project-list.view";
|
import { ProjectListView } from "../../models/view/project-list.view";
|
||||||
@ -40,11 +41,10 @@ export class SecretDialogComponent implements OnInit {
|
|||||||
project: new FormControl("", [Validators.required]),
|
project: new FormControl("", [Validators.required]),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
private destroy$ = new Subject<void>();
|
||||||
private loading = true;
|
private loading = true;
|
||||||
projects: ProjectListView[];
|
projects: ProjectListView[];
|
||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public dialogRef: DialogRef,
|
public dialogRef: DialogRef,
|
||||||
@Inject(DIALOG_DATA) private data: SecretOperation,
|
@Inject(DIALOG_DATA) private data: SecretOperation,
|
||||||
@ -52,7 +52,8 @@ export class SecretDialogComponent implements OnInit {
|
|||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
private platformUtilsService: PlatformUtilsService,
|
||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private dialogService: DialogService
|
private dialogService: DialogService,
|
||||||
|
private organizationService: OrganizationService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async ngOnInit() {
|
async ngOnInit() {
|
||||||
@ -67,6 +68,11 @@ export class SecretDialogComponent implements OnInit {
|
|||||||
this.formGroup.get("project").setValue(this.data.projectId);
|
this.formGroup.get("project").setValue(this.data.projectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.organizationService.get(this.data.organizationId)?.isAdmin) {
|
||||||
|
this.formGroup.get("project").removeValidators(Validators.required);
|
||||||
|
this.formGroup.get("project").updateValueAndValidity();
|
||||||
|
}
|
||||||
|
|
||||||
this.projects = await this.projectService
|
this.projects = await this.projectService
|
||||||
.getProjects(this.data.organizationId)
|
.getProjects(this.data.organizationId)
|
||||||
.then((projects) => projects.sort((a, b) => a.name.localeCompare(b.name)));
|
.then((projects) => projects.sort((a, b) => a.name.localeCompare(b.name)));
|
||||||
@ -157,7 +163,10 @@ export class SecretDialogComponent implements OnInit {
|
|||||||
secretView.name = this.formGroup.value.name;
|
secretView.name = this.formGroup.value.name;
|
||||||
secretView.value = this.formGroup.value.value;
|
secretView.value = this.formGroup.value.value;
|
||||||
secretView.note = this.formGroup.value.notes;
|
secretView.note = this.formGroup.value.notes;
|
||||||
secretView.projects = [this.projects.find((p) => p.id == this.formGroup.value.project)];
|
|
||||||
|
const project = this.projects.find((p) => p.id == this.formGroup.value.project);
|
||||||
|
secretView.projects = project != undefined ? [project] : [];
|
||||||
|
|
||||||
return secretView;
|
return secretView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user