mirror of
https://github.com/supabase/supabase.git
synced 2026-10-13 05:09:12 +03:00
## Context Couple of small QoL improvements for branch management from internal feedback - Use `TimestampInfo` component for branch rows here <img width="786" height="395" alt="image" src="https://github.com/user-attachments/assets/639381e3-359b-4b11-9854-623d8cc7584f" /> - Workflow logs dialog will show branch name + use `TimestampInfo` component as well for workflow runs created at <img width="836" height="462" alt="image" src="https://github.com/user-attachments/assets/1d2af7fe-9445-47ae-a1a3-a5dcf0fecf4c" /> - Selecting a workflow run will then show the run created at in the header description + use `TimestampInfo` component <img width="829" height="256" alt="image" src="https://github.com/user-attachments/assets/9fe65f21-e948-4f49-a9ba-46acd9505f2f" />
86 lines
2.3 KiB
TypeScript
86 lines
2.3 KiB
TypeScript
import { ActionName, ActionStatus, type ActionRunStep } from 'data/actions/action-runs-query'
|
|
import type { PropsWithChildren } from 'react'
|
|
import { Badge, StatusIcon, Tooltip, TooltipContent, TooltipTrigger } from 'ui'
|
|
|
|
export interface ActionStatusBadgeProps {
|
|
name: ActionName
|
|
status: ActionStatus
|
|
}
|
|
|
|
const UNHEALTHY_STATUES: ActionStatus[] = ['DEAD', 'REMOVING']
|
|
const WAITING_STATUSES: ActionStatus[] = ['CREATED', 'RESTARTING', 'RUNNING']
|
|
|
|
export const STATUS_TO_LABEL: Record<ActionStatus, string> = {
|
|
CREATED: 'pending',
|
|
DEAD: 'failed',
|
|
EXITED: 'succeeded',
|
|
PAUSED: 'skipped',
|
|
REMOVING: 'failed',
|
|
RESTARTING: 'restarting',
|
|
RUNNING: 'running',
|
|
}
|
|
|
|
const NAME_TO_LABEL: Record<ActionName, string> = {
|
|
clone: 'Cloning repo',
|
|
pull: 'Pulling data',
|
|
health: 'Health check',
|
|
configure: 'Configurations',
|
|
migrate: 'Migrations',
|
|
seed: 'Data seeding',
|
|
deploy: 'Functions deployment',
|
|
}
|
|
|
|
export const ActionStatusBadgeCondensed = ({
|
|
children,
|
|
status,
|
|
details,
|
|
}: PropsWithChildren<{
|
|
status: ActionStatus
|
|
details: Array<ActionRunStep>
|
|
}>) => {
|
|
if (status === 'EXITED') {
|
|
return null
|
|
}
|
|
|
|
const isUnhealthy = UNHEALTHY_STATUES.includes(status)
|
|
|
|
return (
|
|
<Tooltip>
|
|
<TooltipTrigger asChild>
|
|
<Badge variant={isUnhealthy ? 'destructive' : 'default'} className="gap-1.5">
|
|
{isUnhealthy && <StatusIcon variant="destructive" hideBackground />}
|
|
{children}
|
|
</Badge>
|
|
</TooltipTrigger>
|
|
<TooltipContent>
|
|
Additional {STATUS_TO_LABEL[status]} steps:
|
|
<ul>
|
|
{details.map((step) => (
|
|
<li key={step.name} className="before:content-['-'] before:mr-0.5">
|
|
{NAME_TO_LABEL[step.name]}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</TooltipContent>
|
|
</Tooltip>
|
|
)
|
|
}
|
|
|
|
export const ActionStatusBadge = ({ name, status }: ActionStatusBadgeProps) => {
|
|
if (status === 'EXITED') {
|
|
return null
|
|
}
|
|
|
|
const isUnhealthy = UNHEALTHY_STATUES.includes(status)
|
|
const isWaiting = WAITING_STATUSES.includes(status)
|
|
|
|
return (
|
|
<Badge variant={isUnhealthy ? 'destructive' : 'default'} className="gap-1.5">
|
|
{(isUnhealthy || isWaiting) && (
|
|
<StatusIcon variant={isUnhealthy ? 'destructive' : 'default'} hideBackground />
|
|
)}
|
|
{NAME_TO_LABEL[name]}: {STATUS_TO_LABEL[status]}
|
|
</Badge>
|
|
)
|
|
}
|