mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
[SM-470] fix SM edit secret spinner (#4958)
This commit is contained in:
@@ -40,7 +40,7 @@ export class SecretDialogComponent implements OnInit {
|
||||
project: new FormControl("", [Validators.required]),
|
||||
});
|
||||
|
||||
protected loading = false;
|
||||
private loading = true;
|
||||
projects: ProjectListView[];
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
@@ -55,10 +55,6 @@ export class SecretDialogComponent implements OnInit {
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
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();
|
||||
} else if (this.data.operation !== OperationType.Add) {
|
||||
@@ -69,10 +65,14 @@ export class SecretDialogComponent implements OnInit {
|
||||
if (this.data.projectId) {
|
||||
this.formGroup.get("project").setValue(this.data.projectId);
|
||||
}
|
||||
|
||||
this.projects = await this.projectService
|
||||
.getProjects(this.data.organizationId)
|
||||
.then((projects) => projects.sort((a, b) => a.name.localeCompare(b.name)));
|
||||
}
|
||||
|
||||
async loadData() {
|
||||
this.loading = true;
|
||||
this.formGroup.disable();
|
||||
const secret: SecretView = await this.secretService.getBySecretId(this.data.secretId);
|
||||
this.formGroup.setValue({
|
||||
name: secret.name,
|
||||
@@ -81,6 +81,7 @@ export class SecretDialogComponent implements OnInit {
|
||||
project: secret.projects[0]?.id ?? "",
|
||||
});
|
||||
this.loading = false;
|
||||
this.formGroup.enable();
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
@@ -92,6 +93,10 @@ export class SecretDialogComponent implements OnInit {
|
||||
return this.data.operation === OperationType.Add ? "newSecret" : "editSecret";
|
||||
}
|
||||
|
||||
get showSpinner() {
|
||||
return this.data.operation === OperationType.Edit && this.loading;
|
||||
}
|
||||
|
||||
submit = async () => {
|
||||
this.formGroup.markAllAsTouched();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user