From 56c808c091c2aab18adb24ff93271fd106f0a8b7 Mon Sep 17 00:00:00 2001 From: Yang Luo Date: Sat, 5 Aug 2023 17:41:35 +0800 Subject: [PATCH] Improve menu --- web/src/App.js | 197 +++++++++++++-------------------------------- web/src/Conf.js | 2 - web/src/Setting.js | 8 +- 3 files changed, 55 insertions(+), 152 deletions(-) diff --git a/web/src/App.js b/web/src/App.js index 658ad1f6..adc64dc3 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -18,7 +18,7 @@ import {Helmet} from "react-helmet"; import {MfaRuleRequired} from "./Setting"; import * as Setting from "./Setting"; import {StyleProvider, legacyLogicalPropertiesTransformer} from "@ant-design/cssinjs"; -import {BarsOutlined, DownOutlined, InfoCircleFilled, LogoutOutlined, SettingOutlined} from "@ant-design/icons"; +import {BarsOutlined, DollarOutlined, DownOutlined, InfoCircleFilled, LockOutlined, LogoutOutlined, SafetyCertificateOutlined, SettingOutlined, SolutionOutlined, TeamOutlined} from "@ant-design/icons"; import {Alert, Avatar, Button, Card, ConfigProvider, Drawer, Dropdown, FloatButton, Layout, Menu, Result} from "antd"; import {Link, Redirect, Route, Switch, withRouter} from "react-router-dom"; import OrganizationListPage from "./OrganizationListPage"; @@ -147,58 +147,24 @@ class App extends Component { }); if (uri === "/") { this.setState({selectedMenuKey: "/"}); - } else if (uri.includes("/organizations") || uri.includes("/trees")) { - this.setState({selectedMenuKey: "/organizations"}); - } else if (uri.includes("/users")) { - this.setState({selectedMenuKey: "/users"}); - } else if (uri.includes("/groups")) { - this.setState({selectedMenuKey: "/groups"}); - } else if (uri.includes("/roles")) { - this.setState({selectedMenuKey: "/roles"}); - } else if (uri.includes("/permissions")) { - this.setState({selectedMenuKey: "/permissions"}); - } else if (uri.includes("/models")) { - this.setState({selectedMenuKey: "/models"}); - } else if (uri.includes("/adapters")) { - this.setState({selectedMenuKey: "/adapters"}); - } else if (uri.includes("/enforcers")) { - this.setState({selectedMenuKey: "/enforcers"}); - } else if (uri.includes("/providers")) { - this.setState({selectedMenuKey: "/providers"}); - } else if (uri.includes("/applications")) { - this.setState({selectedMenuKey: "/applications"}); - } else if (uri.includes("/resources")) { - this.setState({selectedMenuKey: "/resources"}); - } else if (uri.includes("/records")) { - this.setState({selectedMenuKey: "/records"}); - } else if (uri.includes("/tokens")) { - this.setState({selectedMenuKey: "/tokens"}); - } else if (uri.includes("/sessions")) { - this.setState({selectedMenuKey: "/sessions"}); - } else if (uri.includes("/webhooks")) { - this.setState({selectedMenuKey: "/webhooks"}); - } else if (uri.includes("/syncers")) { - this.setState({selectedMenuKey: "/syncers"}); - } else if (uri.includes("/certs")) { - this.setState({selectedMenuKey: "/certs"}); - } else if (uri.includes("/products")) { - this.setState({selectedMenuKey: "/products"}); - } else if (uri.includes("/payments")) { - this.setState({selectedMenuKey: "/payments"}); + } else if (uri.includes("/organizations") || uri.includes("/trees") || uri.includes("/users") || uri.includes("/groups")) { + this.setState({selectedMenuKey: "/orgs"}); + } else if (uri.includes("/roles") || uri.includes("/permissions") || uri.includes("/models") || uri.includes("/adapters") || uri.includes("/enforcers")) { + this.setState({selectedMenuKey: "/auth"}); + } else if (uri.includes("/applications") || uri.includes("/providers") || uri.includes("/resources") || uri.includes("/certs")) { + this.setState({selectedMenuKey: "/identity"}); + } else if (uri.includes("/records") || uri.includes("/tokens") || uri.includes("/sessions")) { + this.setState({selectedMenuKey: "/logs"}); + } else if (uri.includes("/products") || uri.includes("/payments") || uri.includes("/plans") || uri.includes("/pricings") || uri.includes("/subscriptions")) { + this.setState({selectedMenuKey: "/business"}); + } else if (uri.includes("/sysinfo") || uri.includes("/syncers") || uri.includes("/webhooks")) { + this.setState({selectedMenuKey: "/admin"}); } else if (uri.includes("/signup")) { this.setState({selectedMenuKey: "/signup"}); } else if (uri.includes("/login")) { this.setState({selectedMenuKey: "/login"}); } else if (uri.includes("/result")) { this.setState({selectedMenuKey: "/result"}); - } else if (uri.includes("/sysinfo")) { - this.setState({selectedMenuKey: "/sysinfo"}); - } else if (uri.includes("/subscriptions")) { - this.setState({selectedMenuKey: "/subscriptions"}); - } else if (uri.includes("/plans")) { - this.setState({selectedMenuKey: "/plans"}); - } else if (uri.includes("/pricings")) { - this.setState({selectedMenuKey: "/pricings"}); } else { this.setState({selectedMenuKey: -1}); } @@ -442,109 +408,54 @@ class App extends Component { , "#")); } - res.push(Setting.getItem({i18next.t("general:Organizations")}, - "/organizations")); + res.push(Setting.getItem({i18next.t("general:User Management")}, "/orgs", , [ + Setting.getItem({i18next.t("general:Organizations")}, "/organizations"), + Setting.getItem({i18next.t("general:Groups")}, "/groups"), + Setting.getItem({i18next.t("general:Users")}, "/users"), + ])); - res.push(Setting.getItem({i18next.t("general:Groups")}, - "/groups")); - - res.push(Setting.getItem({i18next.t("general:Users")}, - "/users" - )); - - res.push(Setting.getItem({i18next.t("general:Roles")}, - "/roles" - )); - - res.push(Setting.getItem({i18next.t("general:Permissions")}, - "/permissions" - )); + res.push(Setting.getItem({i18next.t("general:Authorization")}, "/auth", , [ + Setting.getItem({i18next.t("general:Roles")}, "/roles"), + Setting.getItem({i18next.t("general:Permissions")}, "/permissions"), + Setting.getItem({i18next.t("general:Models")}, "/models"), + Setting.getItem({i18next.t("general:Adapters")}, "/adapters"), + Setting.getItem({i18next.t("general:Enforcers")}, "/enforcers"), + ].filter(item => { + if (!Setting.isLocalAdminUser(this.state.account) && ["/models", "/adapters", "/enforcers"].includes(item.key)) { + return false; + } else { + return true; + } + }))); } if (Setting.isLocalAdminUser(this.state.account)) { - res.push(Setting.getItem({i18next.t("general:Models")}, - "/models" - )); + res.push(Setting.getItem({i18next.t("general:Identity")}, "/identity", , [ + Setting.getItem({i18next.t("general:Applications")}, "/applications"), + Setting.getItem({i18next.t("general:Providers")}, "/providers"), + Setting.getItem({i18next.t("general:Resources")}, "/resources"), + Setting.getItem({i18next.t("general:Certs")}, "/certs"), + ])); - res.push(Setting.getItem({i18next.t("general:Adapters")}, - "/adapters" - )); + res.push(Setting.getItem({i18next.t("general:Logging & Auditing")}, "/logs", , [ + Setting.getItem({i18next.t("general:Records")}, "/records"), + Setting.getItem({i18next.t("general:Tokens")}, "/tokens"), + Setting.getItem({i18next.t("general:Sessions")}, "/sessions"), + ])); - res.push(Setting.getItem({i18next.t("general:Enforcers")}, - "/enforcers" - )); - } + res.push(Setting.getItem({i18next.t("general:Business & Payments")}, "/business", , [ + Setting.getItem({i18next.t("general:Products")}, "/products"), + Setting.getItem({i18next.t("general:Payments")}, "/payments"), + Setting.getItem({i18next.t("general:Plans")}, "/plans"), + Setting.getItem({i18next.t("general:Pricings")}, "/pricings"), + Setting.getItem({i18next.t("general:Subscriptions")}, "/subscriptions"), + ])); - if (Setting.isLocalAdminUser(this.state.account)) { - res.push(Setting.getItem({i18next.t("general:Applications")}, - "/applications" - )); - - res.push(Setting.getItem({i18next.t("general:Providers")}, - "/providers" - )); - - res.push(Setting.getItem({i18next.t("general:Resources")}, - "/resources" - )); - - res.push(Setting.getItem({i18next.t("general:Records")}, - "/records" - )); - - res.push(Setting.getItem({i18next.t("general:Plans")}, - "/plans" - )); - - res.push(Setting.getItem({i18next.t("general:Pricings")}, - "/pricings" - )); - - res.push(Setting.getItem({i18next.t("general:Subscriptions")}, - "/subscriptions" - )); - } - - if (Setting.isLocalAdminUser(this.state.account)) { - res.push(Setting.getItem({i18next.t("general:Tokens")}, - "/tokens" - )); - - res.push(Setting.getItem({i18next.t("general:Sessions")}, - "/sessions" - )); - - res.push(Setting.getItem({i18next.t("general:Webhooks")}, - "/webhooks" - )); - - res.push(Setting.getItem({i18next.t("general:Syncers")}, - "/syncers" - )); - - res.push(Setting.getItem({i18next.t("general:Certs")}, - "/certs" - )); - - if (Conf.EnableExtraPages) { - res.push(Setting.getItem({i18next.t("general:Products")}, - "/products" - )); - - res.push(Setting.getItem({i18next.t("general:Payments")}, - "/payments" - )); - } - } - - if (Setting.isAdminUser(this.state.account)) { - res.push(Setting.getItem({i18next.t("general:System Info")}, - "/sysinfo" - )); - res.push(Setting.getItem({i18next.t("general:Swagger")}, - "/swagger" - )); + res.push(Setting.getItem({i18next.t("general:Admin")}, "/admin", , [ + Setting.getItem({i18next.t("general:System Info")}, "/sysinfo"), + Setting.getItem({i18next.t("general:Syncers")}, "/syncers"), + Setting.getItem({i18next.t("general:Webhooks")}, "/webhooks"), + Setting.getItem({i18next.t("general:Swagger")}, "/swagger")])); } return res; diff --git a/web/src/Conf.js b/web/src/Conf.js index 8db330fb..dc639ff0 100644 --- a/web/src/Conf.js +++ b/web/src/Conf.js @@ -20,8 +20,6 @@ export const IsDemoMode = false; export const ForceLanguage = ""; export const DefaultLanguage = "en"; -export const EnableExtraPages = true; - export const InitThemeAlgorithm = true; export const ThemeDefault = { themeType: "default", diff --git a/web/src/Setting.js b/web/src/Setting.js index 6b7394a8..c9de9fae 100644 --- a/web/src/Setting.js +++ b/web/src/Setting.js @@ -1043,13 +1043,7 @@ export function getLabel(text, tooltip) { } export function getItem(label, key, icon, children, type) { - return { - key, - icon, - children, - label, - type, - }; + return {label: label, key: key, icon: icon, children: children, type: type}; } export function getOption(label, value) {