diff --git a/services/frontend/src/components/Modal/Service/Create.tsx b/services/frontend/src/components/Modal/Service/Create.tsx index 3315933..09cf94a 100644 --- a/services/frontend/src/components/Modal/Service/Create.tsx +++ b/services/frontend/src/components/Modal/Service/Create.tsx @@ -23,7 +23,8 @@ const ModalServiceCreate = (props: IModalServiceProps) => { ...serviceConfigCanvasInitialValues() }, serviceConfig: { - container_name: "" + container_name: "", + labels: [] }, key: "service", type: "SERVICE", diff --git a/services/frontend/src/components/Modal/Service/Edit.tsx b/services/frontend/src/components/Modal/Service/Edit.tsx index 2eb49be..5f1a9d9 100644 --- a/services/frontend/src/components/Modal/Service/Edit.tsx +++ b/services/frontend/src/components/Modal/Service/Edit.tsx @@ -29,7 +29,8 @@ const ModalServiceEdit = (props: IModalServiceProps) => { ...serviceConfigCanvasInitialValues() }, serviceConfig: { - container_name: "" + container_name: "", + labels: [] } }, onSubmit: () => undefined @@ -79,7 +80,7 @@ const ModalServiceEdit = (props: IModalServiceProps) => { } as ICanvasConfig; formik.initialValues.serviceConfig = { ...selectedNode.serviceConfig - } as IService; + } as any; // as IService; } }, [selectedNode]); diff --git a/services/frontend/src/components/Modal/Service/Labels.tsx b/services/frontend/src/components/Modal/Service/Labels.tsx index 9838a34..99ddcdc 100644 --- a/services/frontend/src/components/Modal/Service/Labels.tsx +++ b/services/frontend/src/components/Modal/Service/Labels.tsx @@ -1,6 +1,72 @@ +import { PlusIcon } from "@heroicons/react/outline"; +import Record from "../../Record"; +import { Button } from "@mui/joy"; +import { styled } from "@mui/joy"; +import { useCallback } from "react"; + +const Root = styled("div")` + display: flex; + flex-direction: column; +`; + +const Records = styled("div")` + display: flex; + flex-direction: column; + row-gap: ${({ theme }) => theme.spacing(1)}; +`; + +const AddButton = styled(Button)` + width: 120px; + margin-top: ${({ theme }) => theme.spacing(2)}; +`; + const Labels = (props: any) => { const { formik } = props; - return <>; + const { labels } = formik.values.serviceConfig; + + const handleNewLabel = useCallback(() => { + formik.setFieldValue(`serviceConfig.labels[${labels.length}]`, { + key: "", + value: "" + }); + }, [formik]); + + return ( + 0 ? "flex-start" : "center" }}> + {labels.length > 0 && ( + + {labels.map((label: unknown, index: number) => ( + + ))} + + )} + {labels.length === 0 && ( +

+ The service does not have any labels. +
+ Click "+ New Label" to add a new label. +

+ )} + + + + New Label + +
+ ); }; export default Labels;