feat: rehauled console (#3525)

* new console

* move npm ci to angular build

* rel path for assets

* local grpc copy

* login policy, rm clear views, features rel path

* lock

Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
Max Peintner
2022-04-28 10:35:02 +00:00
committed by GitHub
co-authored by Livio Amstutz
parent 00f7dbe875
commit 08ae39ae19
668 changed files with 47746 additions and 19117 deletions
@@ -1,58 +1,49 @@
<h1 mat-dialog-title>
<span class="title">{{'MEMBER.ADD' | translate}}</span>
<span class="title">{{'MEMBER.ADD' | translate}}</span>
</h1>
<p class="desc"> {{'ORG_DETAIL.MEMBER.ADDDESCRIPTION' | translate}}</p>
<p class="desc cnsl-secondary-text"> {{'ORG_DETAIL.MEMBER.ADDDESCRIPTION' | translate}}</p>
<div mat-dialog-content>
<!-- if no context -->
<ng-container *ngIf="showCreationTypeSelector">
<cnsl-form-field class="full-width" appearance="outline">
<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">
{{ 'MEMBER.CREATIONTYPES.'+type.type | translate}}
</mat-option>
</mat-select>
</cnsl-form-field>
<ng-container
*ngIf="creationType === CreationType.PROJECT_OWNED || creationType === CreationType.PROJECT_GRANTED">
<p>{{'PROJECT.GRANT.CREATE.SEL_PROJECT' | translate}}</p>
<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">
</cnsl-search-project-autocomplete>
</ng-container>
</ng-container>
<!-- if no context end -->
<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">
<cnsl-label>{{ 'ROLESLABEL' | translate }}</cnsl-label>
<mat-select [(ngModel)]="roles" multiple>
<mat-option *ngFor="let role of memberRoleOptions" [value]="role">
{{ role }}
</mat-option>
</mat-select>
<ng-container *ngIf="showCreationTypeSelector">
<cnsl-form-field class="full-width" appearance="outline">
<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">
{{ 'MEMBER.CREATIONTYPES.'+type.type | translate}}
</mat-option>
</mat-select>
</cnsl-form-field>
<ng-container *ngIf="creationType === CreationType.ORG">
<cnsl-org-member-roles-autocomplete (selectionChanged)="setOrgMemberRoles($event)">
</cnsl-org-member-roles-autocomplete>
<ng-container *ngIf="creationType === CreationType.PROJECT_OWNED || creationType === CreationType.PROJECT_GRANTED">
<p>{{'PROJECT.GRANT.CREATE.SEL_PROJECT' | translate}}</p>
<cnsl-search-project-autocomplete class="block" (selectionChanged)="selectProject($event)"
[autocompleteType]="creationType === CreationType.PROJECT_OWNED ? ProjectAutocompleteType.PROJECT_OWNED : creationType === CreationType.PROJECT_GRANTED ? ProjectAutocompleteType.PROJECT_GRANTED : undefined">
</cnsl-search-project-autocomplete>
</ng-container>
</ng-container>
<cnsl-search-user-autocomplete [users]="preselectedUsers" (selectionChanged)="users = $any($event)">
</cnsl-search-user-autocomplete>
<div class="roles-selection">
<mat-checkbox class="role-cb" *ngFor="let role of memberRoleOptions" color="primary" (change)="toggleRole(role)"
[checked]="roles.includes(role)">
<div class="role-cb-content">
<div class="cnsl-chip-dot" [style.background]="getColor(role)"></div>
<span>{{role | roletransform}}</span>
</div>
</mat-checkbox>
</div>
</div>
<div mat-dialog-actions class="action">
<button mat-button (click)="closeDialog()">
{{'ACTIONS.CANCEL' | translate}}
</button>
<button mat-stroked-button (click)="closeDialog()">
{{'ACTIONS.CANCEL' | translate}}
</button>
<button [disabled]="users.length === 0 || roles.length === 0" color="primary" mat-raised-button class="ok-button"
(click)="closeDialogWithSuccess()">
{{'ACTIONS.ADD' | translate}}
</button>
<button [disabled]="users.length === 0 || roles.length === 0" color="primary" mat-raised-button class="ok-button"
(click)="closeDialogWithSuccess()">
{{'ACTIONS.ADD' | translate}}
</button>
</div>
@@ -3,19 +3,34 @@
}
.desc {
color: var(--grey);
font-size: .9rem;
font-size: 0.9rem;
}
.full-width {
width: 100%;
.roles-selection {
display: flex;
flex-direction: column;
max-height: 400px;
overflow-y: auto;
box-sizing: border-box;
.role-cb {
padding: 0.25rem 0;
box-sizing: border-box;
.role-cb-content {
padding-left: 0.5rem;
display: flex;
flex-direction: row;
align-items: center;
}
}
}
.action {
display: flex;
justify-content: flex-end;
justify-content: space-between;
.ok-button {
margin-left: .5rem;
margin-left: 0.5rem;
}
}
@@ -1,12 +1,13 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { Observable } from 'rxjs';
import { GrantedProject, Project, Role } from 'src/app/proto/generated/zitadel/project_pb';
import { GrantedProject, Project } from 'src/app/proto/generated/zitadel/project_pb';
import { User } from 'src/app/proto/generated/zitadel/user_pb';
import { AdminService } from 'src/app/services/admin.service';
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';
import { getMembershipColor } from 'src/app/utils/color';
import { ProjectAutocompleteType } from '../search-project-autocomplete/search-project-autocomplete.component';
@@ -33,14 +34,14 @@ export class MemberCreateDialogComponent {
* 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>; }> = [
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 roles: string[] = [];
public CreationType: any = CreationType;
public ProjectAutocompleteType: any = ProjectAutocompleteType;
public memberRoleOptions: string[] = [];
@@ -72,26 +73,45 @@ export class MemberCreateDialogComponent {
public loadRoles(): void {
switch (this.creationType) {
case CreationType.ORG:
this.mgmtService
.listOrgMemberRoles()
.then((resp) => {
this.memberRoleOptions = resp.resultList;
})
.catch((error) => {
this.toastService.showError(error);
});
break;
case CreationType.PROJECT_GRANTED:
this.mgmtService.listProjectGrantMemberRoles().then(resp => {
this.memberRoleOptions = resp.resultList;
}).catch(error => {
this.toastService.showError(error);
});
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);
});
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);
});
this.adminService
.listIAMMemberRoles()
.then((resp) => {
this.memberRoleOptions = resp.rolesList;
})
.catch((error) => {
this.toastService.showError(error);
});
break;
}
}
@@ -122,4 +142,17 @@ export class MemberCreateDialogComponent {
public setOrgMemberRoles(roles: string[]): void {
this.roles = roles;
}
public toggleRole(role: string): void {
const index = this.roles.findIndex((r) => r === role);
if (index > -1) {
this.roles.splice(index, 1);
} else {
this.roles.push(role);
}
}
public getColor(role: string) {
return getMembershipColor(role)[500];
}
}
@@ -2,36 +2,36 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatButtonModule } from '@angular/material/button';
import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatChipsModule } from '@angular/material/chips';
import { MatDialogModule } from '@angular/material/dialog';
import { MatSelectModule } from '@angular/material/select';
import { TranslateModule } from '@ngx-translate/core';
import { InputModule } from 'src/app/modules/input/input.module';
import { SearchUserAutocompleteModule } from 'src/app/modules/search-user-autocomplete/search-user-autocomplete.module';
import { RoleTransformPipeModule } from 'src/app/pipes/role-transform/role-transform.module';
import {
OrgMemberRolesAutocompleteModule,
} from '../../pages/orgs/org-member-roles-autocomplete/org-member-roles-autocomplete.module';
import { SearchProjectAutocompleteModule } from '../search-project-autocomplete/search-project-autocomplete.module';
import { SearchRolesAutocompleteModule } from '../search-roles-autocomplete/search-roles-autocomplete.module';
import { MemberCreateDialogComponent } from './member-create-dialog.component';
@NgModule({
declarations: [MemberCreateDialogComponent],
imports: [
CommonModule,
MatDialogModule,
MatButtonModule,
MatChipsModule,
TranslateModule,
InputModule,
MatSelectModule,
FormsModule,
ReactiveFormsModule,
SearchUserAutocompleteModule,
SearchRolesAutocompleteModule,
SearchProjectAutocompleteModule,
OrgMemberRolesAutocompleteModule,
],
declarations: [MemberCreateDialogComponent],
imports: [
CommonModule,
MatDialogModule,
MatButtonModule,
MatChipsModule,
TranslateModule,
InputModule,
MatSelectModule,
RoleTransformPipeModule,
FormsModule,
MatCheckboxModule,
ReactiveFormsModule,
SearchUserAutocompleteModule,
SearchRolesAutocompleteModule,
SearchProjectAutocompleteModule,
],
})
export class MemberCreateDialogModule { }
export class MemberCreateDialogModule {}