From da8714a4f6f9ee6f2eb59e46466fea1a6d2c0bae Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Sun, 13 Mar 2022 09:34:50 -0700 Subject: [PATCH] chore: Drive settings sidebar from new config (#3236) --- app/components/Sidebar/Settings.tsx | 122 ++++------------------------ 1 file changed, 15 insertions(+), 107 deletions(-) diff --git a/app/components/Sidebar/Settings.tsx b/app/components/Sidebar/Settings.tsx index f4ffeb79d..fb8fe6c5e 100644 --- a/app/components/Sidebar/Settings.tsx +++ b/app/components/Sidebar/Settings.tsx @@ -1,27 +1,14 @@ +import { groupBy } from "lodash"; import { observer } from "mobx-react"; -import { - NewDocumentIcon, - EmailIcon, - ProfileIcon, - PadlockIcon, - CodeIcon, - UserIcon, - GroupIcon, - LinkIcon, - TeamIcon, - BackIcon, - BeakerIcon, - DownloadIcon, -} from "outline-icons"; +import { BackIcon } from "outline-icons"; import * as React from "react"; import { useTranslation } from "react-i18next"; import { useHistory } from "react-router-dom"; import styled from "styled-components"; import Flex from "~/components/Flex"; import Scrollable from "~/components/Scrollable"; -import SlackIcon from "~/components/SlackIcon"; -import ZapierIcon from "~/components/ZapierIcon"; import env from "~/env"; +import useAuthorizedSettingsConfig from "~/hooks/useAuthorizedSettingsConfig"; import useCurrentTeam from "~/hooks/useCurrentTeam"; import usePolicy from "~/hooks/usePolicy"; import Sidebar from "./Sidebar"; @@ -38,6 +25,8 @@ function SettingsSidebar() { const history = useHistory(); const team = useCurrentTeam(); const can = usePolicy(team.id); + const configs = useAuthorizedSettingsConfig(); + const groupedConfig = groupBy(configs, "group"); const returnToApp = React.useCallback(() => { history.push("/home"); @@ -54,100 +43,19 @@ function SettingsSidebar() { -
-
{t("Account")}
- } - label={t("Profile")} - /> - } - label={t("Notifications")} - /> - {can.createApiKey && ( - } - label={t("API Tokens")} - /> - )} -
-
-
{t("Team")}
- {can.update && ( - } - label={t("Details")} - /> - )} - {can.update && ( - } - label={t("Security")} - /> - )} - {can.update && ( - } - label={t("Features")} - /> - )} - } - exact={false} - label={t("Members")} - /> - } - exact={false} - label={t("Groups")} - /> - } - label={t("Share Links")} - /> - {can.manage && ( - } - label={t("Import")} - /> - )} - {can.export && ( - } - label={t("Export")} - /> - )} -
- {can.update && (env.SLACK_KEY || isHosted) && ( -
-
{t("Integrations")}
- {env.SLACK_KEY && ( + {Object.keys(groupedConfig).map((header) => ( +
+
{header}
+ {groupedConfig[header].map((item) => ( } - label="Slack" + key={item.path} + to={item.path} + icon={} + label={item.name} /> - )} - {isHosted && ( - } - label="Zapier" - /> - )} + ))}
- )} + ))} {can.update && !isHosted && (
{t("Installation")}