feat: add reset button to Global script

This commit is contained in:
wonfen
2026-06-18 15:13:38 +08:00
parent 57b891215e
commit 7e233efd10
3 changed files with 29 additions and 0 deletions
+14
View File
@@ -3,6 +3,7 @@ import {
ContentPasteRounded,
FormatPaintRounded,
OpenInFullRounded,
RestartAltRounded,
} from '@mui/icons-material'
import {
Button,
@@ -41,6 +42,7 @@ export interface EditorViewerProps {
saveDisabled?: boolean
onChange?: (value: string) => void
onSave?: () => void | Promise<void>
onResetToDefault?: () => void
onClose: () => void
onValidate?: (markers: MonacoMarker[]) => void
}
@@ -57,6 +59,7 @@ export const EditorViewer = ({
saveDisabled = false,
onChange,
onSave,
onResetToDefault,
onClose,
onValidate,
}: EditorViewerProps) => {
@@ -298,6 +301,17 @@ export const EditorViewer = ({
</DialogContent>
<DialogActions>
{!readOnly && onResetToDefault && (
<Button
onClick={onResetToDefault}
variant="outlined"
color="warning"
startIcon={<RestartAltRounded />}
disabled={loading}
>
{t('shared.actions.resetToDefault')}
</Button>
)}
<Button onClick={handleClose} variant="outlined">
{t(readOnly ? 'shared.actions.close' : 'shared.actions.cancel')}
</Button>