Files
outline/app/menus/AuthenticationProviderMenu.tsx
Tom Moor 0171534400 feat: Allow admins to reconnect an authentication provider (#14649)
Reconnecting updates the existing provider row in place so that member
authentications stay linked when the external domain or tenant changes.
2026-11-18 22:36:53 -05:00

61 lines
1.8 KiB
TypeScript

import { observer } from "mobx-react";
import { useMemo } from "react";
import { useTranslation } from "react-i18next";
import type AuthenticationProvider from "~/models/AuthenticationProvider";
import Button from "~/components/Button";
import { ConnectedIcon } from "~/components/Icons/ConnectedIcon";
import { DropdownMenu } from "~/components/Menu/DropdownMenu";
import { createAction } from "~/actions";
import { useMenuAction } from "~/hooks/useMenuAction";
interface Props {
/** The connected authentication provider to show the menu for. */
provider: AuthenticationProvider;
/** Callback when the user chooses to reconnect the provider. */
onReconnect: (name: string) => void;
/** Callback when the user chooses to disconnect the provider. */
onDisconnect: (provider: AuthenticationProvider) => void;
}
/**
* A "Connected" button with a menu to reconnect or disconnect an
* authentication provider.
*/
export const AuthenticationProviderMenu = observer(
function AuthenticationProviderMenu({
provider,
onReconnect,
onDisconnect,
}: Props) {
const { t } = useTranslation();
const section = "Authentication";
const actions = useMemo(
() => [
createAction({
name: t("Reconnect"),
section,
perform: () => onReconnect(provider.name),
}),
createAction({
name: `${t("Disconnect")}…`,
section,
dangerous: true,
perform: () => onDisconnect(provider),
}),
],
[t, provider, onReconnect, onDisconnect]
);
const rootAction = useMenuAction(actions);
return (
<DropdownMenu action={rootAction} ariaLabel={t("Connected")}>
<Button icon={<ConnectedIcon />} neutral disclosure>
{t("Connected")}
</Button>
</DropdownMenu>
);
}
);