Skip to content

Commit 9c79840

Browse files
authored
display show/hide buttons only when there're results (#297)
1 parent a8e66a3 commit 9c79840

File tree

1 file changed

+36
-33
lines changed

1 file changed

+36
-33
lines changed

ui/src/components/nodes/Code.tsx

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -156,41 +156,44 @@ export const ResultBlock = memo<any>(function ResultBlock({ id }) {
156156
maxHeight="1000px"
157157
border="1px"
158158
>
159-
<ButtonGroup
160-
sx={[
161-
{
162-
fontSize: "0.8em",
163-
paddingTop: "3px",
164-
paddingBottom: "2px",
165-
lineHeight: "10px",
166-
zIndex: 201,
167-
position: "absolute",
168-
top: 0,
169-
right: 0,
170-
},
171-
]}
172-
variant="text"
173-
aria-label="outlined primary button group"
174-
>
175-
<Button
176-
onClick={() => {
177-
setShowOutput(!showOutput);
178-
}}
179-
variant="text"
180-
size="small"
181-
>
182-
Hide
183-
</Button>
184-
<Button
185-
onClick={() => {
186-
clearResults(id);
187-
}}
159+
{/* FIXME result?.count is not correct, always 0 or 1. */}
160+
{(stdout || (result?.text && result?.count > 0) || error) && (
161+
<ButtonGroup
162+
sx={[
163+
{
164+
fontSize: "0.8em",
165+
paddingTop: "3px",
166+
paddingBottom: "2px",
167+
lineHeight: "10px",
168+
zIndex: 201,
169+
position: "absolute",
170+
top: 0,
171+
right: 0,
172+
},
173+
]}
188174
variant="text"
189-
size="small"
175+
aria-label="outlined primary button group"
190176
>
191-
Clear
192-
</Button>
193-
</ButtonGroup>
177+
<Button
178+
onClick={() => {
179+
setShowOutput(!showOutput);
180+
}}
181+
variant="text"
182+
size="small"
183+
>
184+
Hide
185+
</Button>
186+
<Button
187+
onClick={() => {
188+
clearResults(id);
189+
}}
190+
variant="text"
191+
size="small"
192+
>
193+
Clear
194+
</Button>
195+
</ButtonGroup>
196+
)}
194197

195198
{stdout && (
196199
<Box

0 commit comments

Comments
 (0)