|
|
|
@ -2,6 +2,7 @@ import { SqlUiFactory } from 'nocodb-sdk'
|
|
|
|
|
import type { OracleUi, ProjectType, TableType } from 'nocodb-sdk' |
|
|
|
|
import type { MaybeRef } from '@vueuse/core' |
|
|
|
|
import { useNuxtApp, useRoute, useState } from '#app' |
|
|
|
|
import type { ProjectMetaInfo } from '~/lib' |
|
|
|
|
import { USER_PROJECT_ROLES } from '~/lib' |
|
|
|
|
|
|
|
|
|
export function useProject(projectId?: MaybeRef<string>) { |
|
|
|
@ -13,10 +14,17 @@ export function useProject(projectId?: MaybeRef<string>) {
|
|
|
|
|
const tables = useState<TableType[]>('tables', () => [] as TableType[]) |
|
|
|
|
const route = useRoute() |
|
|
|
|
const { includeM2M } = useGlobal() |
|
|
|
|
|
|
|
|
|
const projectMetaInfo = useState<ProjectMetaInfo | undefined>('projectMetaInfo') |
|
|
|
|
// todo: refactor path param name and variable name
|
|
|
|
|
const projectType = $computed(() => route.params.projectType as string) |
|
|
|
|
|
|
|
|
|
async function loadProjectMetaInfo(force?: boolean) { |
|
|
|
|
if (!projectMetaInfo.value || force) { |
|
|
|
|
const data = await $api.project.metaGet(project.value.id!, {}, {}) |
|
|
|
|
projectMetaInfo.value = data |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function loadProjectRoles() { |
|
|
|
|
projectRoles.value = {} |
|
|
|
|
|
|
|
|
@ -59,5 +67,17 @@ export function useProject(projectId?: MaybeRef<string>) {
|
|
|
|
|
) |
|
|
|
|
const isSharedBase = computed(() => projectType === 'base') |
|
|
|
|
|
|
|
|
|
return { project, tables, loadProjectRoles, loadProject, loadTables, isMysql, isPg, sqlUi, isSharedBase } |
|
|
|
|
return { |
|
|
|
|
project, |
|
|
|
|
tables, |
|
|
|
|
loadProjectRoles, |
|
|
|
|
loadProject, |
|
|
|
|
loadTables, |
|
|
|
|
isMysql, |
|
|
|
|
isPg, |
|
|
|
|
sqlUi, |
|
|
|
|
isSharedBase, |
|
|
|
|
loadProjectMetaInfo, |
|
|
|
|
projectMetaInfo, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|