Browse Source

fix: error handling for duplicate operations

Signed-off-by: mertmit <mertmit99@gmail.com>
feat/export-nest
mertmit 2 years ago
parent
commit
9881d74323
  1. 8
      packages/nc-gui/components/dashboard/TreeView.vue
  2. 8
      packages/nc-gui/components/dlg/ProjectDuplicate.vue
  3. 8
      packages/nc-gui/components/dlg/TableDuplicate.vue
  4. 28
      packages/nc-gui/pages/index/index/index.vue

8
packages/nc-gui/components/dashboard/TreeView.vue

@ -407,6 +407,8 @@ const duplicateTable = async (table: TableType) => {
await loadTables()
}
})
$e('a:table:duplicate')
},
'onUpdate:modelValue': closeDialog,
})
@ -762,7 +764,11 @@ const duplicateTable = async (table: TableType) => {
</div>
</a-menu-item>
<a-menu-item v-if="isUIAllowed('table-duplicate') && !table.mm" @click="duplicateTable(table)">
<a-menu-item
v-if="isUIAllowed('table-duplicate') && !table.mm"
v-e="['c:table:duplicate']"
@click="duplicateTable(table)"
>
<div class="nc-project-menu-item">
{{ $t('general.duplicate') }}
</div>

8
packages/nc-gui/components/dlg/ProjectDuplicate.vue

@ -33,8 +33,12 @@ const isLoading = ref(false)
const _duplicate = async () => {
isLoading.value = true
const jobData = await api.project.duplicate(props.project.id as string, optionsToExclude.value)
props.onOk(jobData as any)
try {
const jobData = await api.project.duplicate(props.project.id as string, optionsToExclude.value)
props.onOk(jobData as any)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
}
isLoading.value = false
dialogShow.value = false
}

8
packages/nc-gui/components/dlg/TableDuplicate.vue

@ -33,8 +33,12 @@ const isLoading = ref(false)
const _duplicate = async () => {
isLoading.value = true
const jobData = await api.dbTable.duplicate(props.table.project_id!, props.table.id!, optionsToExclude.value)
props.onOk(jobData as any)
try {
const jobData = await api.dbTable.duplicate(props.table.project_id!, props.table.id!, optionsToExclude.value)
props.onOk(jobData as any)
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
}
isLoading.value = false
dialogShow.value = false
}

28
packages/nc-gui/pages/index/index/index.vue

@ -89,22 +89,18 @@ const duplicateProject = (project: ProjectType) => {
'modelValue': isOpen,
'project': project,
'onOk': async (jobData: { name: string; id: string }) => {
try {
await loadProjects()
$jobs.subscribe({ name: jobData.name, id: jobData.id }, undefined, async (status: string) => {
if (status === 'completed') {
await loadProjects()
} else if (status === 'failed') {
message.error('Failed to duplicate project')
await loadProjects()
}
})
$e('a:project:duplicate')
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
}
await loadProjects()
$jobs.subscribe({ name: jobData.name, id: jobData.id }, undefined, async (status: string) => {
if (status === 'completed') {
await loadProjects()
} else if (status === 'failed') {
message.error('Failed to duplicate project')
await loadProjects()
}
})
$e('a:project:duplicate')
},
'onUpdate:modelValue': closeDialog,
})

Loading…
Cancel
Save