fix(console): display granted org name in authorizations and show user information (#7116)

* fix: add granted org info to user grants query response

* fix: show user info, tests and add columns to user grant

* fix: add check for org membership

* fix: typo in find logic

---------

Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
Miguel Cabrerizo
2024-01-24 11:36:04 +01:00
committed by GitHub
parent 94b3799690
commit d590da7c7d
20 changed files with 208 additions and 19 deletions

View File

@@ -109,7 +109,7 @@
<ng-container matColumnDef="org">
<th mat-header-cell *matHeaderCellDef>{{ 'PROJECT.GRANT.ORG' | translate }}</th>
<td mat-cell *matCellDef="let grant">
{{ grant.orgName }}
{{ grant.grantedOrgName }}
</td>
</ng-container>
@@ -169,7 +169,7 @@
<i class="las la-trash"></i>
</button>
<button menuActions mat-menu-item [routerLink]="['/users', grant.userId]">
<button menuActions mat-menu-item (click)="showUser(grant)">
{{ 'ACTIONS.TABLE.SHOWUSER' | translate: { value: grant.displayName } }}
</button>
</cnsl-table-actions>

View File

@@ -8,7 +8,7 @@ import { tap } from 'rxjs/operators';
import { enterAnimations } from 'src/app/animations';
import { UserGrant as AuthUserGrant } from 'src/app/proto/generated/zitadel/auth_pb';
import { Role } from 'src/app/proto/generated/zitadel/project_pb';
import { Type, UserGrant as MgmtUserGrant, UserGrantQuery } from 'src/app/proto/generated/zitadel/user_pb';
import { Type, UserGrant as MgmtUserGrant, UserGrantQuery, UserGrant } from 'src/app/proto/generated/zitadel/user_pb';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ManagementService } from 'src/app/services/mgmt.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -18,6 +18,7 @@ import { PageEvent, PaginatorComponent } from '../paginator/paginator.component'
import { UserGrantRoleDialogComponent } from '../user-grant-role-dialog/user-grant-role-dialog.component';
import { WarnDialogComponent } from '../warn-dialog/warn-dialog.component';
import { UserGrantContext, UserGrantsDataSource } from './user-grants-datasource';
import { Org, OrgState } from 'src/app/proto/generated/zitadel/org_pb';
export enum UserGrantListSearchKey {
DISPLAY_NAME,
@@ -68,6 +69,7 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
@Input() public type: Type | undefined = undefined;
public filterOpen: boolean = false;
public myOrgs: Array<Org.AsObject> = [];
constructor(
private authService: GrpcAuthService,
private userService: ManagementService,
@@ -115,6 +117,9 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
}
this.loadGrantsPage(this.type);
this.authService.listMyProjectOrgs(undefined, 0).then((orgs) => {
this.myOrgs = orgs.resultList;
});
}
public ngAfterViewInit(): void {
@@ -300,4 +305,21 @@ export class UserGrantsComponent implements OnInit, AfterViewInit {
this.loadGrantsPage(this.type);
}
}
public showUser(grant: UserGrant.AsObject) {
const org: Org.AsObject = {
id: grant.grantedOrgId,
name: grant.grantedOrgName,
state: OrgState.ORG_STATE_ACTIVE,
primaryDomain: grant.grantedOrgDomain,
};
// Check if user has permissions for that org before changing active org
if (this.myOrgs.find((org) => org.id === grant.grantedOrgId)) {
this.authService.setActiveOrg(org);
this.router.navigate(['/users', grant.userId]);
} else {
this.toast.showInfo('GRANTS.TOAST.CANTSHOWINFO', true);
}
}
}

View File

@@ -2227,7 +2227,8 @@
"TOAST": {
"UPDATED": "Упълномощаването е актуализирано.",
"REMOVED": "Упълномощаването е премахнато",
"BULKREMOVED": "Разрешенията са премахнати."
"BULKREMOVED": "Разрешенията са премахнати.",
"CANTSHOWINFO": "Не можете да посетите профила на този потребител, тъй като не сте член на организацията, към която принадлежи този потребител"
},
"DIALOG": {
"DELETE_TITLE": "Изтриване на разрешението",

View File

@@ -2246,7 +2246,8 @@
"TOAST": {
"UPDATED": "Autorizace aktualizována.",
"REMOVED": "Autorizace odebrána",
"BULKREMOVED": "Autorizace odebrány."
"BULKREMOVED": "Autorizace odebrány.",
"CANTSHOWINFO": "Nemůžete navštívit profil tohoto uživatele, protože nejste členem organizace, do které tento uživatel patří"
},
"DIALOG": {
"DELETE_TITLE": "Smazat autorizaci",

View File

@@ -2236,7 +2236,8 @@
"TOAST": {
"UPDATED": "Berechtigung geändert.",
"REMOVED": "Berechtigung entfernt.",
"BULKREMOVED": "Berechtigungen entfernt."
"BULKREMOVED": "Berechtigungen entfernt.",
"CANTSHOWINFO": "Sie können das Profil dieses Benutzers nicht besuchen, da Sie kein Mitglied der Organisation sind, zu der dieser Benutzer gehört"
},
"DIALOG": {
"DELETE_TITLE": "Authorisierung löschen",

View File

@@ -2255,7 +2255,8 @@
"TOAST": {
"UPDATED": "Authorization updated.",
"REMOVED": "Authorization removed",
"BULKREMOVED": "Authorizations removed."
"BULKREMOVED": "Authorizations removed.",
"CANTSHOWINFO": "You cannot visit this user's profile as you are not a member of the organization where this user belongs to"
},
"DIALOG": {
"DELETE_TITLE": "Delete authorization",

View File

@@ -2234,7 +2234,8 @@
"TOAST": {
"UPDATED": "Autorización actualizada.",
"REMOVED": "Autorización eliminada",
"BULKREMOVED": "Autorizaciones eliminadas."
"BULKREMOVED": "Autorizaciones eliminadas.",
"CANTSHOWINFO": "No puedes visitar el perfil de este usuario porque no eres miembro de la organización a la que pertenece este usuario."
},
"DIALOG": {
"DELETE_TITLE": "Borrar autorización",

View File

@@ -2237,7 +2237,8 @@
"TOAST": {
"UPDATED": "Autorisation mise à jour.",
"REMOVED": "Autorisation supprimée",
"BULKREMOVED": "Autorisations supprimées."
"BULKREMOVED": "Autorisations supprimées.",
"CANTSHOWINFO": "Vous ne pouvez pas visiter le profil de cet utilisateur car vous n'êtes pas membre de l'organisation à laquelle appartient cet utilisateur."
},
"DIALOG": {
"DELETE_TITLE": "Supprimer une autorisation",

View File

@@ -2237,7 +2237,8 @@
"TOAST": {
"UPDATED": "Autorizzazione aggiornata.",
"REMOVED": "Autorizzazione rimossa con successo.",
"BULKREMOVED": "Autorizzazioni rimossi con successo."
"BULKREMOVED": "Autorizzazioni rimossi con successo.",
"CANTSHOWINFO": "Non puoi visitare il profilo di questo utente poiché non sei un membro dell'organizzazione a cui appartiene questo utente"
},
"DIALOG": {
"DELETE_TITLE": "Elima autorizzazione",

View File

@@ -2228,7 +2228,8 @@
"TOAST": {
"UPDATED": "認可が更新されました。",
"REMOVED": "認可が削除されました",
"BULKREMOVED": "認可が削除されました。"
"BULKREMOVED": "認可が削除されました。",
"CANTSHOWINFO": "このユーザーが所属する組織のメンバーではないため、このユーザーのプロフィールにアクセスできません"
},
"DIALOG": {
"DELETE_TITLE": "認可の削除",

View File

@@ -2234,7 +2234,8 @@
"TOAST": {
"UPDATED": "Овластувањето е ажурирано.",
"REMOVED": "Овластувањето е отстрането",
"BULKREMOVED": "Овластувањата се отстранети."
"BULKREMOVED": "Овластувањата се отстранети.",
"CANTSHOWINFO": "Не можете да го посетите профилот на овој корисник бидејќи не сте член на организацијата каде што припаѓа овој корисник"
},
"DIALOG": {
"DELETE_TITLE": "Избриши овластување",

View File

@@ -2255,7 +2255,8 @@
"TOAST": {
"UPDATED": "Autorisatie bijgewerkt.",
"REMOVED": "Autorisatie verwijderd",
"BULKREMOVED": "Autorisaties verwijderd."
"BULKREMOVED": "Autorisaties verwijderd.",
"CANTSHOWINFO": "U kunt het profiel van deze gebruiker niet bezoeken omdat u geen lid bent van de organisatie waartoe deze gebruiker behoort"
},
"DIALOG": {
"DELETE_TITLE": "Verwijder autorisatie",

View File

@@ -2237,7 +2237,8 @@
"TOAST": {
"UPDATED": "Autoryzacja zaktualizowana.",
"REMOVED": "Autoryzacja usunięta",
"BULKREMOVED": "Autoryzacje usunięte."
"BULKREMOVED": "Autoryzacje usunięte.",
"CANTSHOWINFO": "Nie możesz odwiedzić profilu tego użytkownika, ponieważ nie jesteś członkiem organizacji, do której należy ten użytkownik"
},
"DIALOG": {
"DELETE_TITLE": "Usuń autoryzację",

View File

@@ -2232,7 +2232,8 @@
"TOAST": {
"UPDATED": "Autorização atualizada.",
"REMOVED": "Autorização removida",
"BULKREMOVED": "Autorizações removidas."
"BULKREMOVED": "Autorizações removidas.",
"CANTSHOWINFO": "Você não pode visitar o perfil deste usuário porque não é membro da organização à qual esse usuário pertence"
},
"DIALOG": {
"DELETE_TITLE": "Excluir autorização",

View File

@@ -2226,7 +2226,8 @@
"TOAST": {
"UPDATED": "Авторизация обновлена.",
"REMOVED": "Авторизация удалена",
"BULKREMOVED": "Авторизации удалены."
"BULKREMOVED": "Авторизации удалены.",
"CANTSHOWINFO": "Вы не можете посетить профиль этого пользователя, поскольку вы не являетесь членом организации, к которой принадлежит этот пользователь."
},
"DIALOG": {
"DELETE_TITLE": "Удалить авторизацию",

View File

@@ -2236,7 +2236,8 @@
"TOAST": {
"UPDATED": "授权已更新。",
"REMOVED": "已移除授权。",
"BULKREMOVED": "已移除授权。"
"BULKREMOVED": "已移除授权。",
"CANTSHOWINFO": "您无法访问该用户的个人资料,因为您不是该用户所属组织的成员"
},
"DIALOG": {
"DELETE_TITLE": "删除授权",