Skip to content

Commit

Permalink
TSK-1773: make routing-rest-enabled endpoint use the configured env
Browse files Browse the repository at this point in the history
  • Loading branch information
holgerhagen authored and holgerhagen committed Nov 23, 2021
1 parent 2c89353 commit 610eabd
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
<div class="administration-overview">
<nav mat-tab-nav-bar class="administration-overview__navbar" backgroundColor="#f5f5f5" >
<a mat-tab-link class="administration-overview__navbar-links" routerLink="/taskana/administration/workbaskets" [active]="selectedTab == 'workbaskets'"
(click)="selectedTab = 'workbaskets'">Workbaskets</a>
<a mat-tab-link class="administration-overview__navbar-links" routerLink="/taskana/administration/classifications" [active]="selectedTab == 'classifications'"
(click)="selectedTab = 'classifications'">Classifications</a>
<a mat-tab-link class="administration-overview__navbar-links" routerLink="/taskana/administration/access-items-management"
[active]="selectedTab == 'access-items-management'" (click)="selectedTab = 'access-items-management'">Access Items
<nav backgroundColor="#f5f5f5" class="administration-overview__navbar" mat-tab-nav-bar>
<a (click)="selectedTab = 'workbaskets'" [active]="selectedTab == 'workbaskets'"
class="administration-overview__navbar-links" mat-tab-link
routerLink="/taskana/administration/workbaskets">Workbaskets</a>
<a (click)="selectedTab = 'classifications'" [active]="selectedTab == 'classifications'"
class="administration-overview__navbar-links" mat-tab-link
routerLink="/taskana/administration/classifications">Classifications</a>
<a (click)="selectedTab = 'access-items-management'"
[active]="selectedTab == 'access-items-management'"
class="administration-overview__navbar-links"
mat-tab-link routerLink="/taskana/administration/access-items-management">Access Items
Management</a>
<a mat-tab-link class="administration-overview__navbar-links" routerLink="/taskana/administration/task-routing"
[active]="selectedTab == 'task-routing'" (click)="selectedTab = 'task-routing'" *ngIf="(routingAccess$ | async)">Task Routing</a>
<a (click)="selectedTab = 'task-routing'" *ngIf="(routingAccess)"
[active]="selectedTab == 'task-routing'"
class="administration-overview__navbar-links" mat-tab-link
routerLink="/taskana/administration/task-routing">Task Routing</a>
</nav>
<div class="administration-overview__domain">
<mat-form-field appearance="legacy">
<mat-select [value]="selectedDomain" matTooltip="Select domain">
<mat-option *ngFor="let domain of domains" [value]="domain" (click)="switchDomain(domain)">
{{domain? domain : 'MASTER DOMAIN'}}
<mat-option (click)="switchDomain(domain)" *ngFor="let domain of domains" [value]="domain">
{{domain ? domain : 'MASTER DOMAIN'}}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { Observable, of, Subject } from 'rxjs';
import { Router } from '@angular/router';
import { Observable, Subject } from 'rxjs';
import { DomainService } from '../../../shared/services/domain/domain.service';
import { takeUntil } from 'rxjs/operators';
import { TaskanaEngineService } from '../../../shared/services/taskana-engine/taskana-engine.service';
Expand All @@ -17,7 +17,7 @@ export class AdministrationOverviewComponent implements OnInit {

destroy$ = new Subject<void>();
url$: Observable<any>;
routingAccess$: Observable<boolean> = of(false);
routingAccess = false;

constructor(
private router: Router,
Expand All @@ -35,8 +35,12 @@ export class AdministrationOverviewComponent implements OnInit {
}

ngOnInit() {
this.routingAccess$ = this.taskanaEngineService.isCustomRoutingRulesEnabled$;
this.routingAccess$.pipe(takeUntil(this.destroy$)).subscribe();
this.taskanaEngineService
.isCustomRoutingRulesEnabled()
.pipe(takeUntil(this.destroy$))
.subscribe((value) => {
this.routingAccess = value;
});
this.domainService
.getDomains()
.pipe(takeUntil(this.destroy$))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,40 @@
<mat-nav-list class="navlist">
<a mat-list-item class="navlist__item navlist__admin" [routerLink]=[administrationsUrl]
[routerLinkActive]="['active']" *ngIf="administrationAccess" (click)="toggleSidenav()">Administration</a>
<div class="navlist__admin-item">
<a mat-list-item class="navlist__item navlist__admin-workbaskets" [routerLink]=[workbasketsUrl]
[routerLinkActive]="['active__sub']" *ngIf="administrationAccess" (click)="toggleSidenav()">Workbaskets</a>
<a mat-list-item class="navlist__item navlist__admin-classifications" [routerLink]=[classificationUrl]
[routerLinkActive]="['active__sub']" *ngIf="administrationAccess"
(click)="toggleSidenav()">Classifications</a>
<a mat-list-item class="navlist__item navlist__admin-access-items" [routerLink]=[accessUrl]
[routerLinkActive]="['active__sub']" (click)="toggleSidenav()" *ngIf="administrationAccess">Access Items</a>
<a mat-list-item class="navlist__item navlist__admin-task-routing" [routerLink]=[routingUrl]
[routerLinkActive]="['active__sub']" (click)="toggleSidenav()" *ngIf="(routingAccess$ | async)">Task Routing</a>
</div>
<a mat-list-item class="navlist__item navlist__monitor" [routerLink]=[monitorUrl] [routerLinkActive]="['active']"
*ngIf="monitorAccess" (click)="toggleSidenav()">Monitor</a>
<a mat-list-item class="navlist__item navlist__workplace" [routerLink]=[workplaceUrl]
[routerLinkActive]="['active']" *ngIf="workplaceAccess" (click)="toggleSidenav()">Workplace</a>
<div class="navlist__admin-item">
<a mat-list-item class="navlist__item navlist__workplace--workbaskets"
[routerLinkActive]="['active__sub']" *ngIf="workplaceAccess" [routerLink]=[workplaceUrl] [queryParams]="{component: 'workbaskets'}"
(click)="toggleSidenav()">Workbaskets</a>
<a mat-list-item class="navlist__item navlist__workplace--task-search"
[routerLinkActive]="['active__sub']" *ngIf="workplaceAccess" [routerLink]=[workplaceUrl] [queryParams]="{component: 'task-search'}"
(click)="toggleSidenav()">Task Search</a>
</div>
<a mat-list-item class="navlist__item navlist__history" [routerLink]=[historyUrl] [routerLinkActive]="['active']"
*ngIf="historyAccess" (click)="toggleSidenav()">History</a>
<a mat-list-item class="navlist__item navlist__setting" [routerLink]=[settingsURL] [routerLinkActive]="['active']"
*ngIf="settingsAccess" (click)="toggleSidenav()">Settings</a>
<a (click)="toggleSidenav()" *ngIf="administrationAccess" [routerLinkActive]="['active']"
[routerLink]=[administrationsUrl] class="navlist__item navlist__admin" mat-list-item>Administration</a>
<div class="navlist__admin-item">
<a (click)="toggleSidenav()" *ngIf="administrationAccess" [routerLinkActive]="['active__sub']"
[routerLink]=[workbasketsUrl] class="navlist__item navlist__admin-workbaskets"
mat-list-item>Workbaskets</a>
<a (click)="toggleSidenav()" *ngIf="administrationAccess" [routerLinkActive]="['active__sub']"
[routerLink]=[classificationUrl] class="navlist__item navlist__admin-classifications"
mat-list-item>Classifications</a>
<a (click)="toggleSidenav()" *ngIf="administrationAccess" [routerLinkActive]="['active__sub']"
[routerLink]=[accessUrl] class="navlist__item navlist__admin-access-items" mat-list-item>Access
Items</a>
<a (click)="toggleSidenav()" *ngIf="(routingAccess)" [routerLinkActive]="['active__sub']"
[routerLink]=[routingUrl] class="navlist__item navlist__admin-task-routing" mat-list-item>Task
Routing</a>
</div>
<a (click)="toggleSidenav()" *ngIf="monitorAccess" [routerLinkActive]="['active']"
[routerLink]=[monitorUrl]
class="navlist__item navlist__monitor" mat-list-item>Monitor</a>
<a (click)="toggleSidenav()" *ngIf="workplaceAccess" [routerLinkActive]="['active']"
[routerLink]=[workplaceUrl] class="navlist__item navlist__workplace"
mat-list-item>Workplace</a>
<div class="navlist__admin-item">
<a (click)="toggleSidenav()" *ngIf="workplaceAccess"
[queryParams]="{component: 'workbaskets'}" [routerLinkActive]="['active__sub']"
[routerLink]=[workplaceUrl] class="navlist__item navlist__workplace--workbaskets"
mat-list-item>Workbaskets</a>
<a (click)="toggleSidenav()" *ngIf="workplaceAccess"
[queryParams]="{component: 'task-search'}" [routerLinkActive]="['active__sub']"
[routerLink]=[workplaceUrl] class="navlist__item navlist__workplace--task-search"
mat-list-item>Task Search</a>
</div>
<a (click)="toggleSidenav()" *ngIf="historyAccess" [routerLinkActive]="['active']"
[routerLink]=[historyUrl]
class="navlist__item navlist__history" mat-list-item>History</a>
<a (click)="toggleSidenav()" *ngIf="settingsAccess" [routerLinkActive]="['active']"
[routerLink]=[settingsURL]
class="navlist__item navlist__setting" mat-list-item>Settings</a>
</mat-nav-list>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
import { MatGridListModule } from '@angular/material/grid-list';
import { MatListModule } from '@angular/material/list';
import { MatIconModule } from '@angular/material/icon';
import { EMPTY, of } from 'rxjs';
import { EMPTY } from 'rxjs';

const SidenavServiceSpy: Partial<SidenavService> = {
toggleSidenav: jest.fn().mockReturnValue(EMPTY)
Expand All @@ -24,7 +24,7 @@ const SidenavServiceSpy: Partial<SidenavService> = {
const TaskanaEngineServiceSpy: Partial<TaskanaEngineService> = {
hasRole: jest.fn().mockReturnValue(EMPTY),
isHistoryProviderEnabled: jest.fn().mockReturnValue(EMPTY),
isCustomRoutingRulesEnabled$: EMPTY
isCustomRoutingRulesEnabled: jest.fn().mockReturnValue(EMPTY)
};

describe('SidenavListComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { MonitorGuard } from 'app/shared/guards/monitor.guard';
import { UserGuard } from 'app/shared/guards/user.guard';
import { TaskanaEngineService } from '../../services/taskana-engine/taskana-engine.service';
import { SidenavService } from '../../services/sidenav/sidenav.service';
import { Observable, of } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

@Component({
selector: 'taskana-sidenav-list',
Expand All @@ -29,7 +27,7 @@ export class SidenavListComponent implements OnInit {
monitorAccess = false;
workplaceAccess = false;
historyAccess = false;
routingAccess$: Observable<boolean> = of(false);
routingAccess = false;
settingsAccess = false;

constructor(private taskanaEngineService: TaskanaEngineService, private sidenavService: SidenavService) {}
Expand All @@ -41,8 +39,9 @@ export class SidenavListComponent implements OnInit {
this.taskanaEngineService.isHistoryProviderEnabled().subscribe((value) => {
this.historyAccess = value;
});
this.routingAccess$ = this.taskanaEngineService.isCustomRoutingRulesEnabled$;
this.routingAccess$.subscribe();
this.taskanaEngineService.isCustomRoutingRulesEnabled().subscribe((value) => {
this.routingAccess = value;
});
this.settingsAccess = this.administrationAccess;
}

Expand Down
2 changes: 1 addition & 1 deletion web/src/app/shared/guards/task-routing.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class TaskRoutingGuard implements CanActivate {
next: ActivatedRouteSnapshot,
state: RouterStateSnapshot
): Observable<boolean> | Promise<boolean> | boolean {
return this.taskanaEngineService.isCustomRoutingRulesEnabled$.pipe(
return this.taskanaEngineService.isCustomRoutingRulesEnabled().pipe(
map((value) => {
if (value) {
return value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { environment } from 'environments/environment';
import { UserInfo } from 'app/shared/models/user-info';
import { Version } from 'app/shared/models/version';
import { Observable } from 'rxjs';
import { map, shareReplay } from 'rxjs/operators';
import { map } from 'rxjs/operators';

@Injectable()
export class TaskanaEngineService {
currentUserInfo: UserInfo;

constructor(private httpClient: HttpClient) {}

// GET
Expand Down Expand Up @@ -38,14 +39,14 @@ export class TaskanaEngineService {
return this.httpClient.post<string>(`${environment.taskanaLogoutUrl}`, '');
}

isCustomRoutingRulesEnabled(): Observable<boolean> {
return this.httpClient.get<boolean>(`${environment.taskanaRestUrl}/v1/routing-rules/routing-rest-enabled`);
}

isHistoryProviderEnabled(): Observable<boolean> {
return this.httpClient.get<boolean>(`${environment.taskanaRestUrl}/v1/history-provider-enabled`);
}

isCustomRoutingRulesEnabled$ = this.httpClient
.get<boolean>(`${environment.taskanaRestUrl}/v1/routing-rules/routing-rest-enabled`)
.pipe(shareReplay(1));

private findRole(roles2Find: string[]) {
return this.currentUserInfo.roles.find((role) => roles2Find.some((roleLookingFor) => role === roleLookingFor));
}
Expand Down

0 comments on commit 610eabd

Please sign in to comment.