diff --git a/packages/nc-gui/pages/index/index/index.vue b/packages/nc-gui/pages/index/index/index.vue index 5c047953c7..d770cb9438 100644 --- a/packages/nc-gui/pages/index/index/index.vue +++ b/packages/nc-gui/pages/index/index/index.vue @@ -27,7 +27,7 @@ definePageMeta({ title: 'title.myProject', }) -const { $api, $e } = useNuxtApp() +const { $api, $e, $events } = useNuxtApp() const { api, isLoading } = useApi() @@ -74,6 +74,33 @@ const deleteProject = (project: ProjectType) => { }) } +const duplicateProject = (project: ProjectType) => { + Modal.confirm({ + title: `Do you want to duplicate '${project.title}' project?`, + wrapClassName: 'nc-modal-project-duplicate', + okText: 'Yes', + okType: 'primary', + cancelText: 'No', + async onOk() { + try { + const jobData = await api.project.duplicate(project.id as string) + + $events.subscribe(jobData.type, jobData.id, async (data: { status: string }) => { + if (data.status === 'completed' || data.status === 'refresh') { + await loadProjects() + } else if (data.status === 'failed') { + message.error('Failed to duplicate project') + } + }) + + $e('a:project:duplicate') + } catch (e: any) { + message.error(await extractSdkResponseErrorMsg(e)) + } + }, + }) +} + const handleProjectColor = async (projectId: string, color: string) => { const tcolor = tinycolor(color) @@ -122,7 +149,7 @@ const getProjectPrimary = (project: ProjectType) => { const customRow = (record: ProjectType) => ({ onClick: async () => { - await navigateTo(`/nc/${record.id}`) + if (record.status !== 'job') await navigateTo(`/nc/${record.id}`) $e('a:project:open') }, @@ -249,8 +276,13 @@ const copyProjectMeta = async () => {
+ {{ text }}
@@ -260,7 +292,7 @@ const copyProjectMeta = async () => {