Skip to content

Commit 74d249f

Browse files
Update removal to modification
1 parent ddff42f commit 74d249f

File tree

2 files changed

+95
-110
lines changed

2 files changed

+95
-110
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from "@mui/material"
2+
import type React from "react"
3+
import { useState } from "react"
4+
import { globalAddToast } from "../components/GlobalUIControls"
5+
6+
interface DevtoolZoneModificationModalProps {
7+
isOpen: boolean
8+
onClose: () => void
9+
zoneType: "scoring" | "protected"
10+
zoneName: string
11+
onTemporaryModification: () => void
12+
onPermanentModification: () => void
13+
}
14+
15+
const DevtoolZoneModificationModal: React.FC<DevtoolZoneModificationModalProps> = ({
16+
isOpen,
17+
onClose,
18+
zoneType,
19+
zoneName,
20+
onTemporaryModification,
21+
onPermanentModification,
22+
}) => {
23+
const [isModifying, setIsModifying] = useState(false)
24+
25+
const handleTemporaryModification = () => {
26+
onTemporaryModification()
27+
onClose()
28+
}
29+
30+
const handlePermanentModification = async () => {
31+
setIsModifying(true)
32+
try {
33+
await onPermanentModification()
34+
globalAddToast?.(
35+
"info",
36+
"Zone Modified",
37+
`${zoneName} has been permanently modified in the field file.`
38+
)
39+
} catch (error) {
40+
globalAddToast?.(
41+
"error",
42+
"Modification Failed",
43+
"Failed to permanently modify zone in the field file cache."
44+
)
45+
console.error("Failed to modify zone in field file:", error)
46+
} finally {
47+
setIsModifying(false)
48+
onClose()
49+
}
50+
}
51+
52+
return (
53+
<Dialog open={isOpen} onClose={onClose} maxWidth="sm" fullWidth>
54+
<DialogTitle>
55+
Modify {zoneType === "scoring" ? "Scoring" : "Protected"} Zone
56+
</DialogTitle>
57+
<DialogContent>
58+
<Stack spacing={2}>
59+
<Typography variant="body1">
60+
The {zoneType} zone "{zoneName}" was defined in the field file and is cached.
61+
</Typography>
62+
<Typography variant="body2" color="text.secondary">
63+
Choose how you'd like to save your modifications:
64+
</Typography>
65+
<Stack spacing={1}>
66+
<Typography variant="body2">
67+
<strong>Temporary modification:</strong> Save changes until next field reload. Original zone will reappear when you refresh the page.
68+
</Typography>
69+
<Typography variant="body2">
70+
<strong>Permanent modification:</strong> Save changes to the local asset file. This will persist your modifications until you remove it from the cache.
71+
</Typography>
72+
</Stack>
73+
</Stack>
74+
</DialogContent>
75+
<DialogActions>
76+
<Button onClick={onClose} disabled={isModifying}>
77+
Cancel
78+
</Button>
79+
<Button onClick={handleTemporaryModification} disabled={isModifying} variant="outlined" color="warning">
80+
Temporary Modification
81+
</Button>
82+
<Button
83+
onClick={handlePermanentModification}
84+
disabled={isModifying}
85+
variant="contained"
86+
color="primary"
87+
>
88+
{isModifying ? "Modifying..." : "Permanent Modification"}
89+
</Button>
90+
</DialogActions>
91+
</Dialog>
92+
)
93+
}
94+
95+
export default DevtoolZoneModificationModal

fission/src/ui/modals/DevtoolZoneRemovalModal.tsx

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)