mirror of
https://github.com/outline/outline.git
synced 2026-06-13 11:25:03 +03:00
a06671e8ce
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
51 lines
1.2 KiB
TypeScript
51 lines
1.2 KiB
TypeScript
import { LinkIcon } from "outline-icons";
|
|
import * as React from "react";
|
|
import { toast } from "sonner";
|
|
import CopyToClipboard from "~/components/CopyToClipboard";
|
|
import NudeButton from "~/components/NudeButton";
|
|
import Tooltip from "~/components/Tooltip";
|
|
|
|
type Props = {
|
|
/** The value to be copied */
|
|
value: string;
|
|
/** The message to show when the value is copied */
|
|
success: string;
|
|
/** The tooltip message */
|
|
tooltip: string;
|
|
/** An optional icon */
|
|
icon?: React.ReactNode;
|
|
};
|
|
|
|
/**
|
|
* A button that copies a value to the clipboard when clicked and shows a
|
|
* single icon.
|
|
*/
|
|
export function CopyButton({
|
|
value,
|
|
success,
|
|
tooltip,
|
|
icon = <LinkIcon size={20} />,
|
|
}: Props) {
|
|
const timeout = React.useRef<ReturnType<typeof setTimeout>>();
|
|
|
|
const handleCopied = React.useCallback(() => {
|
|
timeout.current = setTimeout(() => {
|
|
toast.message(success);
|
|
}, 100);
|
|
|
|
return () => {
|
|
if (timeout.current) {
|
|
clearTimeout(timeout.current);
|
|
}
|
|
};
|
|
}, [success]);
|
|
|
|
return (
|
|
<Tooltip content={tooltip} placement="top">
|
|
<CopyToClipboard text={value} onCopy={handleCopied}>
|
|
<NudeButton type="button">{icon}</NudeButton>
|
|
</CopyToClipboard>
|
|
</Tooltip>
|
|
);
|
|
}
|