diff --git a/plugins/catalog-graph/api-report.md b/plugins/catalog-graph/api-report.md index eac7351c33..e477fb13d9 100644 --- a/plugins/catalog-graph/api-report.md +++ b/plugins/catalog-graph/api-report.md @@ -30,7 +30,7 @@ export const CatalogGraphPage: (props: { mergeRelations?: boolean | undefined; direction?: Direction | undefined; showFilters?: boolean | undefined; - curve?: Curve | undefined; + curve?: 'curveStepBefore' | 'curveMonotoneX' | undefined; } | undefined; }) => JSX.Element; @@ -55,9 +55,6 @@ export const catalogGraphPlugin: BackstagePlugin< // @public export const catalogGraphRouteRef: RouteRef; -// @public -export type Curve = 'curveStepBefore' | 'curveMonotoneX'; - // @public export enum Direction { BOTTOM_TOP = 'BT', @@ -123,7 +120,7 @@ export const EntityRelationsGraph: (props: { renderLabel?: | DependencyGraphTypes.RenderLabelFunction | undefined; - curve?: Curve | undefined; + curve?: 'curveStepBefore' | 'curveMonotoneX' | undefined; }) => JSX.Element; // @public diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx index 38fcdad918..a6a6c2a711 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CatalogGraphPage.tsx @@ -35,7 +35,6 @@ import React, { MouseEvent, useCallback } from 'react'; import { useNavigate } from 'react-router'; import { ALL_RELATION_PAIRS, - Curve, Direction, EntityNode, EntityRelationsGraph, @@ -112,7 +111,7 @@ export const CatalogGraphPage = (props: { mergeRelations?: boolean; direction?: Direction; showFilters?: boolean; - curve?: Curve; + curve?: 'curveStepBefore' | 'curveMonotoneX'; }; }) => { const { relationPairs = ALL_RELATION_PAIRS, initialState } = props; diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx b/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx index b508d48172..6cda334cf1 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/CurveFilter.tsx @@ -16,8 +16,8 @@ import { Select } from '@backstage/core-components'; import { Box } from '@material-ui/core'; import React, { useCallback } from 'react'; -import { Curve } from '../EntityRelationsGraph'; +type Curve = 'curveStepBefore' | 'curveMonotoneX'; const CURVE_DISPLAY_NAMES: Record = { curveMonotoneX: 'Monotone X', curveStepBefore: 'Step Before', @@ -25,10 +25,10 @@ const CURVE_DISPLAY_NAMES: Record = { export type Props = { value: Curve; - onChange: (value: Curve) => void; + onChange: (value: 'curveStepBefore' | 'curveMonotoneX') => void; }; -const curves: Curve[] = ['curveMonotoneX', 'curveStepBefore']; +const curves: Array = ['curveMonotoneX', 'curveStepBefore']; export const CurveFilter = ({ value, onChange }: Props) => { const handleChange = useCallback(v => onChange(v as Curve), [onChange]); diff --git a/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.ts b/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.ts index 9126f5aef5..43da53c44a 100644 --- a/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.ts +++ b/plugins/catalog-graph/src/components/CatalogGraphPage/useCatalogGraphPage.ts @@ -29,7 +29,7 @@ import { } from 'react'; import { useLocation } from 'react-router'; import usePrevious from 'react-use/lib/usePrevious'; -import { Direction, Curve } from '../EntityRelationsGraph'; +import { Direction } from '../EntityRelationsGraph'; export type CatalogGraphPageValue = { rootEntityNames: CompoundEntityRef[]; @@ -46,8 +46,10 @@ export type CatalogGraphPageValue = { setMergeRelations: Dispatch>; direction: Direction; setDirection: Dispatch>; - curve: Curve; - setCurve: Dispatch>; + curve: 'curveStepBefore' | 'curveMonotoneX'; + setCurve: Dispatch< + React.SetStateAction<'curveStepBefore' | 'curveMonotoneX'> + >; showFilters: boolean; toggleShowFilters: DispatchWithoutAction; }; @@ -64,7 +66,7 @@ export function useCatalogGraphPage({ mergeRelations?: boolean; direction?: Direction; showFilters?: boolean; - curve?: Curve; + curve?: 'curveStepBefore' | 'curveMonotoneX'; }; }): CatalogGraphPageValue { const location = useLocation(); @@ -80,7 +82,7 @@ export function useCatalogGraphPage({ mergeRelations?: string[] | string; direction?: string[] | Direction; showFilters?: string[] | string; - curve?: string[] | Curve; + curve?: string[] | 'curveStepBefore' | 'curveMonotoneX'; }, [location.search], ); @@ -126,7 +128,7 @@ export function useCatalogGraphPage({ ? query.direction : initialState?.direction ?? Direction.LEFT_RIGHT, ); - const [curve, setCurve] = useState(() => + const [curve, setCurve] = useState<'curveStepBefore' | 'curveMonotoneX'>(() => typeof query.curve === 'string' ? query.curve : initialState?.curve ?? 'curveMonotoneX', diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx index c6027e3e12..c0e2f610c1 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/EntityRelationsGraph.tsx @@ -29,7 +29,7 @@ import React, { MouseEvent, useEffect, useMemo } from 'react'; import { CustomLabel } from './CustomLabel'; import { CustomNode } from './CustomNode'; import { ALL_RELATION_PAIRS, RelationPairs } from './relations'; -import { Curve, Direction, EntityEdge, EntityNode } from './types'; +import { Direction, EntityEdge, EntityNode } from './types'; import { useEntityRelationNodesAndEdges } from './useEntityRelationNodesAndEdges'; const useStyles = makeStyles(theme => ({ @@ -82,7 +82,7 @@ export const EntityRelationsGraph = (props: { zoom?: 'enabled' | 'disabled' | 'enable-on-click'; renderNode?: DependencyGraphTypes.RenderNodeFunction; renderLabel?: DependencyGraphTypes.RenderLabelFunction; - curve?: Curve; + curve?: 'curveStepBefore' | 'curveMonotoneX'; }) => { const { rootEntityNames, diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/index.ts b/plugins/catalog-graph/src/components/EntityRelationsGraph/index.ts index 72125cb595..b86c8f05ae 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/index.ts +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/index.ts @@ -22,5 +22,4 @@ export type { EntityEdge, EntityNodeData, EntityNode, - Curve, } from './types'; diff --git a/plugins/catalog-graph/src/components/EntityRelationsGraph/types.ts b/plugins/catalog-graph/src/components/EntityRelationsGraph/types.ts index 68f81e5577..caf6c8c501 100644 --- a/plugins/catalog-graph/src/components/EntityRelationsGraph/types.ts +++ b/plugins/catalog-graph/src/components/EntityRelationsGraph/types.ts @@ -108,13 +108,3 @@ export enum Direction { */ RIGHT_LEFT = 'RL', } - -/** - * Graph curve factory - * - * @public - * - * @see {@link @types/d3-shape/index.d.ts#curveMonotoneX} - * @see {@link @types/d3-shape/index.d.ts#curveStepBefore} - */ -export type Curve = 'curveStepBefore' | 'curveMonotoneX';