mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
bf45e97641
* Update types * fix circular dep * type imports * lint type imports and --fix
64 lines
1.8 KiB
TypeScript
64 lines
1.8 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import { useCallback, useMemo } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import type OAuthAuthentication from "~/models/oauth/OAuthAuthentication";
|
|
import ConfirmationDialog from "~/components/ConfirmationDialog";
|
|
import { DropdownMenu } from "~/components/Menu/DropdownMenu";
|
|
import { OverflowMenuButton } from "~/components/Menu/OverflowMenuButton";
|
|
import useStores from "~/hooks/useStores";
|
|
import { createAction } from "~/actions";
|
|
import { useMenuAction } from "~/hooks/useMenuAction";
|
|
|
|
type Props = {
|
|
/** The OAuthAuthentication to associate with the menu */
|
|
oauthAuthentication: OAuthAuthentication;
|
|
};
|
|
|
|
function OAuthAuthenticationMenu({ oauthAuthentication }: Props) {
|
|
const { dialogs } = useStores();
|
|
const { t } = useTranslation();
|
|
|
|
const handleRevoke = useCallback(() => {
|
|
dialogs.openModal({
|
|
title: t("Revoke {{ appName }}", {
|
|
appName: oauthAuthentication.oauthClient.name,
|
|
}),
|
|
content: (
|
|
<ConfirmationDialog
|
|
onSubmit={async () => {
|
|
await oauthAuthentication.deleteAll();
|
|
dialogs.closeAllModals();
|
|
}}
|
|
submitText={t("Revoke")}
|
|
savingText={`${t("Revoking")}…`}
|
|
danger
|
|
>
|
|
{t("Are you sure you want to revoke access?")}
|
|
</ConfirmationDialog>
|
|
),
|
|
});
|
|
}, [t, dialogs, oauthAuthentication]);
|
|
|
|
const actions = useMemo(
|
|
() => [
|
|
createAction({
|
|
name: t("Revoke"),
|
|
section: "OAuth",
|
|
dangerous: true,
|
|
perform: handleRevoke,
|
|
}),
|
|
],
|
|
[t, handleRevoke]
|
|
);
|
|
|
|
const rootAction = useMenuAction(actions);
|
|
|
|
return (
|
|
<DropdownMenu action={rootAction} ariaLabel={t("Show menu")}>
|
|
<OverflowMenuButton />
|
|
</DropdownMenu>
|
|
);
|
|
}
|
|
|
|
export default observer(OAuthAuthenticationMenu);
|