Skip to content

Commit e3a9af8

Browse files
committed
handle async item resolver
1 parent 2f8c5bb commit e3a9af8

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ export class BootstrapComponent implements OnInit {
1515

1616
constructor(private userMeta: UserService, private navigation: NavigationService) { }
1717

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

2424
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export class NavigationComponent implements OnInit {
1616
constructor(private navigation: NavigationService, private config: ConfigService) {
1717
}
1818

19-
ngOnInit(): void {
19+
async ngOnInit(): Promise<void> {
2020
this.title = this.config.getTitle() || 'Fusio';
2121
this.version = this.config.getVersion();
22-
this.items = this.navigation.getMainNavigation();
22+
this.items = await this.navigation.getMainNavigation();
2323
}
2424

2525
changeNavHeading(item: GroupItem): void {

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ export class NavigationService {
1010
constructor(private backend: BackendService, private config: ConfigService) {
1111
}
1212

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

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

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

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

29-
private checkPermissions(navigation: Array<GroupItem>): Array<GroupItem> {
29+
private async checkPermissions(navigation: Array<GroupItem>): Promise<Array<GroupItem>> {
3030
let result = [];
3131
for (let i = 0; i < navigation.length; i++) {
32-
const children = this.checkPermissionItems(navigation[i].children);
32+
const children = await this.checkPermissionItems(navigation[i].children);
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 checkPermissionItems(items: Items): Array<Item> {
43+
private async checkPermissionItems(items: Items): Promise<Array<Item>> {
4444
if (items instanceof Function) {
45-
items = items.apply(this);
45+
items = await items.apply(this);
4646
}
4747

4848
if (!Array.isArray(items)) {
@@ -70,7 +70,7 @@ export interface GroupItem {
7070
children: Items
7171
}
7272

73-
export type ItemResolver = () => Array<Item>;
73+
export type ItemResolver = () => Promise<Array<Item>>;
7474

7575
export type Items = Array<Item>|ItemResolver;
7676

0 commit comments

Comments
 (0)