Skip to content

Commit

Permalink
fix(client): custom tab view active state
Browse files Browse the repository at this point in the history
  • Loading branch information
webfansplz committed Dec 19, 2023
1 parent 29c2e1a commit 1cecb35
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/client/src/components/common/SideNavItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const props = withDefaults(
)
const route = useRoute()
const tabPath = computed(() => 'path' in props.tab ? props.tab.path! : `/custom-tab-view?name=${(props.tab as ModuleBuiltinTab).name}`)
const tabPath = computed(() => 'path' in props.tab ? (`${props.tab.path.startsWith('/') ? `` : `/`}${props.tab.path!}`) : `/custom-tab-view/${(props.tab as ModuleBuiltinTab).name}`)
const badge = computed(() => 'badge' in props.tab && props.tab.badge?.())
const isActive = computed(() => route.path.startsWith(tabPath.value))
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const routes = [
{ path: '/assets', component: Assets },
{ path: '/graph', component: Graph },
{ path: '/settings', component: Settings },
{ path: '/custom-tab-view', component: CustomTabView },
{ path: '/custom-tab-view/:name', component: CustomTabView },
]

// @TODO: find a better way to handle it
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/pages/custom-tab-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { CustomTab } from '@vue-devtools-next/kit'
const route = useRoute()
const router = useRouter()
const { flattenedTabs } = useAllTabs()
const tabName = computed(() => route.query.name as string | undefined)
const tabName = computed(() => route.params.name as string | undefined)
const tab = computed(() => flattenedTabs.value.find(tab => tabName.value === tab.name) || null!) as ComputedRef<CustomTab>
onMounted(() => {
Expand All @@ -31,13 +31,13 @@ onMounted(() => {
</div>
</PanelGrids>
</template>
<template v-else-if="tab.view.type === 'iframe'">
<template v-else-if="tab?.view?.type === 'iframe'">
<IframeView :src="tab.view.src" />
</template>
<template v-else>
<PanelGrids>
<NCard flex="~ col" h-full items-center justify-center>
Unknown tab type {{ tab.view }}
Unknown tab type {{ tab?.view }}
</NCard>
</PanelGrids>
</template>
Expand Down

0 comments on commit 1cecb35

Please sign in to comment.