feat: workflow node details, dark mode controls, asset preview fixes

- Show full condition details on IF/Switch nodes with person thumbnails
- Show album name and tag on action nodes
- Add dark mode support for React Flow controls via colorMode
- Center images in lightbox preview
- Fix leaflet marker icons for both Webpack and Turbopack bundlers
This commit is contained in:
Varun committed 2026-04-08 20:00:57 +05:30
1 parent 0ede3927f8
commit d2fb4be2b3
10 files changed
+201 -22

No files matched your search

+3 -3
View File
@@ -11,9 +11,9 @@ import markerIcon from 'leaflet/dist/images/marker-icon.png';
import markerShadow from 'leaflet/dist/images/marker-shadow.png';
L.Icon.Default.mergeOptions({
iconUrl: markerIcon.src,
iconRetinaUrl: markerIcon2x.src,
shadowUrl: markerShadow.src,
iconUrl: typeof markerIcon === 'string' ? markerIcon : markerIcon.src,
iconRetinaUrl: typeof markerIcon2x === 'string' ? markerIcon2x : markerIcon2x.src,
shadowUrl: typeof markerShadow === 'string' ? markerShadow : markerShadow.src,
});
interface LeafletHeatMapProps {
+3 -3
View File
@@ -28,9 +28,9 @@ import markerIcon from 'leaflet/dist/images/marker-icon.png'
import markerShadow from 'leaflet/dist/images/marker-shadow.png'
L.Icon.Default.mergeOptions({
iconUrl: markerIcon.src,
iconRetinaUrl: markerIcon2x.src,
shadowUrl: markerShadow.src,
iconUrl: typeof markerIcon === 'string' ? markerIcon : markerIcon.src,
iconRetinaUrl: typeof markerIcon2x === 'string' ? markerIcon2x : markerIcon2x.src,
shadowUrl: typeof markerShadow === 'string' ? markerShadow : markerShadow.src,
})
export interface IAssetDetail {
@@ -10,9 +10,9 @@ import markerIcon from 'leaflet/dist/images/marker-icon.png';
import markerShadow from 'leaflet/dist/images/marker-shadow.png';
L.Icon.Default.mergeOptions({
iconUrl: markerIcon.src,
iconRetinaUrl: markerIcon2x.src,
shadowUrl: markerShadow.src,
iconUrl: typeof markerIcon === 'string' ? markerIcon : markerIcon.src,
iconRetinaUrl: typeof markerIcon2x === 'string' ? markerIcon2x : markerIcon2x.src,
shadowUrl: typeof markerShadow === 'string' ? markerShadow : markerShadow.src,
});
import { MapContainer, TileLayer, useMapEvents } from "react-leaflet";
+1 -1
View File
@@ -290,7 +290,7 @@ const AssetGrid = forwardRef<AssetGridRef, AssetGridProps>(({ assets, isInternal
render={{
slideContainer: ({ children }) => (
<div className="flex h-full w-full">
<div className="flex-1 overflow-hidden">
<div className="flex-1 overflow-hidden flex items-center justify-center">
{children}
</div>
{showInfoPanel && currentAsset && (
@@ -34,13 +34,16 @@ export default function ActionNode({ data, selected }: NodeProps) {
<div className="p-1.5 rounded bg-purple-500/10">
<Icon className="h-4 w-4 text-purple-500" />
</div>
<div>
<div className="min-w-0 flex-1">
<p className="text-xs font-medium text-foreground">{label}</p>
{subType === "create_album" && config.nameTemplate && (
<p className="text-[10px] text-muted-foreground truncate max-w-[140px]">{config.nameTemplate}</p>
<p className="text-[10px] text-muted-foreground truncate max-w-[160px]">{config.nameTemplate}</p>
)}
{(subType === "add_to_album" || subType === "remove_from_album") && config.albumName && (
<p className="text-[10px] text-muted-foreground truncate max-w-[160px]">{config.albumName}</p>
)}
{subType === "tag" && config.tagName && (
<p className="text-[10px] text-muted-foreground">{config.tagName}</p>
<p className="text-[10px] text-muted-foreground truncate max-w-[160px]">{config.tagName}</p>
)}
</div>
</div>
+33 -4
View File
@@ -1,12 +1,38 @@
import { Handle, Position, NodeProps } from "@xyflow/react";
import { GitBranch } from "lucide-react";
import { PERSON_THUBNAIL_PATH } from "@/config/routes";
import { formatConditionSummary } from "./conditionSummary";
function ConditionBadge({ condition }: { condition: any }) {
const summary = formatConditionSummary(condition);
const isPersonType = condition.type === "person";
const personIds: string[] = condition.personIds || (condition.personId ? [condition.personId] : []);
return (
<div className="flex items-center gap-1 min-w-0">
{isPersonType && personIds.length > 0 && (
<div className="flex -space-x-1 shrink-0">
{personIds.slice(0, 3).map((id: string) => (
<img key={id} src={PERSON_THUBNAIL_PATH(id)} alt="" className="h-4 w-4 rounded-full object-cover border border-background" />
))}
{personIds.length > 3 && (
<span className="h-4 w-4 rounded-full bg-muted flex items-center justify-center text-[7px] font-medium border border-background">
+{personIds.length - 3}
</span>
)}
</div>
)}
<span className="text-[10px] text-muted-foreground truncate">{summary}</span>
</div>
);
}
export default function IfNode({ data, selected }: NodeProps) {
const config = data.config ? (typeof data.config === "string" ? JSON.parse(data.config) : data.config) : {};
const conditions = config.conditions || [];
return (
<div className={`px-4 py-3 rounded-lg border-2 bg-background min-w-[200px] ${selected ? "border-blue-500" : "border-yellow-500"}`}>
<div className={`px-4 py-3 rounded-lg border-2 bg-background min-w-[200px] max-w-[280px] ${selected ? "border-blue-500" : "border-yellow-500"}`}>
<Handle type="target" position={Position.Top} className="!bg-yellow-500 !w-3 !h-3" />
<div className="flex items-center gap-2 mb-2">
<div className="p-1.5 rounded bg-yellow-500/10">
@@ -17,9 +43,12 @@ export default function IfNode({ data, selected }: NodeProps) {
{conditions.length > 0 ? (
<div className="space-y-1">
{conditions.map((c: any, i: number) => (
<p key={i} className="text-[10px] text-muted-foreground truncate">
{c.type}{c.city ? `: ${c.city}` : ""}{c.personId ? " (person)" : ""}{c.value !== undefined ? `: ${c.value}` : ""}
</p>
<div key={i}>
<ConditionBadge condition={c} />
{i < conditions.length - 1 && (
<p className="text-[8px] text-muted-foreground/60 font-medium text-center mt-0.5">AND</p>
)}
</div>
))}
</div>
) : (
+39 -5
View File
@@ -1,12 +1,43 @@
import { Handle, Position, NodeProps } from "@xyflow/react";
import { GitFork } from "lucide-react";
import { PERSON_THUBNAIL_PATH } from "@/config/routes";
import { formatConditionSummary } from "./conditionSummary";
function CaseConditions({ conditions }: { conditions: any[] }) {
if (!conditions || conditions.length === 0) return null;
return (
<div className="space-y-0.5 mt-0.5">
{conditions.map((c: any, j: number) => {
const isPersonType = c.type === "person";
const personIds: string[] = c.personIds || (c.personId ? [c.personId] : []);
return (
<div key={j} className="flex items-center gap-1 min-w-0">
{isPersonType && personIds.length > 0 && (
<div className="flex -space-x-1 shrink-0">
{personIds.slice(0, 3).map((id: string) => (
<img key={id} src={PERSON_THUBNAIL_PATH(id)} alt="" className="h-3.5 w-3.5 rounded-full object-cover border border-background" />
))}
{personIds.length > 3 && (
<span className="h-3.5 w-3.5 rounded-full bg-muted flex items-center justify-center text-[6px] font-medium border border-background">
+{personIds.length - 3}
</span>
)}
</div>
)}
<span className="text-[9px] text-muted-foreground/80 truncate">{formatConditionSummary(c)}</span>
</div>
);
})}
</div>
);
}
export default function SwitchNode({ data, selected }: NodeProps) {
const config = data.config ? (typeof data.config === "string" ? JSON.parse(data.config) : data.config) : {};
const cases = config.cases || [];
return (
<div className={`px-4 py-3 rounded-lg border-2 bg-background min-w-[220px] ${selected ? "border-blue-500" : "border-orange-500"}`}>
<div className={`px-4 py-3 rounded-lg border-2 bg-background min-w-[220px] max-w-[300px] ${selected ? "border-blue-500" : "border-orange-500"}`}>
<Handle type="target" position={Position.Top} className="!bg-orange-500 !w-3 !h-3" />
<div className="flex items-center gap-2 mb-2">
<div className="p-1.5 rounded bg-orange-500/10">
@@ -16,11 +47,14 @@ export default function SwitchNode({ data, selected }: NodeProps) {
<span className="text-[10px] text-muted-foreground ml-auto">{cases.length} cases</span>
</div>
{cases.length > 0 && (
<div className="space-y-1 mb-2">
<div className="space-y-1.5 mb-2">
{cases.map((c: any, i: number) => (
<p key={i} className="text-[10px] text-muted-foreground truncate">
{c.label || `Case ${i + 1}`}
</p>
<div key={i} className="border-l-2 border-orange-500/40 pl-2">
<p className="text-[10px] text-foreground font-medium truncate">
{c.label || `Case ${i + 1}`}
</p>
<CaseConditions conditions={c.conditions} />
</div>
))}
</div>
)}
@@ -0,0 +1,107 @@
import { ICondition, ConditionType } from "@/types/workflow";
const conditionTypeLabels: Record<ConditionType, string> = {
person: "Person",
person_unnamed: "Unnamed People",
city: "City",
state: "State",
country: "Country",
geo_radius: "Geo Radius",
date_range: "Date Range",
date_relative: "Relative Date",
day_of_week: "Day of Week",
camera_make: "Camera Make",
camera_model: "Camera Model",
lens: "Lens",
asset_type: "Asset Type",
iso_range: "ISO Range",
focal_length: "Focal Length",
rating: "Rating",
is_favorited: "Favorited",
not_in_album: "Not in Any Album",
not_in_specific_album: "Not in Specific Album",
};
const matchLabels: Record<string, string> = {
equals: "=",
not_equals: "≠",
contains_any: "any of",
contains_all: "all of",
not_contains: "none of",
};
const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
export function formatConditionSummary(c: ICondition): string {
const label = conditionTypeLabels[c.type] || c.type;
switch (c.type) {
case "person": {
const names: string[] = c.personNames || [];
const match = matchLabels[c.match] || c.match || "any of";
if (names.length === 0) return `${label}: (none selected)`;
const nameStr = names.length <= 2 ? names.join(", ") : `${names[0]}, ${names[1]} +${names.length - 2}`;
return `${label} ${match}: ${nameStr}`;
}
case "person_unnamed":
return label;
case "city":
case "state":
case "country": {
const val = c[c.type] || "";
const match = c.match === "not_equals" ? "≠" : "=";
return val ? `${label} ${match} ${val}` : label;
}
case "geo_radius": {
if (c.lat != null && c.lng != null) {
return `${label}: ${c.lat}, ${c.lng} (${c.radiusKm || "?"}km)`;
}
return label;
}
case "date_range": {
const parts: string[] = [];
if (c.after) parts.push(`from ${c.after}`);
if (c.before) parts.push(`to ${c.before}`);
return parts.length > 0 ? `${label}: ${parts.join(" ")}` : label;
}
case "date_relative":
return c.lastDays ? `${label}: last ${c.lastDays} days` : label;
case "day_of_week": {
const days: number[] = c.days || [];
if (days.length === 0) return label;
return `${label}: ${days.sort().map((d) => dayNames[d]).join(", ")}`;
}
case "camera_make":
return c.make ? `${label}: ${c.make}` : label;
case "camera_model":
return c.model ? `${label}: ${c.model}` : label;
case "lens":
return c.lensModel ? `${label}: ${c.lensModel}` : label;
case "asset_type":
return c.assetType ? `${label}: ${c.assetType}` : label;
case "iso_range":
case "focal_length": {
const parts: string[] = [];
if (c.min != null) parts.push(`${c.min}`);
else parts.push("*");
parts.push("–");
if (c.max != null) parts.push(`${c.max}`);
else parts.push("*");
return `${label}: ${parts.join("")}`;
}
case "rating": {
if (c.min != null && c.max != null) return `${label}: ${c.min}–${c.max}`;
if (c.min != null) return `${label}: ≥${c.min}`;
if (c.max != null) return `${label}: ≤${c.max}`;
return label;
}
case "is_favorited":
return c.value === false ? "Not Favorited" : "Favorited";
case "not_in_album":
return label;
case "not_in_specific_album":
return c.albumId ? `${label}: ${c.albumId}` : label;
default:
return label;
}
}
+3
View File
@@ -1,6 +1,7 @@
import "@xyflow/react/dist/style.css";
import { useRouter } from "next/router";
import { useTheme } from "next-themes";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
ReactFlow,
@@ -256,6 +257,7 @@ function TriggerPopover({
function WorkflowEditorInner() {
const router = useRouter();
const { theme } = useTheme();
const { id } = router.query as { id: string };
const reactFlowWrapper = useRef<HTMLDivElement>(null);
const { screenToFlowPosition } = useReactFlow();
@@ -532,6 +534,7 @@ function WorkflowEditorInner() {
{/* Center: Canvas */}
<div className={`flex-1 ${hasApiKey === false ? "hidden" : ""}`} ref={reactFlowWrapper}>
<ReactFlow
colorMode={theme === "dark" ? "dark" : "light"}
nodes={nodes}
edges={edges}
onNodesChange={onNodesChange}
@@ -1,6 +1,7 @@
import "@xyflow/react/dist/style.css";
import { useRouter } from "next/router";
import { useTheme } from "next-themes";
import { useEffect, useMemo, useState } from "react";
import {
ReactFlow,
@@ -212,6 +213,7 @@ function dbEdgeToFlowEdge(e: any): Edge {
function RunDetailInner() {
const router = useRouter();
const { theme } = useTheme();
const { id, runId } = router.query as { id: string; runId: string };
const [loading, setLoading] = useState(true);
@@ -300,6 +302,7 @@ function RunDetailInner() {
{/* Graph */}
<div className="flex-1">
<ReactFlow
colorMode={theme === "dark" ? "dark" : "light"}
nodes={nodes}
edges={edges}
nodeTypes={annotatedNodeTypes}