Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Commit 474a429

Browse files
committed
feat: hide details until query is focused
1 parent 25d396d commit 474a429

File tree

1 file changed

+109
-115
lines changed

1 file changed

+109
-115
lines changed

src/index.js

Lines changed: 109 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,11 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
391391
{queries.map(query => (
392392
<div
393393
key={query.queryHash}
394-
onClick={() => setActiveQueryHash(query.queryHash)}
394+
onClick={() =>
395+
setActiveQueryHash(
396+
activeQueryHash === query.queryHash ? '' : query.queryHash
397+
)
398+
}
395399
style={{
396400
display: 'flex',
397401
borderBottom: `solid 1px ${theme.grayAlt}`,
@@ -436,143 +440,133 @@ export const ReactQueryDevtoolsPanel = React.forwardRef(
436440
))}
437441
</div>
438442
</div>
439-
<div
440-
style={{
441-
flex: '1 1 50%',
442-
display: 'flex',
443-
flexDirection: 'column',
444-
overflow: 'auto',
445-
}}
446-
>
443+
{activeQuery ? (
447444
<div
448445
style={{
449-
padding: '.5rem',
450-
background: theme.backgroundAlt,
446+
flex: '1 1 50%',
447+
display: 'flex',
448+
flexDirection: 'column',
449+
overflow: 'auto',
451450
}}
452451
>
453-
Query Details
454-
</div>
455-
{activeQuery ? (
456-
<>
452+
<div
453+
style={{
454+
padding: '.5rem',
455+
background: theme.backgroundAlt,
456+
}}
457+
>
458+
Query Details
459+
</div>
460+
<div
461+
style={{
462+
padding: '1rem',
463+
display: 'flex',
464+
alignItems: 'center',
465+
justifyContent: 'space-between',
466+
}}
467+
>
468+
<Code
469+
style={{
470+
lineHeight: '1.8rem',
471+
}}
472+
>
473+
{activeQuery.queryHash}
474+
</Code>
475+
<span
476+
style={{
477+
padding: '0.3rem .6rem',
478+
borderRadius: '0.4rem',
479+
fontWeight: 'bold',
480+
textShadow: '0 2px 10px black',
481+
background: getQueryStatusColor(activeQuery, theme),
482+
flexShrink: 0,
483+
}}
484+
>
485+
{getQueryStatusLabel(activeQuery)}
486+
</span>
487+
</div>
488+
<div
489+
style={{
490+
flex: '1',
491+
overflow: 'auto',
492+
}}
493+
>
494+
<div
495+
style={{
496+
background: theme.backgroundAlt,
497+
padding: '.5rem',
498+
}}
499+
>
500+
Actions
501+
</div>
457502
<div
458503
style={{
459504
padding: '1rem',
460-
display: 'flex',
461-
alignItems: 'center',
462-
justifyContent: 'space-between',
463505
}}
464506
>
465-
<Code
507+
<Button
508+
onClick={() => activeQuery.fetch()}
509+
disabled={activeQuery.state.isFetching}
466510
style={{
467-
lineHeight: '1.8rem',
511+
background: theme.active,
468512
}}
469513
>
470-
{activeQuery.queryHash}
471-
</Code>
472-
<span
514+
Refetch
515+
</Button>{' '}
516+
<Button
517+
onClick={() =>
518+
queryCache.removeQueries(q => q === activeQuery)
519+
}
473520
style={{
474-
padding: '0.3rem .6rem',
475-
borderRadius: '0.4rem',
476-
fontWeight: 'bold',
477-
textShadow: '0 2px 10px black',
478-
background: getQueryStatusColor(activeQuery, theme),
479-
flexShrink: 0,
521+
background: theme.danger,
480522
}}
481523
>
482-
{getQueryStatusLabel(activeQuery)}
483-
</span>
524+
Remove
525+
</Button>{' '}
484526
</div>
485527
<div
486528
style={{
487-
flex: '1',
488-
overflow: 'auto',
529+
background: theme.backgroundAlt,
530+
padding: '.5rem',
489531
}}
490532
>
491-
<div
492-
style={{
493-
background: theme.backgroundAlt,
494-
padding: '.5rem',
495-
}}
496-
>
497-
Actions
498-
</div>
499-
<div
500-
style={{
501-
padding: '1rem',
502-
}}
503-
>
504-
<Button
505-
onClick={() => activeQuery.fetch()}
506-
disabled={activeQuery.state.isFetching}
507-
style={{
508-
background: theme.active,
509-
}}
510-
>
511-
Refetch
512-
</Button>{' '}
513-
<Button
514-
onClick={() =>
515-
queryCache.removeQueries(q => q === activeQuery)
516-
}
517-
style={{
518-
background: theme.danger,
519-
}}
520-
>
521-
Remove
522-
</Button>{' '}
523-
</div>
524-
<div
525-
style={{
526-
background: theme.backgroundAlt,
527-
padding: '.5rem',
528-
}}
529-
>
530-
Data Explorer
531-
</div>
532-
<div
533-
style={{
534-
padding: '.5rem',
535-
}}
536-
>
537-
<Explorer
538-
label="Data"
539-
value={activeQueryJson.state.data}
540-
defaultExpanded={{}}
541-
/>
542-
</div>
543-
<div
544-
style={{
545-
background: theme.backgroundAlt,
546-
padding: '.5rem',
547-
}}
548-
>
549-
Query Explorer
550-
</div>
551-
<div
552-
style={{
553-
padding: '.5rem',
533+
Data Explorer
534+
</div>
535+
<div
536+
style={{
537+
padding: '.5rem',
538+
}}
539+
>
540+
<Explorer
541+
label="Data"
542+
value={activeQueryJson.state.data}
543+
defaultExpanded={{}}
544+
/>
545+
</div>
546+
<div
547+
style={{
548+
background: theme.backgroundAlt,
549+
padding: '.5rem',
550+
}}
551+
>
552+
Query Explorer
553+
</div>
554+
<div
555+
style={{
556+
padding: '.5rem',
557+
}}
558+
>
559+
<Explorer
560+
label="Query"
561+
value={activeQueryJson}
562+
defaultExpanded={{
563+
queryKey: true,
554564
}}
555-
>
556-
<Explorer
557-
label="Query"
558-
value={activeQueryJson}
559-
defaultExpanded={{
560-
queryKey: true,
561-
}}
562-
/>
563-
</div>
565+
/>
564566
</div>
565-
</>
566-
) : (
567-
<div
568-
style={{
569-
padding: '1rem',
570-
}}
571-
>
572-
Select a query for more info...
573567
</div>
574-
)}
575-
</div>
568+
</div>
569+
) : null}
576570
</Panel>
577571
</ThemeProvider>
578572
)

0 commit comments

Comments
 (0)