|
|
|
@ -1,7 +1,4 @@
|
|
|
|
import { useEffect, useMemo, useState } from "react";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
import { Formik } from "formik";
|
|
|
|
|
|
|
|
import { XIcon } from "@heroicons/react/outline";
|
|
|
|
|
|
|
|
import General from "./General";
|
|
|
|
|
|
|
|
import type {
|
|
|
|
import type {
|
|
|
|
CallbackFunction,
|
|
|
|
CallbackFunction,
|
|
|
|
IEditVolumeForm,
|
|
|
|
IEditVolumeForm,
|
|
|
|
@ -14,10 +11,7 @@ import {
|
|
|
|
validationSchema
|
|
|
|
validationSchema
|
|
|
|
} from "./form-utils";
|
|
|
|
} from "./form-utils";
|
|
|
|
import { toaster } from "../../../../utils";
|
|
|
|
import { toaster } from "../../../../utils";
|
|
|
|
import { reportErrorsAndSubmit } from "../../../../utils/forms";
|
|
|
|
import FormModal from "../../../FormModal";
|
|
|
|
import { ScrollView } from "../../../ScrollView";
|
|
|
|
|
|
|
|
import Tabs from "../../../Tabs";
|
|
|
|
|
|
|
|
import Tab from "../../../Tab";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
interface IEditVolumeModal {
|
|
|
|
interface IEditVolumeModal {
|
|
|
|
node: IVolumeNodeItem;
|
|
|
|
node: IVolumeNodeItem;
|
|
|
|
@ -27,7 +21,6 @@ interface IEditVolumeModal {
|
|
|
|
|
|
|
|
|
|
|
|
const EditVolumeModal = (props: IEditVolumeModal) => {
|
|
|
|
const EditVolumeModal = (props: IEditVolumeModal) => {
|
|
|
|
const { node, onHide, onUpdateEndpoint } = props;
|
|
|
|
const { node, onHide, onUpdateEndpoint } = props;
|
|
|
|
const [openTab, setOpenTab] = useState("General");
|
|
|
|
|
|
|
|
const [selectedNode, setSelectedNode] = useState<IVolumeNodeItem>();
|
|
|
|
const [selectedNode, setSelectedNode] = useState<IVolumeNodeItem>();
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
@ -36,77 +29,25 @@ const EditVolumeModal = (props: IEditVolumeModal) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [node]);
|
|
|
|
}, [node]);
|
|
|
|
|
|
|
|
|
|
|
|
const handleUpdate = (values: IEditVolumeForm) => {
|
|
|
|
const handleUpdate = (
|
|
|
|
onUpdateEndpoint(getFinalValues(values, selectedNode));
|
|
|
|
finalValues: IVolumeNodeItem,
|
|
|
|
|
|
|
|
values: IEditVolumeForm
|
|
|
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
onUpdateEndpoint(finalValues);
|
|
|
|
toaster(`Updated "${values.entryName}" volume successfully`, "success");
|
|
|
|
toaster(`Updated "${values.entryName}" volume successfully`, "success");
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const initialValues = useMemo(
|
|
|
|
|
|
|
|
() => getInitialValues(selectedNode),
|
|
|
|
|
|
|
|
[selectedNode]
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className="fixed z-50 inset-0 overflow-y-auto">
|
|
|
|
<FormModal
|
|
|
|
<div className="justify-center items-center flex overflow-x-hidden overflow-y-auto fixed inset-0 outline-none focus:outline-none">
|
|
|
|
title="Edit volume"
|
|
|
|
<div
|
|
|
|
tabs={tabs}
|
|
|
|
onClick={onHide}
|
|
|
|
getInitialValues={getInitialValues}
|
|
|
|
className="opacity-25 fixed inset-0 z-40 bg-black"
|
|
|
|
getFinalValues={getFinalValues}
|
|
|
|
></div>
|
|
|
|
selectedNode={selectedNode}
|
|
|
|
<div className="relative w-auto my-6 mx-auto max-w-5xl z-50">
|
|
|
|
validationSchema={validationSchema}
|
|
|
|
<div className="border-0 rounded-lg shadow-lg relative flex flex-col w-full bg-white outline-none focus:outline-none">
|
|
|
|
onHide={onHide}
|
|
|
|
<div className="flex items-center justify-between px-4 py-3 border-b border-solid border-blueGray-200 rounded-t">
|
|
|
|
onCreate={handleUpdate}
|
|
|
|
<h3 className="text-sm font-semibold">Edit top level volumes</h3>
|
|
|
|
/>
|
|
|
|
<button
|
|
|
|
|
|
|
|
className="p-1 ml-auto text-black float-right outline-none focus:outline-none"
|
|
|
|
|
|
|
|
onClick={onHide}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
<span className="block outline-none focus:outline-none">
|
|
|
|
|
|
|
|
<XIcon className="w-4" />
|
|
|
|
|
|
|
|
</span>
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{selectedNode && (
|
|
|
|
|
|
|
|
<Formik
|
|
|
|
|
|
|
|
initialValues={initialValues}
|
|
|
|
|
|
|
|
enableReinitialize={true}
|
|
|
|
|
|
|
|
onSubmit={handleUpdate}
|
|
|
|
|
|
|
|
validationSchema={validationSchema}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{(formik) => (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
<Tabs value={openTab} onChange={setOpenTab}>
|
|
|
|
|
|
|
|
{tabs.map((tab) => (
|
|
|
|
|
|
|
|
<Tab key={tab.name} value={tab.name} title={tab.name} />
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</Tabs>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ScrollView
|
|
|
|
|
|
|
|
height="500px"
|
|
|
|
|
|
|
|
className="relative px-4 py-3 flex-auto"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{openTab === "General" && <General />}
|
|
|
|
|
|
|
|
</ScrollView>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex items-center justify-end px-4 py-3 border-t border-solid border-blueGray-200 rounded-b">
|
|
|
|
|
|
|
|
<button
|
|
|
|
|
|
|
|
className="btn-util"
|
|
|
|
|
|
|
|
type="button"
|
|
|
|
|
|
|
|
onClick={reportErrorsAndSubmit(formik)}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
Save
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</Formik>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|