* fix: add disclosure and transition * fix: keep collections expanded * fix: tune transition and collapsing conditions * fix: collectionIcon expanded props is no longer driven by expanded state * fix: sync issue * fix: managing state together * fix: remove comment * fix: simplify expanded state * fix: remove extra state * fix: remove animation and retain expanded state * fix: remove isCollectionDropped * fix: don't use ref * review suggestions * fix many functional and design issues * don't render every single document in the sidebar, just ones that the user has seen before * chore: Sidebar refinement (#3154) * stash * wip: More sidebar tweaks * Simplify draft bubble * disclosure refactor * wip wip * lint * tweak menu position * Use document emoji for starred docs where available * feat: Trigger cmd+k from sidebar (#3149) * feat: Trigger cmd+k from sidebar * Add hint when opening command bar from sidebar * fix: Clicking internal links in shared documents sometimes reroutes to Login * fix: Spacing issues on connected slack channels list * Merge * fix: Do not prefetch JS bundles on public share links * fix: Buttons show on collection empty state when user does not have permission to edit * fix: the hover area for the "collections" subheading was being obfuscated by the initial collection drop cursor * fix: top-align disclosures * fix: Disclosure color PR feedback fix: Starred no longer draggable * fix: Overflow on sidebar button * fix: Scrollbar in sidebar when command menu is open * Minor alignment issues, clarify back in settings sidebar * fix: Fade component causes SidebarButton missizing Co-authored-by: Nan Yu <thenanyu@gmail.com> Co-authored-by: Tom Moor <tom.moor@gmail.com> Co-authored-by: Nan Yu <thenanyu@gmail.com>
169 lines
4.9 KiB
TypeScript
169 lines
4.9 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import {
|
|
NewDocumentIcon,
|
|
EmailIcon,
|
|
ProfileIcon,
|
|
PadlockIcon,
|
|
CodeIcon,
|
|
UserIcon,
|
|
GroupIcon,
|
|
LinkIcon,
|
|
TeamIcon,
|
|
BackIcon,
|
|
BeakerIcon,
|
|
DownloadIcon,
|
|
} 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 useCurrentTeam from "~/hooks/useCurrentTeam";
|
|
import useStores from "~/hooks/useStores";
|
|
import Sidebar from "./Sidebar";
|
|
import Header from "./components/Header";
|
|
import Section from "./components/Section";
|
|
import SidebarButton from "./components/SidebarButton";
|
|
import SidebarLink from "./components/SidebarLink";
|
|
import Version from "./components/Version";
|
|
|
|
const isHosted = env.DEPLOYMENT === "hosted";
|
|
|
|
function SettingsSidebar() {
|
|
const { t } = useTranslation();
|
|
const history = useHistory();
|
|
const team = useCurrentTeam();
|
|
const { policies } = useStores();
|
|
const can = policies.abilities(team.id);
|
|
|
|
const returnToApp = React.useCallback(() => {
|
|
history.push("/home");
|
|
}, [history]);
|
|
|
|
return (
|
|
<Sidebar>
|
|
<SidebarButton
|
|
title={t("Return to App")}
|
|
image={<StyledBackIcon color="currentColor" />}
|
|
onClick={returnToApp}
|
|
minHeight={48}
|
|
/>
|
|
|
|
<Flex auto column>
|
|
<Scrollable topShadow>
|
|
<Section>
|
|
<Header>{t("Account")}</Header>
|
|
<SidebarLink
|
|
to="/settings"
|
|
icon={<ProfileIcon color="currentColor" />}
|
|
label={t("Profile")}
|
|
/>
|
|
<SidebarLink
|
|
to="/settings/notifications"
|
|
icon={<EmailIcon color="currentColor" />}
|
|
label={t("Notifications")}
|
|
/>
|
|
{can.createApiKey && (
|
|
<SidebarLink
|
|
to="/settings/tokens"
|
|
icon={<CodeIcon color="currentColor" />}
|
|
label={t("API Tokens")}
|
|
/>
|
|
)}
|
|
</Section>
|
|
<Section>
|
|
<Header>{t("Team")}</Header>
|
|
{can.update && (
|
|
<SidebarLink
|
|
to="/settings/details"
|
|
icon={<TeamIcon color="currentColor" />}
|
|
label={t("Details")}
|
|
/>
|
|
)}
|
|
{can.update && (
|
|
<SidebarLink
|
|
to="/settings/security"
|
|
icon={<PadlockIcon color="currentColor" />}
|
|
label={t("Security")}
|
|
/>
|
|
)}
|
|
{can.update && (
|
|
<SidebarLink
|
|
to="/settings/features"
|
|
icon={<BeakerIcon color="currentColor" />}
|
|
label={t("Features")}
|
|
/>
|
|
)}
|
|
<SidebarLink
|
|
to="/settings/members"
|
|
icon={<UserIcon color="currentColor" />}
|
|
exact={false}
|
|
label={t("Members")}
|
|
/>
|
|
<SidebarLink
|
|
to="/settings/groups"
|
|
icon={<GroupIcon color="currentColor" />}
|
|
exact={false}
|
|
label={t("Groups")}
|
|
/>
|
|
<SidebarLink
|
|
to="/settings/shares"
|
|
icon={<LinkIcon color="currentColor" />}
|
|
label={t("Share Links")}
|
|
/>
|
|
{can.manage && (
|
|
<SidebarLink
|
|
to="/settings/import"
|
|
icon={<NewDocumentIcon color="currentColor" />}
|
|
label={t("Import")}
|
|
/>
|
|
)}
|
|
{can.export && (
|
|
<SidebarLink
|
|
to="/settings/export"
|
|
icon={<DownloadIcon color="currentColor" />}
|
|
label={t("Export")}
|
|
/>
|
|
)}
|
|
</Section>
|
|
{can.update && (env.SLACK_KEY || isHosted) && (
|
|
<Section>
|
|
<Header>{t("Integrations")}</Header>
|
|
{env.SLACK_KEY && (
|
|
<SidebarLink
|
|
to="/settings/integrations/slack"
|
|
icon={<SlackIcon color="currentColor" />}
|
|
label="Slack"
|
|
/>
|
|
)}
|
|
{isHosted && (
|
|
<SidebarLink
|
|
to="/settings/integrations/zapier"
|
|
icon={<ZapierIcon color="currentColor" />}
|
|
label="Zapier"
|
|
/>
|
|
)}
|
|
</Section>
|
|
)}
|
|
{can.update && !isHosted && (
|
|
<Section>
|
|
<Header>{t("Installation")}</Header>
|
|
<Version />
|
|
</Section>
|
|
)}
|
|
</Scrollable>
|
|
</Flex>
|
|
</Sidebar>
|
|
);
|
|
}
|
|
|
|
const StyledBackIcon = styled(BackIcon)`
|
|
margin-left: 4px;
|
|
`;
|
|
|
|
export default observer(SettingsSidebar);
|