1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 16:53:34 +00:00

[SM-670] Restrict UI actions based on user permission (#5090)

* Restrict UI actions based on user permission

* Swap to hiding bulk option without permission

* Fix read/write assignment in project service

* Filter projects based on permission in dialog

* Fix encryption error for updating secret result

* Fix spinner (#5182)

* Swap to bit-no-items

* [SM-699] Projects bulk delete - add bulk confirmation dialog (#5200)

* Add bulk confirmation dialog

* Code review updates

* Code review - load projects

* code review - swap to observable

* Code review - remove oninit
This commit is contained in:
Thomas Avery
2023-04-26 13:09:30 -05:00
committed by GitHub
parent 95b1ea318c
commit 208e3f30b4
18 changed files with 259 additions and 88 deletions

View File

@@ -62,6 +62,8 @@ export class SecretDialogComponent implements OnInit {
} else if (this.data.operation !== OperationType.Add) {
this.dialogRef.close();
throw new Error(`The secret dialog was not called with the appropriate operation values.`);
} else if (this.data.operation == OperationType.Add) {
await this.loadProjects(true);
}
if (this.data.projectId) {
@@ -72,15 +74,14 @@ export class SecretDialogComponent implements OnInit {
this.formGroup.get("project").removeValidators(Validators.required);
this.formGroup.get("project").updateValueAndValidity();
}
this.projects = await this.projectService
.getProjects(this.data.organizationId)
.then((projects) => projects.sort((a, b) => a.name.localeCompare(b.name)));
}
async loadData() {
this.formGroup.disable();
const secret: SecretView = await this.secretService.getBySecretId(this.data.secretId);
await this.loadProjects(secret.write);
this.formGroup.setValue({
name: secret.name,
value: secret.value,
@@ -95,6 +96,16 @@ export class SecretDialogComponent implements OnInit {
}
}
async loadProjects(filterByPermission: boolean) {
this.projects = await this.projectService
.getProjects(this.data.organizationId)
.then((projects) => projects.sort((a, b) => a.name.localeCompare(b.name)));
if (filterByPermission) {
this.projects = this.projects.filter((p) => p.write);
}
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();