FN-5894: share project data-boundary and status helpers
Centralize project loading and status-state handling across dashboard surfaces. - add a reusable DataBoundary component for loading, empty, error, and loaded states - extract shared project status config helpers for labels, colors, icons, and initializing detection - update project overview, cards, badges, and selector UI to use the shared helpers - add regression coverage for data-boundary behavior, project overview empty/loading transitions, and status config fallbacks Files changed: packages/dashboard/app/components/DataBoundary.tsx | 64 ++++++++++++++++++++++ packages/dashboard/app/components/ProjectCard.tsx | 48 ++-------------- .../app/components/ProjectHealthBadge.tsx | 45 +-------------- .../dashboard/app/components/ProjectOverview.tsx | 4 +- .../dashboard/app/components/ProjectSelector.tsx | 27 +-------- .../app/components/__tests__/DataBoundary.test.tsx | 62 +++++++++++++++++++++ .../components/__tests__/ProjectOverview.test.tsx | 25 +++++++++ .../__tests__/ProjectThemeTokens.test.tsx | 37 ++++--------- .../utils/__tests__/projectStatusConfig.test.ts | 53 ++++++++++++++++++ .../dashboard/app/utils/projectStatusConfig.ts | 50 +++++++++++++++++ packages/dashboard/vitest.config.ts | 2 + 11 files changed, 282 insertions(+), 135 deletions(-) Fusion-Task-Id: FN-5894 Fusion-Task-Lineage: 3626a4af-b62b-456d-82d7-cf47bbf55c21
This commit is contained in:
@@ -7,15 +7,12 @@ import {
|
||||
Grid3X3,
|
||||
Search,
|
||||
Clock,
|
||||
Play,
|
||||
Pause,
|
||||
AlertCircle,
|
||||
Loader2,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import type { ProjectInfo } from "../api";
|
||||
import type { ProjectStatus } from "@fusion/core";
|
||||
import { getTrailingPath } from "../utils/pathDisplay";
|
||||
import { getProjectStatusConfig, isInitializingStatus } from "../utils/projectStatusConfig";
|
||||
|
||||
export interface ProjectSelectorProps {
|
||||
projects: ProjectInfo[];
|
||||
@@ -25,24 +22,6 @@ export interface ProjectSelectorProps {
|
||||
recentProjectIds?: string[];
|
||||
}
|
||||
|
||||
type StatusConfig = { color: string; icon: typeof Play };
|
||||
|
||||
const STATUS_CONFIG: Record<ProjectStatus, StatusConfig> = {
|
||||
active: { color: "var(--success)", icon: Play },
|
||||
paused: { color: "var(--warning)", icon: Pause },
|
||||
errored: { color: "var(--color-error)", icon: AlertCircle },
|
||||
initializing: { color: "var(--info)", icon: Loader2 },
|
||||
};
|
||||
|
||||
const FALLBACK_STATUS_CONFIG: StatusConfig = {
|
||||
color: "var(--color-error)",
|
||||
icon: AlertCircle,
|
||||
};
|
||||
|
||||
function getStatusConfig(status: string | null | undefined): StatusConfig {
|
||||
return STATUS_CONFIG[status as ProjectStatus] ?? FALLBACK_STATUS_CONFIG;
|
||||
}
|
||||
|
||||
/**
|
||||
* ProjectSelector - Project switcher dropdown with keyboard navigation
|
||||
*
|
||||
@@ -234,13 +213,13 @@ export function ProjectSelector({
|
||||
|
||||
// Render status icon
|
||||
const renderStatusIcon = (status: ProjectStatus) => {
|
||||
const config = getStatusConfig(status);
|
||||
const config = getProjectStatusConfig(status);
|
||||
const Icon = config.icon;
|
||||
return (
|
||||
<Icon
|
||||
size={14}
|
||||
style={{ color: config.color }}
|
||||
className={status === "initializing" ? "animate-spin" : ""}
|
||||
className={isInitializingStatus(status) ? "animate-spin" : ""}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user