fix(dashboard): address ELK layout review feedback
What: Fix three non-blocking issues from PR #232 review. Why: Code quality — unhandled promise rejection risk, type safety, and project convention compliance. Changes: - packages/workflow-dashboard/src/components/workflow-graph/types.ts: add elkLabelX/elkLabelY fields to ConditionEdgeData type (number | null, not optional — per project no-optional-properties rule) - packages/workflow-dashboard/src/components/workflow-graph/use-layout.ts: remove 'as ConditionEdgeData' type assertion (now unnecessary), add .catch() to computeLayout promise - packages/workflow-dashboard/src/components/workflow-graph/condition-edge.tsx: remove redundant inline type extension, use ConditionEdgeData directly Ref: PR #232 review comments
This commit is contained in:
@@ -20,7 +20,7 @@ export function ConditionEdge(props: EdgeProps) {
|
|||||||
data,
|
data,
|
||||||
markerEnd,
|
markerEnd,
|
||||||
} = props;
|
} = props;
|
||||||
const edgeData = data as (ConditionEdgeData & { elkLabelX?: number | null; elkLabelY?: number | null }) | undefined;
|
const edgeData = data as ConditionEdgeData | undefined;
|
||||||
const isFallback = edgeData?.isFallback ?? false;
|
const isFallback = edgeData?.isFallback ?? false;
|
||||||
const isSelfLoop = source === target;
|
const isSelfLoop = source === target;
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ export type ConditionEdgeData = {
|
|||||||
condition: string;
|
condition: string;
|
||||||
conditionDescription: string | null;
|
conditionDescription: string | null;
|
||||||
isFallback: boolean;
|
isFallback: boolean;
|
||||||
|
elkLabelX: number | null;
|
||||||
|
elkLabelY: number | null;
|
||||||
[key: string]: unknown;
|
[key: string]: unknown;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ function buildEdge(e: WorkflowGraphEdge, elkEdgeMap: Map<string, ElkExtendedEdge
|
|||||||
isFallback,
|
isFallback,
|
||||||
elkLabelX: labelX,
|
elkLabelX: labelX,
|
||||||
elkLabelY: labelY,
|
elkLabelY: labelY,
|
||||||
} as ConditionEdgeData,
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,9 +195,16 @@ export function useLayout(input: LayoutInput): LayoutResult {
|
|||||||
roles: JSON.parse(roleJson) as Record<string, { description: string }>,
|
roles: JSON.parse(roleJson) as Record<string, { description: string }>,
|
||||||
nodeStates: input.nodeStates,
|
nodeStates: input.nodeStates,
|
||||||
};
|
};
|
||||||
computeLayout(parsed).then((result) => {
|
computeLayout(parsed)
|
||||||
if (!cancelled) setLayout(result);
|
.then((result) => {
|
||||||
});
|
if (!cancelled) setLayout(result);
|
||||||
|
})
|
||||||
|
.catch((err: unknown) => {
|
||||||
|
if (!cancelled) {
|
||||||
|
// biome-ignore lint/suspicious/noConsole: layout error reporting
|
||||||
|
console.error("ELK layout failed:", err);
|
||||||
|
}
|
||||||
|
});
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user