-
Notifications
You must be signed in to change notification settings - Fork 60
Add Confirmation Before Dev Tool Removal and Modification [AARD-2033]
#1265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ryanzhangofficial
wants to merge
18
commits into
dev
Choose a base branch
from
ryan/2033/add-confirmation-before-dev-tool-removal
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
10988c4
Add zone utils
ryanzhangofficial f1c94c5
Add zone removal modal
ryanzhangofficial 45d77da
chore: formatting
ryanzhangofficial 3f794cc
Merge branch 'dev' into ryan/2033/add-confirmation-before-dev-tool-re…
ryanzhangofficial 2d92ac9
Update toasts and descs
ryanzhangofficial 10c8f1a
Add permanent modification
ryanzhangofficial cde88ab
Update temporary modification
ryanzhangofficial f9d0900
chore: formatting
ryanzhangofficial 988f39a
Merge branch 'dev' into ryan/2033/add-confirmation-before-dev-tool-re…
ryanzhangofficial ddff42f
cleanup
ryanzhangofficial 74d249f
Update removal to modification
ryanzhangofficial 99f51e9
Update DevtoolZoneUtils for restructure & BaseZonePreferences
ryanzhangofficial 273982e
Update interfaces
ryanzhangofficial 9527d0a
chore: formatting
ryanzhangofficial 72888a1
chore: formatting
ryanzhangofficial 232faca
fix: save/cancel button dissappearing
ryanzhangofficial 0aba2ae
Add caching for manual scoring zones
ryanzhangofficial be65676
Update devtool panel to include devhandlers only
ryanzhangofficial File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Stack, Typography } from "@mui/material" | ||
| import type React from "react" | ||
| import { useState } from "react" | ||
| import { globalAddToast } from "../components/GlobalUIControls" | ||
|
|
||
| interface DevtoolZoneRemovalModalProps { | ||
| isOpen: boolean | ||
| onClose: () => void | ||
| zoneType: "scoring" | "protected" | ||
| zoneName: string | ||
| onTemporaryRemoval: () => void | ||
| onPermanentRemoval: () => void | ||
| actionType?: "removal" | "modification" | ||
| } | ||
|
|
||
| const DevtoolZoneRemovalModal: React.FC<DevtoolZoneRemovalModalProps> = ({ | ||
| isOpen, | ||
| onClose, | ||
| zoneType, | ||
| zoneName, | ||
| onTemporaryRemoval, | ||
| onPermanentRemoval, | ||
| actionType = "removal", | ||
| }) => { | ||
| const [isRemoving, setIsRemoving] = useState(false) | ||
|
|
||
| const handleTemporaryRemoval = () => { | ||
| onTemporaryRemoval() | ||
| onClose() | ||
| } | ||
|
|
||
| const handlePermanentRemoval = async () => { | ||
| setIsRemoving(true) | ||
| try { | ||
| await onPermanentRemoval() | ||
| const actionText = actionType === "modification" ? "modified" : "removed" | ||
| const actionCapitalized = actionType === "modification" ? "Modified" : "Removed" | ||
| globalAddToast?.( | ||
| "info", | ||
| `Zone ${actionCapitalized}`, | ||
| `${zoneName} has been permanently ${actionText} in the field file.` | ||
| ) | ||
| } catch (error) { | ||
| const actionText = actionType === "modification" ? "modify" : "remove" | ||
| globalAddToast?.( | ||
| "error", | ||
| `${actionType === "modification" ? "Modification" : "Removal"} Failed`, | ||
| `Failed to permanently ${actionText} zone in the field file cache.` | ||
| ) | ||
| console.error(`Failed to ${actionText} zone in field file:`, error) | ||
| } finally { | ||
| setIsRemoving(false) | ||
| onClose() | ||
| } | ||
| } | ||
|
|
||
| return ( | ||
| <Dialog open={isOpen} onClose={onClose} maxWidth="sm" fullWidth> | ||
ryanzhangofficial marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <DialogTitle> | ||
| {actionType === "modification" ? "Modify" : "Remove"} {zoneType === "scoring" ? "Scoring" : "Protected"}{" "} | ||
| Zone | ||
| </DialogTitle> | ||
| <DialogContent> | ||
| <Stack spacing={2}> | ||
| <Typography variant="body1"> | ||
| The {zoneType} zone "{zoneName}" was defined in the field file and is cached. | ||
| </Typography> | ||
| <Typography variant="body2" color="text.secondary"> | ||
| Choose how you'd like to{" "} | ||
| {actionType === "modification" ? "save your modifications" : "remove it"}: | ||
| </Typography> | ||
| <Stack spacing={1}> | ||
| <Typography variant="body2"> | ||
| <strong>Temporary {actionType === "modification" ? "modification" : "removal"}:</strong>{" "} | ||
| {actionType === "modification" | ||
| ? "Save changes until next field reload. Original zone will reappear when you refresh or reload the field." | ||
| : "Remove zone until next field reload. The zone will reappear when you refresh or reload the field."} | ||
ryanzhangofficial marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </Typography> | ||
| <Typography variant="body2"> | ||
| <strong>Permanent {actionType === "modification" ? "modification" : "removal"}:</strong>{" "} | ||
| {actionType === "modification" | ||
| ? "Save changes to the field file cache. This will persist your modifications on future loads." | ||
ryanzhangofficial marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| : "Remove zone from the field file cache. This will prevent it from reappearing on future loads."} | ||
| </Typography> | ||
| </Stack> | ||
| </Stack> | ||
| </DialogContent> | ||
| <DialogActions> | ||
| <Button onClick={onClose} disabled={isRemoving}> | ||
| Cancel | ||
| </Button> | ||
| <Button onClick={handleTemporaryRemoval} disabled={isRemoving} variant="outlined" color="warning"> | ||
| Temporary {actionType === "modification" ? "Modification" : "Removal"} | ||
| </Button> | ||
| <Button | ||
| onClick={handlePermanentRemoval} | ||
| disabled={isRemoving} | ||
| variant="contained" | ||
| color={actionType === "modification" ? "primary" : "error"} | ||
| > | ||
| {isRemoving | ||
| ? `${actionType === "modification" ? "Modifying" : "Removing"}...` | ||
| : `Permanent ${actionType === "modification" ? "Modification" : "Removal"}`} | ||
| </Button> | ||
| </DialogActions> | ||
| </Dialog> | ||
| ) | ||
| } | ||
|
|
||
| export default DevtoolZoneRemovalModal | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should probably be renamed if this is being generalized