mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-01-02 18:39:05 +01:00
feat: restore unmodified plot on cancel
This commit is contained in:
parent
cddaff4f7e
commit
e54f134770
@ -14,5 +14,6 @@
|
|||||||
height: auto;
|
height: auto;
|
||||||
background-color: var(--panel-bg-color);
|
background-color: var(--panel-bg-color);
|
||||||
color: var(--main-text-color);
|
color: var(--main-text-color);
|
||||||
|
font: var(--fixed-font);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,6 @@ function evalAsync(Plot: any, d3: any, funcText: string): Promise<unknown> {
|
|||||||
function PlotView() {
|
function PlotView() {
|
||||||
const containerRef = React.useRef<HTMLInputElement>();
|
const containerRef = React.useRef<HTMLInputElement>();
|
||||||
const [plotDef, setPlotDef] = React.useState<string>();
|
const [plotDef, setPlotDef] = React.useState<string>();
|
||||||
const [tempDef, setTempDef] = React.useState<string>();
|
|
||||||
const [savedDef, setSavedDef] = React.useState<string>();
|
const [savedDef, setSavedDef] = React.useState<string>();
|
||||||
const [modalUp, setModalUp] = React.useState(false);
|
const [modalUp, setModalUp] = React.useState(false);
|
||||||
/*
|
/*
|
||||||
@ -97,22 +96,33 @@ function PlotView() {
|
|||||||
};
|
};
|
||||||
}, [plotDef]);
|
}, [plotDef]);
|
||||||
|
|
||||||
|
const handleOpen = React.useCallback(() => {
|
||||||
|
setSavedDef(plotDef);
|
||||||
|
setModalUp(true);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleCancel = React.useCallback(() => {
|
||||||
|
setPlotDef(savedDef);
|
||||||
|
setModalUp(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSave = React.useCallback(() => {
|
||||||
|
setModalUp(false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="plot-view">
|
<div className="plot-view">
|
||||||
<Button onClick={() => setModalUp(true)}>Edit</Button>
|
<Button onClick={handleOpen}>Edit</Button>
|
||||||
<div className="plot-window" ref={containerRef} />
|
<div className="plot-window" ref={containerRef} />
|
||||||
{modalUp && (
|
{modalUp && (
|
||||||
<WaveModal
|
<WaveModal title="Plot Definition" onCancel={handleCancel} onSubmit={handleSave} buttonLabel={"Save"}>
|
||||||
title="Plot Definition"
|
|
||||||
onCancel={() => setModalUp(false)}
|
|
||||||
onSubmit={() => setModalUp(false)}
|
|
||||||
>
|
|
||||||
<textarea
|
<textarea
|
||||||
className="plot-config"
|
className="plot-config"
|
||||||
rows={5}
|
rows={5}
|
||||||
onChange={(e) => setPlotDef(e.target.value)}
|
onChange={(e) => setPlotDef(e.target.value)}
|
||||||
spellCheck={false}
|
spellCheck={false}
|
||||||
defaultValue={plotDef}
|
defaultValue={plotDef}
|
||||||
|
wrap={"off"}
|
||||||
/>
|
/>
|
||||||
</WaveModal>
|
</WaveModal>
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user