mirror of
https://github.com/outline/outline.git
synced 2026-11-25 07:04:37 +03:00
* Gemini first-pass * Prevent post-connect login * stash * stash * Add OIDC logo * Separate security page * test * Update icon * test * ui * Add extra guards for disabling auth provider * refactor * test
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import * as React from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import type { Props as ButtonProps } from "~/components/Button";
|
|
import Button from "~/components/Button";
|
|
import ConfirmationDialog from "~/components/ConfirmationDialog";
|
|
import { ConnectedIcon } from "~/components/Icons/ConnectedIcon";
|
|
import Text from "~/components/Text";
|
|
import useStores from "~/hooks/useStores";
|
|
|
|
type Props = ButtonProps<HTMLButtonElement> & {
|
|
confirmationMessage: React.ReactNode;
|
|
onClick: () => Promise<void> | void;
|
|
};
|
|
|
|
export function ConnectedButton({
|
|
onClick,
|
|
confirmationMessage,
|
|
...rest
|
|
}: Props) {
|
|
const { t } = useTranslation();
|
|
const { dialogs } = useStores();
|
|
|
|
const handleClick = () => {
|
|
dialogs.openModal({
|
|
title: t("Disconnect integration"),
|
|
content: (
|
|
<ConfirmDisconnectDialog
|
|
confirmationMessage={confirmationMessage}
|
|
onSubmit={onClick}
|
|
/>
|
|
),
|
|
});
|
|
};
|
|
|
|
return (
|
|
<Button icon={<ConnectedIcon />} neutral onClick={handleClick} {...rest}>
|
|
{t("Connected")}
|
|
</Button>
|
|
);
|
|
}
|
|
|
|
function ConfirmDisconnectDialog({
|
|
confirmationMessage,
|
|
onSubmit,
|
|
}: {
|
|
confirmationMessage: React.ReactNode;
|
|
onSubmit: () => Promise<void> | void;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<ConfirmationDialog
|
|
onSubmit={onSubmit}
|
|
submitText={t("Disconnect")}
|
|
savingText={`${t("Disconnecting")}…`}
|
|
danger
|
|
>
|
|
<Text as="p" type="secondary">
|
|
{confirmationMessage}
|
|
</Text>
|
|
</ConfirmationDialog>
|
|
);
|
|
}
|