Browse Source

fix: better ux for duplicate shared base

pull/6641/head
mertmit 1 year ago
parent
commit
31839dcd9f
  1. 47
      packages/nc-gui/components/dlg/SharedBaseDuplicate.vue
  2. 43
      packages/nc-gui/pages/index.vue

47
packages/nc-gui/components/dlg/SharedBaseDuplicate.vue

@ -13,7 +13,13 @@ const { api } = useApi()
const { sharedBaseId } = useCopySharedBase()
const { workspacesList } = storeToRefs(useWorkspace())
const workspaceStore = useWorkspace()
const { populateWorkspace } = workspaceStore
const { workspacesList } = storeToRefs(workspaceStore)
const { ncNavigateTo } = useGlobal()
const dialogShow = useVModel(props, 'modelValue', emit)
@ -34,6 +40,8 @@ const isLoading = ref(false)
const selectedWorkspace = ref<string>()
const { $e, $poller } = useNuxtApp()
const _duplicate = async () => {
if (!selectedWorkspace.value && isEeUI) return
@ -51,12 +59,41 @@ const _duplicate = async () => {
sharedBaseId.value = null
props.onOk({ ...jobData, workspace_id: selectedWorkspace.value } as any)
$poller.subscribe(
{ id: jobData.id },
async (data: {
id: string
status?: string
data?: {
error?: {
message: string
}
message?: string
result?: any
}
}) => {
if (data.status !== 'close') {
if (data.status === JobStatus.COMPLETED) {
console.log('job completed', jobData)
await ncNavigateTo({
...(isEeUI ? { workspaceId: jobData.fk_workspace_id } : {}),
baseId: jobData.base_id,
})
isLoading.value = false
dialogShow.value = false
} else if (data.status === JobStatus.FAILED) {
message.error('Failed to duplicate shared base')
await populateWorkspace()
isLoading.value = false
dialogShow.value = false
}
}
},
)
$e('a:base:duplicate-shared-base')
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
} finally {
isLoading.value = false
dialogShow.value = false
}
}
</script>

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

@ -16,7 +16,7 @@ const basesStore = useBases()
const { populateWorkspace } = useWorkspace()
const { signedIn, ncNavigateTo } = useGlobal()
const { signedIn } = useGlobal()
const { isUIAllowed } = useRoles()
@ -121,40 +121,6 @@ function toggleDialog(value?: boolean, key?: string, dsState?: string, pId?: str
}
provide(ToggleDialogInj, toggleDialog)
const { $e, $poller } = useNuxtApp()
const DlgSharedBaseDuplicateOnOk = async (jobData: { id: string; base_id: string; workspace_id: string }) => {
await populateWorkspace()
$poller.subscribe(
{ id: jobData.id },
async (data: {
id: string
status?: string
data?: {
error?: {
message: string
}
message?: string
result?: any
}
}) => {
if (data.status !== 'close') {
if (data.status === JobStatus.COMPLETED) {
await ncNavigateTo({
baseId: jobData.base_id,
})
} else if (data.status === JobStatus.FAILED) {
message.error('Failed to duplicate shared base')
await populateWorkspace()
}
}
},
)
$e('a:base:duplicate-shared-base')
}
</script>
<template>
@ -179,12 +145,7 @@ const DlgSharedBaseDuplicateOnOk = async (jobData: { id: string; base_id: string
v-model:data-sources-state="dataSourcesState"
:base-id="baseId"
/>
<DlgSharedBaseDuplicate
v-if="isUIAllowed('baseDuplicate')"
v-model="isDuplicateDlgOpen"
:shared-base-id="sharedBaseId"
:on-ok="DlgSharedBaseDuplicateOnOk"
/>
<DlgSharedBaseDuplicate v-if="isUIAllowed('baseDuplicate')" v-model="isDuplicateDlgOpen" />
</div>
</template>

Loading…
Cancel
Save