The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Fix workspace data export S3 upload and show exports on the admin user page (#28706)
Charles Bochetd8c9c2354a4e
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportSection.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportSection.tsxindex 197df64233b..8107273223e 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportSection.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportSection.tsx@@ -76,7 +76,7 @@ export const SettingsAdminWorkspaceDataExportSection = ({return (<>- <SettingsAdminWorkspaceDataExportsFetchEffect />+ <SettingsAdminWorkspaceDataExportsFetchEffect workspaceId={workspaceId} /><SettingsTableListSection<WorkspaceDataExportRow>title={t`Data export`}description={t`Every object of this workspace as CSV files in one zip, kept for 1 day. Works for suspended workspaces.`}diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportsFetchEffect.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportsFetchEffect.tsxindex 6db6b81ae02..284bac9bcaa 100644--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportsFetchEffect.tsx+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceDataExportsFetchEffect.tsx@@ -1,7 +1,6 @@import { useQuery } from '@apollo/client/react';import { isNonEmptyString } from '@sniptt/guards';import { useEffect } from 'react';-import { useParams } from 'react-router-dom';import { isDefined } from 'twenty-shared/utils';import { useApolloAdminClient } from '@/settings/admin-panel/apollo/hooks/useApolloAdminClient';@@ -15,8 +14,13 @@ import {const PENDING_EXPORT_POLL_INTERVAL_MS = 3000;-export const SettingsAdminWorkspaceDataExportsFetchEffect = () => {- const { workspaceId = '' } = useParams<{ workspaceId: string }>();+type SettingsAdminWorkspaceDataExportsFetchEffectProps = {+ workspaceId: string;+};++export const SettingsAdminWorkspaceDataExportsFetchEffect = ({+ workspaceId,+}: SettingsAdminWorkspaceDataExportsFetchEffectProps) => {const apolloAdminClient = useApolloAdminClient();const setAdminPanelWorkspaceDataExports = useSetAtomFamilyState(adminPanelWorkspaceDataExportsFamilyState,diff --git a/packages/twenty-server/src/engine/core-modules/workspace-data-export/services/workspace-data-export-archive.service.ts b/packages/twenty-server/src/engine/core-modules/workspace-data-export/services/workspace-data-export-archive.service.tsindex b19db7abf05..d173ca3fdbc 100644--- a/packages/twenty-server/src/engine/core-modules/workspace-data-export/services/workspace-data-export-archive.service.ts+++ b/packages/twenty-server/src/engine/core-modules/workspace-data-export/services/workspace-data-export-archive.service.ts@@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';import archiver, { type Archiver } from 'archiver';import { once } from 'events';-import { Readable } from 'stream';+import { PassThrough, pipeline, Readable } from 'stream';import { isNonEmptyArray } from 'twenty-shared/utils';import { FileStorageService } from 'src/engine/core-modules/file-storage/services/file-storage.service';@@ -33,13 +33,17 @@ export class WorkspaceDataExportArchiveService {onPartAdded: () => Promise<void>;}): Promise<number> {const archive = archiver('zip', { zlib: { level: 1 } });+ const archiveBody = new PassThrough();++ pipeline(archive, archiveBody, () => undefined);+const upload = this.fileStorageService.writeFileStream({...buildWorkspaceDataExportResource({workspaceId,exportId,file: { type: 'archive' },}),- stream: archive,+ stream: archiveBody,mimeType: 'application/zip',});const failure = new Promise<never>((_, reject) => {