Browse Source

fix: pass base id to at import modal

pull/6581/head
mertmit 1 year ago
parent
commit
81ddbe92e2
  1. 7
      packages/nc-gui/components/dashboard/TreeView/AddNewTableNode.vue
  2. 7
      packages/nc-gui/components/dashboard/TreeView/BaseOptions.vue
  3. 11
      packages/nc-gui/components/dlg/AirtableImport.vue
  4. 7
      packages/nc-gui/components/project/ImportModal.vue

7
packages/nc-gui/components/dashboard/TreeView/AddNewTableNode.vue

@ -73,8 +73,8 @@ function openQuickImportDialog(type: string, sourceId?: string) {
} }
} }
function openAirtableImportDialog(sourceId?: string) { function openAirtableImportDialog(baseId?: string, sourceId?: string) {
if (!sourceId) return if (!baseId || !sourceId) return
$e('a:actions:import-airtable') $e('a:actions:import-airtable')
@ -82,6 +82,7 @@ function openAirtableImportDialog(sourceId?: string) {
const { close } = useDialog(resolveComponent('DlgAirtableImport'), { const { close } = useDialog(resolveComponent('DlgAirtableImport'), {
'modelValue': isOpen, 'modelValue': isOpen,
'baseId': baseId,
'sourceId': sourceId, 'sourceId': sourceId,
'onUpdate:modelValue': closeDialog, 'onUpdate:modelValue': closeDialog,
}) })
@ -160,7 +161,7 @@ function openTableCreateMagicDialog(sourceId?: string) {
<a-menu-item <a-menu-item
v-if="isUIAllowed('airtableImport', { roles: baseRole })" v-if="isUIAllowed('airtableImport', { roles: baseRole })"
key="quick-import-airtable" key="quick-import-airtable"
@click="openAirtableImportDialog(base.sources[sourceIndex].id)" @click="openAirtableImportDialog(base.id, base.sources[sourceIndex].id)"
> >
<div class="color-transition nc-base-menu-item group"> <div class="color-transition nc-base-menu-item group">
<GeneralIcon icon="airtable" class="group-hover:text-accent" /> <GeneralIcon icon="airtable" class="group-hover:text-accent" />

7
packages/nc-gui/components/dashboard/TreeView/BaseOptions.vue

@ -14,8 +14,8 @@ const baseRole = inject(ProjectRoleInj)
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
function openAirtableImportDialog(sourceId?: string) { function openAirtableImportDialog(baseId?: string, sourceId?: string) {
if (!sourceId) return if (!baseId || !sourceId) return
$e('a:actions:import-airtable') $e('a:actions:import-airtable')
@ -23,6 +23,7 @@ function openAirtableImportDialog(sourceId?: string) {
const { close } = useDialog(resolveComponent('DlgAirtableImport'), { const { close } = useDialog(resolveComponent('DlgAirtableImport'), {
'modelValue': isOpen, 'modelValue': isOpen,
'baseId': baseId,
'sourceId': sourceId, 'sourceId': sourceId,
'onUpdate:modelValue': closeDialog, 'onUpdate:modelValue': closeDialog,
}) })
@ -71,7 +72,7 @@ function openQuickImportDialog(type: string) {
v-if="isUIAllowed('airtableImport', { roles: baseRole })" v-if="isUIAllowed('airtableImport', { roles: baseRole })"
key="quick-import-airtable" key="quick-import-airtable"
v-e="['c:import:airtable']" v-e="['c:import:airtable']"
@click="openAirtableImportDialog(source.id)" @click="openAirtableImportDialog(source.base_id, source.id)"
> >
<GeneralIcon icon="airtable" class="max-w-3.75 group-hover:text-black" /> <GeneralIcon icon="airtable" class="max-w-3.75 group-hover:text-black" />
<div class="ml-0.5">{{ $t('labels.airtable') }}</div> <div class="ml-0.5">{{ $t('labels.airtable') }}</div>

11
packages/nc-gui/components/dlg/AirtableImport.vue

@ -11,14 +11,13 @@ import {
nextTick, nextTick,
onMounted, onMounted,
ref, ref,
storeToRefs,
useBase,
useNuxtApp, useNuxtApp,
watch, watch,
} from '#imports' } from '#imports'
const { modelValue, sourceId } = defineProps<{ const { modelValue, baseId, sourceId } = defineProps<{
modelValue: boolean modelValue: boolean
baseId: string
sourceId: string sourceId: string
}>() }>()
@ -36,8 +35,6 @@ const { refreshCommandPalette } = useCommandPalette()
const { loadTables } = baseStore const { loadTables } = baseStore
const { base } = storeToRefs(baseStore)
const showGoToDashboardButton = ref(false) const showGoToDashboardButton = ref(false)
const step = ref(1) const step = ref(1)
@ -135,7 +132,7 @@ async function createOrUpdate() {
body: payload, body: payload,
}) })
} else { } else {
syncSource.value = await $fetch(`/api/v1/meta/bases/${base.value.id}/syncs/${sourceId}`, { syncSource.value = await $fetch(`/api/v1/meta/bases/${baseId}/syncs/${sourceId}`, {
baseURL, baseURL,
method: 'POST', method: 'POST',
headers: { 'xc-auth': $state.token.value as string }, headers: { 'xc-auth': $state.token.value as string },
@ -187,7 +184,7 @@ async function listenForUpdates() {
} }
async function loadSyncSrc() { async function loadSyncSrc() {
const data: any = await $fetch(`/api/v1/meta/bases/${base.value.id}/syncs/${sourceId}`, { const data: any = await $fetch(`/api/v1/meta/bases/${baseId}/syncs/${sourceId}`, {
baseURL, baseURL,
method: 'GET', method: 'GET',
headers: { 'xc-auth': $state.token.value as string }, headers: { 'xc-auth': $state.token.value as string },

7
packages/nc-gui/components/project/ImportModal.vue

@ -14,8 +14,8 @@ const visible = useVModel(props, 'visible', emits)
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
function openAirtableImportDialog(sourceId?: string) { function openAirtableImportDialog(baseId?: string, sourceId?: string) {
if (!sourceId) return if (!baseId || !sourceId) return
$e('a:actions:import-airtable') $e('a:actions:import-airtable')
@ -23,6 +23,7 @@ function openAirtableImportDialog(sourceId?: string) {
const { close } = useDialog(resolveComponent('DlgAirtableImport'), { const { close } = useDialog(resolveComponent('DlgAirtableImport'), {
'modelValue': isOpen, 'modelValue': isOpen,
'baseId': baseId,
'sourceId': sourceId, 'sourceId': sourceId,
'onUpdate:modelValue': closeDialog, 'onUpdate:modelValue': closeDialog,
}) })
@ -59,7 +60,7 @@ const onClick = (type: 'airtable' | 'csv' | 'excel' | 'json') => {
visible.value = false visible.value = false
if (type === 'airtable') { if (type === 'airtable') {
openAirtableImportDialog(source.value.id) openAirtableImportDialog(source.value.base_id, source.value.id)
} else { } else {
openQuickImportDialog(type) openQuickImportDialog(type)
} }

Loading…
Cancel
Save