From 143c4b88ab2f13d22f30f2d0e62d35d8a2cebbcc Mon Sep 17 00:00:00 2001 From: Michael Quigley Date: Fri, 24 Jan 2025 10:55:22 -0500 Subject: [PATCH] split out ReleaseShareModal (#822) --- ui100/src/ReleaseShareModal.tsx | 53 +++++++++++++++++++++++++++++++++ ui100/src/SharePanel.tsx | 53 ++------------------------------- 2 files changed, 56 insertions(+), 50 deletions(-) create mode 100644 ui100/src/ReleaseShareModal.tsx diff --git a/ui100/src/ReleaseShareModal.tsx b/ui100/src/ReleaseShareModal.tsx new file mode 100644 index 00000000..bdcae63a --- /dev/null +++ b/ui100/src/ReleaseShareModal.tsx @@ -0,0 +1,53 @@ +import {Share} 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 ReleaseShareProps { + close: () => void; + isOpen: boolean; + detail: Share; + action: () => void; +} + +const ReleaseShareModal = ({ close, isOpen, detail, action }: ReleaseShareProps) => { + const [token, setToken] = useState(""); + const [checked, setChecked] = useState(false); + const checkedRef = useRef(); + checkedRef.current = checked; + + const toggleChecked = () => { + setChecked(!checkedRef.current); + } + + useEffect(() => { + setChecked(false); + }, [isOpen]); + + useEffect(() => { + if(detail && detail.token) { + setToken(detail.token); + } + }, [detail]); + + return ( + + + + Release Share + + + Would you like to release the share {token} ? + + + } label={

I confirm the release of {token}

} sx={{ mt: 2 }} /> +
+ + + +
+
+ ) +} + +export default ReleaseShareModal; \ No newline at end of file diff --git a/ui100/src/SharePanel.tsx b/ui100/src/SharePanel.tsx index 88056902..1f22284e 100644 --- a/ui100/src/SharePanel.tsx +++ b/ui100/src/SharePanel.tsx @@ -1,59 +1,12 @@ 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 ShareIcon from "@mui/icons-material/Share"; import {Configuration, MetadataApi, Share, ShareApi} from "./api"; -import {useEffect, useRef, useState} from "react"; +import {useEffect, useState} from "react"; import PropertyTable from "./PropertyTable.tsx"; import useStore from "./model/store.ts"; import DeleteIcon from "@mui/icons-material/Delete"; -import {modalStyle} from "./styling/theme.ts"; - -interface ReleaseShareProps { - close: () => void; - isOpen: boolean; - detail: Share; - action: () => void; -} - -const ReleaseShareModal = ({ close, isOpen, detail, action }: ReleaseShareProps) => { - const [token, setToken] = 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.token) { - setToken(detail.token); - } - }, [detail]); - - return ( - - - - Release Share - - - Would you like to release the share {token} ? - - - } label={

I confirm the release of {token}

} sx={{ mt: 2 }} /> -
- - - -
-
- ) -} +import ReleaseShareModal from "./ReleaseShareModal.tsx"; interface SharePanelProps { share: Node;