fix(console): distinct user grant searches and creates, project grant member edit, import cleanup (#342)

* project grant member edit

* project grant member dialog, import cleanup

* readd project roles

* user login-methods cleanup

* fix sw config, user grant context

* delete user grants, context for creation, search

* contributor box shadow

* password to detail view

* user detail notification

* lint
This commit is contained in:
Max Peintner
2020-07-06 16:17:06 +02:00
committed by GitHub
parent c8cdbe136c
commit 9935784461
56 changed files with 910 additions and 573 deletions
@@ -16,7 +16,7 @@
{{'PROJECT.GRANT.CREATE.ORG_DESCRIPTION_DESC' | translate}}
</p>
<ng-container *ngIf="filter && filter == UserGrantSearchKey.USERGRANTSEARCHKEY_USER_ID">
<ng-container *ngIf="context && context == UserGrantContext.USER">
<h1>{{'PROJECT.GRANT.CREATE.SEL_PROJECT' | translate}}</h1>
<app-search-project-autocomplete class="block" singleOutput="true"
@@ -24,7 +24,8 @@
</app-search-project-autocomplete>
</ng-container>
<ng-container *ngIf="filter && filter == UserGrantSearchKey.USERGRANTSEARCHKEY_PROJECT_ID">
<ng-container
*ngIf="context && (context == UserGrantContext.GRANTED_PROJECT || context == UserGrantContext.OWNED_PROJECT)">
<h1>{{'PROJECT.GRANT.CREATE.SEL_USER' | translate}}</h1>
<app-search-user-autocomplete class="block" singleOutput="true" (selectionChanged)="selectUser($event)">
@@ -43,7 +44,7 @@
<div class="btn-container">
<ng-container *ngIf="currentCreateStep === 1">
<button
[disabled]="!org || (filter == UserGrantSearchKey.USERGRANTSEARCHKEY_PROJECT_ID && !projectId) || (filter == UserGrantSearchKey.USERGRANTSEARCHKEY_USER_ID && !userId)"
[disabled]="!org || ((context == UserGrantContext.GRANTED_PROJECT || context == UserGrantContext.OWNED_PROJECT) && !projectId) || (context == UserGrantContext.USER && !userId)"
(click)="next()" color="primary" mat-raised-button class="big-button" cdkFocusInitial>
{{ 'ACTIONS.CONTINUE' | translate }}
</button>
@@ -2,15 +2,9 @@ import { Location } from '@angular/common';
import { Component, OnDestroy } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import { Subscription } from 'rxjs';
import { UserGrantContext } from 'src/app/modules/user-grants/user-grants-datasource';
import { Org } from 'src/app/proto/generated/auth_pb';
import {
ProjectGrantView,
ProjectRole,
ProjectView,
User,
UserGrant,
UserGrantSearchKey,
} from 'src/app/proto/generated/management_pb';
import { ProjectGrantView, ProjectRole, ProjectView, User, UserGrant } from 'src/app/proto/generated/management_pb';
import { AuthService } from 'src/app/services/auth.service';
import { MgmtUserService } from 'src/app/services/mgmt-user.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -21,6 +15,8 @@ import { ToastService } from 'src/app/services/toast.service';
styleUrls: ['./user-grant-create.component.scss'],
})
export class UserGrantCreateComponent implements OnDestroy {
public context!: UserGrantContext;
public org!: Org.AsObject;
public userId: string = '';
public projectId: string = '';
@@ -30,12 +26,11 @@ export class UserGrantCreateComponent implements OnDestroy {
public STEPS: number = 2; // project, roles
public currentCreateStep: number = 1;
public filter!: UserGrantSearchKey;
public filterValue: string = '';
private subscription: Subscription = new Subscription();
public UserGrantSearchKey: any = UserGrantSearchKey;
public UserGrantContext: any = UserGrantContext;
constructor(
private authService: AuthService,
private userService: MgmtUserService,
@@ -45,18 +40,20 @@ export class UserGrantCreateComponent implements OnDestroy {
) {
this.subscription = this.route.params.subscribe((params: Params) => {
console.log(params);
const { filter, filterValue } = params;
this.filter = filter;
switch (filter) {
case (`${UserGrantSearchKey.USERGRANTSEARCHKEY_PROJECT_ID}`):
this.projectId = filterValue;
break;
case (`${UserGrantSearchKey.USERGRANTSEARCHKEY_USER_ID}`):
this.userId = filterValue;
break;
}
const { context, projectid, grantid, userid } = params;
this.context = context;
console.log(this.projectId, this.userId);
this.projectId = projectid;
this.grantId = grantid;
this.userId = userid;
if (this.userId) {
this.context = UserGrantContext.USER;
} else if (this.projectId && !this.grantId) {
this.context = UserGrantContext.OWNED_PROJECT;
} else if (this.projectId && this.grantId) {
this.context = UserGrantContext.GRANTED_PROJECT;
}
});
this.authService.GetActiveOrg().then(org => {
@@ -69,15 +66,48 @@ export class UserGrantCreateComponent implements OnDestroy {
}
public addGrant(): void {
this.userService.CreateUserGrant(
this.projectId,
this.userId,
this.rolesList,
).then((data: UserGrant) => {
this.close();
}).catch(error => {
this.toast.showError(error.message);
});
switch (this.context) {
case UserGrantContext.USER:
this.userService.CreateUserGrant(
this.projectId,
this.userId,
this.rolesList,
).then((data: UserGrant) => {
this.toast.showInfo('User Grant added');
this.close();
}).catch(error => {
this.toast.showError(error.message);
});
break;
case UserGrantContext.OWNED_PROJECT:
this.userService.CreateProjectUserGrant(
this.projectId,
this.userId,
this.rolesList,
).then((data: UserGrant) => {
this.toast.showInfo('Project User Grant added');
this.close();
}).catch(error => {
this.toast.showError(error.message);
});
break;
case UserGrantContext.GRANTED_PROJECT:
this.userService.CreateProjectGrantUserGrant(
this.org.id,
this.projectId,
this.grantId,
this.userId,
this.rolesList,
).then((data: UserGrant) => {
this.toast.showInfo('Project Grant User Grant added');
this.close();
}).catch(error => {
this.toast.showError(error.message);
});
break;
}
}
public selectProject(project: ProjectView.AsObject | ProjectGrantView.AsObject | any): void {