mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 17:27:40 +00:00
Correct Cloudflare Pages authorization page
This commit is contained in:
@@ -1,102 +1,92 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import Head from "next/head";
|
|
||||||
import Image from "next/image";
|
|
||||||
import Link from "next/link";
|
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { faArrowUpRightFromSquare, faBookOpen } from "@fortawesome/free-solid-svg-icons";
|
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
|
||||||
|
|
||||||
import { useSaveIntegrationAccessToken } from "@app/hooks/api";
|
import {
|
||||||
|
useSaveIntegrationAccessToken
|
||||||
|
} from "@app/hooks/api";
|
||||||
|
|
||||||
import { Button, Card, CardTitle, FormControl, Input } from "../../../components/v2";
|
import { Button,Card, CardTitle, FormControl, Input } from "../../../components/v2";
|
||||||
|
|
||||||
export default function RenderCreateIntegrationPage() {
|
export default function CloudflarePagesIntegrationPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { mutateAsync } = useSaveIntegrationAccessToken();
|
const { mutateAsync } = useSaveIntegrationAccessToken();
|
||||||
|
|
||||||
const [apiKey, setApiKey] = useState("");
|
const [accessKey, setAccessKey] = useState("");
|
||||||
const [apiKeyErrorText, setApiKeyErrorText] = useState("");
|
const [accessKeyErrorText, setAccessKeyErrorText] = useState("");
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [accountId, setAccountId] = useState("");
|
||||||
|
const [accountIdErrorText, setAccountIdErrorText] = useState("");
|
||||||
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
|
|
||||||
const handleButtonClick = async () => {
|
const handleButtonClick = async () => {
|
||||||
try {
|
try {
|
||||||
setApiKeyErrorText("");
|
setAccessKeyErrorText("");
|
||||||
if (apiKey.length === 0) {
|
setAccountIdErrorText("");
|
||||||
setApiKeyErrorText("API Key cannot be blank");
|
if (accessKey.length === 0 || accountId.length === 0) {
|
||||||
return;
|
if (accessKey.length === 0) setAccessKeyErrorText("API token cannot be blank!");
|
||||||
}
|
if (accountId.length === 0) setAccountIdErrorText("Account ID cannot be blank!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
|
||||||
const integrationAuth = await mutateAsync({
|
const integrationAuth = await mutateAsync({
|
||||||
workspaceId: localStorage.getItem("projectData.id"),
|
workspaceId: localStorage.getItem("projectData.id"),
|
||||||
integration: "render",
|
integration: "cloudflare-pages",
|
||||||
accessToken: apiKey
|
accessId: accountId,
|
||||||
});
|
accessToken: accessKey
|
||||||
|
});
|
||||||
|
|
||||||
setIsLoading(false);
|
setAccessKey("");
|
||||||
|
setAccountId("");
|
||||||
|
setIsLoading(false);
|
||||||
|
|
||||||
router.push(`/integrations/render/create?integrationAuthId=${integrationAuth.id}`);
|
router.push(`/integrations/cloudflare-pages/create?integrationAuthId=${integrationAuth.id}`);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex h-full w-full items-center justify-center">
|
<div className="flex h-full w-full items-center justify-center">
|
||||||
<Head>
|
<Card className="max-w-lg rounded-md border border-mineshaft-600 mb-12">
|
||||||
<title>Authorize Render Integration</title>
|
<CardTitle className="text-left px-6" subTitle="After adding your API-key, you will be prompted to set up an integration for a particular Infisical project and environment.">Cloudflare Pages Integration</CardTitle>
|
||||||
<link rel="icon" href="/infisical.ico" />
|
<FormControl
|
||||||
</Head>
|
label="Cloudflare Pages API token"
|
||||||
<Card className="mb-12 max-w-lg rounded-md border border-mineshaft-600">
|
errorText={accessKeyErrorText}
|
||||||
<CardTitle
|
isError={accessKeyErrorText !== "" ?? false}
|
||||||
className="px-6 text-left text-xl"
|
className="mx-6"
|
||||||
subTitle="After adding your API key, you will be prompted to set up an integration for a particular Infisical project and environment."
|
>
|
||||||
>
|
<Input
|
||||||
<div className="flex flex-row items-center">
|
placeholder=""
|
||||||
<div className="inline flex items-center pb-0.5">
|
value={accessKey}
|
||||||
<Image
|
onChange={(e) => setAccessKey(e.target.value)}
|
||||||
src="/images/integrations/Render.png"
|
/>
|
||||||
height={30}
|
</FormControl>
|
||||||
width={30}
|
<FormControl
|
||||||
alt="Render logo"
|
label="Cloudflare Pages Account ID"
|
||||||
/>
|
errorText={accountIdErrorText}
|
||||||
</div>
|
isError={accountIdErrorText !== "" ?? false}
|
||||||
<span className="ml-2.5">Render Integration </span>
|
className="mx-6"
|
||||||
<Link href="https://infisical.com/docs/integrations/cloud/render" passHref>
|
>
|
||||||
<a target="_blank" rel="noopener noreferrer">
|
<Input
|
||||||
<div className="ml-2 mb-1 inline-block cursor-default rounded-md bg-yellow/20 px-1.5 pb-[0.03rem] pt-[0.04rem] text-sm text-yellow opacity-80 hover:opacity-100">
|
placeholder=""
|
||||||
<FontAwesomeIcon icon={faBookOpen} className="mr-1.5" />
|
value={accountId}
|
||||||
Docs
|
onChange={(e) => setAccountId(e.target.value)}
|
||||||
<FontAwesomeIcon
|
/>
|
||||||
icon={faArrowUpRightFromSquare}
|
</FormControl>
|
||||||
className="ml-1.5 mb-[0.07rem] text-xxs"
|
<Button
|
||||||
/>
|
onClick={handleButtonClick}
|
||||||
</div>
|
color="mineshaft"
|
||||||
</a>
|
variant="outline_bg"
|
||||||
</Link>
|
className="mb-6 mt-2 ml-auto mr-6 w-min"
|
||||||
</div>
|
isFullWidth={false}
|
||||||
</CardTitle>
|
isLoading={isLoading}
|
||||||
<FormControl
|
>
|
||||||
label="Render API Key"
|
Connect to Cloudflare Pages
|
||||||
errorText={apiKeyErrorText}
|
</Button>
|
||||||
isError={apiKeyErrorText !== "" ?? false}
|
</Card>
|
||||||
className="px-6"
|
</div>
|
||||||
>
|
);
|
||||||
<Input placeholder="rnd_xxx" value={apiKey} onChange={(e) => setApiKey(e.target.value)} />
|
|
||||||
</FormControl>
|
|
||||||
<Button
|
|
||||||
onClick={handleButtonClick}
|
|
||||||
colorSchema="primary"
|
|
||||||
variant="outline_bg"
|
|
||||||
className="mb-6 mt-2 ml-auto mr-6 w-min"
|
|
||||||
isLoading={isLoading}
|
|
||||||
>
|
|
||||||
Connect to Render
|
|
||||||
</Button>
|
|
||||||
</Card>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderCreateIntegrationPage.requireAuth = true;
|
CloudflarePagesIntegrationPage.requireAuth = true;
|
||||||
Reference in New Issue
Block a user