mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
This PR contains the necessary work to make Outline an OAuth provider including: - OAuth app registration - OAuth app management - Private / public apps (Public in cloud only) - Full OAuth 2.0 spec compatible authentication flow - Granular scopes - User token management screen in settings - Associated API endpoints for programatic access
69 lines
1.9 KiB
TypeScript
69 lines
1.9 KiB
TypeScript
import { observer } from "mobx-react";
|
|
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useMenuState } from "reakit/Menu";
|
|
import OAuthClient from "~/models/oauth/OAuthClient";
|
|
import OAuthClientDeleteDialog from "~/scenes/Settings/components/OAuthClientDeleteDialog";
|
|
import ContextMenu from "~/components/ContextMenu";
|
|
import OverflowMenuButton from "~/components/ContextMenu/OverflowMenuButton";
|
|
import Template from "~/components/ContextMenu/Template";
|
|
import useStores from "~/hooks/useStores";
|
|
import { settingsPath } from "~/utils/routeHelpers";
|
|
|
|
type Props = {
|
|
/** The oauthClient to associate with the menu */
|
|
oauthClient: OAuthClient;
|
|
/** Whether to show the edit button */
|
|
showEdit?: boolean;
|
|
};
|
|
|
|
function OAuthClientMenu({ oauthClient, showEdit }: Props) {
|
|
const menu = useMenuState({
|
|
modal: true,
|
|
});
|
|
const { dialogs } = useStores();
|
|
const { t } = useTranslation();
|
|
|
|
const handleDelete = React.useCallback(() => {
|
|
dialogs.openModal({
|
|
title: t("Delete app"),
|
|
content: (
|
|
<OAuthClientDeleteDialog
|
|
onSubmit={dialogs.closeAllModals}
|
|
oauthClient={oauthClient}
|
|
/>
|
|
),
|
|
});
|
|
}, [t, dialogs, oauthClient]);
|
|
|
|
return (
|
|
<>
|
|
<OverflowMenuButton aria-label={t("Show menu")} {...menu} />
|
|
<ContextMenu {...menu}>
|
|
<Template
|
|
{...menu}
|
|
items={[
|
|
{
|
|
type: "route",
|
|
title: `${t("Edit")}…`,
|
|
visible: showEdit,
|
|
to: settingsPath("applications", oauthClient.id),
|
|
},
|
|
{
|
|
type: "separator",
|
|
},
|
|
{
|
|
type: "button",
|
|
dangerous: true,
|
|
title: `${t("Delete")}…`,
|
|
onClick: handleDelete,
|
|
},
|
|
]}
|
|
/>
|
|
</ContextMenu>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default observer(OAuthClientMenu);
|