From 6e894624db2289a172d4584577bbd5a17ed5ce20 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 12 Aug 2022 23:46:34 +0530 Subject: [PATCH 01/14] wip(gui-v2): change useProject composable to work using shared base id Signed-off-by: Pranav C --- .../components/dashboard/TreeView.vue | 2 +- .../components/general/MiniSidebar.vue | 2 +- .../composables/useApi/interceptors.ts | 2 +- packages/nc-gui-v2/composables/useProject.ts | 25 +++++++++++++------ packages/nc-gui-v2/composables/useTabs.ts | 21 +++++++++++----- .../[projectId]/index.vue | 4 +-- .../[projectId]/index/index.vue | 0 .../index/[type]/[title]/[[viewTitle]].vue | 0 .../[projectId]/index/index/auth.vue | 0 .../[projectId]/index/index/index.vue | 0 10 files changed, 37 insertions(+), 19 deletions(-) rename packages/nc-gui-v2/pages/{nc => [projectType]}/[projectId]/index.vue (98%) rename packages/nc-gui-v2/pages/{nc => [projectType]}/[projectId]/index/index.vue (100%) rename packages/nc-gui-v2/pages/{nc => [projectType]}/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue (100%) rename packages/nc-gui-v2/pages/{nc => [projectType]}/[projectId]/index/index/auth.vue (100%) rename packages/nc-gui-v2/pages/{nc => [projectType]}/[projectId]/index/index/index.vue (100%) diff --git a/packages/nc-gui-v2/components/dashboard/TreeView.vue b/packages/nc-gui-v2/components/dashboard/TreeView.vue index 1056663fb7..ab9f5eb0a2 100644 --- a/packages/nc-gui-v2/components/dashboard/TreeView.vue +++ b/packages/nc-gui-v2/components/dashboard/TreeView.vue @@ -16,7 +16,7 @@ const { $api, $e } = useNuxtApp() const route = useRoute() -const { tables, loadTables } = useProject(route.params.projectId as string) +const { tables, loadTables } = useProject() const { activeTab } = useTabs() const { deleteTable } = useTable() diff --git a/packages/nc-gui-v2/components/general/MiniSidebar.vue b/packages/nc-gui-v2/components/general/MiniSidebar.vue index 9034f44756..81fb2589f6 100644 --- a/packages/nc-gui-v2/components/general/MiniSidebar.vue +++ b/packages/nc-gui-v2/components/general/MiniSidebar.vue @@ -106,7 +106,7 @@ const logout = () => {
diff --git a/packages/nc-gui-v2/composables/useApi/interceptors.ts b/packages/nc-gui-v2/composables/useApi/interceptors.ts index c8c6fd1fa6..6924779344 100644 --- a/packages/nc-gui-v2/composables/useApi/interceptors.ts +++ b/packages/nc-gui-v2/composables/useApi/interceptors.ts @@ -18,7 +18,7 @@ export function addAxiosInterceptors(api: Api) { } if (!config.url?.endsWith('/user/me') && !config.url?.endsWith('/admin/roles')) { - if (route && route.params && route.params.shared_base_id) config.headers['xc-shared-base-id'] = route.params.shared_base_id + if (route && route.params && route.params.projectType === 'base') config.headers['xc-shared-base-id'] = route.params.projectId } return config diff --git a/packages/nc-gui-v2/composables/useProject.ts b/packages/nc-gui-v2/composables/useProject.ts index 7d4fc760db..6ac63b701c 100644 --- a/packages/nc-gui-v2/composables/useProject.ts +++ b/packages/nc-gui-v2/composables/useProject.ts @@ -1,17 +1,19 @@ import { SqlUiFactory } from 'nocodb-sdk' import type { OracleUi, ProjectType, TableType } from 'nocodb-sdk' import type { MaybeRef } from '@vueuse/core' -import { useNuxtApp, useState } from '#app' +import { useNuxtApp, useRoute, useState } from '#app' import { USER_PROJECT_ROLES } from '~/lib' export function useProject(projectId?: MaybeRef) { const projectRoles = useState>(USER_PROJECT_ROLES, () => ({})) const { $api } = useNuxtApp() - - const _projectId = $computed(() => unref(projectId)) + let _projectId = $ref('') const project = useState('project') const tables = useState('tables', () => [] as TableType[]) + const route = useRoute() + + const projectType = $computed(() => route.params.projectType as string) async function loadProjectRoles() { projectRoles.value = {} @@ -29,14 +31,21 @@ export function useProject(projectId?: MaybeRef) { } } - async function loadProject(id: string) { - project.value = await $api.project.read(id) - await loadProjectRoles() + async function loadProject() { + if(unref(projectId)){ + _projectId = unref(projectId)! + } else if (projectType === 'base') { + const baseData = await $api.public.sharedBaseGet(route.params.projectId as string) + _projectId = baseData.project_id! + } else { + _projectId = route.params.projectId as string + } + project.value = await $api.project.read(_projectId!) } watchEffect(async () => { - if (_projectId) { - await loadProject(_projectId) + if (project?.value ) { + await loadProjectRoles() await loadTables() } }) diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts index 99817e6b5a..01072f1765 100644 --- a/packages/nc-gui-v2/composables/useTabs.ts +++ b/packages/nc-gui-v2/composables/useTabs.ts @@ -1,6 +1,9 @@ import type { WritableComputedRef } from '@vue/reactivity' import { navigateTo, useProject, useRoute, useState } from '#imports' +import type { RouterConfig } from '@nuxt/schema' + + export enum TabType { TABLE = 'table', VIEW = 'view', @@ -29,9 +32,11 @@ export function useTabs() { const router = useRouter() const { tables } = useProject() + const projectType = $computed(() => route.params.projectType as string) + const activeTabIndex: WritableComputedRef = computed({ get() { - if ((route.name as string)?.startsWith('nc-projectId-index-index-type-title-viewTitle') && tables.value?.length) { + if ((route.name as string)?.startsWith('projectType-projectId-index-index-type-title-viewTitle') && tables.value?.length) { const tab: Partial = { type: route.params.type as TabType, title: route.params.title as string } const id = tables.value?.find((t) => t.title === tab.title)?.id @@ -56,7 +61,7 @@ export function useTabs() { }, set(index: number) { if (index === -1) { - navigateTo(`/nc/${route.params.projectId}`) + navigateTo(`/${projectType}/${route.params.projectId}`) } else { const tab = tabs.value[index] @@ -91,7 +96,7 @@ export function useTabs() { let newTabIndex = index - 1 if (newTabIndex < 0 && tabs.value?.length > 1) newTabIndex = index + 1 if (newTabIndex === -1) { - await navigateTo(`/nc/${route.params.projectId}`) + await navigateTo(`/${projectType}/${route.params.projectId}`) } else { await navigateToTab(tabs.value?.[newTabIndex]) } @@ -102,11 +107,15 @@ export function useTabs() { function navigateToTab(tab: TabItem) { switch (tab.type) { case TabType.TABLE: - return navigateTo(`/nc/${route.params.projectId}/table/${tab?.title}${tab.viewTitle ? `/${tab.viewTitle}` : ''}`) + return navigateTo( + `/${projectType}/${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}` : ''}`) + return navigateTo( + `/${projectType}/${route.params.projectId}/view/${tab?.title}${tab.viewTitle ? `/${tab.viewTitle}` : ''}`, + ) case TabType.AUTH: - return navigateTo(`/nc/${route.params.projectId}/auth`) + return navigateTo(`/${projectType}/${route.params.projectId}/auth`) } } diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue similarity index 98% rename from packages/nc-gui-v2/pages/nc/[projectId]/index.vue rename to packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue index d90987b1d3..613c503d33 100644 --- a/packages/nc-gui-v2/pages/nc/[projectId]/index.vue +++ b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index.vue @@ -5,7 +5,7 @@ import { openLink } from '~/utils' const route = useRoute() -const { project, loadProject, loadTables } = useProject(route.params.projectId as string) +const { project, loadProject, loadTables } = useProject() const { addTab, clearTabs } = useTabs() @@ -39,7 +39,7 @@ function toggleDialog(value?: boolean, key?: string) { openDialogKey.value = key } -await loadProject(route.params.projectId as string) +await loadProject() await loadTables() diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue similarity index 100% rename from packages/nc-gui-v2/pages/nc/[projectId]/index/index.vue rename to packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index.vue diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue similarity index 100% rename from packages/nc-gui-v2/pages/nc/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue rename to packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/[type]/[title]/[[viewTitle]].vue diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/auth.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/auth.vue similarity index 100% rename from packages/nc-gui-v2/pages/nc/[projectId]/index/index/auth.vue rename to packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/auth.vue diff --git a/packages/nc-gui-v2/pages/nc/[projectId]/index/index/index.vue b/packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue similarity index 100% rename from packages/nc-gui-v2/pages/nc/[projectId]/index/index/index.vue rename to packages/nc-gui-v2/pages/[projectType]/[projectId]/index/index/index.vue From 3957ecebf0f7460ccf68ca520baff9db8d40dca3 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Fri, 12 Aug 2022 23:59:25 +0530 Subject: [PATCH 02/14] feat(gui-v2): skip auth validation if shared base route Signed-off-by: Pranav C --- packages/nc-gui-v2/composables/useApi/interceptors.ts | 3 ++- packages/nc-gui-v2/composables/useProject.ts | 4 ++-- packages/nc-gui-v2/composables/useTabs.ts | 4 +--- packages/nc-gui-v2/middleware/auth.global.ts | 3 +++ 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/nc-gui-v2/composables/useApi/interceptors.ts b/packages/nc-gui-v2/composables/useApi/interceptors.ts index 6924779344..e65cb25edb 100644 --- a/packages/nc-gui-v2/composables/useApi/interceptors.ts +++ b/packages/nc-gui-v2/composables/useApi/interceptors.ts @@ -18,7 +18,8 @@ export function addAxiosInterceptors(api: Api) { } if (!config.url?.endsWith('/user/me') && !config.url?.endsWith('/admin/roles')) { - if (route && route.params && route.params.projectType === 'base') config.headers['xc-shared-base-id'] = route.params.projectId + if (route && route.params && route.params.projectType === 'base') + config.headers['xc-shared-base-id'] = route.params.projectId } return config diff --git a/packages/nc-gui-v2/composables/useProject.ts b/packages/nc-gui-v2/composables/useProject.ts index 6ac63b701c..94909945ca 100644 --- a/packages/nc-gui-v2/composables/useProject.ts +++ b/packages/nc-gui-v2/composables/useProject.ts @@ -32,7 +32,7 @@ export function useProject(projectId?: MaybeRef) { } async function loadProject() { - if(unref(projectId)){ + if (unref(projectId)) { _projectId = unref(projectId)! } else if (projectType === 'base') { const baseData = await $api.public.sharedBaseGet(route.params.projectId as string) @@ -44,7 +44,7 @@ export function useProject(projectId?: MaybeRef) { } watchEffect(async () => { - if (project?.value ) { + if (project?.value) { await loadProjectRoles() await loadTables() } diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts index 01072f1765..4e5e3f6ac5 100644 --- a/packages/nc-gui-v2/composables/useTabs.ts +++ b/packages/nc-gui-v2/composables/useTabs.ts @@ -1,8 +1,6 @@ import type { WritableComputedRef } from '@vue/reactivity' -import { navigateTo, useProject, useRoute, useState } from '#imports' - import type { RouterConfig } from '@nuxt/schema' - +import { navigateTo, useProject, useRoute, useState } from '#imports' export enum TabType { TABLE = 'table', diff --git a/packages/nc-gui-v2/middleware/auth.global.ts b/packages/nc-gui-v2/middleware/auth.global.ts index 06e6b822c1..55ecafab02 100644 --- a/packages/nc-gui-v2/middleware/auth.global.ts +++ b/packages/nc-gui-v2/middleware/auth.global.ts @@ -23,6 +23,9 @@ import { useGlobal } from '#imports' export default defineNuxtRouteMiddleware((to, from) => { const state = useGlobal() + /** if shred base allow without validating token */ + if (to.params?.projectType === 'base') return + /** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */ if ((to.meta.requiresAuth || typeof to.meta.requiresAuth === 'undefined') && !state.signedIn.value) { return navigateTo('/signin') From 50fc98f827daad5706d361ce7326d4ca4bc15749 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 00:05:54 +0530 Subject: [PATCH 03/14] fix(gui-v2): make required prop optional Signed-off-by: Pranav C --- packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue b/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue index 0d25a4a950..2b73c1f690 100644 --- a/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue +++ b/packages/nc-gui-v2/components/smartsheet-header/VirtualCell.vue @@ -5,7 +5,7 @@ import type { Ref } from 'vue' import { ColumnInj, IsFormInj, MetaInj } from '~/context' import { provide, toRef, useMetas, useProvideColumnCreateStore } from '#imports' -const props = defineProps<{ column: ColumnType & { meta: any }; hideMenu?: boolean; required: boolean }>() +const props = defineProps<{ column: ColumnType & { meta: any }; hideMenu?: boolean; required?: boolean }>() const column = toRef(props, 'column') const hideMenu = toRef(props, 'hideMenu') From 5dbbe8bffa46fa5359a464e8ff98a59525bb3089 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 00:06:23 +0530 Subject: [PATCH 04/14] fix(gui-v2): remove unnecessary watchEffect Signed-off-by: Pranav C --- packages/nc-gui-v2/composables/useProject.ts | 9 ++------- packages/nc-gui-v2/middleware/auth.global.ts | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/packages/nc-gui-v2/composables/useProject.ts b/packages/nc-gui-v2/composables/useProject.ts index 94909945ca..990325e791 100644 --- a/packages/nc-gui-v2/composables/useProject.ts +++ b/packages/nc-gui-v2/composables/useProject.ts @@ -41,15 +41,10 @@ export function useProject(projectId?: MaybeRef) { _projectId = route.params.projectId as string } project.value = await $api.project.read(_projectId!) + await loadProjectRoles() + await loadTables() } - watchEffect(async () => { - if (project?.value) { - await loadProjectRoles() - await loadTables() - } - }) - const projectBaseType = $computed(() => project.value?.bases?.[0]?.type || '') const isMysql = computed(() => ['mysql', 'mysql2'].includes(projectBaseType)) diff --git a/packages/nc-gui-v2/middleware/auth.global.ts b/packages/nc-gui-v2/middleware/auth.global.ts index 55ecafab02..740514cbb2 100644 --- a/packages/nc-gui-v2/middleware/auth.global.ts +++ b/packages/nc-gui-v2/middleware/auth.global.ts @@ -23,7 +23,7 @@ import { useGlobal } from '#imports' export default defineNuxtRouteMiddleware((to, from) => { const state = useGlobal() - /** if shred base allow without validating token */ + /** if shred base allow without validating */ if (to.params?.projectType === 'base') return /** if auth is required or unspecified (same as required) and user is not signed in, redirect to signin page */ From 351d201be817298d2f8e469864a8b8990e531a30 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 00:40:20 +0530 Subject: [PATCH 05/14] fix(gui-v2): avoid duplicate meta api call by keeping active loading state Signed-off-by: Pranav C --- .../components/dashboard/TreeView.vue | 4 +- packages/nc-gui-v2/composables/useMetas.ts | 57 +++++++++++-------- packages/nc-gui-v2/composables/useTabs.ts | 1 - 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/packages/nc-gui-v2/components/dashboard/TreeView.vue b/packages/nc-gui-v2/components/dashboard/TreeView.vue index ab9f5eb0a2..224820610c 100644 --- a/packages/nc-gui-v2/components/dashboard/TreeView.vue +++ b/packages/nc-gui-v2/components/dashboard/TreeView.vue @@ -2,7 +2,7 @@ import type { TableType } from 'nocodb-sdk' import Sortable from 'sortablejs' import { Empty } from 'ant-design-vue' -import { useNuxtApp, useRoute } from '#app' +import { useNuxtApp } from '#app' import { computed, useProject, useTable, useTabs, watchEffect } from '#imports' import { TabType } from '~/composables' import MdiView from '~icons/mdi/eye-circle-outline' @@ -14,8 +14,6 @@ const { addTab } = useTabs() const { $api, $e } = useNuxtApp() -const route = useRoute() - const { tables, loadTables } = useProject() const { activeTab } = useTabs() const { deleteTable } = useTable() diff --git a/packages/nc-gui-v2/composables/useMetas.ts b/packages/nc-gui-v2/composables/useMetas.ts index c1225e225b..b67534d84a 100644 --- a/packages/nc-gui-v2/composables/useMetas.ts +++ b/packages/nc-gui-v2/composables/useMetas.ts @@ -1,6 +1,8 @@ +import { message } from 'ant-design-vue' import type { WatchStopHandle } from 'vue' import type { TableInfoType, TableType } from 'nocodb-sdk' import { useProject } from './useProject' +import { extractSdkResponseErrorMsg } from '~/utils' import { useNuxtApp, useState } from '#app' export function useMetas() { @@ -11,53 +13,62 @@ export function useMetas() { const loadingState = useState>('metas-loading-state', () => ({})) const getMeta = async (tableIdOrTitle: string, force = false): Promise => { - if (!force && metas.value[tableIdOrTitle]) return metas.value[tableIdOrTitle] - - const modelId = (tables.value.find((t) => t.title === tableIdOrTitle || t.id === tableIdOrTitle) || {}).id - - if (!modelId) { - console.warn(`Table '${tableIdOrTitle}' is not found in the table list`) - return null - } - /** wait until loading is finished if requesting same meta */ - if (!force) { + if (!force && loadingState.value[tableIdOrTitle]) { await new Promise((resolve) => { let unwatch: WatchStopHandle + // set maximum 20sec timeout to wait loading meta const timeout = setTimeout(() => { unwatch?.() clearTimeout(timeout) resolve(null) - }, 20000) + }, 10000) + // watch for loading state change unwatch = watch( - () => loadingState.value[modelId], + () => !!loadingState.value[tableIdOrTitle], (isLoading) => { if (!isLoading) { clearTimeout(timeout) - resolve(null) unwatch?.() + resolve(null) } }, { immediate: true }, ) }) - if (metas.value[modelId]) return metas.value[modelId] + if (metas.value[tableIdOrTitle]) { + return metas.value[tableIdOrTitle] + } } + loadingState.value[tableIdOrTitle] = true + try { + if (!force && metas.value[tableIdOrTitle]) { + return metas.value[tableIdOrTitle] + } - loadingState.value[modelId] = true + const modelId = tableIdOrTitle.startsWith('md_') ? tableIdOrTitle : tables.value.find((t) => t.title === tableIdOrTitle)?.id - const model = await $api.dbTable.read(modelId) - metas.value = { - ...metas.value, - [model.id!]: model, - [model.title]: model, - } + if (!modelId) { + console.warn(`Table '${tableIdOrTitle}' is not found in the table list`) + return null + } - loadingState.value[modelId] = false + const model = await $api.dbTable.read(modelId) + metas.value = { + ...metas.value, + [model.id!]: model, + [model.title]: model, + } - return model + return model + } catch (e: any) { + message.error(await extractSdkResponseErrorMsg(e)) + } finally { + delete loadingState.value[tableIdOrTitle] + } + return null } const clearAllMeta = () => { diff --git a/packages/nc-gui-v2/composables/useTabs.ts b/packages/nc-gui-v2/composables/useTabs.ts index 4e5e3f6ac5..4c3c08d8e4 100644 --- a/packages/nc-gui-v2/composables/useTabs.ts +++ b/packages/nc-gui-v2/composables/useTabs.ts @@ -1,5 +1,4 @@ import type { WritableComputedRef } from '@vue/reactivity' -import type { RouterConfig } from '@nuxt/schema' import { navigateTo, useProject, useRoute, useState } from '#imports' export enum TabType { From 651e7e8bbaa61463e3898fdf1391ba210f0cf7ef Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 11:11:06 +0530 Subject: [PATCH 06/14] fix(gui-v2): bae url correction Signed-off-by: Pranav C --- .../components/tabs/auth/user-management/ShareBase.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue b/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue index 148b8d7e6a..fd30bc2233 100644 --- a/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue +++ b/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue @@ -26,7 +26,7 @@ const { project } = useProject() const { copy } = useClipboard() -const url = $computed(() => (base && base.uuid ? `${dashboardUrl}/nc/base/${base.uuid}` : null)) +const url = $computed(() => (base && base.uuid ? `${dashboardUrl}/base/${base.uuid}` : null)) const loadBase = async () => { try { From d2e44b4176aae16ee78514a4147926c30505d03b Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 11:16:28 +0530 Subject: [PATCH 07/14] refactor(gui-v2): remove unused injection key Signed-off-by: Pranav C --- packages/nc-gui-v2/context/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/nc-gui-v2/context/index.ts b/packages/nc-gui-v2/context/index.ts index 7dc6d976ed..a20176ca5a 100644 --- a/packages/nc-gui-v2/context/index.ts +++ b/packages/nc-gui-v2/context/index.ts @@ -5,7 +5,6 @@ import type { useViewData } from '#imports' import type { Row } from '~/composables' import type { TabItem } from '~/composables/useTabs' -export const EditEnabledInj: InjectionKey = Symbol('edit-enabled') export const ActiveCellInj: InjectionKey> = Symbol('active-cell') export const RowInj: InjectionKey> = Symbol('row') export const ColumnInj: InjectionKey> = Symbol('column-injection') From 852d3e017b6bb7bed8b38b94293fb6c578b08ba6 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 11:23:23 +0530 Subject: [PATCH 08/14] chore(gui-v2): lint Signed-off-by: Pranav C --- packages/nc-gui-v2/composables/useMetas.ts | 1 + packages/nc-gui-v2/composables/useProject.ts | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/nc-gui-v2/composables/useMetas.ts b/packages/nc-gui-v2/composables/useMetas.ts index b67534d84a..732f5393fe 100644 --- a/packages/nc-gui-v2/composables/useMetas.ts +++ b/packages/nc-gui-v2/composables/useMetas.ts @@ -13,6 +13,7 @@ export function useMetas() { const loadingState = useState>('metas-loading-state', () => ({})) const getMeta = async (tableIdOrTitle: string, force = false): Promise => { + if (!tableIdOrTitle) return null /** wait until loading is finished if requesting same meta */ if (!force && loadingState.value[tableIdOrTitle]) { await new Promise((resolve) => { diff --git a/packages/nc-gui-v2/composables/useProject.ts b/packages/nc-gui-v2/composables/useProject.ts index 990325e791..f11e5a1124 100644 --- a/packages/nc-gui-v2/composables/useProject.ts +++ b/packages/nc-gui-v2/composables/useProject.ts @@ -13,6 +13,7 @@ export function useProject(projectId?: MaybeRef) { const tables = useState('tables', () => [] as TableType[]) const route = useRoute() + // todo: refactor path param name and variable name const projectType = $computed(() => route.params.projectType as string) async function loadProjectRoles() { @@ -52,6 +53,7 @@ export function useProject(projectId?: MaybeRef) { const sqlUi = computed( () => SqlUiFactory.create({ client: projectBaseType }) as Exclude, typeof OracleUi>, ) + const isSharedBase = computed(() => projectType === 'base') - return { project, tables, loadProjectRoles, loadProject, loadTables, isMysql, isPg, sqlUi } + return { project, tables, loadProjectRoles, loadProject, loadTables, isMysql, isPg, sqlUi, isSharedBase } } From ae2434c736d6ade71bf91a694ac8a6ce332b5d99 Mon Sep 17 00:00:00 2001 From: Pranav C Date: Sat, 13 Aug 2022 12:51:06 +0530 Subject: [PATCH 09/14] feat(gui-v2): hide menu in shared base and add footer overlay Signed-off-by: Pranav C --- packages/nc-gui-v2/layouts/base.vue | 4 +++- packages/nc-gui-v2/layouts/default.vue | 13 ++++++++++++- .../pages/[projectType]/[projectId]/index.vue | 14 +++++++++++--- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui-v2/layouts/base.vue b/packages/nc-gui-v2/layouts/base.vue index a99c63a5cf..2c49275d69 100644 --- a/packages/nc-gui-v2/layouts/base.vue +++ b/packages/nc-gui-v2/layouts/base.vue @@ -4,6 +4,8 @@ import { computed, useGlobal, useRoute } from '#imports' const { signOut, signedIn, isLoading, user } = useGlobal() +const { isSharedBase } = useProject() + const route = useRoute() const email = computed(() => user.value?.email ?? '---') @@ -49,7 +51,7 @@ const logout = () => { -