Skip to content

Commit 764ff83

Browse files
committed
wip
1 parent 553fcf0 commit 764ff83

File tree

3 files changed

+73
-25
lines changed

3 files changed

+73
-25
lines changed

apps/web/src/components/ExecutionStatusText.tsx

+25-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { format } from 'date-fns'
22
import {
33
CheckCircleIcon,
4+
ChevronDownIcon,
5+
ChevronRightIcon,
46
CloudArrowDownIcon,
57
Cog8ToothIcon,
68
} from '@heroicons/react/20/solid'
@@ -10,19 +12,25 @@ type StartExecutionStatusTextProps = {
1012
startExecutionTime: string | null
1113
}
1214

13-
type LastExecutedStatusTextProps = {
15+
interface LastExecutedStatusTextProps {
1416
lastExecutionTime: string
17+
isResultHidden: boolean
18+
onToggleResultHidden: () => void
1519
}
16-
17-
export const QuerySucceededText = ({
18-
lastExecutionTime,
19-
}: LastExecutedStatusTextProps) => {
20+
export function QuerySucceededText(props: LastExecutedStatusTextProps) {
2021
return (
2122
<span className="font-syne text-gray-300 text-xs flex items-center select-none">
22-
<CheckCircleIcon className="w-4 h-4 mr-1" />
23+
<button className="group mr-1" onClick={props.onToggleResultHidden}>
24+
<CheckCircleIcon className="w-4 h-4 group-hover:hidden" />
25+
{props.isResultHidden ? (
26+
<ChevronRightIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
27+
) : (
28+
<ChevronDownIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
29+
)}
30+
</button>
2331
<span className="pt-0.5">
2432
This query was last executed at{' '}
25-
{format(new Date(lastExecutionTime), "h:mm a '-' do MMM, yyyy")}
33+
{format(new Date(props.lastExecutionTime), "h:mm a '-' do MMM, yyyy")}
2634
</span>
2735
</span>
2836
)
@@ -95,15 +103,20 @@ export const ExecutingPythonText = ({
95103
)
96104
}
97105

98-
export const PythonSucceededText = ({
99-
lastExecutionTime,
100-
}: LastExecutedStatusTextProps) => {
106+
export function PythonSucceededText(props: LastExecutedStatusTextProps) {
101107
return (
102108
<span className="font-syne text-gray-300 text-xs flex items-center select-none">
103-
<CheckCircleIcon className="w-4 h-4 mr-1" />
109+
<button className="group mr-1" onClick={props.onToggleResultHidden}>
110+
<CheckCircleIcon className="w-4 h-4 group-hover:hidden" />
111+
{props.isResultHidden ? (
112+
<ChevronRightIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
113+
) : (
114+
<ChevronDownIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
115+
)}
116+
</button>
104117
<span className="pt-0.5">
105118
This code was last executed at{' '}
106-
{format(new Date(lastExecutionTime), "h:mm a '-' do MMM, yyyy")}
119+
{format(new Date(props.lastExecutionTime), "h:mm a '-' do MMM, yyyy")}
107120
</span>
108121
</span>
109122
)

apps/web/src/components/v2Editor/customBlocks/python/index.tsx

+29-10
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ import { exhaustiveCheck } from '@briefer/types'
4747
import { useBlockExecutions } from '@/hooks/useBlockExecution'
4848
import { head } from 'ramda'
4949
import { useAITasks } from '@/hooks/useAITasks'
50-
import { CommandLineIcon } from '@heroicons/react/24/solid'
50+
import {
51+
ChevronDownIcon,
52+
ChevronRightIcon,
53+
CommandLineIcon,
54+
} from '@heroicons/react/24/solid'
5155
import { TooltipV2 } from '@/components/Tooltips'
5256
import { DashboardMode, dashboardModeHasControls } from '@/components/Dashboard'
5357

@@ -188,12 +192,25 @@ function PythonBlock(props: Props) {
188192
const startQueryTime = props.block.getAttribute('startQueryTime')
189193
const lastQueryTime = props.block.getAttribute('lastQueryTime')
190194

195+
const isCodeHidden =
196+
props.block.getAttribute('isCodeHidden') &&
197+
(!props.dashboardMode || !dashboardModeHasControls(props.dashboardMode))
198+
const isResultHidden =
199+
props.block.getAttribute('isResultHidden') &&
200+
(!props.dashboardMode || !dashboardModeHasControls(props.dashboardMode))
201+
191202
const queryStatusText: JSX.Element | null = useMemo(() => {
192203
switch (status) {
193204
case 'idle':
194205
case 'completed':
195206
if (source?.toJSON() === lastQuery && lastQueryTime) {
196-
return <PythonSucceededText lastExecutionTime={lastQueryTime} />
207+
return (
208+
<PythonSucceededText
209+
lastExecutionTime={lastQueryTime}
210+
isResultHidden={isResultHidden ?? false}
211+
onToggleResultHidden={toggleResultHidden}
212+
/>
213+
)
197214
}
198215
return null
199216
case 'running':
@@ -216,15 +233,10 @@ function PythonBlock(props: Props) {
216233
lastQueryTime,
217234
source.toJSON(),
218235
envStatus,
236+
isResultHidden,
237+
toggleResultHidden,
219238
])
220239

221-
const isCodeHidden =
222-
props.block.getAttribute('isCodeHidden') &&
223-
(!props.dashboardMode || !dashboardModeHasControls(props.dashboardMode))
224-
const isResultHidden =
225-
props.block.getAttribute('isResultHidden') &&
226-
(!props.dashboardMode || !dashboardModeHasControls(props.dashboardMode))
227-
228240
const { title } = getBaseAttributes(props.block)
229241
const onChangeTitle = useCallback(
230242
(e: React.ChangeEvent<HTMLInputElement>) => {
@@ -454,7 +466,14 @@ function PythonBlock(props: Props) {
454466
>
455467
<div className="flex items-center justify-between px-3 pr-4 gap-x-4 font-sans h-12">
456468
<div className="select-none text-gray-300 text-xs flex items-center w-full h-full gap-x-1.5">
457-
<CommandLineIcon className="h-4 w-4 text-gray-400" />
469+
<button className="group" onClick={toggleCodeHidden}>
470+
<CommandLineIcon className="h-4 w-4 text-gray-400 group-hover:hidden" />
471+
{isCodeHidden ? (
472+
<ChevronRightIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
473+
) : (
474+
<ChevronDownIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
475+
)}
476+
</button>
458477
<input
459478
type="text"
460479
className={clsx(

apps/web/src/components/v2Editor/customBlocks/sql/index.tsx

+19-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ import { useBlockExecutions } from '@/hooks/useBlockExecution'
7272
import { head } from 'ramda'
7373
import { useAITasks } from '@/hooks/useAITasks'
7474
import useFeatureFlags from '@/hooks/useFeatureFlags'
75-
import { CircleStackIcon } from '@heroicons/react/24/solid'
75+
import { ChevronDownIcon, CircleStackIcon } from '@heroicons/react/24/solid'
7676
import { TooltipV2 } from '@/components/Tooltips'
7777
import { DashboardMode, dashboardModeHasControls } from '@/components/Dashboard'
78+
import { ChevronRightIcon } from '@heroicons/react/24/outline'
7879

7980
interface Props {
8081
block: Y.XmlElement<SQLBlock>
@@ -330,7 +331,13 @@ function SQLBlock(props: Props) {
330331
case 'idle':
331332
case 'completed': {
332333
if (source?.toJSON() === lastQuery && lastQueryTime) {
333-
return <QuerySucceededText lastExecutionTime={lastQueryTime} />
334+
return (
335+
<QuerySucceededText
336+
lastExecutionTime={lastQueryTime}
337+
isResultHidden={isResultHidden}
338+
onToggleResultHidden={toggleResultHidden}
339+
/>
340+
)
334341
}
335342

336343
return null
@@ -352,6 +359,8 @@ function SQLBlock(props: Props) {
352359
lastQueryTime,
353360
source.toJSON(),
354361
envStatus,
362+
isResultHidden,
363+
toggleResultHidden,
355364
])
356365

357366
const onSubmitEditWithAI = useCallback(() => {
@@ -764,7 +773,14 @@ function SQLBlock(props: Props) {
764773
)}
765774
>
766775
<div className="select-none text-gray-300 text-xs flex items-center w-full h-full gap-x-1.5">
767-
<CircleStackIcon className="h-4 w-4 text-gray-400" />
776+
<button className="group" onClick={toggleCodeHidden}>
777+
<CircleStackIcon className="h-4 w-4 text-gray-400 group-hover:hidden" />
778+
{isCodeHiddenProp ? (
779+
<ChevronRightIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
780+
) : (
781+
<ChevronDownIcon className="h-4 w-4 text-gray-400 hidden group-hover:block" />
782+
)}
783+
</button>
768784
<input
769785
type="text"
770786
className={clsx(

0 commit comments

Comments
 (0)