mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-16 06:45:28 +00:00
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { useState } from "react";
|
|
import { useNavigate } from "@tanstack/react-router";
|
|
|
|
import { Button, Card, CardTitle, FormControl, Input } from "@app/components/v2";
|
|
import { useWorkspace } from "@app/context";
|
|
import { useSaveIntegrationAccessToken } from "@app/hooks/api";
|
|
|
|
export const CodefreshAuthorizePage = () => {
|
|
const navigate = useNavigate();
|
|
const { mutateAsync } = useSaveIntegrationAccessToken();
|
|
|
|
const [apiKey, setApiKey] = useState("");
|
|
const [apiKeyErrorText, setApiKeyErrorText] = useState("");
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const { currentWorkspace } = useWorkspace();
|
|
|
|
const handleButtonClick = async () => {
|
|
try {
|
|
setApiKeyErrorText("");
|
|
if (apiKey.length === 0) {
|
|
setApiKeyErrorText("API Key cannot be blank");
|
|
return;
|
|
}
|
|
|
|
setIsLoading(true);
|
|
|
|
const integrationAuth = await mutateAsync({
|
|
workspaceId: currentWorkspace.id,
|
|
integration: "codefresh",
|
|
accessToken: apiKey
|
|
});
|
|
|
|
setIsLoading(false);
|
|
|
|
navigate({
|
|
to: "/secret-manager/$projectId/integrations/codefresh/create",
|
|
params: {
|
|
projectId: currentWorkspace.id
|
|
},
|
|
search: {
|
|
integrationAuthId: integrationAuth.id
|
|
}
|
|
});
|
|
} catch (err) {
|
|
console.error(err);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="flex h-full w-full items-center justify-center">
|
|
<Card className="max-w-md rounded-md p-8">
|
|
<CardTitle className="text-center">Codefresh Integration</CardTitle>
|
|
<FormControl
|
|
label="Codefresh API Key"
|
|
errorText={apiKeyErrorText}
|
|
isError={apiKeyErrorText !== ""}
|
|
>
|
|
<Input placeholder="" value={apiKey} onChange={(e) => setApiKey(e.target.value)} />
|
|
</FormControl>
|
|
<Button
|
|
onClick={handleButtonClick}
|
|
color="mineshaft"
|
|
className="mt-4"
|
|
isLoading={isLoading}
|
|
>
|
|
Connect to Codefresh
|
|
</Button>
|
|
</Card>
|
|
</div>
|
|
);
|
|
};
|