Removed the onPostTransformation hook and all debug-related logic
Signed-off-by: Gustaf Räntilä <g.rantila@gmail.com>
This commit is contained in:
@@ -181,16 +181,8 @@ export type EntityRelationsGraphProps = {
|
||||
renderLabel?: DependencyGraphTypes.RenderLabelFunction<EntityEdge>;
|
||||
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][];
|
||||
|
||||
|
||||
@@ -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<EntityEdge>;
|
||||
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(() => {
|
||||
|
||||
-20
@@ -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<unknown>) => 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');
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user