Skip to content

Commit 2e38026

Browse files
committed
add context
1 parent 6ca8927 commit 2e38026

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

projects/fusio-sdk/src/lib/component/account-container/account-container.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class AccountContainerComponent implements OnInit {
1515
constructor(private router: Router, private route: ActivatedRoute, private navigation: NavigationService) { }
1616

1717
async ngOnInit(): Promise<void> {
18-
this.items = await this.navigation.getAccountNavigation();
18+
this.items = await this.navigation.getAccountNavigation(this);
1919
this.active = this.items[0].title;
2020

2121
this.route.url.subscribe(() => {

projects/fusio-sdk/src/lib/component/bootstrap/bootstrap.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export class BootstrapComponent implements OnInit {
1717

1818
async ngOnInit(): Promise<void> {
1919
this.user = this.userMeta.get();
20-
this.userMenu = await this.navigation.getUserNavigation();
21-
this.anonymousMenu = await this.navigation.getAnonymousNavigation();
20+
this.userMenu = await this.navigation.getUserNavigation(this);
21+
this.anonymousMenu = await this.navigation.getAnonymousNavigation(this);
2222
}
2323

2424
}

projects/fusio-sdk/src/lib/component/navigation/navigation.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class NavigationComponent implements OnInit {
1919
async ngOnInit(): Promise<void> {
2020
this.title = this.config.getTitle() || 'Fusio';
2121
this.version = this.config.getVersion();
22-
this.items = await this.navigation.getMainNavigation();
22+
this.items = await this.navigation.getMainNavigation(this);
2323
}
2424

2525
changeNavHeading(item: GroupItem): void {

projects/fusio-sdk/src/lib/service/navigation.service.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable } from '@angular/core';
1+
import {Injectable, OnInit} from '@angular/core';
22
import {ConfigService} from "./config.service";
33
import {BackendService} from "./backend.service";
44

@@ -10,26 +10,26 @@ export class NavigationService {
1010
constructor(private backend: BackendService, private config: ConfigService) {
1111
}
1212

13-
async getMainNavigation(): Promise<Array<GroupItem>> {
14-
return this.checkPermissions(this.config.getNavigation());
13+
async getMainNavigation(context: OnInit): Promise<Array<GroupItem>> {
14+
return this.checkPermissions(this.config.getNavigation(), context);
1515
}
1616

17-
async getUserNavigation(): Promise<Array<Item>> {
18-
return this.checkPermissionItems(this.config.getUserNavigation());
17+
async getUserNavigation(context: OnInit): Promise<Array<Item>> {
18+
return this.checkPermissionItems(this.config.getUserNavigation(), context);
1919
}
2020

21-
async getAnonymousNavigation(): Promise<Array<Item>> {
22-
return this.checkPermissionItems(this.config.getAnonymousNavigation());
21+
async getAnonymousNavigation(context: OnInit): Promise<Array<Item>> {
22+
return this.checkPermissionItems(this.config.getAnonymousNavigation(), context);
2323
}
2424

25-
async getAccountNavigation(): Promise<Array<Item>> {
26-
return this.checkPermissionItems(this.config.getAccountNavigation());
25+
async getAccountNavigation(context: OnInit): Promise<Array<Item>> {
26+
return this.checkPermissionItems(this.config.getAccountNavigation(), context);
2727
}
2828

29-
private async checkPermissions(navigation: Array<GroupItem>): Promise<Array<GroupItem>> {
29+
private async checkPermissions(navigation: Array<GroupItem>, context: OnInit): Promise<Array<GroupItem>> {
3030
let result = [];
3131
for (let i = 0; i < navigation.length; i++) {
32-
const children = await this.checkPermissionItems(navigation[i].children);
32+
const children = await this.checkPermissionItems(navigation[i].children, context);
3333
if (children.length > 0) {
3434
let menu = navigation[i];
3535
menu.children = children;
@@ -40,9 +40,9 @@ export class NavigationService {
4040
return result;
4141
}
4242

43-
private async checkPermissionItems(items: Items): Promise<Array<Item>> {
43+
private async checkPermissionItems(items: Items, context: OnInit): Promise<Array<Item>> {
4444
if (items instanceof Function) {
45-
items = await items.apply(this);
45+
items = await items.apply(context);
4646
}
4747

4848
if (!Array.isArray(items)) {

0 commit comments

Comments
 (0)