|
|
|
@ -1,58 +1,48 @@
|
|
|
|
import { useState } from "react";
|
|
|
|
import { useCallback, useMemo, useState } from "react";
|
|
|
|
import { Formik } from "formik";
|
|
|
|
import { Formik } from "formik";
|
|
|
|
import * as yup from "yup";
|
|
|
|
|
|
|
|
import { XIcon } from "@heroicons/react/outline";
|
|
|
|
import { XIcon } from "@heroicons/react/outline";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
|
|
|
getFinalValues,
|
|
|
|
|
|
|
|
getInitialValues,
|
|
|
|
|
|
|
|
validationSchema
|
|
|
|
|
|
|
|
} from "./form-utils";
|
|
|
|
import General from "./General";
|
|
|
|
import General from "./General";
|
|
|
|
import Labels from "./Labels";
|
|
|
|
import Labels from "./Labels";
|
|
|
|
import {
|
|
|
|
|
|
|
|
topLevelVolumeConfigInitialValues,
|
|
|
|
|
|
|
|
volumeConfigCanvasInitialValues
|
|
|
|
|
|
|
|
} from "../../../utils";
|
|
|
|
|
|
|
|
import { CallbackFunction } from "../../../types";
|
|
|
|
import { CallbackFunction } from "../../../types";
|
|
|
|
|
|
|
|
|
|
|
|
interface ICreateVolumeModal {
|
|
|
|
interface ICreateVolumeModalProps {
|
|
|
|
onHide: CallbackFunction;
|
|
|
|
onHide: CallbackFunction;
|
|
|
|
onAddEndpoint: CallbackFunction;
|
|
|
|
onAddEndpoint: CallbackFunction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const CreateVolumeModal = (props: ICreateVolumeModal) => {
|
|
|
|
const tabs = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "General",
|
|
|
|
|
|
|
|
href: "#",
|
|
|
|
|
|
|
|
current: true,
|
|
|
|
|
|
|
|
hidden: false
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "Labels",
|
|
|
|
|
|
|
|
href: "#",
|
|
|
|
|
|
|
|
current: false,
|
|
|
|
|
|
|
|
hidden: false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const classNames = (...classes: string[]) => classes.filter(Boolean).join(" ");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CreateVolumeModal = (props: ICreateVolumeModalProps) => {
|
|
|
|
const { onHide, onAddEndpoint } = props;
|
|
|
|
const { onHide, onAddEndpoint } = props;
|
|
|
|
const [openTab, setOpenTab] = useState("General");
|
|
|
|
const [openTab, setOpenTab] = useState("General");
|
|
|
|
const handleCreate = (values: any, formik: any) => {
|
|
|
|
|
|
|
|
onAddEndpoint(values);
|
|
|
|
const handleCreate = useCallback((values: any, formik: any) => {
|
|
|
|
|
|
|
|
onAddEndpoint(getFinalValues(values));
|
|
|
|
formik.resetForm();
|
|
|
|
formik.resetForm();
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
const validationSchema = yup.object({
|
|
|
|
|
|
|
|
canvasConfig: yup.object({
|
|
|
|
const initialValues = useMemo(() => getInitialValues(), []);
|
|
|
|
node_name: yup
|
|
|
|
|
|
|
|
.string()
|
|
|
|
|
|
|
|
.max(256, "volume name should be 256 characters or less")
|
|
|
|
|
|
|
|
.required("volume name is required")
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
volumeConfig: yup.object({
|
|
|
|
|
|
|
|
name: yup
|
|
|
|
|
|
|
|
.string()
|
|
|
|
|
|
|
|
.max(256, "name should be 256 characters or less")
|
|
|
|
|
|
|
|
.required("name is required")
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
const tabs = [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "General",
|
|
|
|
|
|
|
|
href: "#",
|
|
|
|
|
|
|
|
current: true,
|
|
|
|
|
|
|
|
hidden: false
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: "Labels",
|
|
|
|
|
|
|
|
href: "#",
|
|
|
|
|
|
|
|
current: false,
|
|
|
|
|
|
|
|
hidden: false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
const classNames = (...classes: string[]) => {
|
|
|
|
|
|
|
|
return classes.filter(Boolean).join(" ");
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
|
|
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
|
|
|
@ -64,7 +54,7 @@ const CreateVolumeModal = (props: ICreateVolumeModal) => {
|
|
|
|
<div className="relative w-auto my-6 mx-auto max-w-5xl z-50">
|
|
|
|
<div className="relative w-auto my-6 mx-auto max-w-5xl z-50">
|
|
|
|
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
|
|
|
|
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
|
|
|
|
<div className="flex items-center justify-between px-4 py-3 border-b border-solid border-blueGray-200 rounded-t">
|
|
|
|
<div className="flex items-center justify-between px-4 py-3 border-b border-solid border-blueGray-200 rounded-t">
|
|
|
|
<h3 className="text-sm font-semibold">Create top level volume</h3>
|
|
|
|
<h3 className="text-sm font-semibold">Add top level volume</h3>
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
className="p-1 ml-auto text-black float-right outline-none focus:outline-none"
|
|
|
|
className="p-1 ml-auto text-black float-right outline-none focus:outline-none"
|
|
|
|
onClick={onHide}
|
|
|
|
onClick={onHide}
|
|
|
|
@ -76,23 +66,9 @@ const CreateVolumeModal = (props: ICreateVolumeModal) => {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<Formik
|
|
|
|
<Formik
|
|
|
|
initialValues={{
|
|
|
|
initialValues={initialValues}
|
|
|
|
canvasConfig: {
|
|
|
|
|
|
|
|
...volumeConfigCanvasInitialValues()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
volumeConfig: {
|
|
|
|
|
|
|
|
...topLevelVolumeConfigInitialValues()
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
key: "volume",
|
|
|
|
|
|
|
|
type: "VOLUME",
|
|
|
|
|
|
|
|
inputs: [],
|
|
|
|
|
|
|
|
outputs: [],
|
|
|
|
|
|
|
|
config: {}
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
enableReinitialize={true}
|
|
|
|
enableReinitialize={true}
|
|
|
|
onSubmit={(values, formik) => {
|
|
|
|
onSubmit={handleCreate}
|
|
|
|
handleCreate(values, formik);
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
validationSchema={validationSchema}
|
|
|
|
validationSchema={validationSchema}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{(formik) => (
|
|
|
|
{(formik) => (
|
|
|
|
@ -133,9 +109,7 @@ const CreateVolumeModal = (props: ICreateVolumeModal) => {
|
|
|
|
<button
|
|
|
|
<button
|
|
|
|
className="btn-util"
|
|
|
|
className="btn-util"
|
|
|
|
type="button"
|
|
|
|
type="button"
|
|
|
|
onClick={() => {
|
|
|
|
onClick={formik.submitForm}
|
|
|
|
formik.submitForm();
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
Add
|
|
|
|
Add
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
|