@@ -222,8 +222,9 @@ const showRenameTableDlg = (table: TableType) => {
- Rename
+
+ Rename
Delete
@@ -238,12 +239,16 @@ const showRenameTableDlg = (table: TableType) => {
- Table Rename
+ Table Rename
Table Delete
- Tables Refresh
+ Tables Refresh
diff --git a/packages/nc-gui-v2/components/dlg/TableRename.vue b/packages/nc-gui-v2/components/dlg/TableRename.vue
index a50170317c..2f72a74a7a 100644
--- a/packages/nc-gui-v2/components/dlg/TableRename.vue
+++ b/packages/nc-gui-v2/components/dlg/TableRename.vue
@@ -1,90 +1,89 @@
- {{ $t("general.cancel") }}
- {{ $t("general.submit") }}
+ {{ $t('general.cancel') }}
+ {{ $t('general.submit') }}
diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts
index 169fdbd7b3..d2fef08531 100644
--- a/packages/nc-gui-v2/composables/useTabs.ts
+++ b/packages/nc-gui-v2/composables/useTabs.ts
@@ -6,6 +6,13 @@ export interface TabItem {
id?: string
}
+function getPredicate(key: Partial) {
+ return (tab: TabItem) =>
+ (!('id' in key) || tab.id === key.id) &&
+ (!('title' in key) || tab.title === key.id) &&
+ (!('type' in key) || tab.type === key.id)
+}
+
export default () => {
const tabs = useState('tabs', () => [])
const activeTab = useState('activeTab', () => 0)
@@ -25,13 +32,21 @@ export default () => {
const clearTabs = () => {
tabs.value = []
}
- const closeTab = (key: number | TabItem) => {
+
+ const closeTab = (key: number | Partial) => {
if (typeof key === 'number') tabs.value.splice(key, 1)
else {
- const index = tabs.value.findIndex((tab) => tab.id === key.id && tab.type === key.type && tab.title === key.title)
+ const index = tabs.value.findIndex(getPredicate(key))
if (index > -1) tabs.value.splice(index, 1)
}
}
- return { tabs, addTab, activeTab, clearTabs, closeTab }
+ const updateTab = (key: number | Partial, newTabItemProps: Partial) => {
+ const tab = typeof key === 'number' ? tabs.value[key] : tabs.value.find(getPredicate(key))
+ if (tab) {
+ Object.assign(tab, newTabItemProps)
+ }
+ }
+
+ return { tabs, addTab, activeTab, clearTabs, closeTab, updateTab }
}
diff --git a/packages/nc-gui-v2/pages/nc/[projectId].vue b/packages/nc-gui-v2/pages/nc/[projectId].vue
index 5401064648..01b32f99f0 100644
--- a/packages/nc-gui-v2/pages/nc/[projectId].vue
+++ b/packages/nc-gui-v2/pages/nc/[projectId].vue
@@ -2,7 +2,7 @@
const route = useRoute()
const { loadProject, loadTables } = useProject(route.params.projectId as string)
const { clearTabs, addTab } = useTabs()
-const {$state} = useNuxtApp()
+const { $state } = useNuxtApp()
addTab({ type: 'auth', title: 'Team & Auth' })