Skip to content

Commit f47c28d

Browse files
authored
add clear result button (#290)
1 parent f52999a commit f47c28d

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

ui/src/components/nodes/Code.tsx

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { NodeResizeControl, NodeResizer } from "reactflow";
6262
import "@reactflow/node-resizer/dist/style.css";
6363
import { NewPodButtons, ResizeIcon } from "./utils";
6464
import { timeDifference } from "../../lib/utils";
65+
import { ButtonGroup } from "@mui/material";
6566

6667
function Timer({ lastExecutedAt }) {
6768
const [counter, setCounter] = useState(0);
@@ -85,6 +86,7 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
8586
(state) => state.pods[id].lastExecutedAt
8687
);
8788
const [showOutput, setShowOutput] = useState(true);
89+
const clearResults = useStore(store, (state) => state.clearResults);
8890
return (
8991
<Box
9092
sx={{
@@ -150,11 +152,7 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
150152
maxHeight="1000px"
151153
border="1px"
152154
>
153-
{/* <Box bgcolor="lightgray">Error</Box> */}
154-
<Button
155-
onClick={() => {
156-
setShowOutput(!showOutput);
157-
}}
155+
<ButtonGroup
158156
sx={[
159157
{
160158
fontSize: "0.8em",
@@ -168,10 +166,28 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
168166
},
169167
]}
170168
variant="text"
171-
size="small"
169+
aria-label="outlined primary button group"
172170
>
173-
Hide output
174-
</Button>
171+
<Button
172+
onClick={() => {
173+
setShowOutput(!showOutput);
174+
}}
175+
variant="text"
176+
size="small"
177+
>
178+
Hide
179+
</Button>
180+
<Button
181+
onClick={() => {
182+
clearResults(id);
183+
}}
184+
variant="text"
185+
size="small"
186+
>
187+
Clear
188+
</Button>
189+
</ButtonGroup>
190+
175191
{stdout && (
176192
<Box
177193
whiteSpace="pre-wrap"

ui/src/lib/store/runtimeSlice.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
495495
state.pods[id].result = null;
496496
state.pods[id].stdout = "";
497497
state.pods[id].error = null;
498+
state.pods[id].dirty = true;
498499
})
499500
);
500501
},
@@ -505,6 +506,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
505506
state.pods[id].result = null;
506507
state.pods[id].stdout = "";
507508
state.pods[id].error = null;
509+
state.pods[id].dirty = true;
508510
});
509511
})
510512
);

0 commit comments

Comments
 (0)