diff --git a/ui100/src/EnvironmentPanel.tsx b/ui100/src/EnvironmentPanel.tsx index 93cf5f84..34f9c3ff 100644 --- a/ui100/src/EnvironmentPanel.tsx +++ b/ui100/src/EnvironmentPanel.tsx @@ -57,25 +57,6 @@ const EnvironmentPanel = ({environment}: EnvironmentPanelProps) => { }) }, [environment]); - const releaseEnvironment = () => { - if(environment.data && environment.data.envZId) { - console.log("releasing"); - let cfg = new Configuration({ - headers: { - "X-TOKEN": user.token - } - }); - let environmentApi = new EnvironmentApi(cfg); - environmentApi.disable({body: {identity: environment.data.envZId as string}}) - .then(d => { - setReleaseEnvironmentOpen(false); - }) - .catch(e => { - console.log("releaseEnvironment", e); - }); - } - } - return ( <> @@ -97,7 +78,7 @@ const EnvironmentPanel = ({environment}: EnvironmentPanelProps) => { - + ); } diff --git a/ui100/src/ReleaseEnvironmentModal.tsx b/ui100/src/ReleaseEnvironmentModal.tsx index ba0de2a2..b8b0cb8c 100644 --- a/ui100/src/ReleaseEnvironmentModal.tsx +++ b/ui100/src/ReleaseEnvironmentModal.tsx @@ -1,22 +1,25 @@ -import {Environment} from "./api"; +import {Configuration, Environment, EnvironmentApi} 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"; +import {User} from "./model/user.ts"; +import {Node} from "@xyflow/react"; interface ReleaseEnvironmentProps { close: () => void; isOpen: boolean; + user: User; + environment: Node; detail: Environment; - action: () => void; } -const ReleaseEnvironmentModal = ({ close, isOpen, detail, action }: ReleaseEnvironmentProps) => { +const ReleaseEnvironmentModal = ({ close, isOpen, user, environment, detail }: ReleaseEnvironmentProps) => { const [description, setDescription] = useState(""); const [checked, setChecked] = useState(false); const checkedRef = useRef(); checkedRef.current = checked; - const toggleChecked = (event: React.ChangeEvent) => { + const toggleChecked = () => { setChecked(!checkedRef.current); } @@ -30,6 +33,27 @@ const ReleaseEnvironmentModal = ({ close, isOpen, detail, action }: ReleaseEnvir } }, [detail]); + const releaseEnvironment = () => { + if(environment.data && environment.data.envZId) { + console.log("releasing"); + let cfg = new Configuration({ + headers: { + "X-TOKEN": user.token + } + }); + let environmentApi = new EnvironmentApi(cfg); + environmentApi.disable({body: {identity: environment.data.envZId as string}}) + .then(d => { + close(); + }) + .catch(e => { + e.response.json().then(ex => { + console.log("releaseEnvironment", ex.message); + }) + }); + } + } + return ( @@ -46,7 +70,7 @@ const ReleaseEnvironmentModal = ({ close, isOpen, detail, action }: ReleaseEnvir } label={

I confirm the release of {description}

} sx={{ mt: 2 }} /> - +