mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-09 02:12:59 +00:00
a55d1245f8
* fix(fleet): resolve version detection pipeline for Docker builds The Dockerfile backend-builder stage was missing a COPY of the root package.json, causing generate-version.js to fall back to "0.0.0-dev" at build time. At runtime, the filesystem walk also failed (root package.json not in the final image), producing the string "unknown" which the frontend rendered as "vunknown". Changes: - Dockerfile: copy root package.json into backend-builder stage - CapabilityRegistry: return null (not "unknown") for unresolvable versions; add isValidVersion() type guard; normalize remote meta responses to strip "unknown"/"0.0.0-dev" sentinel values - Fleet endpoints: hoist gateway version validation outside per-node loops; treat unresolvable remote versions as "potentially outdated" instead of silently marking them up to date - FleetView: guard all version display points (card badge, update button, gateway label, modal columns) via shared formatVersion() - EditorLayout, CapabilityGate: use shared isValidVersion utility - New frontend/src/lib/version.ts shared utility - Docs: add troubleshooting section for version display edge cases - Screenshots: updated Fleet Overview and Node Updates modal * docs: update fleet node updates screenshot with live remote node
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { type ReactNode } from 'react';
|
|
import { Unplug } from 'lucide-react';
|
|
import { useNodes } from '@/context/NodeContext';
|
|
import type { Capability } from '@/lib/capabilities';
|
|
import { isValidVersion } from '@/lib/version';
|
|
|
|
interface CapabilityGateProps {
|
|
capability: Capability;
|
|
featureName?: string;
|
|
children: ReactNode;
|
|
}
|
|
|
|
export function CapabilityGate({ capability, featureName = 'This feature', children }: CapabilityGateProps) {
|
|
const { hasCapability, activeNode, activeNodeMeta } = useNodes();
|
|
|
|
if (hasCapability(capability)) return <>{children}</>;
|
|
|
|
const nodeName = activeNode?.name ?? 'this node';
|
|
const versionHint = isValidVersion(activeNodeMeta?.version)
|
|
? `${nodeName} is running v${activeNodeMeta.version}`
|
|
: `${nodeName} does not support this capability`;
|
|
|
|
return (
|
|
<div className="relative">
|
|
<div className="opacity-40 pointer-events-none select-none blur-[2px]">
|
|
{children}
|
|
</div>
|
|
<div className="absolute inset-0 flex items-start justify-center pt-8">
|
|
<div className="flex items-center gap-2 px-3 py-1.5 rounded-full bg-muted/80 border border-border text-muted-foreground text-xs">
|
|
<Unplug className="w-3 h-3" strokeWidth={1.5} />
|
|
{featureName} is not available: {versionHint}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|