From f60635f5faad932a943006852cc434779dd6185a Mon Sep 17 00:00:00 2001 From: selankon Date: Tue, 3 Dec 2024 11:41:39 -0300 Subject: [PATCH] chore(menu): improve menu groups --- .../src/upgradeAvailable.js | 2 +- plugins/lime-plugin-mesh-wide-config/index.ts | 5 +- .../src/meshConfigMenu.tsx | 12 ++++ .../lime-plugin-mesh-wide-upgrade/index.ts | 1 + .../src/meshUpgradeMenu.tsx | 2 +- plugins/lime-plugin-mesh-wide/index.ts | 1 + src/components/icons/teenny/adjust.jsx | 14 ++++ src/config.ts | 2 +- src/containers/Menu/menu.js | 64 +++++++------------ src/types.d.ts | 9 +-- 10 files changed, 58 insertions(+), 54 deletions(-) create mode 100755 plugins/lime-plugin-mesh-wide-config/src/meshConfigMenu.tsx create mode 100644 src/components/icons/teenny/adjust.jsx diff --git a/plugins/lime-plugin-firmware/src/upgradeAvailable.js b/plugins/lime-plugin-firmware/src/upgradeAvailable.js index bc3cadfb7..82a865ba8 100644 --- a/plugins/lime-plugin-firmware/src/upgradeAvailable.js +++ b/plugins/lime-plugin-firmware/src/upgradeAvailable.js @@ -22,7 +22,7 @@ export const UpgradeAvailableBanner = () => { // @ts-ignore {({ path }) => - !["firmware", "releaseInfo", "meshwideupgrade"].includes( + !["firmware", "releaseInfo", "meshwide/upgrade"].includes( path.replace("/", "") ) && (
( + + + + Mesh Wide Config + + +); diff --git a/plugins/lime-plugin-mesh-wide-upgrade/index.ts b/plugins/lime-plugin-mesh-wide-upgrade/index.ts index 18c78799f..7a42a8e5a 100644 --- a/plugins/lime-plugin-mesh-wide-upgrade/index.ts +++ b/plugins/lime-plugin-mesh-wide-upgrade/index.ts @@ -6,4 +6,5 @@ export default { page: MeshUpgradePage, menu: MeshUpgradeMenu, isCommunityProtected: true, + menuGroup: "meshwide", } as LimePlugin; diff --git a/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeMenu.tsx b/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeMenu.tsx index cb5d73711..3b27bdc67 100755 --- a/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeMenu.tsx +++ b/plugins/lime-plugin-mesh-wide-upgrade/src/meshUpgradeMenu.tsx @@ -5,7 +5,7 @@ import { GlobeAmericasIcon } from "components/icons/teenny/globe"; export const MeshUpgradeMenu = () => ( - + Mesh Wide Upgrade diff --git a/plugins/lime-plugin-mesh-wide/index.ts b/plugins/lime-plugin-mesh-wide/index.ts index 1837c2c72..0fe963120 100644 --- a/plugins/lime-plugin-mesh-wide/index.ts +++ b/plugins/lime-plugin-mesh-wide/index.ts @@ -5,4 +5,5 @@ export default { name: "MeshWide", page: MeshWidePage, menu: MeshWideMenu, + menuGroup: "meshwide", } as LimePlugin; diff --git a/src/components/icons/teenny/adjust.jsx b/src/components/icons/teenny/adjust.jsx new file mode 100644 index 000000000..1584768ed --- /dev/null +++ b/src/components/icons/teenny/adjust.jsx @@ -0,0 +1,14 @@ +export const AdjustVertical = () => ( + + + +); diff --git a/src/config.ts b/src/config.ts index fd1219a79..9e0e6f8b2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -29,6 +29,6 @@ export const plugins: LimePlugin[] = [ ChangeNode, RemoteSupport, Pirania, + MeshConfigPage, Fbw, // does not have menu item - MeshConfigPage, // does not have menu item ]; diff --git a/src/containers/Menu/menu.js b/src/containers/Menu/menu.js index ce6e7a4d1..32e62c22e 100644 --- a/src/containers/Menu/menu.js +++ b/src/containers/Menu/menu.js @@ -1,18 +1,18 @@ -import { Trans } from "@lingui/macro"; -import { useState } from "preact/hooks"; - import { plugins } from "../../config"; import style from "./style.less"; export const Menu = ({ opened, toggle }) => { - const [currentView, setCurrentView] = useState("node"); - const hasCommunityPlugins = () => - plugins.filter((p) => p.menuView && p.menuView === "community").length > - 0; - function changeCurrentView(e) { - e.preventDefault(); - setCurrentView(currentView === "node" ? "community" : "node"); - } + // Group plugins by menuGroup + const groupedPlugins = plugins + .filter((plugin) => plugin.page && plugin.menu) // Only include plugins with both `page` and `menu` + .reduce((groups, plugin) => { + const group = plugin.menuGroup || "default"; // Use "default" for plugins without a menuGroup + if (!groups[group]) { + groups[group] = []; + } + groups[group].push(plugin.menu); + return groups; + }, {}); return (
{ } d-flex flex-column`} > - {hasCommunityPlugins() && ( - - )} + {components.map((Component, index) => ( + + ))} +
+ ))} +
); }; diff --git a/src/types.d.ts b/src/types.d.ts index 349bdbbf3..71fabd784 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -12,15 +12,8 @@ interface LimePlugin { name: string; page: typeof JSX.Element; menu: typeof JSX.Element; - menuView?: string; isCommunityProtected?: boolean; additionalRoutes?: LimeRoutes[]; additionalProtectedRoutes?: LimeRoutes[]; - store?: { - name: string; - epics?: any; // FIXME - reducer?: any; // FIXME - selector?: any; // FIXME - constants?: any; // FIXME - }; + menuGroup?: string; }