feat: mcp copy to clipboard

This commit is contained in:
Nevo David 2025-04-14 11:49:44 +07:00
parent de14aead77
commit 026957b96e
1 changed files with 14 additions and 5 deletions

View File

@ -9,7 +9,7 @@ import { useVariables } from '@gitroom/react/helpers/variable.context';
export const PublicComponent = () => {
const user = useUser();
const {frontEndUrl} = useVariables();
const { backendUrl } = useVariables();
const toaster = useToaster();
const [reveal, setReveal] = useState(false);
const [reveal2, setReveal2] = useState(false);
@ -19,6 +19,11 @@ export const PublicComponent = () => {
copy(user?.publicApi!);
}, [user]);
const copyToClipboard2 = useCallback(() => {
toaster.show('MCP copied to clipboard', 'success');
copy(`${backendUrl}/mcp/` + user?.publicApi + '/sse');
}, [user]);
if (!user || !user.publicApi) {
return null;
}
@ -64,11 +69,15 @@ export const PublicComponent = () => {
<div className="my-[16px] mt-[16px] bg-sixth border-fifth items-center border rounded-[4px] p-[24px] flex gap-[24px]">
<div className="flex items-center">
{reveal2 ? (
`${frontEndUrl}/mcp/` + user.publicApi + '/sse'
`${backendUrl}/mcp/` + user.publicApi + '/sse'
) : (
<>
<div className="blur-sm">{(`${frontEndUrl}/mcp/` + user.publicApi + '/sse').slice(0, -5)}</div>
<div>{(`${frontEndUrl}/mcp/` + user.publicApi + '/sse').slice(-5)}</div>
<div className="blur-sm">
{(`${backendUrl}/mcp/` + user.publicApi + '/sse').slice(0, -5)}
</div>
<div>
{(`${backendUrl}/mcp/` + user.publicApi + '/sse').slice(-5)}
</div>
</>
)}
</div>
@ -76,7 +85,7 @@ export const PublicComponent = () => {
{!reveal2 ? (
<Button onClick={() => setReveal2(true)}>Reveal</Button>
) : (
<Button onClick={copyToClipboard}>Copy Key</Button>
<Button onClick={copyToClipboard2}>Copy Key</Button>
)}
</div>
</div>