mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
321d0ee124
* chore: Remove `Action` v1 dependency * cleanup * rename
50 lines
1.2 KiB
TypeScript
50 lines
1.2 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import {
|
|
navigateToWorkspaceSettings,
|
|
logout,
|
|
} from "~/actions/definitions/navigation";
|
|
import {
|
|
createTeam,
|
|
switchTeamsList,
|
|
desktopLoginTeam,
|
|
} from "~/actions/definitions/teams";
|
|
import useActionContext from "~/hooks/useActionContext";
|
|
import { DropdownMenu } from "~/components/Menu/DropdownMenu";
|
|
import { ActionSeparator } from "~/actions";
|
|
import { useMenuAction } from "~/hooks/useMenuAction";
|
|
|
|
type Props = {
|
|
children?: React.ReactNode;
|
|
};
|
|
|
|
const TeamMenu: React.FC = ({ children }: Props) => {
|
|
const { t } = useTranslation();
|
|
const context = useActionContext({ isMenu: true });
|
|
|
|
// NOTE: it's useful to memoize on the team id and session because the action
|
|
// menu is not cached at all.
|
|
const actions = React.useMemo(
|
|
() => [
|
|
...switchTeamsList(context),
|
|
createTeam,
|
|
desktopLoginTeam,
|
|
ActionSeparator,
|
|
navigateToWorkspaceSettings,
|
|
logout,
|
|
],
|
|
[context]
|
|
);
|
|
|
|
const rootAction = useMenuAction(actions);
|
|
|
|
return (
|
|
<DropdownMenu action={rootAction} align="start" ariaLabel={t("Account")}>
|
|
{children}
|
|
</DropdownMenu>
|
|
);
|
|
};
|
|
|
|
export default observer(TeamMenu);
|