Merge branch 'develop' of github.com:thecodingmachine/workadventure
This commit is contained in:
@@ -82,3 +82,35 @@ function checkSubMenuToShow() {
|
||||
}
|
||||
|
||||
checkSubMenuToShow();
|
||||
|
||||
export const customMenuIframe = new Map<string, { url: string; allowApi: boolean }>();
|
||||
|
||||
export function handleMenuRegistrationEvent(
|
||||
menuName: string,
|
||||
iframeUrl: string | undefined = undefined,
|
||||
source: string | undefined = undefined,
|
||||
options: { allowApi: boolean }
|
||||
) {
|
||||
if (get(subMenusStore).includes(menuName)) {
|
||||
console.warn("The menu " + menuName + " already exist.");
|
||||
return;
|
||||
}
|
||||
|
||||
subMenusStore.addMenu(menuName);
|
||||
|
||||
if (iframeUrl !== undefined) {
|
||||
const url = new URL(iframeUrl, source);
|
||||
customMenuIframe.set(menuName, { url: url.toString(), allowApi: options.allowApi });
|
||||
}
|
||||
}
|
||||
|
||||
export function handleMenuUnregisterEvent(menuName: string) {
|
||||
const subMenuGeneral: string[] = Object.values(SubMenusInterface);
|
||||
if (subMenuGeneral.includes(menuName)) {
|
||||
console.warn("The menu " + menuName + " is a mandatory menu. It can't be remove");
|
||||
return;
|
||||
}
|
||||
|
||||
subMenusStore.removeMenu(menuName);
|
||||
customMenuIframe.delete(menuName);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user