From c1a86f0808ea2d2b6de7ecdd12f389491da0a5a3 Mon Sep 17 00:00:00 2001 From: mertmit Date: Thu, 29 Dec 2022 23:22:04 +0300 Subject: [PATCH 1/4] fix: use ref for forcedProjectId Signed-off-by: mertmit --- packages/nc-gui/composables/useProject.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/composables/useProject.ts b/packages/nc-gui/composables/useProject.ts index 5f97cc7434..d9257aa20d 100644 --- a/packages/nc-gui/composables/useProject.ts +++ b/packages/nc-gui/composables/useProject.ts @@ -42,9 +42,9 @@ const [setup, use] = useInjectionState(() => { const lastOpenedViewMap = ref>({}) - let forcedProjectId: string | undefined + const forcedProjectId = ref() - const projectId = computed(() => forcedProjectId || (route.params.projectId as string)) + const projectId = computed(() => forcedProjectId.value || (route.params.projectId as string)) // todo: refactor path param name and variable name const projectType = $computed(() => route.params.projectType as string) @@ -107,7 +107,7 @@ const [setup, use] = useInjectionState(() => { } async function loadProject(withTheme = true, forcedId?: string) { - if (forcedId) forcedProjectId = forcedId + if (forcedId) forcedProjectId.value = forcedId if (projectType === 'base') { try { const baseData = await api.public.sharedBaseGet(route.params.projectId as string) From 7f2a5103f6522c1065c80b880f9715c7d7f5399c Mon Sep 17 00:00:00 2001 From: mertmit Date: Fri, 30 Dec 2022 00:06:55 +0300 Subject: [PATCH 2/4] fix: useRoute from vue-router in useProject Signed-off-by: mertmit --- packages/nc-gui/composables/useProject.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui/composables/useProject.ts b/packages/nc-gui/composables/useProject.ts index d9257aa20d..1c0b9669f5 100644 --- a/packages/nc-gui/composables/useProject.ts +++ b/packages/nc-gui/composables/useProject.ts @@ -1,6 +1,7 @@ import type { BaseType, OracleUi, ProjectType, TableType } from 'nocodb-sdk' import { SqlUiFactory } from 'nocodb-sdk' import { isString } from '@vueuse/core' +import { useRoute } from 'vue-router' import { ClientType, computed, @@ -11,7 +12,6 @@ import { useInjectionState, useNuxtApp, useRoles, - useRoute, useRouter, useTheme, } from '#imports' From f5e14c525b6615ece40b9d3757a53c4cbed54c00 Mon Sep 17 00:00:00 2001 From: mertmit Date: Fri, 30 Dec 2022 12:42:50 +0300 Subject: [PATCH 3/4] fix: treeview load project consistently Signed-off-by: mertmit --- packages/nc-gui/components/dashboard/TreeView.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui/components/dashboard/TreeView.vue b/packages/nc-gui/components/dashboard/TreeView.vue index 68b63b7c47..1fdb747cfc 100644 --- a/packages/nc-gui/components/dashboard/TreeView.vue +++ b/packages/nc-gui/components/dashboard/TreeView.vue @@ -35,7 +35,7 @@ const { addTab, updateTab } = useTabs() const { $api, $e } = useNuxtApp() -const { bases, tables, loadTables, isSharedBase } = useProject() +const { project, loadProject, bases, tables, loadTables, isSharedBase } = useProject() const { activeTab } = useTabs() @@ -324,6 +324,12 @@ const setIcon = async (icon: string, table: TableType) => { message.error(await extractSdkResponseErrorMsg(e)) } } + +onMounted(async () => { + if (!project.value?.id) { + await loadProject() + } +})