Skip to content

Commit f741dd2

Browse files
authored
feat(query-devtools): Add clear cache and remove btns (#6051)
* feat(query-devtools): Add clear cache and remove btns * Fix remove button classname
1 parent bd498e1 commit f741dd2

File tree

2 files changed

+55
-3
lines changed

2 files changed

+55
-3
lines changed

packages/query-devtools/src/Devtools.tsx

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
Search,
3434
Settings,
3535
TanstackLogo,
36+
Trash,
3637
Wifi,
3738
} from './icons'
3839
import Explorer from './Explorer'
@@ -519,6 +520,19 @@ export const DevtoolsPanel: Component<DevtoolsPanelProps> = (props) => {
519520
</div>
520521

521522
<div class={cx(styles.actionsContainer, 'tsqd-actions-container')}>
523+
<button
524+
onClick={() => {
525+
cache().clear()
526+
}}
527+
class={cx(
528+
styles.actionsBtn,
529+
'tsqd-actions-btn',
530+
'tsqd-action-clear-cache',
531+
)}
532+
aria-label="Clear query cache"
533+
>
534+
<Trash />
535+
</button>
522536
<button
523537
onClick={() => {
524538
if (offline()) {
@@ -1088,6 +1102,27 @@ const QueryDetails = () => {
10881102
></span>
10891103
Reset
10901104
</button>
1105+
<button
1106+
class={cx(
1107+
css`
1108+
color: ${tokens.colors.pink[400]};
1109+
`,
1110+
'tsqd-query-details-actions-btn',
1111+
'tsqd-query-details-action-remove',
1112+
)}
1113+
onClick={() => {
1114+
queryClient.removeQueries(activeQuery())
1115+
setSelectedQueryHash(null)
1116+
}}
1117+
disabled={statusLabel() === 'fetching'}
1118+
>
1119+
<span
1120+
class={css`
1121+
background-color: ${tokens.colors.pink[400]};
1122+
`}
1123+
></span>
1124+
Remove
1125+
</button>
10911126
<button
10921127
class={cx(
10931128
css`
@@ -1614,9 +1649,6 @@ const getStyles = () => {
16141649
outline-offset: 2px;
16151650
outline: 2px solid ${colors.blue[800]};
16161651
}
1617-
& span:nth-child(2) {
1618-
color: ${colors.gray[300]}${alpha[80]};
1619-
}
16201652
`,
16211653
statusTooltip: css`
16221654
position: absolute;

packages/query-devtools/src/icons/index.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,26 @@ export function Search() {
2020
)
2121
}
2222

23+
export function Trash() {
24+
return (
25+
<svg
26+
width="24"
27+
height="24"
28+
viewBox="0 0 24 24"
29+
fill="none"
30+
xmlns="http://www.w3.org/2000/svg"
31+
>
32+
<path
33+
d="M9 3H15M3 6H21M19 6L18.2987 16.5193C18.1935 18.0975 18.1409 18.8867 17.8 19.485C17.4999 20.0118 17.0472 20.4353 16.5017 20.6997C15.882 21 15.0911 21 13.5093 21H10.4907C8.90891 21 8.11803 21 7.49834 20.6997C6.95276 20.4353 6.50009 20.0118 6.19998 19.485C5.85911 18.8867 5.8065 18.0975 5.70129 16.5193L5 6M10 10.5V15.5M14 10.5V15.5"
34+
stroke="#98A2B3"
35+
stroke-width="1.66667"
36+
stroke-linecap="round"
37+
stroke-linejoin="round"
38+
/>
39+
</svg>
40+
)
41+
}
42+
2343
export function ChevronDown() {
2444
return (
2545
<svg

0 commit comments

Comments
 (0)