Browse Source

fix(gui-v2): show error when createTable fails

pull/2885/head
Wing-Kam Wong 2 years ago
parent
commit
88631ed572
  1. 9
      packages/nc-gui-v2/composables/useTableCreate.ts

9
packages/nc-gui-v2/composables/useTableCreate.ts

@ -2,6 +2,8 @@ import type { TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk' import { UITypes } from 'nocodb-sdk'
import { useNuxtApp } from '#app' import { useNuxtApp } from '#app'
import { useProject } from '#imports' import { useProject } from '#imports'
import { useToast } from 'vue-toastification'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
export default (onTableCreate?: (tableMeta: TableType) => void) => { export default (onTableCreate?: (tableMeta: TableType) => void) => {
const table = reactive<{ title: string; table_name: string; columns: Record<string, boolean> }>({ const table = reactive<{ title: string; table_name: string; columns: Record<string, boolean> }>({
@ -16,9 +18,13 @@ export default (onTableCreate?: (tableMeta: TableType) => void) => {
}) })
const { sqlUi, project, tables } = useProject() const { sqlUi, project, tables } = useProject()
const toast = useToast()
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
const createTable = async () => { const createTable = async () => {
try {
if (!sqlUi?.value) return if (!sqlUi?.value) return
const columns = sqlUi?.value?.getNewTableColumns().filter((col) => { const columns = sqlUi?.value?.getNewTableColumns().filter((col) => {
if (col.column_name === 'id' && table.columns.id_ag) { if (col.column_name === 'id' && table.columns.id_ag) {
@ -36,6 +42,9 @@ export default (onTableCreate?: (tableMeta: TableType) => void) => {
}) })
onTableCreate?.(tableMeta) onTableCreate?.(tableMeta)
} catch (e: any) {
toast.error(await extractSdkResponseErrorMsg(e))
}
} }
watch( watch(

Loading…
Cancel
Save