Skip to content

Commit dd18099

Browse files
committed
feat(devtools): go to cache tab from collections
1 parent d7d1038 commit dd18099

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

packages/nuxt/client/components/devtools/CacheCollectionItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const props = defineProps<{
88
selected?: boolean
99
}>()
1010
11-
const cacheCount = computed(() => Object.keys(props.state[props.collection.name] ?? {}).length)
11+
const cacheCount = computed(() => Object.keys(props.state?.[props.collection.name] ?? {}).length)
1212
</script>
1313

1414
<template>

packages/nuxt/client/components/devtools/CollectionItem.vue

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ const props = defineProps<{
88
const { cache } = useStoreCache()
99
1010
const cacheCount = computed(() => Object.keys((cache.value as any)[props.item.name] ?? {}).length)
11+
12+
const tab = useLocalStorage('rstore-devtools-tab', '0')
13+
const selectedCollection = useLocalStorage<string | null>('rstore-devtools-selected-cache-collection', null)
14+
15+
function goToCache() {
16+
selectedCollection.value = props.item.name
17+
tab.value = '1'
18+
}
1119
</script>
1220

1321
<template>
@@ -21,29 +29,14 @@ const cacheCount = computed(() => Object.keys((cache.value as any)[props.item.na
2129
{{ item.name }}
2230
</div>
2331

24-
<UPopover
25-
arrow
26-
>
27-
<template #default="{ open }">
28-
<UBadge
29-
:label="cacheCount || '0'"
30-
variant="subtle"
31-
:color="cacheCount ? 'primary' : 'neutral'"
32-
icon="lucide:database"
33-
:class="{
34-
'ring ring-green-500': open,
35-
'font-bold': cacheCount > 0,
36-
}"
37-
/>
38-
</template>
39-
40-
<template #content>
41-
<CodeSnippet
42-
:code="(cache as any)[props.item.name] ?? {}"
43-
class="text-xs p-2 max-w-120 max-h-90 overflow-auto"
44-
/>
45-
</template>
46-
</UPopover>
32+
<UButton
33+
:label="String(cacheCount) || '0'"
34+
variant="subtle"
35+
:color="cacheCount ? 'primary' : 'neutral'"
36+
size="xs"
37+
icon="lucide:database"
38+
@click="goToCache()"
39+
/>
4740
</div>
4841

4942
<div class="text-xs font-mono border border-default rounded p-2 flex gap-4">

0 commit comments

Comments
 (0)