mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-24 05:38:46 +00:00
fix(console): migrate from tslint to eslint, project delete from table (#2490)
* es lint * modify tsconfig, auto lint some stuff * lint * lint * lint * lint * html ts lint * lint * lint, tsconfig * fix project delete, state table * eslint config, remove cnslHint directive * mfa selector, info row fixes * lint * fix login policy, granted orgs table state, lint Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
co-authored by
Florian Forster
parent
bdf63800f7
commit
b1caef81da
@@ -10,7 +10,7 @@
|
||||
<cnsl-label>{{ 'MEMBER.CREATIONTYPE' | translate }}</cnsl-label>
|
||||
<mat-select [(ngModel)]="creationType" (selectionChange)="loadRoles()">
|
||||
<mat-option *ngFor="let type of creationTypes" [value]="type.type"
|
||||
[disabled]="(type.disabled$ | async) == false">
|
||||
[disabled]="(type.disabled$ | async) === false">
|
||||
{{ 'MEMBER.CREATIONTYPES.'+type.type | translate}}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
@@ -19,16 +19,16 @@
|
||||
<ng-container
|
||||
*ngIf="creationType === CreationType.PROJECT_OWNED || creationType === CreationType.PROJECT_GRANTED">
|
||||
<p>{{'PROJECT.GRANT.CREATE.SEL_PROJECT' | translate}}</p>
|
||||
<app-search-project-autocomplete class="block" singleOutput="true"
|
||||
<cnsl-search-project-autocomplete class="block" [singleOutput]="true"
|
||||
(selectionChanged)="selectProject($event)"
|
||||
[autocompleteType]="creationType === CreationType.PROJECT_OWNED ? ProjectAutocompleteType.PROJECT_OWNED : creationType === CreationType.PROJECT_GRANTED ? ProjectAutocompleteType.PROJECT_GRANTED : undefined">
|
||||
</app-search-project-autocomplete>
|
||||
</cnsl-search-project-autocomplete>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
<!-- if no context end -->
|
||||
|
||||
<app-search-user-autocomplete [users]="preselectedUsers" (selectionChanged)="users = $event">
|
||||
</app-search-user-autocomplete>
|
||||
<cnsl-search-user-autocomplete [users]="preselectedUsers" (selectionChanged)="users = $any($event)">
|
||||
</cnsl-search-user-autocomplete>
|
||||
|
||||
<cnsl-form-field class="full-width" appearance="outline"
|
||||
*ngIf="creationType === CreationType.PROJECT_OWNED || creationType === CreationType.PROJECT_GRANTED || creationType === CreationType.IAM">
|
||||
@@ -41,8 +41,8 @@
|
||||
</cnsl-form-field>
|
||||
|
||||
<ng-container *ngIf="creationType === CreationType.ORG">
|
||||
<app-org-member-roles-autocomplete (selectionChanged)="setOrgMemberRoles($event)">
|
||||
</app-org-member-roles-autocomplete>
|
||||
<cnsl-org-member-roles-autocomplete (selectionChanged)="setOrgMemberRoles($event)">
|
||||
</cnsl-org-member-roles-autocomplete>
|
||||
</ng-container>
|
||||
|
||||
</div>
|
||||
@@ -51,7 +51,7 @@
|
||||
{{'ACTIONS.CANCEL' | translate}}
|
||||
</button>
|
||||
|
||||
<button [disabled]="users.length == 0 || roles.length == 0" color="primary" mat-raised-button class="ok-button"
|
||||
<button [disabled]="users.length === 0 || roles.length === 0" color="primary" mat-raised-button class="ok-button"
|
||||
(click)="closeDialogWithSuccess()">
|
||||
{{'ACTIONS.ADD' | translate}}
|
||||
</button>
|
||||
|
||||
@@ -11,115 +11,115 @@ import { ToastService } from 'src/app/services/toast.service';
|
||||
import { ProjectAutocompleteType } from '../search-project-autocomplete/search-project-autocomplete.component';
|
||||
|
||||
export enum CreationType {
|
||||
PROJECT_OWNED = 0,
|
||||
PROJECT_GRANTED = 1,
|
||||
ORG = 2,
|
||||
IAM = 3,
|
||||
PROJECT_OWNED = 0,
|
||||
PROJECT_GRANTED = 1,
|
||||
ORG = 2,
|
||||
IAM = 3,
|
||||
}
|
||||
@Component({
|
||||
selector: 'app-member-create-dialog',
|
||||
templateUrl: './member-create-dialog.component.html',
|
||||
styleUrls: ['./member-create-dialog.component.scss'],
|
||||
selector: 'cnsl-member-create-dialog',
|
||||
templateUrl: './member-create-dialog.component.html',
|
||||
styleUrls: ['./member-create-dialog.component.scss'],
|
||||
})
|
||||
export class MemberCreateDialogComponent {
|
||||
private projectId: string = '';
|
||||
private grantId: string = '';
|
||||
public preselectedUsers: Array<User.AsObject> = [];
|
||||
private projectId: string = '';
|
||||
private grantId: string = '';
|
||||
public preselectedUsers: Array<User.AsObject> = [];
|
||||
|
||||
public creationType!: CreationType;
|
||||
public creationType!: CreationType;
|
||||
|
||||
/**
|
||||
* Specifies options for creating members,
|
||||
* without ending $, to enable write event permission even if user is allowed
|
||||
* to create members for only one specific project.
|
||||
*/
|
||||
public creationTypes: Array<{ type: CreationType, disabled$: Observable<boolean>; }> = [
|
||||
{ type: CreationType.IAM, disabled$: this.authService.isAllowed(['iam.member.write$']) },
|
||||
{ type: CreationType.ORG, disabled$: this.authService.isAllowed(['org.member.write$']) },
|
||||
{ type: CreationType.PROJECT_OWNED, disabled$: this.authService.isAllowed(['project.member.write']) },
|
||||
{ type: CreationType.PROJECT_GRANTED, disabled$: this.authService.isAllowed(['project.grant.member.write']) },
|
||||
];
|
||||
public users: Array<User.AsObject> = [];
|
||||
public roles: Array<Role.AsObject> | string[] = [];
|
||||
public CreationType: any = CreationType;
|
||||
public ProjectAutocompleteType: any = ProjectAutocompleteType;
|
||||
public memberRoleOptions: string[] = [];
|
||||
/**
|
||||
* Specifies options for creating members,
|
||||
* without ending $, to enable write event permission even if user is allowed
|
||||
* to create members for only one specific project.
|
||||
*/
|
||||
public creationTypes: Array<{ type: CreationType, disabled$: Observable<boolean>; }> = [
|
||||
{ type: CreationType.IAM, disabled$: this.authService.isAllowed(['iam.member.write$']) },
|
||||
{ type: CreationType.ORG, disabled$: this.authService.isAllowed(['org.member.write$']) },
|
||||
{ type: CreationType.PROJECT_OWNED, disabled$: this.authService.isAllowed(['project.member.write']) },
|
||||
{ type: CreationType.PROJECT_GRANTED, disabled$: this.authService.isAllowed(['project.grant.member.write']) },
|
||||
];
|
||||
public users: Array<User.AsObject> = [];
|
||||
public roles: Array<Role.AsObject> | string[] = [];
|
||||
public CreationType: any = CreationType;
|
||||
public ProjectAutocompleteType: any = ProjectAutocompleteType;
|
||||
public memberRoleOptions: string[] = [];
|
||||
|
||||
public showCreationTypeSelector: boolean = false;
|
||||
constructor(
|
||||
private mgmtService: ManagementService,
|
||||
private adminService: AdminService,
|
||||
private authService: GrpcAuthService,
|
||||
public dialogRef: MatDialogRef<MemberCreateDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
if (data?.projectId) {
|
||||
this.projectId = data.projectId;
|
||||
}
|
||||
if (data?.user) {
|
||||
this.preselectedUsers = [data.user];
|
||||
this.users = [data.user];
|
||||
}
|
||||
|
||||
if (data?.creationType !== undefined) {
|
||||
this.creationType = data.creationType;
|
||||
this.loadRoles();
|
||||
} else {
|
||||
this.showCreationTypeSelector = true;
|
||||
}
|
||||
public showCreationTypeSelector: boolean = false;
|
||||
constructor(
|
||||
private mgmtService: ManagementService,
|
||||
private adminService: AdminService,
|
||||
private authService: GrpcAuthService,
|
||||
public dialogRef: MatDialogRef<MemberCreateDialogComponent>,
|
||||
@Inject(MAT_DIALOG_DATA) public data: any,
|
||||
private toastService: ToastService,
|
||||
) {
|
||||
if (data?.projectId) {
|
||||
this.projectId = data.projectId;
|
||||
}
|
||||
if (data?.user) {
|
||||
this.preselectedUsers = [data.user];
|
||||
this.users = [data.user];
|
||||
}
|
||||
|
||||
public loadRoles(): void {
|
||||
switch (this.creationType) {
|
||||
case CreationType.PROJECT_GRANTED:
|
||||
this.mgmtService.listProjectGrantMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.resultList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
case CreationType.PROJECT_OWNED:
|
||||
this.mgmtService.listProjectMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.resultList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
case CreationType.IAM:
|
||||
this.adminService.listIAMMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.rolesList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
}
|
||||
if (data?.creationType !== undefined) {
|
||||
this.creationType = data.creationType;
|
||||
this.loadRoles();
|
||||
} else {
|
||||
this.showCreationTypeSelector = true;
|
||||
}
|
||||
}
|
||||
|
||||
public selectProject(project: Project.AsObject | GrantedProject.AsObject | any): void {
|
||||
if (project.projectId && project.grantId) {
|
||||
this.projectId = project.projectId;
|
||||
this.grantId = project.grantId;
|
||||
} else if (project.id) {
|
||||
this.projectId = project.id;
|
||||
}
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
public closeDialogWithSuccess(): void {
|
||||
this.dialogRef.close({
|
||||
users: this.users,
|
||||
roles: this.roles,
|
||||
creationType: this.creationType,
|
||||
projectId: this.projectId,
|
||||
grantId: this.grantId,
|
||||
public loadRoles(): void {
|
||||
switch (this.creationType) {
|
||||
case CreationType.PROJECT_GRANTED:
|
||||
this.mgmtService.listProjectGrantMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.resultList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
case CreationType.PROJECT_OWNED:
|
||||
this.mgmtService.listProjectMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.resultList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
case CreationType.IAM:
|
||||
this.adminService.listIAMMemberRoles().then(resp => {
|
||||
this.memberRoleOptions = resp.rolesList;
|
||||
}).catch(error => {
|
||||
this.toastService.showError(error);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public setOrgMemberRoles(roles: string[]): void {
|
||||
this.roles = roles;
|
||||
public selectProject(project: Project.AsObject | GrantedProject.AsObject | any): void {
|
||||
if (project.projectId && project.grantId) {
|
||||
this.projectId = project.projectId;
|
||||
this.grantId = project.grantId;
|
||||
} else if (project.id) {
|
||||
this.projectId = project.id;
|
||||
}
|
||||
}
|
||||
|
||||
public closeDialog(): void {
|
||||
this.dialogRef.close(false);
|
||||
}
|
||||
|
||||
public closeDialogWithSuccess(): void {
|
||||
this.dialogRef.close({
|
||||
users: this.users,
|
||||
roles: this.roles,
|
||||
creationType: this.creationType,
|
||||
projectId: this.projectId,
|
||||
grantId: this.grantId,
|
||||
});
|
||||
}
|
||||
|
||||
public setOrgMemberRoles(roles: string[]): void {
|
||||
this.roles = roles;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user