Browse Source

fix(gui-v2): tab navigation bug

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3065/head
Pranav C 2 years ago
parent
commit
075c19c507
  1. 23
      packages/nc-gui-v2/composables/useTabs.ts

23
packages/nc-gui-v2/composables/useTabs.ts

@ -61,15 +61,7 @@ export function useTabs() {
const tab = tabs.value[index]
if (!tab) return
switch (tab.type) {
case TabType.TABLE:
return navigateTo(`/nc/${route.params.projectId}/table/${tab?.title}${tab.viewTitle ? `/${tab.viewTitle}` : ''}`)
case TabType.VIEW:
return navigateTo(`/nc/${route.params.projectId}/view/${tab?.title}${tab.viewTitle ? `/${tab.viewTitle}` : ''}`)
case TabType.AUTH:
return navigateTo(`/nc/${route.params.projectId}/auth`)
}
return navigateToTab(tab)
}
},
})
@ -101,12 +93,23 @@ export function useTabs() {
if (newTabIndex === -1) {
await navigateTo(`/nc/${route.params.projectId}`)
} else {
await navigateTo(`/nc/${route.params.projectId}/table/${tabs.value?.[newTabIndex]?.title}`)
await navigateToTab(tabs.value?.[newTabIndex])
}
}
tabs.value.splice(index, 1)
}
function navigateToTab(tab: TabItem) {
switch (tab.type) {
case TabType.TABLE:
return navigateTo(`/nc/${route.params.projectId}/table/${tab?.title}${tab.viewTitle ? `/${tab.viewTitle}` : ''}`)
case TabType.VIEW:
return navigateTo(`/nc/${route.params.projectId}/view/${tab?.title}${tab.viewTitle ? `/${tab.viewTitle}` : ''}`)
case TabType.AUTH:
return navigateTo(`/nc/${route.params.projectId}/auth`)
}
}
const updateTab = (key: number | Partial<TabItem>, newTabItemProps: Partial<TabItem>) => {
const tab = typeof key === 'number' ? tabs.value[key] : tabs.value.find(getPredicate(key))
if (tab) {

Loading…
Cancel
Save