Skip to content

Commit

Permalink
add clear result button (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
lihebi committed May 8, 2023
1 parent f52999a commit f47c28d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
32 changes: 24 additions & 8 deletions ui/src/components/nodes/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { NodeResizeControl, NodeResizer } from "reactflow";
import "@reactflow/node-resizer/dist/style.css";
import { NewPodButtons, ResizeIcon } from "./utils";
import { timeDifference } from "../../lib/utils";
import { ButtonGroup } from "@mui/material";

function Timer({ lastExecutedAt }) {
const [counter, setCounter] = useState(0);
Expand All @@ -85,6 +86,7 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
(state) => state.pods[id].lastExecutedAt
);
const [showOutput, setShowOutput] = useState(true);
const clearResults = useStore(store, (state) => state.clearResults);
return (
<Box
sx={{
Expand Down Expand Up @@ -150,11 +152,7 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
maxHeight="1000px"
border="1px"
>
{/* <Box bgcolor="lightgray">Error</Box> */}
<Button
onClick={() => {
setShowOutput(!showOutput);
}}
<ButtonGroup
sx={[
{
fontSize: "0.8em",
Expand All @@ -168,10 +166,28 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
},
]}
variant="text"
size="small"
aria-label="outlined primary button group"
>
Hide output
</Button>
<Button
onClick={() => {
setShowOutput(!showOutput);
}}
variant="text"
size="small"
>
Hide
</Button>
<Button
onClick={() => {
clearResults(id);
}}
variant="text"
size="small"
>
Clear
</Button>
</ButtonGroup>

{stdout && (
<Box
whiteSpace="pre-wrap"
Expand Down
2 changes: 2 additions & 0 deletions ui/src/lib/store/runtimeSlice.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
state.pods[id].result = null;
state.pods[id].stdout = "";
state.pods[id].error = null;
state.pods[id].dirty = true;
})
);
},
Expand All @@ -505,6 +506,7 @@ export const createRuntimeSlice: StateCreator<MyState, [], [], RuntimeSlice> = (
state.pods[id].result = null;
state.pods[id].stdout = "";
state.pods[id].error = null;
state.pods[id].dirty = true;
});
})
);
Expand Down

0 comments on commit f47c28d

Please sign in to comment.