From b1b362366ee7f6f549d84d7a64e55fb6eb85697c Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Fri, 2 Dec 2022 14:55:02 +0800 Subject: [PATCH 01/71] fix(nc-gui): type issues --- packages/nc-gui/components/cell/Json.vue | 4 +- packages/nc-gui/components/cell/TextArea.vue | 2 +- .../components/cell/attachment/Carousel.vue | 4 +- .../nc-gui/components/general/Tooltip.vue | 11 +++++- .../components/smartsheet/ApiSnippet.vue | 9 +---- .../nc-gui/components/smartsheet/Grid.vue | 13 ++++--- .../components/smartsheet/VirtualCell.vue | 2 +- .../smartsheet/column/EditOrAddProvider.vue | 2 +- .../column/LinkedToAnotherRecordOptions.vue | 10 +++-- .../smartsheet/column/LookupOptions.vue | 39 ++++++++----------- .../smartsheet/column/RollupOptions.vue | 32 +++++++-------- .../components/smartsheet/column/utils.ts | 9 +++++ .../components/smartsheet/header/Cell.vue | 7 +++- .../smartsheet/header/VirtualCell.vue | 2 +- .../toolbar/KanbanStackEditOrAdd.vue | 12 +++++- .../smartsheet/toolbar/MoreActions.vue | 4 +- .../smartsheet/toolbar/SearchData.vue | 7 ++-- .../smartsheet/toolbar/SortListMenu.vue | 9 ++++- .../smartsheet/toolbar/ViewActions.vue | 24 ++++++------ .../components/tabs/auth/UserManagement.vue | 2 +- .../tabs/auth/user-management/UsersModal.vue | 2 +- .../nc-gui/components/template/Editor.vue | 11 +----- .../components/ListChildItems.vue | 26 +++++++------ packages/nc-gui/components/webhook/List.vue | 2 +- .../composables/useColumnCreateStore.ts | 11 ++++-- .../useExpandedFormDetached/index.ts | 2 +- packages/nc-gui/composables/useLTARStore.ts | 2 +- packages/nc-gui/composables/useSharedView.ts | 5 +-- .../nc-gui/composables/useSmartsheetStore.ts | 2 +- packages/nc-gui/package-lock.json | 11 ++++++ packages/nc-gui/package.json | 1 + .../form/[viewId]/index/index.vue | 5 ++- packages/nc-gui/pages/forgot-password.vue | 5 ++- .../nc-gui/pages/index/index/[projectId].vue | 3 +- packages/nc-gui/pages/index/index/create.vue | 3 +- packages/nc-gui/pages/projects/index.vue | 3 +- .../nc-gui/pages/projects/index/index.vue | 5 +-- packages/nc-gui/pages/signup/[[token]].vue | 9 +++-- packages/nc-gui/utils/sortUtils.ts | 2 +- packages/nc-gui/utils/viewUtils.ts | 8 +++- packages/nc-gui/web-types.json | 4 ++ 41 files changed, 190 insertions(+), 136 deletions(-) create mode 100644 packages/nc-gui/components/smartsheet/column/utils.ts diff --git a/packages/nc-gui/components/cell/Json.vue b/packages/nc-gui/components/cell/Json.vue index f89ddf87aa..8d8d6b9831 100644 --- a/packages/nc-gui/components/cell/Json.vue +++ b/packages/nc-gui/components/cell/Json.vue @@ -135,13 +135,13 @@ useSelectedCellKeyupListener(active, (e) => {
Cancel
-
Save
+
Save
() const emits = defineEmits(['update:modelValue']) diff --git a/packages/nc-gui/components/cell/attachment/Carousel.vue b/packages/nc-gui/components/cell/attachment/Carousel.vue index 4933e7d396..63a7c1bb0f 100644 --- a/packages/nc-gui/components/cell/attachment/Carousel.vue +++ b/packages/nc-gui/components/cell/attachment/Carousel.vue @@ -47,7 +47,7 @@ onClickOutside(carouselRef, () => { diff --git a/packages/nc-gui/components/dashboard/settings/DataSources.vue b/packages/nc-gui/components/dashboard/settings/DataSources.vue new file mode 100644 index 0000000000..8f4d227157 --- /dev/null +++ b/packages/nc-gui/components/dashboard/settings/DataSources.vue @@ -0,0 +1,101 @@ + + + diff --git a/packages/nc-gui/components/dashboard/settings/Modal.vue b/packages/nc-gui/components/dashboard/settings/Modal.vue index db7a2bd156..c0c9f0310c 100644 --- a/packages/nc-gui/components/dashboard/settings/Modal.vue +++ b/packages/nc-gui/components/dashboard/settings/Modal.vue @@ -1,5 +1,6 @@ + + + + diff --git a/packages/nc-gui/components/dlg/TableCreate.vue b/packages/nc-gui/components/dlg/TableCreate.vue index e950102b36..96cb6cec16 100644 --- a/packages/nc-gui/components/dlg/TableCreate.vue +++ b/packages/nc-gui/components/dlg/TableCreate.vue @@ -4,6 +4,7 @@ import { TabType } from '~/lib' const props = defineProps<{ modelValue: boolean + baseId: string }>() const emit = defineEmits(['update:modelValue']) @@ -28,7 +29,7 @@ const { table, createTable, generateUniqueTitle, tables, project } = useTable(as }) dialogShow.value = false -}) +}, props.baseId) const useForm = Form.useForm @@ -51,11 +52,11 @@ const validators = computed(() => { validator: (rule: any, value: any) => { return new Promise((resolve, reject) => { let tableNameLengthLimit = 255 - if (isMysql) { + if (isMysql(props.baseId)) { tableNameLengthLimit = 64 - } else if (isPg) { + } else if (isPg(props.baseId)) { tableNameLengthLimit = 63 - } else if (isMssql) { + } else if (isMssql(props.baseId)) { tableNameLengthLimit = 128 } const projectPrefix = project?.value?.prefix || '' diff --git a/packages/nc-gui/components/template/Editor.vue b/packages/nc-gui/components/template/Editor.vue index 2f99813c49..24fb40b834 100644 --- a/packages/nc-gui/components/template/Editor.vue +++ b/packages/nc-gui/components/template/Editor.vue @@ -66,7 +66,7 @@ const { addTab } = useTabs() const { sqlUis, project, loadTables } = useProject() -const sqlUi = ref(meta.value?.base_id ? sqlUis.value[meta.value?.base_id] : sqlUis.value[0]) +const sqlUi = ref(meta.value?.base_id ? sqlUis.value[meta.value?.base_id] : Object.values(sqlUis.value)[0]) const hasSelectColumn = ref([]) diff --git a/packages/nc-gui/composables/useColumnCreateStore.ts b/packages/nc-gui/composables/useColumnCreateStore.ts index a8d8d0c68a..d31ac88e16 100644 --- a/packages/nc-gui/composables/useColumnCreateStore.ts +++ b/packages/nc-gui/composables/useColumnCreateStore.ts @@ -36,7 +36,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState const { $e } = useNuxtApp() - const sqlUi = ref(meta.value?.base_id ? sqlUis.value[meta.value?.base_id] : sqlUis.value[0]) + const sqlUi = ref(meta.value?.base_id ? sqlUis.value[meta.value?.base_id] : Object.values(sqlUis.value)[0]) const isEdit = computed(() => !!column?.value?.id) diff --git a/packages/nc-gui/composables/useSmartsheetStore.ts b/packages/nc-gui/composables/useSmartsheetStore.ts index 934924154d..a0982e4b66 100644 --- a/packages/nc-gui/composables/useSmartsheetStore.ts +++ b/packages/nc-gui/composables/useSmartsheetStore.ts @@ -15,7 +15,7 @@ const [useProvideSmartsheetStore, useSmartsheetStore] = useInjectionState( const { $api } = useNuxtApp() const { sqlUis } = useProject() - const sqlUi = ref(meta.value?.base_id ? sqlUis.value[meta.value?.base_id] : sqlUis.value[0]) + const sqlUi = ref(meta.value?.base_id ? sqlUis.value[meta.value?.base_id] : Object.values(sqlUis.value)[0]) const cellRefs = ref([]) diff --git a/packages/nc-gui/composables/useTable.ts b/packages/nc-gui/composables/useTable.ts index b95a3c880b..3de4ddde10 100644 --- a/packages/nc-gui/composables/useTable.ts +++ b/packages/nc-gui/composables/useTable.ts @@ -16,7 +16,7 @@ import { } from '#imports' import { TabType } from '~/lib' -export function useTable(onTableCreate?: (tableMeta: TableType) => void) { +export function useTable(onTableCreate?: (tableMeta: TableType) => void, baseId?: string) { const table = reactive<{ title: string; table_name: string; columns: string[] }>({ title: '', table_name: '', @@ -34,7 +34,7 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void) { const { closeTab } = useTabs() const { sqlUis, project, tables } = useProject() - const sqlUi = ref(sqlUis.value[0]) + const sqlUi = computed(() => (baseId && sqlUis.value[baseId] ? sqlUis.value[baseId] : Object.values(sqlUis.value)[0])) const createTable = async () => { if (!sqlUi?.value) return @@ -49,7 +49,7 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void) { }) try { - const tableMeta = await $api.dbTable.create(project?.value?.id as string, { + const tableMeta = await $api.base.tableCreate(project?.value?.id as string, baseId as string, { ...table, columns, }) From 743c160eef57b081207bf3fa34f86395e52a600e Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 24 Sep 2022 17:34:21 +0300 Subject: [PATCH 15/71] fix: multiple source project prefix Signed-off-by: mertmit --- packages/nc-gui/composables/useTable.ts | 2 +- packages/nocodb/src/lib/meta/api/tableApis.ts | 7 ++++--- packages/nocodb/src/lib/meta/helpers/getTableName.ts | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/composables/useTable.ts b/packages/nc-gui/composables/useTable.ts index 3de4ddde10..6b9368c0c3 100644 --- a/packages/nc-gui/composables/useTable.ts +++ b/packages/nc-gui/composables/useTable.ts @@ -63,7 +63,7 @@ export function useTable(onTableCreate?: (tableMeta: TableType) => void, baseId? watch( () => table.title, (title) => { - table.table_name = `${project?.value?.prefix || ''}${title}` + table.table_name = `${title}` }, ) diff --git a/packages/nocodb/src/lib/meta/api/tableApis.ts b/packages/nocodb/src/lib/meta/api/tableApis.ts index 778a553b3b..89df8a5072 100644 --- a/packages/nocodb/src/lib/meta/api/tableApis.ts +++ b/packages/nocodb/src/lib/meta/api/tableApis.ts @@ -90,6 +90,7 @@ export async function tableList(req: Request, res: Response) { export async function tableCreate(req: Request, res) { const project = await Project.getWithInfo(req.params.projectId); let base = project.bases[0]; + if (req.params.baseId) { base = project.bases.find((b) => b.id === req.params.baseId); } @@ -103,7 +104,7 @@ export async function tableCreate(req: Request, res) { ); } - if (project.prefix) { + if (base.is_meta && project.prefix) { if (!req.body.table_name.startsWith(project.prefix)) { req.body.table_name = `${project.prefix}_${req.body.table_name}`; } @@ -228,14 +229,14 @@ export async function tableUpdate(req: Request, res) { const project = await Project.getWithInfo(req.body.project_id); const base = project.bases.find((b) => b.id === model.base_id); - + if (!req.body.table_name) { NcError.badRequest( 'Missing table name `table_name` property in request body' ); } - if (project.prefix) { + if (base.is_meta && project.prefix) { if (!req.body.table_name.startsWith(project.prefix)) { req.body.table_name = `${project.prefix}${req.body.table_name}`; } diff --git a/packages/nocodb/src/lib/meta/helpers/getTableName.ts b/packages/nocodb/src/lib/meta/helpers/getTableName.ts index cff2d54cbd..4dc49ba652 100644 --- a/packages/nocodb/src/lib/meta/helpers/getTableName.ts +++ b/packages/nocodb/src/lib/meta/helpers/getTableName.ts @@ -7,7 +7,7 @@ export default function getTableNameAlias( base: Base ): string { let tn = tableName; - if (prefix) { + if (base.is_meta && prefix) { tn = tn.replace(prefix, ''); } From 1cf10e8fd91bf3c01c0be32f0c775a9259dc5cf1 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 24 Sep 2022 17:58:15 +0300 Subject: [PATCH 16/71] fix: multiple source sync views Signed-off-by: mertmit --- packages/nocodb/src/lib/meta/api/baseApis.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/nocodb/src/lib/meta/api/baseApis.ts b/packages/nocodb/src/lib/meta/api/baseApis.ts index 7b015135b7..b21985a000 100644 --- a/packages/nocodb/src/lib/meta/api/baseApis.ts +++ b/packages/nocodb/src/lib/meta/api/baseApis.ts @@ -126,14 +126,14 @@ async function populateMeta(base: Base, project: Project): Promise { return t; }); - // TODO add base prefix - /* filter based on prefix - if (project?.prefix) { + + /* filter based on prefix */ + if (base.is_meta && project?.prefix) { tables = tables.filter((t) => { return t?.tn?.startsWith(project?.prefix); }); } - */ + info.tablesCount = tables.length; @@ -297,7 +297,7 @@ async function populateMeta(base: Base, project: Project): Promise { }); /* filter based on prefix */ - if (project?.prefix) { + if (base.is_meta && project?.prefix) { views = tables.filter((t) => { return t?.tn?.startsWith(project?.prefix); }); From 121c4ed71c327ce863c1db49ac02480992426fc9 Mon Sep 17 00:00:00 2001 From: mertmit Date: Sat, 24 Sep 2022 18:33:42 +0300 Subject: [PATCH 17/71] fix: show only tables within same base as child table for LTAR Signed-off-by: mertmit --- .../smartsheet/column/LinkedToAnotherRecordOptions.vue | 2 +- .../nc-gui/components/smartsheet/column/LookupOptions.vue | 2 +- .../nc-gui/components/smartsheet/column/RollupOptions.vue | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue index e5840621e9..f137ed3edd 100644 --- a/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/LinkedToAnotherRecordOptions.vue @@ -44,7 +44,7 @@ const refTables = $computed(() => { return [] } - return tables.filter((t) => t.type === ModelTypes.TABLE) + return tables.filter((t) => t.type === ModelTypes.TABLE && t.base_id === meta?.base_id) }) const filterOption = (value: string, option: { key: string }) => option.key.toLowerCase().includes(value.toLowerCase()) diff --git a/packages/nc-gui/components/smartsheet/column/LookupOptions.vue b/packages/nc-gui/components/smartsheet/column/LookupOptions.vue index 77279ae9f1..0667cc7b9f 100644 --- a/packages/nc-gui/components/smartsheet/column/LookupOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/LookupOptions.vue @@ -34,7 +34,7 @@ const refTables = $computed(() => { } const _refTables = meta.columns - .filter((column) => column.uidt === UITypes.LinkToAnotherRecord && !column.system) + .filter((column) => column.uidt === UITypes.LinkToAnotherRecord && !column.system && column.base_id === meta?.base_id) .map((column) => ({ col: column.colOptions, column, diff --git a/packages/nc-gui/components/smartsheet/column/RollupOptions.vue b/packages/nc-gui/components/smartsheet/column/RollupOptions.vue index 960cbb7507..20e1a54333 100644 --- a/packages/nc-gui/components/smartsheet/column/RollupOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/RollupOptions.vue @@ -47,7 +47,13 @@ const refTables = $computed(() => { } const _refTables = meta.columns - .filter((c) => c.uidt === UITypes.LinkToAnotherRecord && (c.colOptions as LinkToAnotherRecordType).type !== 'bt' && !c.system) + .filter( + (c) => + c.uidt === UITypes.LinkToAnotherRecord && + (c.colOptions as LinkToAnotherRecordType).type !== 'bt' && + !c.system && + c.base_id === meta?.base_id, + ) .map((c) => ({ col: c.colOptions, column: c, From 5c433e3086283f35ff4e4da6aecb4133e8d5563b Mon Sep 17 00:00:00 2001 From: mertmit Date: Sun, 25 Sep 2022 16:43:16 +0300 Subject: [PATCH 18/71] feat: team & settings modal data sources tab revised Signed-off-by: mertmit --- packages/nc-gui/components.d.ts | 7 +- .../nc-gui/components/cell/DateTimePicker.vue | 4 +- .../nc-gui/components/cell/MultiSelect.vue | 2 +- .../nc-gui/components/cell/TimePicker.vue | 6 +- .../nc-gui/components/dashboard/TreeView.vue | 16 +- .../dashboard/settings/AppStore.vue | 169 +++++++++--------- .../dashboard/settings/DataSources.vue | 142 ++++++++++----- .../components/dashboard/settings/Erd.vue | 10 +- .../dashboard/settings/Metadata.vue | 10 +- .../components/dashboard/settings/Modal.vue | 153 +++++++++++----- .../components/dashboard/settings/UIAcl.vue | 11 +- .../nc-gui/components/dlg/TableRename.vue | 9 +- packages/nc-gui/components/erd/View.vue | 19 +- .../components/general/AddBaseButton.vue | 21 +++ .../smartsheet/column/CurrencyOptions.vue | 4 +- .../components/virtual-cell/Formula.vue | 2 +- .../composables/useColumnCreateStore.ts | 11 +- packages/nc-gui/composables/useProject.ts | 8 +- packages/nc-gui/context/index.ts | 1 + packages/nc-gui/lib/enums.ts | 9 + .../pages/[projectType]/[projectId]/index.vue | 13 +- .../nocodb/src/lib/meta/api/metaDiffApis.ts | 7 + 22 files changed, 421 insertions(+), 213 deletions(-) create mode 100644 packages/nc-gui/components/general/AddBaseButton.vue diff --git a/packages/nc-gui/components.d.ts b/packages/nc-gui/components.d.ts index 1664e337f5..3af2f902d4 100644 --- a/packages/nc-gui/components.d.ts +++ b/packages/nc-gui/components.d.ts @@ -10,6 +10,8 @@ declare module '@vue/runtime-core' { AAlert: typeof import('ant-design-vue/es')['Alert'] AAutoComplete: typeof import('ant-design-vue/es')['AutoComplete'] ABadgeRibbon: typeof import('ant-design-vue/es')['BadgeRibbon'] + ABreadcrumb: typeof import('ant-design-vue/es')['Breadcrumb'] + ABreadcrumbItem: typeof import('ant-design-vue/es')['BreadcrumbItem'] AButton: typeof import('ant-design-vue/es')['Button'] ACard: typeof import('ant-design-vue/es')['Card'] ACardMeta: typeof import('ant-design-vue/es')['CardMeta'] @@ -65,7 +67,6 @@ declare module '@vue/runtime-core' { ATabs: typeof import('ant-design-vue/es')['Tabs'] ATag: typeof import('ant-design-vue/es')['Tag'] ATextarea: typeof import('ant-design-vue/es')['Textarea'] - ATimePicker: typeof import('ant-design-vue/es')['TimePicker'] ATooltip: typeof import('ant-design-vue/es')['Tooltip'] ATypographyTitle: typeof import('ant-design-vue/es')['TypographyTitle'] AUploadDragger: typeof import('ant-design-vue/es')['UploadDragger'] @@ -144,7 +145,9 @@ declare module '@vue/runtime-core' { MdiContentSave: typeof import('~icons/mdi/content-save')['default'] MdiContentSaveEdit: typeof import('~icons/mdi/content-save-edit')['default'] MdiCurrencyUsd: typeof import('~icons/mdi/currency-usd')['default'] + MdiDatabaseLockOutline: typeof import('~icons/mdi/database-lock-outline')['default'] MdiDatabaseOutline: typeof import('~icons/mdi/database-outline')['default'] + MdiDatabasePlusOutline: typeof import('~icons/mdi/database-plus-outline')['default'] MdiDatabaseSync: typeof import('~icons/mdi/database-sync')['default'] MdiDelete: typeof import('~icons/mdi/delete')['default'] MdiDeleteOutline: typeof import('~icons/mdi/delete-outline')['default'] @@ -176,6 +179,7 @@ declare module '@vue/runtime-core' { MdiFunction: typeof import('~icons/mdi/function')['default'] MdiGestureDoubleTap: typeof import('~icons/mdi/gesture-double-tap')['default'] MdiGithub: typeof import('~icons/mdi/github')['default'] + MdiGraphOutline: typeof import('~icons/mdi/graph-outline')['default'] MdiHeart: typeof import('~icons/mdi/heart')['default'] MdiHook: typeof import('~icons/mdi/hook')['default'] MdiInformation: typeof import('~icons/mdi/information')['default'] @@ -193,6 +197,7 @@ declare module '@vue/runtime-core' { MdiMagnify: typeof import('~icons/mdi/magnify')['default'] MdiMenu: typeof import('~icons/mdi/menu')['default'] MdiMenuDown: typeof import('~icons/mdi/menu-down')['default'] + MdiMenuIcon: typeof import('~icons/mdi/menu-icon')['default'] MdiMicrosoftTeams: typeof import('~icons/mdi/microsoft-teams')['default'] MdiMinusCircleOutline: typeof import('~icons/mdi/minus-circle-outline')['default'] MdiMoonFull: typeof import('~icons/mdi/moon-full')['default'] diff --git a/packages/nc-gui/components/cell/DateTimePicker.vue b/packages/nc-gui/components/cell/DateTimePicker.vue index 8819d23ce7..8ad758b8b8 100644 --- a/packages/nc-gui/components/cell/DateTimePicker.vue +++ b/packages/nc-gui/components/cell/DateTimePicker.vue @@ -28,9 +28,11 @@ const active = inject(ActiveCellInj, ref(false)) const editable = inject(EditModeInj, ref(false)) +const column = inject(ColumnInj)! + let isDateInvalid = $ref(false) -const dateFormat = isMysql ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ' +const dateFormat = isMysql(column.value.base_id) ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD HH:mm:ssZ' let localState = $computed({ get() { diff --git a/packages/nc-gui/components/cell/MultiSelect.vue b/packages/nc-gui/components/cell/MultiSelect.vue index 0e8ac91571..3815933e49 100644 --- a/packages/nc-gui/components/cell/MultiSelect.vue +++ b/packages/nc-gui/components/cell/MultiSelect.vue @@ -105,7 +105,7 @@ const vModel = computed({ const selectedTitles = computed(() => modelValue ? typeof modelValue === 'string' - ? isMysql + ? isMysql(column.value.base_id) ? modelValue.split(',').sort((a, b) => { const opa = options.value.find((el) => el.title === a) const opb = options.value.find((el) => el.title === b) diff --git a/packages/nc-gui/components/cell/TimePicker.vue b/packages/nc-gui/components/cell/TimePicker.vue index 6402de2bed..1d9f8fe7c6 100644 --- a/packages/nc-gui/components/cell/TimePicker.vue +++ b/packages/nc-gui/components/cell/TimePicker.vue @@ -1,6 +1,6 @@ diff --git a/packages/nc-gui/components/dashboard/settings/DataSources.vue b/packages/nc-gui/components/dashboard/settings/DataSources.vue index 8f4d227157..af8395cb3b 100644 --- a/packages/nc-gui/components/dashboard/settings/DataSources.vue +++ b/packages/nc-gui/components/dashboard/settings/DataSources.vue @@ -2,69 +2,90 @@ import { Empty } from 'ant-design-vue' import type { BaseType } from 'nocodb-sdk' import CreateBase from './data-sources/CreateBase.vue' +import Metadata from './Metadata.vue' +import UIAcl from './UIAcl.vue' +import Erd from './Erd.vue' +import { DataSourcesSubTab } from '~/lib' import { useNuxtApp, useProject } from '#imports' +interface Props { + state: string + reload: boolean +} + +const props = defineProps() + +const emits = defineEmits(['update:state', 'update:reload']) + +const vModel = useVModel(props, 'state', emits) +const vReload = useVModel(props, 'reload', emits) + const { $api } = useNuxtApp() const { project } = useProject() -let isLoading = $ref(false) let sources = $ref([]) -const newSourceTab = $ref(false) +let activeBaseId = $ref('') +let metadiffbases = $ref([]) async function loadBases() { try { if (!project.value?.id) return - isLoading = true + vReload.value = true const baseList = await $api.base.list(project.value?.id) if (baseList.bases.list && baseList.bases.list.length) { sources = baseList.bases.list } + loadMetaDiff() } catch (e) { console.error(e) } finally { - isLoading = false + vReload.value = false + } +} + +async function loadMetaDiff() { + try { + if (!project.value?.id) return + + metadiffbases = [] + + const metadiff = await $api.project.metaDiffGet(project.value?.id) + for (const model of metadiff) { + if (model.detectedChanges?.length > 0) { + metadiffbases.push(model.base_id) + } + } + } catch (e) { + console.error(e) } } +const baseAction = (baseId: string, action: string) => { + activeBaseId = baseId + vModel.value = action +} + onMounted(async () => { if (sources.length === 0) { await loadBases() } }) + +watch( + () => props.reload, + async (reload) => { + if (reload) { + await loadBases() + } + }, +) diff --git a/packages/nc-gui/components/dashboard/settings/Erd.vue b/packages/nc-gui/components/dashboard/settings/Erd.vue index e8ca1d8bd8..d89b7e8d1e 100644 --- a/packages/nc-gui/components/dashboard/settings/Erd.vue +++ b/packages/nc-gui/components/dashboard/settings/Erd.vue @@ -1,5 +1,13 @@ + + diff --git a/packages/nc-gui/components/dashboard/settings/Metadata.vue b/packages/nc-gui/components/dashboard/settings/Metadata.vue index e515eb9fb2..5d69142a4e 100644 --- a/packages/nc-gui/components/dashboard/settings/Metadata.vue +++ b/packages/nc-gui/components/dashboard/settings/Metadata.vue @@ -1,6 +1,12 @@