mirror of
https://github.com/nocodb/nocodb.git
synced 2026-04-30 04:46:59 +00:00
refactor: rename project and base
- Rename `Project` => `Base` - Rename `Base` => `Source` - Remove `db` from data/meta api endpoints - Add backward compatibility for old apis - Migrations for renaming table and columns Signed-off-by: Pranav C <pranavxc@gmail.com>
This commit is contained in:
@@ -17,7 +17,7 @@ import {
|
||||
iconMap,
|
||||
nextTick,
|
||||
onMounted,
|
||||
projectTitleValidator,
|
||||
baseTitleValidator,
|
||||
readFile,
|
||||
ref,
|
||||
storeToRefs,
|
||||
@@ -29,18 +29,18 @@ import {
|
||||
|
||||
const props = defineProps<{ connectionType?: ClientType }>()
|
||||
|
||||
const emit = defineEmits(['baseCreated', 'close'])
|
||||
const emit = defineEmits(['sourceCreated', 'close'])
|
||||
|
||||
const connectionType = computed(() => props.connectionType ?? ClientType.MYSQL)
|
||||
|
||||
const projectStore = useProject()
|
||||
const { loadProject } = useProjects()
|
||||
const { project } = storeToRefs(projectStore)
|
||||
const baseStore = useBase()
|
||||
const { loadProject } = useBases()
|
||||
const { base } = storeToRefs(baseStore)
|
||||
|
||||
const { loadProjectTables } = useTablesStore()
|
||||
|
||||
const _projectId = inject(ProjectIdInj, undefined)
|
||||
const projectId = computed(() => _projectId?.value ?? project.value?.id)
|
||||
const baseId = computed(() => _projectId?.value ?? base.value?.id)
|
||||
|
||||
const useForm = Form.useForm
|
||||
|
||||
@@ -56,7 +56,7 @@ const { $e } = useNuxtApp()
|
||||
|
||||
const { t } = useI18n()
|
||||
|
||||
const creatingBase = ref(false)
|
||||
const creatingSource = ref(false)
|
||||
|
||||
const formState = ref<ProjectCreateForm>({
|
||||
title: '',
|
||||
@@ -122,9 +122,9 @@ const validators = computed(() => {
|
||||
'title': [
|
||||
{
|
||||
required: true,
|
||||
message: 'Base name is required',
|
||||
message: 'Source name is required',
|
||||
},
|
||||
projectTitleValidator,
|
||||
baseTitleValidator,
|
||||
],
|
||||
'extraParameters': [extraParameterValidator],
|
||||
'dataSource.client': [fieldRequiredValidator()],
|
||||
@@ -234,7 +234,7 @@ const focusInvalidInput = () => {
|
||||
|
||||
const { $poller } = useNuxtApp()
|
||||
|
||||
const createBase = async () => {
|
||||
const createSource = async () => {
|
||||
try {
|
||||
await validate()
|
||||
} catch (e) {
|
||||
@@ -243,15 +243,15 @@ const createBase = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!projectId.value) return
|
||||
if (!baseId.value) return
|
||||
|
||||
creatingBase.value = true
|
||||
creatingSource.value = true
|
||||
|
||||
const connection = getConnectionConfig()
|
||||
|
||||
const config = { ...formState.value.dataSource, connection }
|
||||
|
||||
const jobData = await api.base.create(projectId.value, {
|
||||
const jobData = await api.source.create(baseId.value, {
|
||||
alias: formState.value.title,
|
||||
type: formState.value.dataSource.client,
|
||||
config,
|
||||
@@ -276,17 +276,17 @@ const createBase = async () => {
|
||||
if (data.status === JobStatus.COMPLETED) {
|
||||
$e('a:base:create:extdb')
|
||||
|
||||
if (projectId.value) {
|
||||
await loadProject(projectId.value, true)
|
||||
await loadProjectTables(projectId.value, true)
|
||||
if (baseId.value) {
|
||||
await loadProject(baseId.value, true)
|
||||
await loadProjectTables(baseId.value, true)
|
||||
}
|
||||
|
||||
emit('baseCreated')
|
||||
emit('sourceCreated')
|
||||
emit('close')
|
||||
creatingBase.value = false
|
||||
creatingSource.value = false
|
||||
} else if (status === JobStatus.FAILED) {
|
||||
message.error('Failed to create base')
|
||||
creatingBase.value = false
|
||||
creatingSource.value = false
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -304,7 +304,7 @@ const testConnection = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
$e('a:base:create:extdb:test-connection', [])
|
||||
$e('a:source:create:extdb:test-connection', [])
|
||||
|
||||
try {
|
||||
testingConnection.value = true
|
||||
@@ -403,8 +403,8 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="create-base bg-white relative flex flex-col justify-center gap-2 w-full">
|
||||
<h1 class="prose-2xl font-bold self-start mb-4 flex items-center gap-2">
|
||||
<div class="create-source bg-white relative flex flex-col justify-center gap-2 w-full">
|
||||
<h1 class="prose-xl font-bold self-start mb-4 flex items-center gap-2">
|
||||
{{ $t('title.newBase') }}
|
||||
<DashboardSettingsDataSourcesInfo />
|
||||
<span class="flex-grow"></span>
|
||||
@@ -413,7 +413,7 @@ watch(
|
||||
<a-form
|
||||
ref="form"
|
||||
:model="formState"
|
||||
name="external-project-create-form"
|
||||
name="external-base-create-form"
|
||||
layout="horizontal"
|
||||
no-style
|
||||
:label-col="{ span: 8 }"
|
||||
@@ -424,7 +424,7 @@ watch(
|
||||
maxHeight: '60vh',
|
||||
}"
|
||||
>
|
||||
<a-form-item label="Base Name" v-bind="validateInfos.title">
|
||||
<a-form-item label="Source Name" v-bind="validateInfos.title">
|
||||
<a-input v-model:value="formState.title" class="nc-extdb-proj-name" />
|
||||
</a-form-item>
|
||||
|
||||
@@ -628,13 +628,12 @@ watch(
|
||||
</NcButton>
|
||||
|
||||
<NcButton
|
||||
v-e="['a:source:create']"
|
||||
size="small"
|
||||
type="primary"
|
||||
:disabled="!testSuccess"
|
||||
:loading="creatingBase"
|
||||
class="nc-extdb-btn-submit !rounded-md"
|
||||
@click="createBase"
|
||||
@click="createSource"
|
||||
>
|
||||
{{ $t('general.submit') }}
|
||||
</NcButton>
|
||||
@@ -688,7 +687,7 @@ watch(
|
||||
@apply !min-h-0;
|
||||
}
|
||||
|
||||
.create-base {
|
||||
.create-source {
|
||||
:deep(.ant-input-affix-wrapper),
|
||||
:deep(.ant-input),
|
||||
:deep(.ant-select) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { BaseType } from 'nocodb-sdk'
|
||||
import type { SourceType } from 'nocodb-sdk'
|
||||
import { Form, message } from 'ant-design-vue'
|
||||
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select'
|
||||
import type { DefaultConnection, ProjectCreateForm, SQLiteConnection } from '#imports'
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
getTestDatabaseName,
|
||||
iconMap,
|
||||
onMounted,
|
||||
projectTitleValidator,
|
||||
baseTitleValidator,
|
||||
readFile,
|
||||
ref,
|
||||
storeToRefs,
|
||||
@@ -27,17 +27,17 @@ import {
|
||||
} from '#imports'
|
||||
|
||||
const props = defineProps<{
|
||||
baseId: string
|
||||
sourceId: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits(['baseUpdated', 'close'])
|
||||
|
||||
const projectStore = useProject()
|
||||
const projectsStore = useProjects()
|
||||
const { project } = storeToRefs(projectStore)
|
||||
const baseStore = useBase()
|
||||
const basesStore = useBases()
|
||||
const { base } = storeToRefs(baseStore)
|
||||
|
||||
const _projectId = inject(ProjectIdInj, undefined)
|
||||
const projectId = computed(() => _projectId?.value ?? project.value?.id)
|
||||
const baseId = computed(() => _projectId?.value ?? base.value?.id)
|
||||
|
||||
const useForm = Form.useForm
|
||||
|
||||
@@ -79,7 +79,7 @@ const customFormState = ref<ProjectCreateForm>({
|
||||
|
||||
const validators = computed(() => {
|
||||
return {
|
||||
'title': [projectTitleValidator],
|
||||
'title': [baseTitleValidator],
|
||||
'extraParameters': [extraParameterValidator],
|
||||
'dataSource.client': [fieldRequiredValidator()],
|
||||
...(formState.value.dataSource.client === ClientType.SQLITE
|
||||
@@ -214,13 +214,13 @@ const editBase = async () => {
|
||||
}
|
||||
|
||||
try {
|
||||
if (!project.value?.id) return
|
||||
if (!base.value?.id) return
|
||||
|
||||
const connection = getConnectionConfig()
|
||||
|
||||
const config = { ...formState.value.dataSource, connection }
|
||||
|
||||
await api.base.update(project.value?.id, props.baseId, {
|
||||
await api.source.update(base.value?.id, props.sourceId, {
|
||||
alias: formState.value.title,
|
||||
type: formState.value.dataSource.client,
|
||||
config,
|
||||
@@ -228,9 +228,9 @@ const editBase = async () => {
|
||||
inflection_table: formState.value.inflection.inflectionTable,
|
||||
})
|
||||
|
||||
$e('a:base:edit:extdb')
|
||||
$e('a:source:edit:extdb')
|
||||
|
||||
await projectsStore.loadProject(projectId.value!, true)
|
||||
await basesStore.loadProject(baseId.value!, true)
|
||||
emit('baseUpdated')
|
||||
emit('close')
|
||||
} catch (e: any) {
|
||||
@@ -246,7 +246,7 @@ const testConnection = async () => {
|
||||
return
|
||||
}
|
||||
|
||||
$e('a:base:edit:extdb:test-connection', [])
|
||||
$e('a:source:edit:extdb:test-connection', [])
|
||||
|
||||
try {
|
||||
testingConnection.value = true
|
||||
@@ -315,12 +315,12 @@ watch(
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
// load base config
|
||||
// load source config
|
||||
onMounted(async () => {
|
||||
if (project.value?.id) {
|
||||
if (base.value?.id) {
|
||||
const definedParameters = ['host', 'port', 'user', 'password', 'database']
|
||||
|
||||
const activeBase = (await api.base.read(project.value?.id, props.baseId)) as BaseType
|
||||
const activeBase = (await api.source.read(base.value?.id, props.sourceId)) as SourceType
|
||||
|
||||
const tempParameters = Object.entries(activeBase.config.connection)
|
||||
.filter(([key]) => !definedParameters.includes(key))
|
||||
@@ -342,13 +342,13 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="edit-base bg-white relative flex flex-col justify-start gap-2 w-full p-2">
|
||||
<h1 class="prose-2xl font-bold self-start">{{ $t('activity.editBase') }}</h1>
|
||||
<div class="edit-source bg-white relative flex flex-col justify-start gap-2 w-full p-2">
|
||||
<h1 class="prose-2xl font-bold self-start">{{ $t('activity.editSource') }}</h1>
|
||||
|
||||
<a-form
|
||||
ref="form"
|
||||
:model="formState"
|
||||
name="external-project-create-form"
|
||||
name="external-base-create-form"
|
||||
layout="horizontal"
|
||||
no-style
|
||||
:label-col="{ span: 8 }"
|
||||
@@ -359,7 +359,7 @@ onMounted(async () => {
|
||||
maxHeight: '60vh',
|
||||
}"
|
||||
>
|
||||
<a-form-item label="Base Name" v-bind="validateInfos.title">
|
||||
<a-form-item label="Source Name" v-bind="validateInfos.title">
|
||||
<a-input v-model:value="formState.title" class="nc-extdb-proj-name" />
|
||||
</a-form-item>
|
||||
|
||||
@@ -625,7 +625,7 @@ onMounted(async () => {
|
||||
@apply !min-h-0;
|
||||
}
|
||||
|
||||
.edit-base {
|
||||
.edit-source {
|
||||
:deep(.ant-input-affix-wrapper),
|
||||
:deep(.ant-input),
|
||||
:deep(.ant-select) {
|
||||
|
||||
Reference in New Issue
Block a user