app: centralize kind→icon in one KIND_ICONS map
Every surface hand-mapped deployment kind → lucide icon, so they could (and did) drift. Add KIND_ICONS/kindIcon to lib/labels beside kindLabel, and route KindBadge (→ all detail headers/cards/sections), the Overview tiles, and the program links through it.
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { cn } from "@/lib/utils"
|
import { cn } from "@/lib/utils"
|
||||||
import { KIND_DESCRIPTIONS, kindLabel } from "@/lib/labels"
|
import { KIND_DESCRIPTIONS, kindIcon, kindLabel } from "@/lib/labels"
|
||||||
|
|
||||||
// Derived deployment kind → badge color.
|
// Derived deployment kind → badge color.
|
||||||
const kindColors: Record<string, string> = {
|
const kindColors: Record<string, string> = {
|
||||||
@@ -12,15 +12,17 @@ const kindColors: Record<string, string> = {
|
|||||||
|
|
||||||
export function KindBadge({ kind }: { kind: string | null }) {
|
export function KindBadge({ kind }: { kind: string | null }) {
|
||||||
if (!kind) return null
|
if (!kind) return null
|
||||||
|
const Icon = kindIcon(kind)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-block text-[0.65rem] font-semibold uppercase px-1.5 py-0.5 rounded",
|
"inline-flex items-center gap-1 text-[0.65rem] font-semibold uppercase px-1.5 py-0.5 rounded",
|
||||||
kindColors[kind] ?? "bg-gray-600 text-gray-200",
|
kindColors[kind] ?? "bg-gray-600 text-gray-200",
|
||||||
)}
|
)}
|
||||||
title={KIND_DESCRIPTIONS[kind]}
|
title={KIND_DESCRIPTIONS[kind]}
|
||||||
>
|
>
|
||||||
|
<Icon size={11} className="shrink-0" />
|
||||||
{kindLabel(kind)}
|
{kindLabel(kind)}
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,3 +1,24 @@
|
|||||||
|
import type { LucideIcon } from "lucide-react"
|
||||||
|
import { Box, Clock, LayoutTemplate, Package, Server, Waypoints, Wrench } from "lucide-react"
|
||||||
|
|
||||||
|
// Canonical kind → icon — the single source of truth so the nav, Overview tiles,
|
||||||
|
// cards, the System map, and the command palette all speak one visual language.
|
||||||
|
// (Colors live in KindBadge; labels/descriptions are below.) `program` is the
|
||||||
|
// catalog pseudo-kind, not a deployment kind — the same Package glyph the
|
||||||
|
// Programs nav entry and Overview tile use.
|
||||||
|
export const KIND_ICONS: Record<string, LucideIcon> = {
|
||||||
|
service: Server,
|
||||||
|
job: Clock,
|
||||||
|
tool: Wrench,
|
||||||
|
static: LayoutTemplate,
|
||||||
|
reference: Waypoints,
|
||||||
|
program: Package,
|
||||||
|
}
|
||||||
|
|
||||||
|
export function kindIcon(kind: string): LucideIcon {
|
||||||
|
return KIND_ICONS[kind] ?? Box
|
||||||
|
}
|
||||||
|
|
||||||
export const LAUNCHER_LABELS: Record<string, string> = {
|
export const LAUNCHER_LABELS: Record<string, string> = {
|
||||||
python: "Python",
|
python: "Python",
|
||||||
command: "Command",
|
command: "Command",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Link } from "react-router-dom"
|
import { Link } from "react-router-dom"
|
||||||
import { Clock, Globe, Package, Server, Share2, Wrench } from "lucide-react"
|
import { Globe, Share2 } from "lucide-react"
|
||||||
|
import { KIND_ICONS } from "@/lib/labels"
|
||||||
import {
|
import {
|
||||||
useGateway,
|
useGateway,
|
||||||
useJobs,
|
useJobs,
|
||||||
@@ -33,28 +34,28 @@ export function Overview() {
|
|||||||
const tiles = [
|
const tiles = [
|
||||||
{
|
{
|
||||||
to: "/services",
|
to: "/services",
|
||||||
icon: Server,
|
icon: KIND_ICONS.service,
|
||||||
label: "Services",
|
label: "Services",
|
||||||
value: services?.length ?? 0,
|
value: services?.length ?? 0,
|
||||||
detail: services ? `${upCount(serviceIds)} up` : "",
|
detail: services ? `${upCount(serviceIds)} up` : "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/scheduled",
|
to: "/scheduled",
|
||||||
icon: Clock,
|
icon: KIND_ICONS.job,
|
||||||
label: "Scheduled",
|
label: "Scheduled",
|
||||||
value: jobs?.length ?? 0,
|
value: jobs?.length ?? 0,
|
||||||
detail: jobs ? `${jobs.length === 1 ? "job" : "jobs"}` : "",
|
detail: jobs ? `${jobs.length === 1 ? "job" : "jobs"}` : "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/tools",
|
to: "/tools",
|
||||||
icon: Wrench,
|
icon: KIND_ICONS.tool,
|
||||||
label: "Tools",
|
label: "Tools",
|
||||||
value: tools?.length ?? 0,
|
value: tools?.length ?? 0,
|
||||||
detail: tools ? "on PATH" : "",
|
detail: tools ? "on PATH" : "",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
to: "/programs",
|
to: "/programs",
|
||||||
icon: Package,
|
icon: KIND_ICONS.program,
|
||||||
label: "Programs",
|
label: "Programs",
|
||||||
value: programs?.length ?? 0,
|
value: programs?.length ?? 0,
|
||||||
detail: programs ? "in catalog" : "",
|
detail: programs ? "in catalog" : "",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { useParams, Link } from "react-router-dom"
|
import { useParams, Link } from "react-router-dom"
|
||||||
import { Clock, Package } from "lucide-react"
|
import { Clock } from "lucide-react"
|
||||||
|
import { kindIcon } from "@/lib/labels"
|
||||||
import { useJob } from "@/services/api/hooks"
|
import { useJob } from "@/services/api/hooks"
|
||||||
import { LogViewer } from "@/components/LogViewer"
|
import { LogViewer } from "@/components/LogViewer"
|
||||||
import { DetailHeader } from "@/components/detail/DetailHeader"
|
import { DetailHeader } from "@/components/detail/DetailHeader"
|
||||||
@@ -8,6 +9,8 @@ import { SystemdPanel } from "@/components/detail/SystemdPanel"
|
|||||||
import { ConfigPanel } from "@/components/detail/ConfigPanel"
|
import { ConfigPanel } from "@/components/detail/ConfigPanel"
|
||||||
import { RelatedDeployments } from "@/components/detail/RelatedDeployments"
|
import { RelatedDeployments } from "@/components/detail/RelatedDeployments"
|
||||||
|
|
||||||
|
const ProgramIcon = kindIcon("program")
|
||||||
|
|
||||||
export function ScheduledDetailPage() {
|
export function ScheduledDetailPage() {
|
||||||
const { name } = useParams<{ name: string }>()
|
const { name } = useParams<{ name: string }>()
|
||||||
const { data: deployment, isLoading, error, refetch } = useJob(name ?? "")
|
const { data: deployment, isLoading, error, refetch } = useJob(name ?? "")
|
||||||
@@ -58,7 +61,7 @@ export function ScheduledDetailPage() {
|
|||||||
to={`/programs/${deployment.program}`}
|
to={`/programs/${deployment.program}`}
|
||||||
className="flex items-center gap-1.5 min-w-0 text-[var(--primary)] hover:underline"
|
className="flex items-center gap-1.5 min-w-0 text-[var(--primary)] hover:underline"
|
||||||
>
|
>
|
||||||
<Package size={14} className="shrink-0" /> {deployment.program}
|
<ProgramIcon size={14} className="shrink-0" /> {deployment.program}
|
||||||
</Link>
|
</Link>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user