From 442fe8ff4840c361373383a3c1cfce167b2879f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20R=C3=A4ntil=C3=A4?= Date: Tue, 9 Sep 2025 22:52:16 +0200 Subject: [PATCH] Removed the onPostTransformation hook and all debug-related logic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gustaf Räntilä --- plugins/catalog-graph/report.api.md | 8 ----- .../EntityRelationsGraph.tsx | 4 --- .../useEntityRelationNodesAndEdges.ts | 20 ----------- plugins/catalog-graph/src/index.ts | 5 +-- .../src/lib/graph-transformations/index.ts | 7 +--- .../src/lib/graph-transformations/types.ts | 35 ------------------- 6 files changed, 2 insertions(+), 77 deletions(-) diff --git a/plugins/catalog-graph/report.api.md b/plugins/catalog-graph/report.api.md index 883c79acf4..8194209cf5 100644 --- a/plugins/catalog-graph/report.api.md +++ b/plugins/catalog-graph/report.api.md @@ -181,16 +181,8 @@ export type EntityRelationsGraphProps = { renderLabel?: DependencyGraphTypes.RenderLabelFunction; curve?: 'curveStepBefore' | 'curveMonotoneX'; showArrowHeads?: boolean; - onPostTransformation?: GraphTransformationDebugger; }; -// @public -export type GraphTransformationDebugger = ( - transformation: string | undefined, - transformationContext: TransformationContext, - clonedContext: TransformationContext, -) => void; - // @public export type RelationPairs = [string, string][]; diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx index 47ce365cb6..f77ca4b37d 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx @@ -33,7 +33,6 @@ import { DefaultRenderNode } from './DefaultRenderNode'; import { RelationPairs } from '../../lib/types'; import { Direction, EntityEdge, EntityNode } from '../../lib/types'; import { useEntityRelationNodesAndEdges } from './useEntityRelationNodesAndEdges'; -import { GraphTransformationDebugger } from '../../lib/graph-transformations'; /** @public */ export type EntityRelationsGraphClassKey = 'progress' | 'container' | 'graph'; @@ -92,7 +91,6 @@ export type EntityRelationsGraphProps = { renderLabel?: DependencyGraphTypes.RenderLabelFunction; curve?: 'curveStepBefore' | 'curveMonotoneX'; showArrowHeads?: boolean; - onPostTransformation?: GraphTransformationDebugger; }; /** @@ -118,7 +116,6 @@ export const EntityRelationsGraph = (props: EntityRelationsGraphProps) => { renderLabel, curve, showArrowHeads, - onPostTransformation, } = props; const theme = useTheme(); @@ -142,7 +139,6 @@ export const EntityRelationsGraph = (props: EntityRelationsGraphProps) => { entityFilter, onNodeClick, relationPairs, - onPostTransformation, }); useEffect(() => { diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityRelationNodesAndEdges.ts b/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityRelationNodesAndEdges.ts index 2aa301fef9..7a6f8361e5 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityRelationNodesAndEdges.ts +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/useEntityRelationNodesAndEdges.ts @@ -24,8 +24,6 @@ import { buildGraph } from '../../lib/graph'; import { BuiltInTransformations, builtInTransformations, - cloneTransformationContext, - GraphTransformationDebugger, GraphTransformer, TransformationContext, } from '../../lib/graph-transformations'; @@ -43,7 +41,6 @@ export function useEntityRelationNodesAndEdges({ entityFilter, onNodeClick, relationPairs: incomingRelationPairs, - onPostTransformation, }: { rootEntityRefs: string[]; maxDepth?: number; @@ -54,7 +51,6 @@ export function useEntityRelationNodesAndEdges({ entityFilter?: (entity: Entity) => boolean; onNodeClick?: (value: EntityNode, event: MouseEvent) => void; relationPairs?: RelationPairs; - onPostTransformation?: GraphTransformationDebugger; }): { loading: boolean; nodes?: EntityNode[]; @@ -129,20 +125,6 @@ export function useEntityRelationNodesAndEdges({ maxDepth, }; - const debugTransformation = ( - transformation: BuiltInTransformations | GraphTransformer | undefined, - ) => { - onPostTransformation?.( - typeof transformation === 'function' - ? transformation.name - : transformation, - transformationContext, - cloneTransformationContext(transformationContext), - ); - }; - - debugTransformation(undefined); - const runTransformation = ( transformation: BuiltInTransformations | GraphTransformer, ) => { @@ -151,8 +133,6 @@ export function useEntityRelationNodesAndEdges({ } else { builtInTransformations[transformation](transformationContext); } - - debugTransformation(transformation); }; runTransformation('reduce-edges'); diff --git a/plugins/catalog-graph/src/index.ts b/plugins/catalog-graph/src/index.ts index d020e96989..95ac5048cb 100644 --- a/plugins/catalog-graph/src/index.ts +++ b/plugins/catalog-graph/src/index.ts @@ -35,7 +35,4 @@ export type { EntityNode, } from './lib/types'; export { Direction } from './lib/types'; -export type { - TransformationContext, - GraphTransformationDebugger, -} from './lib/graph-transformations'; +export type { TransformationContext } from './lib/graph-transformations'; diff --git a/plugins/catalog-graph/src/lib/graph-transformations/index.ts b/plugins/catalog-graph/src/lib/graph-transformations/index.ts index 3ed4cdba21..764a20a8d2 100644 --- a/plugins/catalog-graph/src/lib/graph-transformations/index.ts +++ b/plugins/catalog-graph/src/lib/graph-transformations/index.ts @@ -14,12 +14,7 @@ * limitations under the License. */ -export type { - GraphTransformer, - TransformationContext, - GraphTransformationDebugger, -} from './types'; -export { cloneTransformationContext } from './types'; +export type { GraphTransformer, TransformationContext } from './types'; import { reduceEdges } from './reduce-edges'; import { setDistances } from './set-distance'; diff --git a/plugins/catalog-graph/src/lib/graph-transformations/types.ts b/plugins/catalog-graph/src/lib/graph-transformations/types.ts index 9e498ba027..dc13057a04 100644 --- a/plugins/catalog-graph/src/lib/graph-transformations/types.ts +++ b/plugins/catalog-graph/src/lib/graph-transformations/types.ts @@ -45,38 +45,3 @@ export interface TransformationContext { * @public */ export type GraphTransformer = (context: TransformationContext) => void; - -/** - * A function that debugs a graph transformation. - * It is given the three arguments: - * * The transformation that was just applied (or undefined before the first - * transformation). If the transformation is a function, its `.name` property - * will be used. - * * The current state (context) of the graph, which _can_ be mutated - * * A cloned copy of the context, useful for logging (as transformations are - * made in place, the original context is modified and the logs will be - * confusing) - * - * @public - */ -export type GraphTransformationDebugger = ( - transformation: string | undefined, - transformationContext: TransformationContext, - clonedContext: TransformationContext, -) => void; - -/** @internal */ -export function cloneTransformationContext( - transformationContext: TransformationContext, -): TransformationContext { - const clonesContext = JSON.parse( - JSON.stringify(transformationContext), - ) as TransformationContext; - clonesContext.edges = clonesContext.edges.sort((a, b) => { - return a.from.localeCompare(b.from) || a.to.localeCompare(b.to); - }); - - clonesContext.nodeDistances = new Map(transformationContext.nodeDistances); - - return clonesContext; -}