-
Notifications
You must be signed in to change notification settings - Fork 195
/
Copy pathDeploymentCredentialsForm.tsx
66 lines (65 loc) · 1.9 KB
/
DeploymentCredentialsForm.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { EnterIcon, EyeNoneIcon, EyeOpenIcon } from "@radix-ui/react-icons";
import { Button } from "dashboard-common/elements/Button";
import { TextInput } from "dashboard-common/elements/TextInput";
import { useState } from "react";
export function DeploymentCredentialsForm({
onSubmit,
initialAdminKey,
initialDeploymentUrl,
}: {
onSubmit: (adminKey: string, deploymentUrl: string) => Promise<void>;
initialAdminKey: string | null;
initialDeploymentUrl: string | null;
}) {
const [draftAdminKey, setDraftAdminKey] = useState<string>(
initialAdminKey ?? "",
);
const [draftDeploymentUrl, setDraftDeploymentUrl] = useState<string>(
initialDeploymentUrl ?? "",
);
const [showKey, setShowKey] = useState(false);
return (
<form
className="flex w-[30rem] flex-col gap-2"
onSubmit={(e) => {
e.preventDefault();
void onSubmit(draftAdminKey, draftDeploymentUrl);
}}
>
<TextInput
id="deploymentUrl"
label="Deployment URL"
value={draftDeploymentUrl}
placeholder="Enter the deployment URL"
onChange={(e) => {
setDraftDeploymentUrl(e.target.value);
}}
/>
<TextInput
id="adminKey"
label="Admin Key"
type={showKey ? "text" : "password"}
Icon={showKey ? EyeNoneIcon : EyeOpenIcon}
outerClassname="w-[30rem]"
placeholder="Enter the admin key for this deployment"
value={draftAdminKey}
action={() => {
setShowKey(!showKey);
}}
description="The admin key is required every time you open the dashboard."
onChange={(e) => {
setDraftAdminKey(e.target.value);
}}
/>
<Button
type="submit"
icon={<EnterIcon />}
disabled={!draftAdminKey || !draftDeploymentUrl}
size="xs"
className="ml-auto w-fit"
>
Log In
</Button>
</form>
);
}