Custom Menu Items (#79)

* Custom Menu Items

* update readme

* fix indentation
This commit is contained in:
Aine
2024-10-21 23:33:51 +03:00
committed by GitHub
parent be867b6b0d
commit ca71038874
6 changed files with 95 additions and 23 deletions

View File

@@ -3,7 +3,7 @@ import React from "react";
import { createRoot } from "react-dom/client";
import App from "./App";
import { AppContext } from "./AppContext";
import { AppContext, MenuItem } from "./AppContext";
import storage from "./storage";
fetch("config.json")
@@ -12,9 +12,24 @@ fetch("config.json")
if (props.asManagedUsers) {
storage.setItem("as_managed_users", JSON.stringify(props.asManagedUsers));
}
if (props.supportURL) {
storage.setItem("support_url", props.supportURL);
let menu: MenuItem[] = [];
if (props.menu) {
menu = props.menu;
}
if (props.supportURL) {
const migratedSupportURL = {
label: "Contact support",
icon: "SupportAgent",
url: props.supportURL,
};
console.warn("supportURL config option is deprecated. Please, use the menu option instead. Automatically migrated to the new menu option:", migratedSupportURL);
menu.push(migratedSupportURL as MenuItem);
}
if (menu.length > 0) {
storage.setItem("menu", JSON.stringify(menu));
}
return createRoot(document.getElementById("root")).render(
<React.StrictMode>
<AppContext.Provider value={props}>