diff --git a/ui100/src/EnvironmentPanel.tsx b/ui100/src/EnvironmentPanel.tsx index e5d7a662..93cf5f84 100644 --- a/ui100/src/EnvironmentPanel.tsx +++ b/ui100/src/EnvironmentPanel.tsx @@ -1,63 +1,13 @@ import {Node} from "@xyflow/react"; -import {Box, Button, Checkbox, FormControlLabel, Grid2, Modal, Tooltip, Typography} from "@mui/material"; +import {Button, Grid2, Tooltip, Typography} from "@mui/material"; import EnvironmentIcon from "@mui/icons-material/Computer"; -import {useEffect, useRef, useState} from "react"; +import {useEffect, useState} from "react"; import {Configuration, Environment, EnvironmentApi, MetadataApi} from "./api"; import PropertyTable from "./PropertyTable.tsx"; import SecretToggle from "./SecretToggle.tsx"; import useStore from "./model/store.ts"; import DeleteIcon from "@mui/icons-material/Delete"; -import {modalStyle} from "./styling/theme.ts"; - -interface ReleaseEnvironmentProps { - close: () => void; - isOpen: boolean; - detail: Environment; - action: () => void; -} - -const ReleaseEnvironmentModal = ({ close, isOpen, detail, action }: ReleaseEnvironmentProps) => { - const [description, setDescription] = useState(""); - const [checked, setChecked] = useState(false); - const checkedRef = useRef(); - checkedRef.current = checked; - - const toggleChecked = (event: React.ChangeEvent) => { - setChecked(!checkedRef.current); - } - - useEffect(() => { - setChecked(false); - }, [isOpen]); - - useEffect(() => { - if(detail && detail.description) { - setDescription(detail.description); - } - }, [detail]); - - return ( - - - - Release Environment - - - Would you like to release the environment {description} ? - - - Releasing this environment will also release any shares and accesses that are associated with it. - - - } label={

I confirm the release of {description}

} sx={{ mt: 2 }} /> -
- - - -
-
- ); -} +import ReleaseEnvironmentModal from "./ReleaseEnvironmentModal.tsx"; interface EnvironmentPanelProps { environment: Node; @@ -108,14 +58,15 @@ const EnvironmentPanel = ({environment}: EnvironmentPanelProps) => { }, [environment]); const releaseEnvironment = () => { - if(detail && detail.zId) { + if(environment.data && environment.data.envZId) { + console.log("releasing"); let cfg = new Configuration({ headers: { "X-TOKEN": user.token } }); - let environment = new EnvironmentApi(cfg); - environment.disable({body: {identity: detail.zId}}) + let environmentApi = new EnvironmentApi(cfg); + environmentApi.disable({body: {identity: environment.data.envZId as string}}) .then(d => { setReleaseEnvironmentOpen(false); }) diff --git a/ui100/src/ReleaseEnvironmentModal.tsx b/ui100/src/ReleaseEnvironmentModal.tsx new file mode 100644 index 00000000..ba0de2a2 --- /dev/null +++ b/ui100/src/ReleaseEnvironmentModal.tsx @@ -0,0 +1,56 @@ +import {Environment} from "./api"; +import {useEffect, useRef, useState} from "react"; +import {Box, Button, Checkbox, FormControlLabel, Grid2, Modal, Typography} from "@mui/material"; +import {modalStyle} from "./styling/theme.ts"; + +interface ReleaseEnvironmentProps { + close: () => void; + isOpen: boolean; + detail: Environment; + action: () => void; +} + +const ReleaseEnvironmentModal = ({ close, isOpen, detail, action }: ReleaseEnvironmentProps) => { + const [description, setDescription] = useState(""); + const [checked, setChecked] = useState(false); + const checkedRef = useRef(); + checkedRef.current = checked; + + const toggleChecked = (event: React.ChangeEvent) => { + setChecked(!checkedRef.current); + } + + useEffect(() => { + setChecked(false); + }, [isOpen]); + + useEffect(() => { + if(detail && detail.description) { + setDescription(detail.description); + } + }, [detail]); + + return ( + + + + Release Environment + + + Would you like to release the environment {description} ? + + + Releasing this environment will also release any shares and accesses that are associated with it. + + + } label={

I confirm the release of {description}

} sx={{ mt: 2 }} /> +
+ + + +
+
+ ); +} + +export default ReleaseEnvironmentModal; \ No newline at end of file