* fix: Logic error in toast fix: Remove useless component * fix: Logout not clearing all stores * Add icons to notification settings * Add eslint rule to enforce spaced comment * Add eslint rule for arrow-body-style * Add eslint rule to enforce self-closing components * Add menu to api key settings Fix: Deleting webhook subscription does not remove from UI Split webhook subscriptions into active and inactive Styling updates
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { MenuButton, useMenuState } from "reakit/Menu";
|
|
import ContextMenu from "~/components/ContextMenu";
|
|
import Template from "~/components/ContextMenu/Template";
|
|
import {
|
|
navigateToProfileSettings,
|
|
navigateToAccountPreferences,
|
|
openKeyboardShortcuts,
|
|
openChangelog,
|
|
openAPIDocumentation,
|
|
openBugReportUrl,
|
|
openFeedbackUrl,
|
|
logout,
|
|
downloadApp,
|
|
} from "~/actions/definitions/navigation";
|
|
import { changeTheme } from "~/actions/definitions/settings";
|
|
import usePrevious from "~/hooks/usePrevious";
|
|
import useStores from "~/hooks/useStores";
|
|
import separator from "~/menus/separator";
|
|
|
|
const AccountMenu: React.FC = ({ children }) => {
|
|
const menu = useMenuState({
|
|
placement: "bottom-end",
|
|
modal: true,
|
|
});
|
|
const { ui } = useStores();
|
|
const { theme } = ui;
|
|
const previousTheme = usePrevious(theme);
|
|
const { t } = useTranslation();
|
|
|
|
React.useEffect(() => {
|
|
if (theme !== previousTheme) {
|
|
menu.hide();
|
|
}
|
|
}, [menu, theme, previousTheme]);
|
|
|
|
const actions = React.useMemo(
|
|
() => [
|
|
openKeyboardShortcuts,
|
|
downloadApp,
|
|
openAPIDocumentation,
|
|
separator(),
|
|
openChangelog,
|
|
openFeedbackUrl,
|
|
openBugReportUrl,
|
|
changeTheme,
|
|
navigateToProfileSettings,
|
|
navigateToAccountPreferences,
|
|
separator(),
|
|
logout,
|
|
],
|
|
[]
|
|
);
|
|
|
|
return (
|
|
<>
|
|
<MenuButton {...menu}>{children}</MenuButton>
|
|
<ContextMenu {...menu} aria-label={t("Account")}>
|
|
<Template {...menu} items={undefined} actions={actions} />
|
|
</ContextMenu>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default observer(AccountMenu);
|