mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-03 05:25:56 +00:00
adjustment: converted remaining salug validation to use slugify
This commit is contained in:
@@ -17,7 +17,6 @@ type Props = {
|
||||
};
|
||||
|
||||
// TODO: Migrate to better form management and validation. Preferable react-hook-form + yup
|
||||
// We should remove this?
|
||||
/**
|
||||
* The dialog modal for when the user wants to create a new workspace
|
||||
* @param {*} param0
|
||||
|
||||
+14
-3
@@ -1,5 +1,6 @@
|
||||
import { Controller, useForm } from "react-hook-form";
|
||||
import { yupResolver } from "@hookform/resolvers/yup";
|
||||
import slugify from "@sindresorhus/slugify";
|
||||
import * as yup from "yup";
|
||||
|
||||
import { createNotification } from "@app/components/notifications";
|
||||
@@ -16,13 +17,19 @@ type Props = {
|
||||
|
||||
const schema = yup.object({
|
||||
name: yup.string().label("Environment Name").required(),
|
||||
slug: yup.string().label("Environment Slug").matches(/^[^./]*$/g, { message: "Invalid [.] or [/] not allowed"}).required()
|
||||
slug: yup
|
||||
.string()
|
||||
.label("Environment Slug")
|
||||
.test({
|
||||
test: (slug) => slugify(slug as string) === slug,
|
||||
message: "Slug must be a valid slug"
|
||||
})
|
||||
.required()
|
||||
});
|
||||
|
||||
export type FormData = yup.InferType<typeof schema>;
|
||||
|
||||
export const UpdateEnvironmentModal = ({ popUp, handlePopUpClose, handlePopUpToggle }: Props) => {
|
||||
|
||||
const { currentWorkspace } = useWorkspace();
|
||||
const { mutateAsync, isLoading } = useUpdateWsEnvironment();
|
||||
const { control, handleSubmit, reset } = useForm<FormData>({
|
||||
@@ -108,7 +115,11 @@ export const UpdateEnvironmentModal = ({ popUp, handlePopUpClose, handlePopUpTog
|
||||
Update
|
||||
</Button>
|
||||
|
||||
<Button onClick={() => handlePopUpClose("updateEnv")} colorSchema="secondary" variant="plain">
|
||||
<Button
|
||||
onClick={() => handlePopUpClose("updateEnv")}
|
||||
colorSchema="secondary"
|
||||
variant="plain"
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user