diff --git a/plugins/tech-radar/src/components/Radar/Radar.test.tsx b/plugins/tech-radar/src/components/Radar/Radar.test.tsx index 5260c298fa..b76eb20a16 100644 --- a/plugins/tech-radar/src/components/Radar/Radar.test.tsx +++ b/plugins/tech-radar/src/components/Radar/Radar.test.tsx @@ -18,10 +18,9 @@ import React from 'react'; import { renderInTestApp } from '@backstage/test-utils'; import GetBBoxPolyfill from '../../utils/polyfills/getBBox'; -import Radar from './Radar'; -import type { RadarProps } from './types'; +import Radar, { Props } from './Radar'; -const minProps: RadarProps = { +const minProps: Props = { width: 500, height: 200, quadrants: [{ id: 'languages', name: 'Languages' }], diff --git a/plugins/tech-radar/src/components/Radar/Radar.tsx b/plugins/tech-radar/src/components/Radar/Radar.tsx index a6dc045325..8ba5af9811 100644 --- a/plugins/tech-radar/src/components/Radar/Radar.tsx +++ b/plugins/tech-radar/src/components/Radar/Radar.tsx @@ -15,20 +15,27 @@ */ import React, { useMemo, useRef, useState } from 'react'; -import type { Entry } from '../../utils/types'; +import type { Entry, Quadrant, Ring } from '../../utils/types'; import RadarPlot from '../RadarPlot'; -import { RadarProps } from './types'; import { adjustEntries, adjustQuadrants, adjustRings } from './utils'; +export type Props = { + width: number; + height: number; + quadrants: Quadrant[]; + rings: Ring[]; + entries: Entry[]; + svgProps?: object; +}; + const Radar = ({ width, height, quadrants, rings, entries, - getRingColor, ...props -}: RadarProps): JSX.Element => { +}: Props): JSX.Element => { const radius = Math.min(width, height) / 2; // State @@ -59,7 +66,6 @@ const Radar = ({ return ( Color; -}; diff --git a/plugins/tech-radar/src/components/RadarComponent.tsx b/plugins/tech-radar/src/components/RadarComponent.tsx index bf8fdd85da..1f14e9d258 100644 --- a/plugins/tech-radar/src/components/RadarComponent.tsx +++ b/plugins/tech-radar/src/components/RadarComponent.tsx @@ -20,8 +20,7 @@ import React, { useEffect } from 'react'; import useAsync from 'react-use/lib/useAsync'; import { RadarEntry, techRadarApiRef, TechRadarLoaderResponse } from '../api'; import Radar from '../components/Radar'; -import { Entry, Ring } from '../utils/types'; -import { RadarProps } from './Radar/types'; +import { Entry } from '../utils/types'; const useTechRadarLoader = (id: string | undefined) => { const errorApi = useApi(errorApiRef); @@ -90,8 +89,6 @@ export interface TechRadarComponentProps { * Text to filter {@link RadarEntry} inside Tech Radar */ searchText?: string; - - getRingColor?: RadarProps['getRingColor']; } /** @@ -105,7 +102,6 @@ export interface TechRadarComponentProps { */ export function RadarComponent(props: TechRadarComponentProps) { const { loading, error, value: data } = useTechRadarLoader(props.id); - const { getRingColor = (ring: Ring) => ring.color } = props; const mapToEntries = ( loaderResponse: TechRadarLoaderResponse, @@ -140,7 +136,6 @@ export function RadarComponent(props: TechRadarComponentProps) { {!loading && !error && data && ( (theme => ({ @@ -49,7 +47,7 @@ const useStyles = makeStyles(theme => ({ // A component for the background grid of the radar, with axes, rings etc. It will render around the origin, i.e. // assume that (0, 0) is in the middle of the drawing. const RadarGrid = (props: Props) => { - const { radius, rings, getRingColor } = props; + const { radius, rings } = props; const classes = useStyles(props); const makeRingNode = (ringIndex: number, ringRadius?: number) => [ @@ -65,9 +63,7 @@ const RadarGrid = (props: Props) => { y={ringRadius !== undefined ? -ringRadius + 42 : undefined} textAnchor="middle" className={classes.text} - style={{ - fill: getRingColor ? getRingColor(rings[ringIndex]) : undefined, - }} + style={{ fill: rings[ringIndex].color }} > {rings[ringIndex].name} , diff --git a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx index 1db6c52517..38d3757ff8 100644 --- a/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx +++ b/plugins/tech-radar/src/components/RadarLegend/RadarLegend.tsx @@ -88,7 +88,6 @@ const RadarLegend = ({ entries, onEntryMouseEnter, onEntryMouseLeave, - getRingColor, ...props }: RadarLegendProps): JSX.Element => { const classes = useStyles(props); @@ -97,7 +96,6 @@ const RadarLegend = ({ {quadrants.map(quadrant => ( ; onEntryMouseEnter: RadarLegendProps['onEntryMouseEnter']; onEntryMouseLeave: RadarLegendProps['onEntryMouseLeave']; - getRingColor: RadarLegendProps['getRingColor']; }; export const RadarLegendQuadrant = ({ @@ -38,7 +37,6 @@ export const RadarLegendQuadrant = ({ classes, onEntryMouseEnter, onEntryMouseLeave, - getRingColor, }: RadarLegendQuadrantProps) => { return ( ; onEntryMouseEnter?: RadarLegendProps['onEntryMouseEnter']; onEntryMouseLeave?: RadarLegendProps['onEntryMouseEnter']; - getRingColor?: RadarLegendProps['getRingColor']; }; export const RadarLegendRing = ({ @@ -35,14 +34,10 @@ export const RadarLegendRing = ({ classes, onEntryMouseEnter, onEntryMouseLeave, - getRingColor, }: RadarLegendRingProps) => { return (
-

+

{ring.name}

{entries.length === 0 ? ( diff --git a/plugins/tech-radar/src/components/RadarLegend/types.ts b/plugins/tech-radar/src/components/RadarLegend/types.ts index 9974a6592b..cdac1bfe9d 100644 --- a/plugins/tech-radar/src/components/RadarLegend/types.ts +++ b/plugins/tech-radar/src/components/RadarLegend/types.ts @@ -15,7 +15,6 @@ */ import { Entry, Quadrant, Ring } from '../../utils/types'; -import { RadarProps } from '../Radar/types'; export type Segments = { [k: number]: { [k: number]: Entry[] }; @@ -27,6 +26,4 @@ export type RadarLegendProps = { entries: Entry[]; onEntryMouseEnter?: (entry: Entry) => void; onEntryMouseLeave?: (entry: Entry) => void; - - getRingColor?: RadarProps['getRingColor']; }; diff --git a/plugins/tech-radar/src/components/RadarPlot/RadarPlot.tsx b/plugins/tech-radar/src/components/RadarPlot/RadarPlot.tsx index a51d1dacd9..d9788be887 100644 --- a/plugins/tech-radar/src/components/RadarPlot/RadarPlot.tsx +++ b/plugins/tech-radar/src/components/RadarPlot/RadarPlot.tsx @@ -22,7 +22,6 @@ import RadarEntry from '../RadarEntry'; import RadarBubble from '../RadarBubble'; import RadarFooter from '../RadarFooter'; import RadarLegend from '../RadarLegend'; -import { RadarProps } from '../Radar/types'; export type Props = { width: number; @@ -34,8 +33,6 @@ export type Props = { activeEntry?: Entry; onEntryMouseEnter?: (entry: Entry) => void; onEntryMouseLeave?: (entry: Entry) => void; - - getRingColor?: RadarProps['getRingColor']; }; // A component that draws the radar circle. @@ -50,7 +47,6 @@ const RadarPlot = (props: Props): JSX.Element => { activeEntry, onEntryMouseEnter, onEntryMouseLeave, - getRingColor, } = props; return ( @@ -65,10 +61,9 @@ const RadarPlot = (props: Props): JSX.Element => { onEntryMouseLeave={ onEntryMouseLeave && (entry => onEntryMouseLeave(entry)) } - getRingColor={getRingColor} /> - + {entries.map(entry => (