mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-06-06 19:35:44 +02:00
Update files source page to not show status when no files uploaded
This commit is contained in:
parent
ee6a7ab763
commit
4562e7c137
5 changed files with 50 additions and 36 deletions
|
|
@ -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<z.infer<typeof DataSource>>;
|
||||
|
|
@ -158,7 +163,7 @@ export async function addDocsToDataSource({
|
|||
}[]
|
||||
}): Promise<void> {
|
||||
await projectAuthCheck(projectId);
|
||||
await getDataSource(projectId, sourceId);
|
||||
const source = await getDataSource(projectId, sourceId);
|
||||
|
||||
await dataSourceDocsCollection.insertMany(docData.map(doc => {
|
||||
const record: z.infer<typeof DataSourceDoc> = {
|
||||
|
|
@ -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({
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -200,12 +200,15 @@ export function SourcePage({
|
|||
</SectionContent>
|
||||
</SectionRow>
|
||||
|
||||
<SectionRow>
|
||||
<SectionLabel>Source</SectionLabel>
|
||||
<SectionContent>
|
||||
<SourceStatus status={source.status} projectId={projectId} />
|
||||
</SectionContent>
|
||||
</SectionRow>
|
||||
{/* Only show status when it exists */}
|
||||
{source.status && (
|
||||
<SectionRow>
|
||||
<SectionLabel>Status</SectionLabel>
|
||||
<SectionContent>
|
||||
<SourceStatus status={source.status} projectId={projectId} />
|
||||
</SectionContent>
|
||||
</SectionRow>
|
||||
)}
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
|
|
|
|||
|
|
@ -102,9 +102,11 @@ export function SourcesList({ projectId }: { projectId: string }) {
|
|||
<th className="w-[20%] px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">
|
||||
Type
|
||||
</th>
|
||||
<th className="w-[35%] px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">
|
||||
Status
|
||||
</th>
|
||||
{sources.some(source => source.status) && (
|
||||
<th className="w-[35%] px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">
|
||||
Status
|
||||
</th>
|
||||
)}
|
||||
<th className="w-[15%] px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500 dark:text-gray-400">
|
||||
Active
|
||||
</th>
|
||||
|
|
@ -152,16 +154,18 @@ export function SourcesList({ projectId }: { projectId: string }) {
|
|||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td className="px-6 py-4 text-left">
|
||||
<div className="text-sm">
|
||||
<SelfUpdatingSourceStatus
|
||||
sourceId={source._id}
|
||||
projectId={projectId}
|
||||
initialStatus={source.status}
|
||||
compact={true}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
{sources.some(source => source.status) && (
|
||||
<td className="px-6 py-4 text-left">
|
||||
<div className="text-sm">
|
||||
<SelfUpdatingSourceStatus
|
||||
sourceId={source._id}
|
||||
projectId={projectId}
|
||||
initialStatus={source.status}
|
||||
compact={true}
|
||||
/>
|
||||
</div>
|
||||
</td>
|
||||
)}
|
||||
<td className="px-6 py-4 text-left">
|
||||
<ToggleSource
|
||||
projectId={projectId}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ export function Form({
|
|||
data: {
|
||||
type: formData.get('type') as 'files_local' | 'files_s3',
|
||||
},
|
||||
status: 'ready',
|
||||
});
|
||||
|
||||
router.push(`/projects/${projectId}/sources/${source._id}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue