mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 21:27:10 +00:00
some review changes
This commit is contained in:
+4
-6
@@ -208,7 +208,7 @@ export const GatewayCliDeploymentMethod = () => {
|
|||||||
placeholder="Enter gateway name..."
|
placeholder="Enter gateway name..."
|
||||||
isError={Boolean(errors.name)}
|
isError={Boolean(errors.name)}
|
||||||
/>
|
/>
|
||||||
{errors.name && <p className="mt-1 text-sm text-red-500">{errors.name}</p>}
|
{errors.name && <p className="mt-1 text-sm text-red">{errors.name}</p>}
|
||||||
|
|
||||||
<FormLabel label="Relay" tooltipText="The relay to use with your gateway." className="mt-4" />
|
<FormLabel label="Relay" tooltipText="The relay to use with your gateway." className="mt-4" />
|
||||||
<FilterableSelect
|
<FilterableSelect
|
||||||
@@ -236,7 +236,7 @@ export const GatewayCliDeploymentMethod = () => {
|
|||||||
getOptionValue={(option) => option.id}
|
getOptionValue={(option) => option.id}
|
||||||
components={{ Option: RelayOption }}
|
components={{ Option: RelayOption }}
|
||||||
/>
|
/>
|
||||||
{errors.relay && <p className="mt-1 text-sm text-red-500">{errors.relay}</p>}
|
{errors.relay && <p className="mt-1 text-sm text-red">{errors.relay}</p>}
|
||||||
|
|
||||||
<FormLabel
|
<FormLabel
|
||||||
label="Instance Domain"
|
label="Instance Domain"
|
||||||
@@ -249,9 +249,7 @@ export const GatewayCliDeploymentMethod = () => {
|
|||||||
placeholder="https://app.infisical.com"
|
placeholder="https://app.infisical.com"
|
||||||
isError={Boolean(errors.instanceDomain)}
|
isError={Boolean(errors.instanceDomain)}
|
||||||
/>
|
/>
|
||||||
{errors.instanceDomain && (
|
{errors.instanceDomain && <p className="mt-1 text-sm text-red">{errors.instanceDomain}</p>}
|
||||||
<p className="mt-1 text-sm text-red-500">{errors.instanceDomain}</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<FormLabel
|
<FormLabel
|
||||||
label="Identity"
|
label="Identity"
|
||||||
@@ -274,7 +272,7 @@ export const GatewayCliDeploymentMethod = () => {
|
|||||||
getOptionValue={(option) => option.id}
|
getOptionValue={(option) => option.id}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
/>
|
/>
|
||||||
{errors.identity && <p className="mt-1 text-sm text-red-500">{errors.identity}</p>}
|
{errors.identity && <p className="mt-1 text-sm text-red">{errors.identity}</p>}
|
||||||
|
|
||||||
<div className="mt-6 flex items-center">
|
<div className="mt-6 flex items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ export const GatewayDeploymentMethodSelect = ({ onSelect }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid h-118 grid-cols-4 content-start gap-2">
|
<div className="grid h-fit grid-cols-4 content-start gap-2">
|
||||||
{deploymentOptions.map((option) => {
|
{deploymentOptions.map((option) => {
|
||||||
const { image, name, method } = option;
|
const { image, name, method } = option;
|
||||||
|
|
||||||
|
|||||||
+78
-10
@@ -13,7 +13,13 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
ModalClose
|
ModalClose
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { useOrganization } from "@app/context";
|
import {
|
||||||
|
OrgPermissionIdentityActions,
|
||||||
|
OrgPermissionSubjects,
|
||||||
|
useOrganization,
|
||||||
|
useOrgPermission
|
||||||
|
} from "@app/context";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useAddIdentityTokenAuth,
|
useAddIdentityTokenAuth,
|
||||||
useCreateTokenIdentityTokenAuth,
|
useCreateTokenIdentityTokenAuth,
|
||||||
@@ -22,11 +28,13 @@ import {
|
|||||||
} from "@app/hooks/api";
|
} from "@app/hooks/api";
|
||||||
import { slugSchema } from "@app/lib/schemas";
|
import { slugSchema } from "@app/lib/schemas";
|
||||||
|
|
||||||
const formSchema = z.object({
|
const baseFormSchema = z.object({
|
||||||
name: slugSchema({ field: "name" }),
|
name: slugSchema({ field: "name" }),
|
||||||
host: z.string().min(1, "Host is required"),
|
host: z.string().min(1, "Host is required"),
|
||||||
|
instanceDomain: z.string().url("Must be a valid URL").or(z.literal(""))
|
||||||
|
});
|
||||||
|
|
||||||
instanceDomain: z.string().url("Must be a valid URL").or(z.literal("")),
|
const formSchemaWithIdentity = baseFormSchema.extend({
|
||||||
identity: z
|
identity: z
|
||||||
.object(
|
.object(
|
||||||
{
|
{
|
||||||
@@ -39,11 +47,16 @@ const formSchema = z.object({
|
|||||||
.refine((val) => val !== null, { message: "Identity is required" })
|
.refine((val) => val !== null, { message: "Identity is required" })
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const formSchemaWithToken = baseFormSchema.extend({
|
||||||
|
identityToken: z.string().min(1, "Token is required")
|
||||||
|
});
|
||||||
|
|
||||||
export const RelayCliDeploymentMethod = () => {
|
export const RelayCliDeploymentMethod = () => {
|
||||||
const { protocol, hostname, port } = window.location;
|
const { protocol, hostname, port } = window.location;
|
||||||
const portSuffix = port && port !== "80" ? `:${port}` : "";
|
const portSuffix = port && port !== "80" ? `:${port}` : "";
|
||||||
const siteURL = `${protocol}//${hostname}${portSuffix}`;
|
const siteURL = `${protocol}//${hostname}${portSuffix}`;
|
||||||
|
|
||||||
|
const [addTokenManually, setAddTokenManually] = useState(false);
|
||||||
const [step, setStep] = useState<"form" | "command">("form");
|
const [step, setStep] = useState<"form" | "command">("form");
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState("");
|
||||||
const [host, setHost] = useState("");
|
const [host, setHost] = useState("");
|
||||||
@@ -69,6 +82,12 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
const { currentOrg } = useOrganization();
|
const { currentOrg } = useOrganization();
|
||||||
const organizationId = currentOrg?.id || "";
|
const organizationId = currentOrg?.id || "";
|
||||||
|
|
||||||
|
const { permission } = useOrgPermission();
|
||||||
|
const canCreateToken = permission.can(
|
||||||
|
OrgPermissionIdentityActions.CreateToken,
|
||||||
|
OrgPermissionSubjects.Identity
|
||||||
|
);
|
||||||
|
|
||||||
const { data: identityMembershipOrgsData, isPending: isIdentitiesLoading } =
|
const { data: identityMembershipOrgsData, isPending: isIdentitiesLoading } =
|
||||||
useGetIdentityMembershipOrgs({
|
useGetIdentityMembershipOrgs({
|
||||||
organizationId,
|
organizationId,
|
||||||
@@ -84,7 +103,9 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
|
|
||||||
const handleGenerateCommand = async () => {
|
const handleGenerateCommand = async () => {
|
||||||
setFormErrors([]);
|
setFormErrors([]);
|
||||||
const validation = formSchema.safeParse({ name, host, instanceDomain, identity });
|
|
||||||
|
if (canCreateToken) {
|
||||||
|
const validation = formSchemaWithIdentity.safeParse({ name, host, instanceDomain, identity });
|
||||||
if (!validation.success) {
|
if (!validation.success) {
|
||||||
setFormErrors(validation.error.issues);
|
setFormErrors(validation.error.issues);
|
||||||
return;
|
return;
|
||||||
@@ -127,6 +148,19 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
});
|
});
|
||||||
setIdentityToken("");
|
setIdentityToken("");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const validation = formSchemaWithToken.safeParse({
|
||||||
|
name,
|
||||||
|
host,
|
||||||
|
instanceDomain,
|
||||||
|
identityToken
|
||||||
|
});
|
||||||
|
if (!validation.success) {
|
||||||
|
setFormErrors(validation.error.issues);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setStep("command");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleIdentityChange = (
|
const handleIdentityChange = (
|
||||||
@@ -194,7 +228,7 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
placeholder="Enter relay name..."
|
placeholder="Enter relay name..."
|
||||||
isError={Boolean(errors.name)}
|
isError={Boolean(errors.name)}
|
||||||
/>
|
/>
|
||||||
{errors.name && <p className="mt-1 text-sm text-red-500">{errors.name}</p>}
|
{errors.name && <p className="mt-1 text-sm text-red">{errors.name}</p>}
|
||||||
|
|
||||||
<FormLabel
|
<FormLabel
|
||||||
label="Host"
|
label="Host"
|
||||||
@@ -207,7 +241,7 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
placeholder="0.0.0.0"
|
placeholder="0.0.0.0"
|
||||||
isError={Boolean(errors.host)}
|
isError={Boolean(errors.host)}
|
||||||
/>
|
/>
|
||||||
{errors.host && <p className="mt-1 text-sm text-red-500">{errors.host}</p>}
|
{errors.host && <p className="mt-1 text-sm text-red">{errors.host}</p>}
|
||||||
|
|
||||||
<FormLabel
|
<FormLabel
|
||||||
label="Instance Domain"
|
label="Instance Domain"
|
||||||
@@ -220,10 +254,10 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
placeholder="https://app.infisical.com"
|
placeholder="https://app.infisical.com"
|
||||||
isError={Boolean(errors.instanceDomain)}
|
isError={Boolean(errors.instanceDomain)}
|
||||||
/>
|
/>
|
||||||
{errors.instanceDomain && (
|
{errors.instanceDomain && <p className="mt-1 text-sm text-red">{errors.instanceDomain}</p>}
|
||||||
<p className="mt-1 text-sm text-red-500">{errors.instanceDomain}</p>
|
|
||||||
)}
|
|
||||||
|
|
||||||
|
{canCreateToken && !addTokenManually ? (
|
||||||
|
<>
|
||||||
<FormLabel
|
<FormLabel
|
||||||
label="Identity"
|
label="Identity"
|
||||||
tooltipText="The identity that your relay will use for authentication."
|
tooltipText="The identity that your relay will use for authentication."
|
||||||
@@ -245,7 +279,41 @@ export const RelayCliDeploymentMethod = () => {
|
|||||||
getOptionValue={(option) => option.id}
|
getOptionValue={(option) => option.id}
|
||||||
getOptionLabel={(option) => option.name}
|
getOptionLabel={(option) => option.name}
|
||||||
/>
|
/>
|
||||||
{errors.identity && <p className="mt-1 text-sm text-red-500">{errors.identity}</p>}
|
<p className="mt-1 text-xs text-yellow">
|
||||||
|
Selecting an identity will automatically enable token auth and generate a token.{" "}
|
||||||
|
<button
|
||||||
|
onClick={() => setAddTokenManually(true)}
|
||||||
|
className="cursor-pointer underline transition-opacity hover:opacity-70"
|
||||||
|
>
|
||||||
|
Add token manually
|
||||||
|
</button>
|
||||||
|
</p>
|
||||||
|
{errors.identity && <p className="mt-1 text-sm text-red">{errors.identity}</p>}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<FormLabel
|
||||||
|
label="Identity Token"
|
||||||
|
tooltipText="The identity token that your relay will use for authentication."
|
||||||
|
className="mt-4"
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
value={identityToken}
|
||||||
|
onChange={(e) => setIdentityToken(e.target.value)}
|
||||||
|
placeholder="Enter identity token..."
|
||||||
|
isError={Boolean(errors.identityToken)}
|
||||||
|
/>
|
||||||
|
{canCreateToken && (
|
||||||
|
<button
|
||||||
|
onClick={() => setAddTokenManually(false)}
|
||||||
|
className="mt-1 cursor-pointer text-xs text-mineshaft-400 underline transition-opacity hover:opacity-70"
|
||||||
|
>
|
||||||
|
Autogenerate token for identity
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
{errors.identityToken && <p className="mt-1 text-sm text-red">{errors.identityToken}</p>}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="mt-6 flex items-center">
|
<div className="mt-6 flex items-center">
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@ export const RelayDeploymentMethodSelect = ({ onSelect }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid h-118 grid-cols-4 content-start gap-2">
|
<div className="grid h-fit grid-cols-4 content-start gap-2">
|
||||||
{deploymentOptions.map((option) => {
|
{deploymentOptions.map((option) => {
|
||||||
const { image, name, method } = option;
|
const { image, name, method } = option;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user