fix(console): role assignment manipulation #10517 (#11756)

# Which Problems Are Solved

The management console deletes all roles if user grant is not
manipulated before saving in the dialog.


# How the Problems Are Solved

Correctly prefill the selected role assignments so when no change was
done we keep the current state.

# Additional Changes

- Prevents displaying misleading error messages to users when a role
assignment operation results in no actual changes.

# Additional Context

- Closes #10517

Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
Ramon
2026-03-10 12:59:44 +00:00
committed by GitHub
co-authored by Max Peintner
parent defa7b5d0e
commit 33c635fbc3
5 changed files with 102 additions and 77 deletions
@@ -1,6 +1,15 @@
import { Component, Inject } from '@angular/core';
import { Component, inject, Inject, signal } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
export type UserGrantRoleDialogData = {
projectId: string;
grantId?: string;
selectedRoleKeysList: string[];
i18nTitle: string;
};
export type UserGrantRoleDialogResult = { roles: string[] };
@Component({
selector: 'cnsl-user-grant-role-dialog',
templateUrl: './user-grant-role-dialog.component.html',
@@ -8,30 +17,19 @@ import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
standalone: false,
})
export class UserGrantRoleDialogComponent {
public projectId: string = '';
public grantId: string = '';
public selectedRoleKeysList: string[] = [];
public selectedRoleKeys: string[] = [];
constructor(
public dialogRef: MatDialogRef<UserGrantRoleDialogComponent>,
@Inject(MAT_DIALOG_DATA) public data: any,
) {
this.projectId = data.projectId;
this.grantId = data.grantId;
this.selectedRoleKeysList = data.selectedRoleKeysList;
}
protected readonly data: UserGrantRoleDialogData = inject(MAT_DIALOG_DATA);
private readonly dialogRef: MatDialogRef<UserGrantRoleDialogComponent, UserGrantRoleDialogResult> = inject(MatDialogRef);
private readonly selectedRoleKeys = signal([...this.data.selectedRoleKeysList]);
public selectRoles(selected: string[]): void {
this.selectedRoleKeys = selected;
this.selectedRoleKeys.set(selected);
}
public closeDialog(): void {
this.dialogRef.close(false);
this.dialogRef.close();
}
public closeDialogWithSuccess(): void {
this.dialogRef.close({ roles: this.selectedRoleKeys });
this.dialogRef.close({ roles: this.selectedRoleKeys() });
}
}