mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 02:26:26 +00:00
fix: secerets mgmt project slug automatic generation
This commit is contained in:
+10
-3
@@ -1,5 +1,6 @@
|
|||||||
import { Controller, useForm } from "react-hook-form";
|
import { Controller, useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
|
import slugify from "@sindresorhus/slugify";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
@@ -31,7 +32,7 @@ type ContentProps = {
|
|||||||
const Content = ({ onComplete }: ContentProps) => {
|
const Content = ({ onComplete }: ContentProps) => {
|
||||||
const { currentProject } = useProject();
|
const { currentProject } = useProject();
|
||||||
const { mutateAsync, isPending } = useCreateWsEnvironment();
|
const { mutateAsync, isPending } = useCreateWsEnvironment();
|
||||||
const { control, handleSubmit } = useForm<FormData>({
|
const { control, handleSubmit, setValue } = useForm<FormData>({
|
||||||
resolver: zodResolver(schema)
|
resolver: zodResolver(schema)
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,15 +53,21 @@ const Content = ({ onComplete }: ContentProps) => {
|
|||||||
onComplete(env);
|
onComplete(env);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleEnvironmentNameChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
const { value } = e.target;
|
||||||
|
setValue("environmentName", value);
|
||||||
|
setValue("environmentSlug", slugify(value, { lowercase: true }));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={handleSubmit(onFormSubmit)}>
|
<form onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
defaultValue=""
|
defaultValue=""
|
||||||
name="environmentName"
|
name="environmentName"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field: { onChange, ...field }, fieldState: { error } }) => (
|
||||||
<FormControl label="Environment Name" isError={Boolean(error)} errorText={error?.message}>
|
<FormControl label="Environment Name" isError={Boolean(error)} errorText={error?.message}>
|
||||||
<Input {...field} />
|
<Input {...field} onChange={handleEnvironmentNameChange} />
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user