Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/ui/badge-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CircleCheck, LoaderCircle } from 'lucide-react'
import type { Progress } from '../../types/upload-progress.ts'
import { cn } from '../../utils/cn.ts'

export type Status = Progress['status'] | 'pinned'
export type Status = Progress['status'] | 'pinned' | 'published'

type BadgeStatusProps = VariantProps<typeof badgeVariants> & {
status: Status
Expand All @@ -15,6 +15,7 @@ const badgeVariants = cva('inline-flex items-center gap-1 pl-1.5 pr-2 py-0.5 rou
'in-progress': 'bg-badge-in-progress text-badge-in-progress-text border border-badge-in-progress-border',
completed: 'bg-brand-950 text-brand-700 border border-brand-900',
pinned: 'bg-brand-950 text-brand-700 border border-brand-900',
published: 'bg-yellow-600/30 border border-yellow-400/20 text-yellow-200',
error: null,
pending: 'bg-zinc-800 border border-zinc-700 text-zinc-300',
},
Expand All @@ -28,6 +29,7 @@ const statusIcons: Record<Status, React.ReactNode> = {
'in-progress': <LoaderCircle className="animate-spin" size={12} />,
completed: <CircleCheck size={12} />,
pinned: <CircleCheck size={12} />,
published: null,
error: null,
pending: null,
}
Expand All @@ -36,6 +38,7 @@ const statusLabels: Record<Status, string | null> = {
'in-progress': 'In progress',
completed: 'Complete',
pinned: 'Pinned',
published: 'Published',
error: null,
pending: 'Pending',
}
Expand Down
9 changes: 8 additions & 1 deletion src/hooks/use-upload-progress.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Status } from '@/components/ui/badge-status.tsx'
import { useMemo } from 'react'
import type { Progress } from '../types/upload-progress.ts'
import { createStepGroup } from '../utils/upload-status.ts'
Expand Down Expand Up @@ -32,7 +33,7 @@ export interface UploadProgressInfo {
/**
* Badge status for the file card header
*/
badgeStatus: 'pinned' | 'error' | 'in-progress' | 'pending'
badgeStatus: Status
}

/**
Expand Down Expand Up @@ -112,11 +113,17 @@ export function useUploadProgress(progresses: Progress[], cid?: string): UploadP

// Check if any step is in error (excluding IPNI failures)
const hasError = progresses.some((p) => p.status === 'error' && p.step !== 'announcing-cids')
const finalizingStep = progresses.find((p) => p.step === 'finalizing-transaction')
const announcingStep = progresses.find((p) => p.step === 'announcing-cids')


// Determine the badge status for the file card header
const getBadgeStatus = (): UploadProgressInfo['badgeStatus'] => {
if (isCompleted) return 'pinned'
if (hasError) return 'error'
if (finalizingStep?.status === 'completed' && announcingStep?.status !== 'completed') {
return 'published'
}
// Check if any step is in progress
if (progresses.some((p) => p.status === 'in-progress')) return 'in-progress'
// If no steps are in progress but not all completed, must be pending
Expand Down
Loading