Skip to content
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

add clear result button #290

Merged
merged 1 commit into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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