-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b293a82
commit 40a44f4
Showing
5 changed files
with
59 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { BaseMenu, DynamicMenu, Menu, MenuAction } from "../menus"; | ||
|
||
// export function instantiateMenu(menu: Menu) { | ||
// if (menuType(menu) == "class") { | ||
// if (menu instanceof BaseMenu) { | ||
// return menu; | ||
// } | ||
|
||
// // @ts-ignore | ||
// return new menu(this.request, this.response); | ||
// } | ||
|
||
// return menu; | ||
// } | ||
|
||
export function menuType(val: Menu): "class" | "dynamic" { | ||
// TODO: document why this special case is needed | ||
if (/^DynamicMenu$/i.test(val.constructor.name)) { | ||
return "dynamic"; | ||
} | ||
return "class"; | ||
} | ||
|
||
export async function getMenuActions(menu: Menu): Promise<MenuAction[]> { | ||
if (menuType(menu!) == "class") { | ||
return (await (menu as unknown as BaseMenu).actions()) || []; | ||
} else { | ||
return await (menu as DynamicMenu).getActions() | ||
} | ||
} |