Files
silo-server/web/src/components/admin/TaskStatusBadge.tsx
T
2933e0581f fix(web): make pre-merge frontend checks pass at HEAD (prettier drift + 15 stale tests) (#119)
* style(web): run prettier over drifted files

prettier --check was failing on 19 files at HEAD. The pinned prettier
version (3.8.1) has not changed since the initial migration, so the
drift came from unformatted commits, not a toolchain bump. Formatting
changes only, no behavior change.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* test(web): sync stale test harnesses with current components

15 tests across 6 files were failing at HEAD; the components were
committed already out of sync with their tests in the initial
migration. All fixes are in test files only:

- SectionRow / SeriesContent: mock the watch playback controller
  required by ContinueWatchingCard and MediaItemMenu, mock the new
  useSimilarItems hook, add useOptionalAuth to the auth mock, and
  wrap renders in QueryClientProvider for MediaItemMenu query hooks
- SeriesContent: read rating from item.user_rating (the useRating
  hook no longer exists)
- ProfilesSettings: add useHouseholdSessions to the profiles mock
  for the new HouseholdStreamsPanel
- ImpersonationBanner: match the redesigned banner ("Viewing as",
  sticky full-width bar instead of sidebar offset)
- EpisodeRow: watched indicator uses the text-success token now
- profile-management: use a valid DiceBear preset ref; "adventurer"
  no longer resolves and round-trips to ""

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-06-09 19:17:14 -04:00

44 lines
1.2 KiB
TypeScript

import type { ExecutionResult } from "@/api/types";
import { Badge } from "@/components/ui/badge";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { cn } from "@/lib/utils";
interface TaskStatusBadgeProps {
result: Pick<ExecutionResult, "status" | "error_message">;
className?: string;
}
export function TaskStatusBadge({ result, className }: TaskStatusBadgeProps) {
const variant =
result.status === "failed"
? "destructive"
: result.status === "cancelled"
? "outline"
: "secondary";
const badge = (
<Badge variant={variant} className={cn("shrink-0", className)}>
{result.status}
</Badge>
);
const errorMessage = result.error_message?.trim();
if (result.status !== "failed" || !errorMessage) {
return badge;
}
return (
<TooltipProvider delayDuration={150}>
<Tooltip>
<TooltipTrigger asChild>
<span className="inline-flex cursor-help" tabIndex={0}>
{badge}
</span>
</TooltipTrigger>
<TooltipContent side="top" className="max-w-[min(28rem,80vw)] whitespace-pre-wrap">
{errorMessage}
</TooltipContent>
</Tooltip>
</TooltipProvider>
);
}