From d2fb4be2b380f684d4866025856e799034ff99b0 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 8 Apr 2026 20:00:57 +0530 Subject: [PATCH] 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 --- src/components/LeafletHeatMap.tsx | 6 +- src/components/asset-info/AssetInfoPanel.tsx | 6 +- .../TagMissingLocationDialog/Map.tsx | 6 +- src/components/shared/AssetGrid.tsx | 2 +- src/components/workflows/nodes/ActionNode.tsx | 9 +- src/components/workflows/nodes/IfNode.tsx | 37 +++++- src/components/workflows/nodes/SwitchNode.tsx | 44 ++++++- .../workflows/nodes/conditionSummary.ts | 107 ++++++++++++++++++ src/pages/workflows/[id].tsx | 3 + src/pages/workflows/[id]/runs/[runId].tsx | 3 + 10 files changed, 201 insertions(+), 22 deletions(-) create mode 100644 src/components/workflows/nodes/conditionSummary.ts diff --git a/src/components/LeafletHeatMap.tsx b/src/components/LeafletHeatMap.tsx index 2280d91..12c0218 100644 --- a/src/components/LeafletHeatMap.tsx +++ b/src/components/LeafletHeatMap.tsx @@ -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 { diff --git a/src/components/asset-info/AssetInfoPanel.tsx b/src/components/asset-info/AssetInfoPanel.tsx index 1b935f2..a8f967d 100644 --- a/src/components/asset-info/AssetInfoPanel.tsx +++ b/src/components/asset-info/AssetInfoPanel.tsx @@ -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 { diff --git a/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx b/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx index 68385ef..7121d9f 100644 --- a/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx +++ b/src/components/assets/missing-location/TagMissingLocationDialog/Map.tsx @@ -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"; diff --git a/src/components/shared/AssetGrid.tsx b/src/components/shared/AssetGrid.tsx index f8bb084..c21a349 100644 --- a/src/components/shared/AssetGrid.tsx +++ b/src/components/shared/AssetGrid.tsx @@ -290,7 +290,7 @@ const AssetGrid = forwardRef(({ assets, isInternal render={{ slideContainer: ({ children }) => (
-
+
{children}
{showInfoPanel && currentAsset && ( diff --git a/src/components/workflows/nodes/ActionNode.tsx b/src/components/workflows/nodes/ActionNode.tsx index 290d7d4..fea2f50 100644 --- a/src/components/workflows/nodes/ActionNode.tsx +++ b/src/components/workflows/nodes/ActionNode.tsx @@ -34,13 +34,16 @@ export default function ActionNode({ data, selected }: NodeProps) {
-
+

{label}

{subType === "create_album" && config.nameTemplate && ( -

{config.nameTemplate}

+

{config.nameTemplate}

+ )} + {(subType === "add_to_album" || subType === "remove_from_album") && config.albumName && ( +

{config.albumName}

)} {subType === "tag" && config.tagName && ( -

{config.tagName}

+

{config.tagName}

)}
diff --git a/src/components/workflows/nodes/IfNode.tsx b/src/components/workflows/nodes/IfNode.tsx index 4f64aea..e425749 100644 --- a/src/components/workflows/nodes/IfNode.tsx +++ b/src/components/workflows/nodes/IfNode.tsx @@ -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 ( +
+ {isPersonType && personIds.length > 0 && ( +
+ {personIds.slice(0, 3).map((id: string) => ( + + ))} + {personIds.length > 3 && ( + + +{personIds.length - 3} + + )} +
+ )} + {summary} +
+ ); +} 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 ( -
+
@@ -17,9 +43,12 @@ export default function IfNode({ data, selected }: NodeProps) { {conditions.length > 0 ? (
{conditions.map((c: any, i: number) => ( -

- {c.type}{c.city ? `: ${c.city}` : ""}{c.personId ? " (person)" : ""}{c.value !== undefined ? `: ${c.value}` : ""} -

+
+ + {i < conditions.length - 1 && ( +

AND

+ )} +
))}
) : ( diff --git a/src/components/workflows/nodes/SwitchNode.tsx b/src/components/workflows/nodes/SwitchNode.tsx index 2e70f10..5c84501 100644 --- a/src/components/workflows/nodes/SwitchNode.tsx +++ b/src/components/workflows/nodes/SwitchNode.tsx @@ -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 ( +
+ {conditions.map((c: any, j: number) => { + const isPersonType = c.type === "person"; + const personIds: string[] = c.personIds || (c.personId ? [c.personId] : []); + return ( +
+ {isPersonType && personIds.length > 0 && ( +
+ {personIds.slice(0, 3).map((id: string) => ( + + ))} + {personIds.length > 3 && ( + + +{personIds.length - 3} + + )} +
+ )} + {formatConditionSummary(c)} +
+ ); + })} +
+ ); +} 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 ( -
+
@@ -16,11 +47,14 @@ export default function SwitchNode({ data, selected }: NodeProps) { {cases.length} cases
{cases.length > 0 && ( -
+
{cases.map((c: any, i: number) => ( -

- {c.label || `Case ${i + 1}`} -

+
+

+ {c.label || `Case ${i + 1}`} +

+ +
))}
)} diff --git a/src/components/workflows/nodes/conditionSummary.ts b/src/components/workflows/nodes/conditionSummary.ts new file mode 100644 index 0000000..5cc441c --- /dev/null +++ b/src/components/workflows/nodes/conditionSummary.ts @@ -0,0 +1,107 @@ +import { ICondition, ConditionType } from "@/types/workflow"; + +const conditionTypeLabels: Record = { + 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 = { + 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; + } +} diff --git a/src/pages/workflows/[id].tsx b/src/pages/workflows/[id].tsx index b3f86d5..24ce4e7 100644 --- a/src/pages/workflows/[id].tsx +++ b/src/pages/workflows/[id].tsx @@ -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(null); const { screenToFlowPosition } = useReactFlow(); @@ -532,6 +534,7 @@ function WorkflowEditorInner() { {/* Center: Canvas */}