From 4562e7c1370a3ecf82c24f62e3f26b714f6342d1 Mon Sep 17 00:00:00 2001 From: akhisud3195 Date: Tue, 13 May 2025 15:12:22 +0530 Subject: [PATCH] Update files source page to not show status when no files uploaded --- .../rowboat/app/actions/datasource_actions.ts | 38 +++++++++++-------- .../rowboat/app/lib/types/datasource_types.ts | 2 +- .../sources/[sourceId]/source-page.tsx | 15 +++++--- .../sources/components/sources-list.tsx | 30 ++++++++------- .../projects/[projectId]/sources/new/form.tsx | 1 - 5 files changed, 50 insertions(+), 36 deletions(-) diff --git a/apps/rowboat/app/actions/datasource_actions.ts b/apps/rowboat/app/actions/datasource_actions.ts index cc6fe18b..cbaced48 100644 --- a/apps/rowboat/app/actions/datasource_actions.ts +++ b/apps/rowboat/app/actions/datasource_actions.ts @@ -62,10 +62,15 @@ export async function createDataSource({ description, createdAt: (new Date()).toISOString(), attempts: 0, - status: status, version: 1, data, }; + + // Only set status for non-file data sources + if (data.type !== 'files_local' && data.type !== 'files_s3') { + source.status = status; + } + await dataSourcesCollection.insertOne(source); const { _id, ...rest } = source as WithId>; @@ -158,7 +163,7 @@ export async function addDocsToDataSource({ }[] }): Promise { await projectAuthCheck(projectId); - await getDataSource(projectId, sourceId); + const source = await getDataSource(projectId, sourceId); await dataSourceDocsCollection.insertMany(docData.map(doc => { const record: z.infer = { @@ -177,19 +182,22 @@ export async function addDocsToDataSource({ return recordWithId; })); - await dataSourcesCollection.updateOne( - { _id: new ObjectId(sourceId) }, - { - $set: { - status: 'pending', - attempts: 0, - lastUpdatedAt: new Date().toISOString(), - }, - $inc: { - version: 1, - }, - } - ); + // Only set status to pending when files are added + if (docData.length > 0 && (source.data.type === 'files_local' || source.data.type === 'files_s3')) { + await dataSourcesCollection.updateOne( + { _id: new ObjectId(sourceId) }, + { + $set: { + status: 'pending', + attempts: 0, + lastUpdatedAt: new Date().toISOString(), + }, + $inc: { + version: 1, + }, + } + ); + } } export async function listDocsInDataSource({ diff --git a/apps/rowboat/app/lib/types/datasource_types.ts b/apps/rowboat/app/lib/types/datasource_types.ts index 70cc729c..fa207daf 100644 --- a/apps/rowboat/app/lib/types/datasource_types.ts +++ b/apps/rowboat/app/lib/types/datasource_types.ts @@ -10,7 +10,7 @@ export const DataSource = z.object({ z.literal('ready'), z.literal('error'), z.literal('deleted'), - ]), + ]).optional(), version: z.number(), error: z.string().optional(), createdAt: z.string().datetime(), diff --git a/apps/rowboat/app/projects/[projectId]/sources/[sourceId]/source-page.tsx b/apps/rowboat/app/projects/[projectId]/sources/[sourceId]/source-page.tsx index ce087cf2..6c4abade 100644 --- a/apps/rowboat/app/projects/[projectId]/sources/[sourceId]/source-page.tsx +++ b/apps/rowboat/app/projects/[projectId]/sources/[sourceId]/source-page.tsx @@ -200,12 +200,15 @@ export function SourcePage({ - - Source - - - - + {/* Only show status when it exists */} + {source.status && ( + + Status + + + + + )} diff --git a/apps/rowboat/app/projects/[projectId]/sources/components/sources-list.tsx b/apps/rowboat/app/projects/[projectId]/sources/components/sources-list.tsx index 89fe9d89..81fe2358 100644 --- a/apps/rowboat/app/projects/[projectId]/sources/components/sources-list.tsx +++ b/apps/rowboat/app/projects/[projectId]/sources/components/sources-list.tsx @@ -102,9 +102,11 @@ export function SourcesList({ projectId }: { projectId: string }) { Type - - Status - + {sources.some(source => source.status) && ( + + Status + + )} Active @@ -152,16 +154,18 @@ export function SourcesList({ projectId }: { projectId: string }) { )} - -
- -
- + {sources.some(source => source.status) && ( + +
+ +
+ + )}