import { Modal } from 'ant-design-vue' import type { LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk' import { useToast } from 'vue-toastification' import useTabs, { TabType } from '~/composables/useTabs' import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' export default () => { const { $e, $api } = useNuxtApp() const toast = useToast() const { getMeta, removeMeta } = useMetas() const { loadTables } = useProject() const { closeTab } = useTabs() const deleteTable = (table: TableType) => { $e('c:table:delete') // 'Click Submit to Delete The table' Modal.confirm({ title: `Click Yes to Delete The table : ${table.title}`, okText: 'Yes', okType: 'danger', cancelText: 'No', async onOk() { try { const meta = (await getMeta(table.id as string)) as TableType const relationColumns = meta?.columns?.filter((c) => c.uidt === UITypes.LinkToAnotherRecord) if (relationColumns?.length) { const refColMsgs = await Promise.all( relationColumns.map(async (c, i) => { const refMeta = (await getMeta( (c?.colOptions as LinkToAnotherRecordType)?.fk_related_model_id as string, )) as TableType return `${i + 1}. ${c.title} is a LinkToAnotherRecord of ${(refMeta && refMeta.title) || c.title}` }), ) toast.info( h('div', { innerHTML: `