@backstage/core-components 0.16.3 → 0.16.4-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -0
- package/dist/components/DependencyGraph/DependencyGraph.esm.js +1 -1
- package/dist/components/DependencyGraph/DependencyGraph.esm.js.map +1 -1
- package/dist/components/DependencyGraph/Edge.esm.js.map +1 -1
- package/dist/components/DependencyGraph/Node.esm.js.map +1 -1
- package/dist/components/LogViewer/RealLogViewer.esm.js +18 -6
- package/dist/components/LogViewer/RealLogViewer.esm.js.map +1 -1
- package/dist/components/StructuredMetadataTable/StructuredMetadataTable.esm.js +24 -4
- package/dist/components/StructuredMetadataTable/StructuredMetadataTable.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/layout/ErrorPage/StackDetails.esm.js +1 -1
- package/package.json +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @backstage/core-components
|
|
2
2
|
|
|
3
|
+
## 0.16.4-next.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 47c27c2: Upgrade `dagre` to `@dagrejs/dagre`
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/config@1.3.2
|
|
10
|
+
- @backstage/core-plugin-api@1.10.4-next.0
|
|
11
|
+
- @backstage/errors@1.2.7
|
|
12
|
+
- @backstage/theme@0.6.4-next.0
|
|
13
|
+
- @backstage/version-bridge@1.0.11-next.0
|
|
14
|
+
|
|
15
|
+
## 0.16.4-next.0
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 9c9f4ff: Added `nestedValuesAsYaml` option to `StructuredMetadataTable` to render data as yaml.
|
|
20
|
+
- 17088d2: Updating the `TaskLogStream` to take up all space in a running task, and also show the last line of the log by default
|
|
21
|
+
- 58ec9e7: Removed older versions of React packages as a preparatory step for upgrading to React 19. This commit does not introduce any functional changes, but removes dependencies on previous React versions, allowing for a cleaner upgrade path in subsequent commits.
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- @backstage/core-plugin-api@1.10.4-next.0
|
|
24
|
+
- @backstage/version-bridge@1.0.11-next.0
|
|
25
|
+
- @backstage/theme@0.6.4-next.0
|
|
26
|
+
- @backstage/config@1.3.2
|
|
27
|
+
- @backstage/errors@1.2.7
|
|
28
|
+
|
|
3
29
|
## 0.16.3
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
|
@@ -2,7 +2,7 @@ import React__default from 'react';
|
|
|
2
2
|
import * as d3Zoom from 'd3-zoom';
|
|
3
3
|
import * as d3Selection from 'd3-selection';
|
|
4
4
|
import useTheme from '@material-ui/core/styles/useTheme';
|
|
5
|
-
import dagre from 'dagre';
|
|
5
|
+
import dagre from '@dagrejs/dagre';
|
|
6
6
|
import debounce from 'lodash/debounce';
|
|
7
7
|
import { DependencyGraphTypes } from './types.esm.js';
|
|
8
8
|
import { Node } from './Node.esm.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyGraph.esm.js","sources":["../../../src/components/DependencyGraph/DependencyGraph.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport * as d3Zoom from 'd3-zoom';\nimport * as d3Selection from 'd3-selection';\nimport useTheme from '@material-ui/core/styles/useTheme';\nimport dagre from 'dagre';\nimport debounce from 'lodash/debounce';\nimport { DependencyGraphTypes as Types } from './types';\nimport { Node } from './Node';\nimport { Edge, GraphEdge } from './Edge';\nimport { ARROW_MARKER_ID } from './constants';\n\n/**\n * Properties of {@link DependencyGraph}\n *\n * @public\n * @remarks\n * `<NodeData>` and `<EdgeData>` are useful when rendering custom or edge labels\n */\nexport interface DependencyGraphProps<NodeData, EdgeData>\n extends React.SVGProps<SVGSVGElement> {\n /**\n * Edges of graph\n */\n edges: Types.DependencyEdge<EdgeData>[];\n /**\n * Nodes of Graph\n */\n nodes: Types.DependencyNode<NodeData>[];\n /**\n * Graph {@link DependencyGraphTypes.Direction | direction}\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Direction.TOP_BOTTOM`\n */\n direction?: Types.Direction;\n /**\n * Node {@link DependencyGraphTypes.Alignment | alignment}\n */\n align?: Types.Alignment;\n /**\n * Margin between nodes on each rank\n *\n * @remarks\n *\n * Default: 50\n */\n nodeMargin?: number;\n /**\n * Margin between edges\n *\n * @remarks\n *\n * Default: 10\n */\n edgeMargin?: number;\n /**\n * Margin between each rank\n *\n * @remarks\n *\n * Default: 50\n */\n rankMargin?: number;\n /**\n * Margin on left and right of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingX?: number;\n /**\n * Margin on top and bottom of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingY?: number;\n /**\n * Heuristic used to find set of edges that will make graph acyclic\n */\n acyclicer?: 'greedy';\n /**\n * {@link DependencyGraphTypes.Ranker | Algorithm} used to rank nodes\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Ranker.NETWORK_SIMPLEX`\n */\n ranker?: Types.Ranker;\n /**\n * {@link DependencyGraphTypes.LabelPosition | Position} of label in relation to edge\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelPosition?: Types.LabelPosition;\n /**\n * How much to move label away from edge\n *\n * @remarks\n *\n * Applies only when {@link DependencyGraphProps.labelPosition} is `DependencyGraphTypes.LabelPosition.LEFT` or\n * `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelOffset?: number;\n /**\n * Minimum number of ranks to keep between connected nodes\n */\n edgeRanks?: number;\n /**\n * Weight applied to edges in graph\n */\n edgeWeight?: number;\n /**\n * Custom node rendering component\n */\n renderNode?: Types.RenderNodeFunction<NodeData>;\n /**\n * Custom label rendering component\n */\n renderLabel?: Types.RenderLabelFunction<EdgeData>;\n /**\n * {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs | Defs} shared by rendered SVG to be used by\n * {@link DependencyGraphProps.renderNode} and/or {@link DependencyGraphProps.renderLabel}\n */\n defs?: JSX.Element | JSX.Element[];\n /**\n * Controls zoom behavior of graph\n *\n * @remarks\n *\n * Default: `enabled`\n */\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n /**\n * A factory for curve generators addressing both lines and areas.\n *\n * @remarks\n *\n * Default: 'curveMonotoneX'\n */\n curve?: 'curveStepBefore' | 'curveMonotoneX';\n /**\n * Controls if the arrow heads should be rendered or not.\n *\n * Default: false\n */\n showArrowHeads?: boolean;\n /**\n * Controls if the graph should be contained or grow\n *\n * @remarks\n *\n * Default: 'grow'\n */\n fit?: 'grow' | 'contain';\n}\n\nconst WORKSPACE_ID = 'workspace';\n\n/**\n * Graph component used to visualize relations between entities\n *\n * @public\n */\nexport function DependencyGraph<NodeData, EdgeData>(\n props: DependencyGraphProps<NodeData, EdgeData>,\n) {\n const {\n edges,\n nodes,\n renderNode,\n direction = Types.Direction.TOP_BOTTOM,\n align,\n nodeMargin = 50,\n edgeMargin = 10,\n rankMargin = 50,\n paddingX = 0,\n paddingY = 0,\n acyclicer,\n ranker = Types.Ranker.NETWORK_SIMPLEX,\n labelPosition = Types.LabelPosition.RIGHT,\n labelOffset = 10,\n edgeRanks = 1,\n edgeWeight = 1,\n renderLabel,\n defs,\n zoom = 'enabled',\n curve = 'curveMonotoneX',\n showArrowHeads = false,\n fit = 'grow',\n ...svgProps\n } = props;\n const theme = useTheme();\n const [containerWidth, setContainerWidth] = React.useState<number>(100);\n const [containerHeight, setContainerHeight] = React.useState<number>(100);\n\n const graph = React.useRef<\n dagre.graphlib.Graph<Types.DependencyNode<NodeData>>\n >(new dagre.graphlib.Graph());\n const [graphWidth, setGraphWidth] = React.useState<number>(\n graph.current.graph()?.width || 0,\n );\n const [graphHeight, setGraphHeight] = React.useState<number>(\n graph.current.graph()?.height || 0,\n );\n const [graphNodes, setGraphNodes] = React.useState<string[]>([]);\n const [graphEdges, setGraphEdges] = React.useState<dagre.Edge[]>([]);\n\n const maxWidth = Math.max(graphWidth, containerWidth);\n const maxHeight = Math.max(graphHeight, containerHeight);\n const minHeight = Math.min(graphHeight, containerHeight);\n\n const scalableHeight = fit === 'grow' ? maxHeight : minHeight;\n\n const containerRef = React.useMemo(\n () =>\n debounce((node: SVGSVGElement) => {\n if (!node) {\n return;\n }\n // Set up zooming + panning\n const container = d3Selection.select<SVGSVGElement, null>(node);\n const workspace = d3Selection.select(node.getElementById(WORKSPACE_ID));\n\n function enableZoom() {\n container.call(\n d3Zoom\n .zoom<SVGSVGElement, null>()\n .scaleExtent([1, Infinity])\n .on('zoom', event => {\n event.transform.x = Math.min(\n 0,\n Math.max(\n event.transform.x,\n maxWidth - maxWidth * event.transform.k,\n ),\n );\n event.transform.y = Math.min(\n 0,\n Math.max(\n event.transform.y,\n maxHeight - maxHeight * event.transform.k,\n ),\n );\n workspace.attr('transform', event.transform);\n }),\n );\n }\n\n if (zoom === 'enabled') {\n enableZoom();\n } else if (zoom === 'enable-on-click') {\n container.on('click', () => enableZoom());\n }\n\n const { width: newContainerWidth, height: newContainerHeight } =\n node.getBoundingClientRect();\n if (containerWidth !== newContainerWidth) {\n setContainerWidth(newContainerWidth);\n }\n if (containerHeight !== newContainerHeight) {\n setContainerHeight(newContainerHeight);\n }\n }, 100),\n [containerHeight, containerWidth, maxWidth, maxHeight, zoom],\n );\n\n const setNodesAndEdges = React.useCallback(() => {\n // Cleaning up lingering nodes and edges\n const currentGraphNodes = graph.current.nodes();\n const currentGraphEdges = graph.current.edges();\n\n currentGraphNodes.forEach(nodeId => {\n const remainingNode = nodes.some(node => node.id === nodeId);\n if (!remainingNode) {\n graph.current.removeNode(nodeId);\n }\n });\n\n currentGraphEdges.forEach(e => {\n const remainingEdge = edges.some(\n edge => edge.from === e.v && edge.to === e.w,\n );\n if (!remainingEdge) {\n graph.current.removeEdge(e.v, e.w);\n }\n });\n\n // Adding/updating nodes and edges\n nodes.forEach(node => {\n const existingNode = graph.current\n .nodes()\n .find(nodeId => node.id === nodeId);\n\n if (existingNode && graph.current.node(existingNode)) {\n const { width, height, x, y } = graph.current.node(existingNode);\n graph.current.setNode(existingNode, { ...node, width, height, x, y });\n } else {\n graph.current.setNode(node.id, { ...node, width: 0, height: 0 });\n }\n });\n\n edges.forEach(e => {\n graph.current.setEdge(e.from, e.to, {\n ...e,\n label: e.label,\n width: 0,\n height: 0,\n labelpos: labelPosition,\n labeloffset: labelOffset,\n weight: edgeWeight,\n minlen: edgeRanks,\n });\n });\n }, [edges, nodes, labelPosition, labelOffset, edgeWeight, edgeRanks]);\n\n const updateGraph = React.useMemo(\n () =>\n debounce(\n () => {\n dagre.layout(graph.current);\n const { height, width } = graph.current.graph();\n const newHeight = Math.max(0, height || 0);\n const newWidth = Math.max(0, width || 0);\n setGraphWidth(newWidth);\n setGraphHeight(newHeight);\n\n setGraphNodes(graph.current.nodes());\n setGraphEdges(graph.current.edges());\n },\n 250,\n { leading: true },\n ),\n [],\n );\n\n React.useEffect(() => {\n graph.current.setGraph({\n rankdir: direction,\n align,\n nodesep: nodeMargin,\n edgesep: edgeMargin,\n ranksep: rankMargin,\n marginx: paddingX,\n marginy: paddingY,\n acyclicer,\n ranker,\n });\n\n setNodesAndEdges();\n updateGraph();\n\n return updateGraph.cancel;\n }, [\n acyclicer,\n align,\n direction,\n edgeMargin,\n paddingX,\n paddingY,\n nodeMargin,\n rankMargin,\n ranker,\n setNodesAndEdges,\n updateGraph,\n ]);\n\n function setNode(id: string, node: Types.DependencyNode<NodeData>) {\n graph.current.setNode(id, node);\n updateGraph();\n return graph.current;\n }\n\n function setEdge(id: dagre.Edge, edge: Types.DependencyEdge<EdgeData>) {\n graph.current.setEdge(id, edge);\n updateGraph();\n return graph.current;\n }\n\n return (\n <svg\n ref={containerRef}\n {...svgProps}\n width=\"100%\"\n height={scalableHeight}\n viewBox={`0 0 ${maxWidth} ${maxHeight}`}\n >\n <defs>\n <marker\n id={ARROW_MARKER_ID}\n viewBox=\"0 0 24 24\"\n markerWidth=\"14\"\n markerHeight=\"14\"\n refX=\"16\"\n refY=\"12\"\n orient=\"auto\"\n markerUnits=\"strokeWidth\"\n >\n <path\n fill={theme.palette.textSubtle}\n d=\"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z\"\n />\n </marker>\n {defs}\n </defs>\n <g id={WORKSPACE_ID}>\n <svg\n width={graphWidth}\n height={graphHeight}\n y={maxHeight / 2 - graphHeight / 2}\n x={maxWidth / 2 - graphWidth / 2}\n viewBox={`0 0 ${graphWidth} ${graphHeight}`}\n >\n {graphEdges.map(e => {\n const edge = graph.current.edge(e) as GraphEdge<EdgeData>;\n if (!edge) return null;\n return (\n <Edge\n key={`${e.v}-${e.w}`}\n id={e}\n setEdge={setEdge}\n render={renderLabel}\n edge={edge}\n curve={curve}\n showArrowHeads={showArrowHeads}\n />\n );\n })}\n {graphNodes.map((id: string) => {\n const node = graph.current.node(id);\n if (!node) return null;\n return (\n <Node\n key={id}\n setNode={setNode}\n render={renderNode}\n node={node}\n />\n );\n })}\n </svg>\n </g>\n </svg>\n );\n}\n"],"names":["Types","React"],"mappings":";;;;;;;;;;;AAkLA,MAAM,YAAe,GAAA,WAAA;AAOd,SAAS,gBACd,KACA,EAAA;AACA,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA,GAAYA,qBAAM,SAAU,CAAA,UAAA;AAAA,IAC5B,KAAA;AAAA,IACA,UAAa,GAAA,EAAA;AAAA,IACb,UAAa,GAAA,EAAA;AAAA,IACb,UAAa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CAAC,EAAe,KAAA;AAC9B,QAAA,MAAM,IAAO,GAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,EAAE,CAAA;AAClC,QAAI,IAAA,CAAC,MAAa,OAAA,IAAA;AAClB,QACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,GAAK,EAAA,EAAA;AAAA,YACL,OAAA;AAAA,YACA,MAAQ,EAAA,UAAA;AAAA,YACR;AAAA;AAAA,SACF;AAAA,OAEH;AAAA,KAEL;AAAA,GACF;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"DependencyGraph.esm.js","sources":["../../../src/components/DependencyGraph/DependencyGraph.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport * as d3Zoom from 'd3-zoom';\nimport * as d3Selection from 'd3-selection';\nimport useTheme from '@material-ui/core/styles/useTheme';\nimport dagre from '@dagrejs/dagre';\nimport debounce from 'lodash/debounce';\nimport { DependencyGraphTypes as Types } from './types';\nimport { Node } from './Node';\nimport { Edge, GraphEdge } from './Edge';\nimport { ARROW_MARKER_ID } from './constants';\n\n/**\n * Properties of {@link DependencyGraph}\n *\n * @public\n * @remarks\n * `<NodeData>` and `<EdgeData>` are useful when rendering custom or edge labels\n */\nexport interface DependencyGraphProps<NodeData, EdgeData>\n extends React.SVGProps<SVGSVGElement> {\n /**\n * Edges of graph\n */\n edges: Types.DependencyEdge<EdgeData>[];\n /**\n * Nodes of Graph\n */\n nodes: Types.DependencyNode<NodeData>[];\n /**\n * Graph {@link DependencyGraphTypes.Direction | direction}\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Direction.TOP_BOTTOM`\n */\n direction?: Types.Direction;\n /**\n * Node {@link DependencyGraphTypes.Alignment | alignment}\n */\n align?: Types.Alignment;\n /**\n * Margin between nodes on each rank\n *\n * @remarks\n *\n * Default: 50\n */\n nodeMargin?: number;\n /**\n * Margin between edges\n *\n * @remarks\n *\n * Default: 10\n */\n edgeMargin?: number;\n /**\n * Margin between each rank\n *\n * @remarks\n *\n * Default: 50\n */\n rankMargin?: number;\n /**\n * Margin on left and right of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingX?: number;\n /**\n * Margin on top and bottom of whole graph\n *\n * @remarks\n *\n * Default: 0\n */\n paddingY?: number;\n /**\n * Heuristic used to find set of edges that will make graph acyclic\n */\n acyclicer?: 'greedy';\n /**\n * {@link DependencyGraphTypes.Ranker | Algorithm} used to rank nodes\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.Ranker.NETWORK_SIMPLEX`\n */\n ranker?: Types.Ranker;\n /**\n * {@link DependencyGraphTypes.LabelPosition | Position} of label in relation to edge\n *\n * @remarks\n *\n * Default: `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelPosition?: Types.LabelPosition;\n /**\n * How much to move label away from edge\n *\n * @remarks\n *\n * Applies only when {@link DependencyGraphProps.labelPosition} is `DependencyGraphTypes.LabelPosition.LEFT` or\n * `DependencyGraphTypes.LabelPosition.RIGHT`\n */\n labelOffset?: number;\n /**\n * Minimum number of ranks to keep between connected nodes\n */\n edgeRanks?: number;\n /**\n * Weight applied to edges in graph\n */\n edgeWeight?: number;\n /**\n * Custom node rendering component\n */\n renderNode?: Types.RenderNodeFunction<NodeData>;\n /**\n * Custom label rendering component\n */\n renderLabel?: Types.RenderLabelFunction<EdgeData>;\n /**\n * {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs | Defs} shared by rendered SVG to be used by\n * {@link DependencyGraphProps.renderNode} and/or {@link DependencyGraphProps.renderLabel}\n */\n defs?: JSX.Element | JSX.Element[];\n /**\n * Controls zoom behavior of graph\n *\n * @remarks\n *\n * Default: `enabled`\n */\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n /**\n * A factory for curve generators addressing both lines and areas.\n *\n * @remarks\n *\n * Default: 'curveMonotoneX'\n */\n curve?: 'curveStepBefore' | 'curveMonotoneX';\n /**\n * Controls if the arrow heads should be rendered or not.\n *\n * Default: false\n */\n showArrowHeads?: boolean;\n /**\n * Controls if the graph should be contained or grow\n *\n * @remarks\n *\n * Default: 'grow'\n */\n fit?: 'grow' | 'contain';\n}\n\nconst WORKSPACE_ID = 'workspace';\n\n/**\n * Graph component used to visualize relations between entities\n *\n * @public\n */\nexport function DependencyGraph<NodeData, EdgeData>(\n props: DependencyGraphProps<NodeData, EdgeData>,\n) {\n const {\n edges,\n nodes,\n renderNode,\n direction = Types.Direction.TOP_BOTTOM,\n align,\n nodeMargin = 50,\n edgeMargin = 10,\n rankMargin = 50,\n paddingX = 0,\n paddingY = 0,\n acyclicer,\n ranker = Types.Ranker.NETWORK_SIMPLEX,\n labelPosition = Types.LabelPosition.RIGHT,\n labelOffset = 10,\n edgeRanks = 1,\n edgeWeight = 1,\n renderLabel,\n defs,\n zoom = 'enabled',\n curve = 'curveMonotoneX',\n showArrowHeads = false,\n fit = 'grow',\n ...svgProps\n } = props;\n const theme = useTheme();\n const [containerWidth, setContainerWidth] = React.useState<number>(100);\n const [containerHeight, setContainerHeight] = React.useState<number>(100);\n\n const graph = React.useRef<\n dagre.graphlib.Graph<Types.DependencyNode<NodeData>>\n >(new dagre.graphlib.Graph());\n const [graphWidth, setGraphWidth] = React.useState<number>(\n graph.current.graph()?.width || 0,\n );\n const [graphHeight, setGraphHeight] = React.useState<number>(\n graph.current.graph()?.height || 0,\n );\n const [graphNodes, setGraphNodes] = React.useState<string[]>([]);\n const [graphEdges, setGraphEdges] = React.useState<dagre.Edge[]>([]);\n\n const maxWidth = Math.max(graphWidth, containerWidth);\n const maxHeight = Math.max(graphHeight, containerHeight);\n const minHeight = Math.min(graphHeight, containerHeight);\n\n const scalableHeight = fit === 'grow' ? maxHeight : minHeight;\n\n const containerRef = React.useMemo(\n () =>\n debounce((node: SVGSVGElement) => {\n if (!node) {\n return;\n }\n // Set up zooming + panning\n const container = d3Selection.select<SVGSVGElement, null>(node);\n const workspace = d3Selection.select(node.getElementById(WORKSPACE_ID));\n\n function enableZoom() {\n container.call(\n d3Zoom\n .zoom<SVGSVGElement, null>()\n .scaleExtent([1, Infinity])\n .on('zoom', event => {\n event.transform.x = Math.min(\n 0,\n Math.max(\n event.transform.x,\n maxWidth - maxWidth * event.transform.k,\n ),\n );\n event.transform.y = Math.min(\n 0,\n Math.max(\n event.transform.y,\n maxHeight - maxHeight * event.transform.k,\n ),\n );\n workspace.attr('transform', event.transform);\n }),\n );\n }\n\n if (zoom === 'enabled') {\n enableZoom();\n } else if (zoom === 'enable-on-click') {\n container.on('click', () => enableZoom());\n }\n\n const { width: newContainerWidth, height: newContainerHeight } =\n node.getBoundingClientRect();\n if (containerWidth !== newContainerWidth) {\n setContainerWidth(newContainerWidth);\n }\n if (containerHeight !== newContainerHeight) {\n setContainerHeight(newContainerHeight);\n }\n }, 100),\n [containerHeight, containerWidth, maxWidth, maxHeight, zoom],\n );\n\n const setNodesAndEdges = React.useCallback(() => {\n // Cleaning up lingering nodes and edges\n const currentGraphNodes = graph.current.nodes();\n const currentGraphEdges = graph.current.edges();\n\n currentGraphNodes.forEach(nodeId => {\n const remainingNode = nodes.some(node => node.id === nodeId);\n if (!remainingNode) {\n graph.current.removeNode(nodeId);\n }\n });\n\n currentGraphEdges.forEach(e => {\n const remainingEdge = edges.some(\n edge => edge.from === e.v && edge.to === e.w,\n );\n if (!remainingEdge) {\n graph.current.removeEdge(e.v, e.w);\n }\n });\n\n // Adding/updating nodes and edges\n nodes.forEach(node => {\n const existingNode = graph.current\n .nodes()\n .find(nodeId => node.id === nodeId);\n\n if (existingNode && graph.current.node(existingNode)) {\n const { width, height, x, y } = graph.current.node(existingNode);\n graph.current.setNode(existingNode, { ...node, width, height, x, y });\n } else {\n graph.current.setNode(node.id, { ...node, width: 0, height: 0 });\n }\n });\n\n edges.forEach(e => {\n graph.current.setEdge(e.from, e.to, {\n ...e,\n label: e.label,\n width: 0,\n height: 0,\n labelpos: labelPosition,\n labeloffset: labelOffset,\n weight: edgeWeight,\n minlen: edgeRanks,\n });\n });\n }, [edges, nodes, labelPosition, labelOffset, edgeWeight, edgeRanks]);\n\n const updateGraph = React.useMemo(\n () =>\n debounce(\n () => {\n dagre.layout(graph.current);\n const { height, width } = graph.current.graph();\n const newHeight = Math.max(0, height || 0);\n const newWidth = Math.max(0, width || 0);\n setGraphWidth(newWidth);\n setGraphHeight(newHeight);\n\n setGraphNodes(graph.current.nodes());\n setGraphEdges(graph.current.edges());\n },\n 250,\n { leading: true },\n ),\n [],\n );\n\n React.useEffect(() => {\n graph.current.setGraph({\n rankdir: direction,\n align,\n nodesep: nodeMargin,\n edgesep: edgeMargin,\n ranksep: rankMargin,\n marginx: paddingX,\n marginy: paddingY,\n acyclicer,\n ranker,\n });\n\n setNodesAndEdges();\n updateGraph();\n\n return updateGraph.cancel;\n }, [\n acyclicer,\n align,\n direction,\n edgeMargin,\n paddingX,\n paddingY,\n nodeMargin,\n rankMargin,\n ranker,\n setNodesAndEdges,\n updateGraph,\n ]);\n\n function setNode(id: string, node: Types.DependencyNode<NodeData>) {\n graph.current.setNode(id, node);\n updateGraph();\n return graph.current;\n }\n\n function setEdge(id: dagre.Edge, edge: Types.DependencyEdge<EdgeData>) {\n graph.current.setEdge(id, edge);\n updateGraph();\n return graph.current;\n }\n\n return (\n <svg\n ref={containerRef}\n {...svgProps}\n width=\"100%\"\n height={scalableHeight}\n viewBox={`0 0 ${maxWidth} ${maxHeight}`}\n >\n <defs>\n <marker\n id={ARROW_MARKER_ID}\n viewBox=\"0 0 24 24\"\n markerWidth=\"14\"\n markerHeight=\"14\"\n refX=\"16\"\n refY=\"12\"\n orient=\"auto\"\n markerUnits=\"strokeWidth\"\n >\n <path\n fill={theme.palette.textSubtle}\n d=\"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z\"\n />\n </marker>\n {defs}\n </defs>\n <g id={WORKSPACE_ID}>\n <svg\n width={graphWidth}\n height={graphHeight}\n y={maxHeight / 2 - graphHeight / 2}\n x={maxWidth / 2 - graphWidth / 2}\n viewBox={`0 0 ${graphWidth} ${graphHeight}`}\n >\n {graphEdges.map(e => {\n const edge = graph.current.edge(e) as GraphEdge<EdgeData>;\n if (!edge) return null;\n return (\n <Edge\n key={`${e.v}-${e.w}`}\n id={e}\n setEdge={setEdge}\n render={renderLabel}\n edge={edge}\n curve={curve}\n showArrowHeads={showArrowHeads}\n />\n );\n })}\n {graphNodes.map((id: string) => {\n const node = graph.current.node(id);\n if (!node) return null;\n return (\n <Node\n key={id}\n setNode={setNode}\n render={renderNode}\n node={node}\n />\n );\n })}\n </svg>\n </g>\n </svg>\n );\n}\n"],"names":["Types","React"],"mappings":";;;;;;;;;;;AAkLA,MAAM,YAAe,GAAA,WAAA;AAOd,SAAS,gBACd,KACA,EAAA;AACA,EAAM,MAAA;AAAA,IACJ,KAAA;AAAA,IACA,KAAA;AAAA,IACA,UAAA;AAAA,IACA,SAAA,GAAYA,qBAAM,SAAU,CAAA,UAAA;AAAA,IAC5B,KAAA;AAAA,IACA,UAAa,GAAA,EAAA;AAAA,IACb,UAAa,GAAA,EAAA;AAAA,IACb,UAAa,GAAA,EAAA;AAAA,IACb,QAAW,GAAA,CAAA;AAAA,IACX,QAAW,GAAA,CAAA;AAAA,IACX,SAAA;AAAA,IACA,MAAA,GAASA,qBAAM,MAAO,CAAA,eAAA;AAAA,IACtB,aAAA,GAAgBA,qBAAM,aAAc,CAAA,KAAA;AAAA,IACpC,WAAc,GAAA,EAAA;AAAA,IACd,SAAY,GAAA,CAAA;AAAA,IACZ,UAAa,GAAA,CAAA;AAA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AA;AAAA,YACR;AAAA;AAAA,SACF;AAAA,OAEH;AAAA,KAEL;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Edge.esm.js","sources":["../../../src/components/DependencyGraph/Edge.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport * as d3Shape from 'd3-shape';\nimport isFinite from 'lodash/isFinite';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\nimport { DependencyGraphTypes as Types } from './types';\nimport { ARROW_MARKER_ID, EDGE_TEST_ID, LABEL_TEST_ID } from './constants';\nimport { DefaultLabel } from './DefaultLabel';\nimport dagre from 'dagre';\n\n/* Based on: https://github.com/dagrejs/dagre/wiki#configuring-the-layout */\nexport type EdgeProperties = {\n label?: string;\n width?: number;\n height?: number;\n labeloffset?: number;\n labelpos?: Types.LabelPosition;\n minlen?: number;\n weight?: number;\n};\nexport type GraphEdge<T> = Types.DependencyEdge<T> &\n dagre.GraphEdge &\n EdgeProperties;\n\n/** @public */\nexport type DependencyGraphEdgeClassKey = 'path' | 'label';\n\nconst useStyles = makeStyles(\n theme => ({\n path: {\n strokeWidth: 1.3,\n stroke: theme.palette.textSubtle,\n fill: 'none',\n transition: `${theme.transitions.duration.shortest}ms`,\n },\n label: {\n transition: `${theme.transitions.duration.shortest}ms`,\n },\n }),\n { name: 'BackstageDependencyGraphEdge' },\n);\n\ntype EdgePoint = dagre.GraphEdge['points'][0];\n\n/** @public */\nexport type EdgeComponentProps<T = unknown> = {\n id: dagre.Edge;\n edge: GraphEdge<T>;\n render?: Types.RenderLabelFunction<T>;\n setEdge: (\n id: dagre.Edge,\n edge: Types.DependencyEdge<T>,\n ) => dagre.graphlib.Graph<{}>;\n curve: 'curveStepBefore' | 'curveMonotoneX';\n showArrowHeads?: boolean;\n};\n\nconst renderDefault = (props: Types.RenderLabelProps<unknown>) => (\n <DefaultLabel {...props} />\n);\n\nexport function Edge<EdgeData>({\n render = renderDefault,\n setEdge,\n id,\n edge,\n curve,\n showArrowHeads,\n}: EdgeComponentProps<EdgeData>) {\n const { x = 0, y = 0, width, height, points } = edge;\n const labelProps: Types.DependencyEdge<EdgeData> = edge;\n const classes = useStyles();\n\n const labelRef = React.useRef<SVGGElement>(null);\n\n React.useLayoutEffect(() => {\n // set the label width to the actual rendered width to properly layout graph\n if (labelRef.current) {\n let { height: renderedHeight, width: renderedWidth } =\n labelRef.current.getBBox();\n renderedHeight = Math.round(renderedHeight);\n renderedWidth = Math.round(renderedWidth);\n\n if (renderedHeight !== height || renderedWidth !== width) {\n setEdge(id, {\n ...edge,\n height: renderedHeight,\n width: renderedWidth,\n });\n }\n }\n }, [edge, height, width, setEdge, id]);\n\n let path: string = '';\n\n const createPath = React.useMemo(\n () =>\n d3Shape\n .line<EdgePoint>()\n .x(d => d.x)\n .y(d => d.y)\n .curve(d3Shape[curve]),\n [curve],\n );\n\n if (points) {\n const finitePoints = points.filter(\n (point: EdgePoint) => isFinite(point.x) && isFinite(point.y),\n );\n path = createPath(finitePoints) || '';\n }\n\n return (\n <>\n {path && (\n <path\n data-testid={EDGE_TEST_ID}\n className={classes.path}\n markerEnd={showArrowHeads ? `url(#${ARROW_MARKER_ID})` : undefined}\n d={path}\n />\n )}\n {labelProps.label ? (\n <g\n ref={labelRef}\n data-testid={LABEL_TEST_ID}\n className={classes.label}\n transform={`translate(${x},${y})`}\n >\n {render({ edge: labelProps })}\n </g>\n ) : null}\n </>\n );\n}\n"],"names":["React"],"mappings":";;;;;;;AA0CA,MAAM,SAAY,GAAA,U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AAA,aAAA;AAAA,MACb,WAAW,OAAQ,CAAA,KAAA;AAAA,MACnB,SAAW,EAAA,CAAA,UAAA,EAAa,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA;AAAA,KAAA;AAAA,IAE7B,MAAO,CAAA,EAAE,IAAM,EAAA,UAAA,EAAY;AAAA,MAE5B,IACN,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"Edge.esm.js","sources":["../../../src/components/DependencyGraph/Edge.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport * as d3Shape from 'd3-shape';\nimport isFinite from 'lodash/isFinite';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\nimport { DependencyGraphTypes as Types } from './types';\nimport { ARROW_MARKER_ID, EDGE_TEST_ID, LABEL_TEST_ID } from './constants';\nimport { DefaultLabel } from './DefaultLabel';\nimport dagre from '@dagrejs/dagre';\n\n/* Based on: https://github.com/dagrejs/dagre/wiki#configuring-the-layout */\nexport type EdgeProperties = {\n label?: string;\n width?: number;\n height?: number;\n labeloffset?: number;\n labelpos?: Types.LabelPosition;\n minlen?: number;\n weight?: number;\n};\nexport type GraphEdge<T> = Types.DependencyEdge<T> &\n dagre.GraphEdge &\n EdgeProperties;\n\n/** @public */\nexport type DependencyGraphEdgeClassKey = 'path' | 'label';\n\nconst useStyles = makeStyles(\n theme => ({\n path: {\n strokeWidth: 1.3,\n stroke: theme.palette.textSubtle,\n fill: 'none',\n transition: `${theme.transitions.duration.shortest}ms`,\n },\n label: {\n transition: `${theme.transitions.duration.shortest}ms`,\n },\n }),\n { name: 'BackstageDependencyGraphEdge' },\n);\n\ntype EdgePoint = dagre.GraphEdge['points'][0];\n\n/** @public */\nexport type EdgeComponentProps<T = unknown> = {\n id: dagre.Edge;\n edge: GraphEdge<T>;\n render?: Types.RenderLabelFunction<T>;\n setEdge: (\n id: dagre.Edge,\n edge: Types.DependencyEdge<T>,\n ) => dagre.graphlib.Graph<{}>;\n curve: 'curveStepBefore' | 'curveMonotoneX';\n showArrowHeads?: boolean;\n};\n\nconst renderDefault = (props: Types.RenderLabelProps<unknown>) => (\n <DefaultLabel {...props} />\n);\n\nexport function Edge<EdgeData>({\n render = renderDefault,\n setEdge,\n id,\n edge,\n curve,\n showArrowHeads,\n}: EdgeComponentProps<EdgeData>) {\n const { x = 0, y = 0, width, height, points } = edge;\n const labelProps: Types.DependencyEdge<EdgeData> = edge;\n const classes = useStyles();\n\n const labelRef = React.useRef<SVGGElement>(null);\n\n React.useLayoutEffect(() => {\n // set the label width to the actual rendered width to properly layout graph\n if (labelRef.current) {\n let { height: renderedHeight, width: renderedWidth } =\n labelRef.current.getBBox();\n renderedHeight = Math.round(renderedHeight);\n renderedWidth = Math.round(renderedWidth);\n\n if (renderedHeight !== height || renderedWidth !== width) {\n setEdge(id, {\n ...edge,\n height: renderedHeight,\n width: renderedWidth,\n });\n }\n }\n }, [edge, height, width, setEdge, id]);\n\n let path: string = '';\n\n const createPath = React.useMemo(\n () =>\n d3Shape\n .line<EdgePoint>()\n .x(d => d.x)\n .y(d => d.y)\n .curve(d3Shape[curve]),\n [curve],\n );\n\n if (points) {\n const finitePoints = points.filter(\n (point: EdgePoint) => isFinite(point.x) && isFinite(point.y),\n );\n path = createPath(finitePoints) || '';\n }\n\n return (\n <>\n {path && (\n <path\n data-testid={EDGE_TEST_ID}\n className={classes.path}\n markerEnd={showArrowHeads ? `url(#${ARROW_MARKER_ID})` : undefined}\n d={path}\n />\n )}\n {labelProps.label ? (\n <g\n ref={labelRef}\n data-testid={LABEL_TEST_ID}\n className={classes.label}\n transform={`translate(${x},${y})`}\n >\n {render({ edge: labelProps })}\n </g>\n ) : null}\n </>\n );\n}\n"],"names":["React"],"mappings":";;;;;;;AA0CA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,IAAM,EAAA;AAAA,MACJ,WAAa,EAAA,GAAA;AAAA,MACb,MAAA,EAAQ,MAAM,OAAQ,CAAA,UAAA;AAAA,MACtB,IAAM,EAAA,MAAA;AAAA,MACN,UAAY,EAAA,CAAA,EAAG,KAAM,CAAA,WAAA,CAAY,SAAS,QAAQ,CAAA,EAAA;AAAA,KACpD;AAAA,IACA,KAAO,EAAA;AAAA,MACL,UAAY,EAAA,CAAA,EAAG,KAAM,CAAA,WAAA,CAAY,SAAS,QAAQ,CAAA,EAAA;AAAA;AACpD,GACF,CAAA;AAAA,EACA,EAAE,MAAM,8BAA+B;AACzC,CAAA;AAiBA,MAAM,gBAAgB,CAAC,KAAA,qBACpBA,cAAA,CAAA,aAAA,CAAA,YAAA,EAAA,EAAc,GAAG,KAAO,EAAA,CAAA;AAGpB,SAAS,IAAe,CAAA;AAAA,EAC7B,MAAS,GAAA,aAAA;AAAA,EACT,OAAA;AAAA,EACA,EAAA;AAAA,EACA,IAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CAAiC,EAAA;AAC/B,EAAM,MAAA,EAAE,IAAI,CAAG,EAAA,CAAA,GAAI,GAAG,KAAO,EAAA,MAAA,EAAQ,QAAW,GAAA,IAAA;AAChD,EAAA,MAAM,UAA6C,GAAA,IAAA;AACnD,EAAA,MAAM,UAAU,SAAU,EAAA;AAE1B,EAAM,MAAA,QAAA,GAAWA,cAAM,CAAA,MAAA,CAAoB,IAAI,CAAA;AAE/C,EAAAA,cAAA,CAAM,gBAAgB,MAAM;AAE1B,IAAA,IAAI,SAAS,OAAS,EAAA;AACpB,MAAI,IAAA,EAAE,QAAQ,cAAgB,EAAA,KAAA,EAAO,eACnC,GAA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EAAA;AAAA;AAAA,GACL,EAED,WAAW,KACV,mBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,GAAK,EAAA,QAAA;AAAA,MACL,aAAa,EAAA,aAAA;AAAA,MACb,WAAW,OAAQ,CAAA,KAAA;AAAA,MACnB,SAAW,EAAA,CAAA,UAAA,EAAa,CAAC,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA;AAAA,KAAA;AAAA,IAE7B,MAAO,CAAA,EAAE,IAAM,EAAA,UAAA,EAAY;AAAA,MAE5B,IACN,CAAA;AAEJ;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Node.esm.js","sources":["../../../src/components/DependencyGraph/Node.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\nimport { DefaultNode } from './DefaultNode';\nimport { DependencyGraphTypes as Types } from './types';\nimport { NODE_TEST_ID } from './constants';\nimport dagre from 'dagre';\n\n/** @public */\nexport type DependencyGraphNodeClassKey = 'node';\n\nconst useStyles = makeStyles(\n theme => ({\n node: {\n transition: `${theme.transitions.duration.shortest}ms`,\n },\n }),\n { name: 'BackstageDependencyGraphNode' },\n);\n\nexport type GraphNode<T> = dagre.Node<Types.DependencyNode<T>>;\n\nexport type NodeComponentProps<T> = {\n node: GraphNode<T>;\n render?: Types.RenderNodeFunction<T>;\n setNode: dagre.graphlib.Graph['setNode'];\n};\n\nconst renderDefault = (props: Types.RenderNodeProps) => (\n <DefaultNode {...props} />\n);\n\nexport function Node<T>({\n render = renderDefault,\n setNode,\n node,\n}: NodeComponentProps<T>) {\n const { width, height, x = 0, y = 0 } = node;\n const nodeProps: Types.DependencyNode<T> = node;\n const classes = useStyles();\n const nodeRef = React.useRef<SVGGElement | null>(null);\n\n React.useLayoutEffect(() => {\n // set the node width to the actual rendered width to properly layout graph\n if (nodeRef.current) {\n let { height: renderedHeight, width: renderedWidth } =\n nodeRef.current.getBBox();\n renderedHeight = Math.round(renderedHeight);\n renderedWidth = Math.round(renderedWidth);\n\n if (renderedHeight !== height || renderedWidth !== width) {\n setNode(node.id, {\n ...node,\n height: renderedHeight,\n width: renderedWidth,\n });\n }\n }\n }, [node, width, height, setNode]);\n\n return (\n <g\n ref={nodeRef}\n data-testid={NODE_TEST_ID}\n className={classes.node}\n transform={`translate(${x - width / 2},${y - height / 2})`}\n >\n {render({ node: nodeProps })}\n </g>\n );\n}\n"],"names":["React"],"mappings":";;;;;AA0BA,MAAM,SAAY,GAAA,UAAA;AAAA,EAChB,CAAU,KAAA,MAAA;AAAA,IACR,IAAM,EAAA;AAAA,MACJ,UAAY,EAAA,CAAA,EAAG,KAAM,CAAA,WAAA,CAAY,SAAS,QAAQ,CAAA,EAAA;AAAA;AACpD,GACF,CAAA;AAAA,EACA,EAAE,MAAM,8BAA+B;AACzC,CAAA;AAUA,MAAM,gBAAgB,CAAC,KAAA,qBACpBA,cAAA,CAAA,aAAA,CAAA,WAAA,EAAA,EAAa,GAAG,KAAO,EAAA,CAAA;AAGnB,SAAS,IAAQ,CAAA;AAAA,EACtB,MAAS,GAAA,aAAA;AAAA,EACT,OAAA;AAAA,EACA;AACF,CAA0B,EAAA;AACxB,EAAA,MAAM,EAAE,KAAO,EAAA,MAAA,EAAQ,IAAI,CAAG,EAAA,CAAA,GAAI,GAAM,GAAA,IAAA;AACxC,EAAA,MAAM,SAAqC,GAAA,IAAA;AAC3C,EAAA,MAAM,UAAU,SAAU,EAAA;AAC1B,EAAM,MAAA,OAAA,GAAUA,cAAM,CAAA,MAAA,CAA2B,IAAI,CAAA;AAErD,EAAAA,cAAA,CAAM,gBAAgB,MAAM;AAE1B,IAAA,IAAI,QAAQ,OAAS,EAAA;AACnB,MAAI,IAAA,EAAE,QAAQ,cAAgB,EAAA,KAAA,EAAO,eACnC,GAAA,OAAA,CAAQ,QAAQ,OAAQ,EAAA;AAC1B,MAAiB,cAAA,GAAA,IAAA,CAAK,MAAM,cAAc,CAAA;AAC1C,MAAgB,aAAA,GAAA,IAAA,CAAK,MAAM,aAAa,CAAA;AAExC,MAAI,IAAA,cAAA,KAAmB,MAAU,IAAA,aAAA,KAAkB,KAAO,EAAA;AACxD,QAAA,OAAA,CAAQ,KAAK,EAAI,EAAA;AAAA,UACf,GAAG,IAAA;AAAA,UACH,MAAQ,EAAA,cAAA;AAAA,UACR,KAAO,EAAA;AAAA,SACR,CAAA;AAAA;AACH;AACF,KACC,CAAC,IAAA,EAAM,KAAO,EAAA,MAAA,EAAQ,OAAO,CAAC,CAAA;AAEjC,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,GAAK,EAAA,OAAA;AAAA,MACL,aAAa,EAAA,YAAA;AAAA,MACb,WAAW,OAAQ,CAAA,IAAA;AAAA,MACnB,SAAA,EAAW,aAAa,CAAI,GAAA,KAAA,GAAQ,CAAC,CAAI,CAAA,EAAA,CAAA,GAAI,SAAS,CAAC,CAAA,CAAA;AAAA,KAAA;AAAA,IAEtD,MAAO,CAAA,EAAE,IAAM,EAAA,SAAA,EAAW;AAAA,GAC7B;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"Node.esm.js","sources":["../../../src/components/DependencyGraph/Node.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\nimport { DefaultNode } from './DefaultNode';\nimport { DependencyGraphTypes as Types } from './types';\nimport { NODE_TEST_ID } from './constants';\nimport dagre from '@dagrejs/dagre';\n\n/** @public */\nexport type DependencyGraphNodeClassKey = 'node';\n\nconst useStyles = makeStyles(\n theme => ({\n node: {\n transition: `${theme.transitions.duration.shortest}ms`,\n },\n }),\n { name: 'BackstageDependencyGraphNode' },\n);\n\nexport type GraphNode<T> = dagre.Node<Types.DependencyNode<T>>;\n\nexport type NodeComponentProps<T> = {\n node: GraphNode<T>;\n render?: Types.RenderNodeFunction<T>;\n setNode: dagre.graphlib.Graph['setNode'];\n};\n\nconst renderDefault = (props: Types.RenderNodeProps) => (\n <DefaultNode {...props} />\n);\n\nexport function Node<T>({\n render = renderDefault,\n setNode,\n node,\n}: NodeComponentProps<T>) {\n const { width, height, x = 0, y = 0 } = node;\n const nodeProps: Types.DependencyNode<T> = node;\n const classes = useStyles();\n const nodeRef = React.useRef<SVGGElement | null>(null);\n\n React.useLayoutEffect(() => {\n // set the node width to the actual rendered width to properly layout graph\n if (nodeRef.current) {\n let { height: renderedHeight, width: renderedWidth } =\n nodeRef.current.getBBox();\n renderedHeight = Math.round(renderedHeight);\n renderedWidth = Math.round(renderedWidth);\n\n if (renderedHeight !== height || renderedWidth !== width) {\n setNode(node.id, {\n ...node,\n height: renderedHeight,\n width: renderedWidth,\n });\n }\n }\n }, [node, width, height, setNode]);\n\n return (\n <g\n ref={nodeRef}\n data-testid={NODE_TEST_ID}\n className={classes.node}\n transform={`translate(${x - width / 2},${y - height / 2})`}\n >\n {render({ node: nodeProps })}\n </g>\n );\n}\n"],"names":["React"],"mappings":";;;;;AA0BA,MAAM,SAAY,GAAA,UAA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CAAA;AAEjC,EACE,uBAAAA,cAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,GAAK,EAAA,OAAA;AAAA,MACL,aAAa,EAAA,YAAA;AAAA,MACb,WAAW,OAAQ,CAAA,IAAA;AAAA,MACnB,SAAA,EAAW,aAAa,CAAI,GAAA,KAAA,GAAQ,CAAC,CAAI,CAAA,EAAA,CAAA,GAAI,SAAS,CAAC,CAAA,CAAA;AAAA,KAAA;AAAA,IAEtD,MAAO,CAAA,EAAE,IAAM,EAAA,SAAA,EAAW;AAAA,GAC7B;AAEJ;;;;"}
|
|
@@ -2,7 +2,7 @@ import Box from '@material-ui/core/Box';
|
|
|
2
2
|
import IconButton from '@material-ui/core/IconButton';
|
|
3
3
|
import CopyIcon from '@material-ui/icons/FileCopy';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import React__default, {
|
|
5
|
+
import React__default, { useState, useMemo, useEffect } from 'react';
|
|
6
6
|
import { useLocation } from 'react-router-dom';
|
|
7
7
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
8
8
|
import { FixedSizeList } from 'react-window';
|
|
@@ -15,17 +15,27 @@ import { useLogViewerSelection } from './useLogViewerSelection.esm.js';
|
|
|
15
15
|
|
|
16
16
|
function RealLogViewer(props) {
|
|
17
17
|
const classes = useStyles({ classes: props.classes });
|
|
18
|
-
const
|
|
18
|
+
const [fixedListInstance, setFixedListInstance] = useState(null);
|
|
19
19
|
const processor = useMemo(() => new AnsiProcessor(), []);
|
|
20
20
|
const lines = processor.process(props.text);
|
|
21
21
|
const search = useLogViewerSearch(lines);
|
|
22
22
|
const selection = useLogViewerSelection(lines);
|
|
23
23
|
const location = useLocation();
|
|
24
24
|
useEffect(() => {
|
|
25
|
-
if (
|
|
26
|
-
|
|
25
|
+
if (fixedListInstance) {
|
|
26
|
+
fixedListInstance.scrollToItem(lines.length - 1, "end");
|
|
27
27
|
}
|
|
28
|
-
}, [
|
|
28
|
+
}, [fixedListInstance, lines]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!fixedListInstance) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (search.resultLine) {
|
|
34
|
+
fixedListInstance.scrollToItem(search.resultLine - 1, "center");
|
|
35
|
+
} else {
|
|
36
|
+
fixedListInstance.scrollToItem(lines.length - 1, "end");
|
|
37
|
+
}
|
|
38
|
+
}, [fixedListInstance, search.resultLine, lines]);
|
|
29
39
|
useEffect(() => {
|
|
30
40
|
if (location.hash) {
|
|
31
41
|
const line = parseInt(location.hash.replace(/\D/g, ""), 10);
|
|
@@ -38,7 +48,9 @@ function RealLogViewer(props) {
|
|
|
38
48
|
return /* @__PURE__ */ React__default.createElement(AutoSizer, null, ({ height, width }) => /* @__PURE__ */ React__default.createElement(Box, { style: { width, height }, className: classes.root }, /* @__PURE__ */ React__default.createElement(Box, { className: classes.header }, /* @__PURE__ */ React__default.createElement(LogViewerControls, { ...search })), /* @__PURE__ */ React__default.createElement(
|
|
39
49
|
FixedSizeList,
|
|
40
50
|
{
|
|
41
|
-
ref:
|
|
51
|
+
ref: (instance) => {
|
|
52
|
+
setFixedListInstance(instance);
|
|
53
|
+
},
|
|
42
54
|
className: classes.log,
|
|
43
55
|
height: (height || 480) - HEADER_SIZE,
|
|
44
56
|
width: width || 640,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RealLogViewer.esm.js","sources":["../../../src/components/LogViewer/RealLogViewer.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@material-ui/core/Box';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport classnames from 'classnames';\nimport React, { useEffect, useMemo,
|
|
1
|
+
{"version":3,"file":"RealLogViewer.esm.js","sources":["../../../src/components/LogViewer/RealLogViewer.tsx"],"sourcesContent":["/*\n * Copyright 2021 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Box from '@material-ui/core/Box';\nimport IconButton from '@material-ui/core/IconButton';\nimport CopyIcon from '@material-ui/icons/FileCopy';\nimport classnames from 'classnames';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { useLocation } from 'react-router-dom';\nimport AutoSizer from 'react-virtualized-auto-sizer';\nimport { FixedSizeList } from 'react-window';\n\nimport { AnsiLine, AnsiProcessor } from './AnsiProcessor';\nimport { LogLine } from './LogLine';\nimport { LogViewerControls } from './LogViewerControls';\nimport { HEADER_SIZE, useStyles } from './styles';\nimport { useLogViewerSearch } from './useLogViewerSearch';\nimport { useLogViewerSelection } from './useLogViewerSelection';\n\nexport interface RealLogViewerProps {\n text: string;\n classes?: { root?: string };\n}\n\nexport function RealLogViewer(props: RealLogViewerProps) {\n const classes = useStyles({ classes: props.classes });\n const [fixedListInstance, setFixedListInstance] = useState<FixedSizeList<\n AnsiLine[]\n > | null>(null);\n\n // The processor keeps state that optimizes appending to the text\n const processor = useMemo(() => new AnsiProcessor(), []);\n const lines = processor.process(props.text);\n\n const search = useLogViewerSearch(lines);\n const selection = useLogViewerSelection(lines);\n const location = useLocation();\n\n useEffect(() => {\n if (fixedListInstance) {\n fixedListInstance.scrollToItem(lines.length - 1, 'end');\n }\n }, [fixedListInstance, lines]);\n\n useEffect(() => {\n if (!fixedListInstance) {\n return;\n }\n if (search.resultLine) {\n fixedListInstance.scrollToItem(search.resultLine - 1, 'center');\n } else {\n fixedListInstance.scrollToItem(lines.length - 1, 'end');\n }\n }, [fixedListInstance, search.resultLine, lines]);\n\n useEffect(() => {\n if (location.hash) {\n // #line-6 -> 6\n const line = parseInt(location.hash.replace(/\\D/g, ''), 10);\n selection.setSelection(line, false);\n }\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n\n const handleSelectLine = (\n line: number,\n event: { shiftKey: boolean; preventDefault: () => void },\n ) => {\n selection.setSelection(line, event.shiftKey);\n };\n\n return (\n <AutoSizer>\n {({ height, width }: { height?: number; width?: number }) => (\n <Box style={{ width, height }} className={classes.root}>\n <Box className={classes.header}>\n <LogViewerControls {...search} />\n </Box>\n <FixedSizeList\n ref={(instance: FixedSizeList<AnsiLine[]>) => {\n setFixedListInstance(instance);\n }}\n className={classes.log}\n height={(height || 480) - HEADER_SIZE}\n width={width || 640}\n itemData={search.lines}\n itemSize={20}\n itemCount={search.lines.length}\n >\n {({ index, style, data }) => {\n const line = data[index];\n const { lineNumber } = line;\n return (\n <Box\n style={{ ...style }}\n className={classnames(classes.line, {\n [classes.lineSelected]: selection.isSelected(lineNumber),\n })}\n >\n {selection.shouldShowButton(lineNumber) && (\n <IconButton\n data-testid=\"copy-button\"\n size=\"small\"\n className={classes.lineCopyButton}\n onClick={() => selection.copySelection()}\n >\n <CopyIcon fontSize=\"inherit\" />\n </IconButton>\n )}\n <a\n role=\"row\"\n target=\"_self\"\n href={`#line-${lineNumber}`}\n className={classes.lineNumber}\n onClick={event => handleSelectLine(lineNumber, event)}\n onKeyPress={event => handleSelectLine(lineNumber, event)}\n >\n {lineNumber}\n </a>\n <LogLine\n line={line}\n classes={classes}\n searchText={search.searchText}\n highlightResultIndex={\n search.resultLine === lineNumber\n ? search.resultLineIndex\n : undefined\n }\n />\n </Box>\n );\n }}\n </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AAA,YACnB,oBACE,EAAA,MAAA,CAAO,UAAe,KAAA,UAAA,GAClB,OAAO,eACP,GAAA,KAAA;AAAA;AAAA;AAER,OACF;AAAA;AAEJ,GAEJ,CAEJ,CAAA;AAEJ;;;;"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React__default, { Fragment } from 'react';
|
|
2
|
-
import { createStyles, withStyles } from '@material-ui/core/styles';
|
|
3
2
|
import startCase from 'lodash/startCase';
|
|
4
3
|
import Typography from '@material-ui/core/Typography';
|
|
5
4
|
import { MetadataList, MetadataTable, MetadataTableItem, MetadataListItem } from './MetadataTable.esm.js';
|
|
5
|
+
import { CodeSnippet } from '../CodeSnippet/CodeSnippet.esm.js';
|
|
6
|
+
import jsyaml from 'js-yaml';
|
|
7
|
+
import { createStyles, withStyles } from '@material-ui/core/styles';
|
|
6
8
|
|
|
7
9
|
const listStyle = createStyles({
|
|
8
10
|
root: {
|
|
@@ -37,8 +39,25 @@ function toValue(value, options, nested) {
|
|
|
37
39
|
if (React__default.isValidElement(value)) {
|
|
38
40
|
return /* @__PURE__ */ React__default.createElement(Fragment, null, value);
|
|
39
41
|
}
|
|
40
|
-
if (value !== null && typeof value === "object"
|
|
41
|
-
|
|
42
|
+
if (value !== null && typeof value === "object") {
|
|
43
|
+
if (options.nestedValuesAsYaml) {
|
|
44
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
45
|
+
CodeSnippet,
|
|
46
|
+
{
|
|
47
|
+
language: "yaml",
|
|
48
|
+
text: jsyaml.dump(value),
|
|
49
|
+
customStyle: {
|
|
50
|
+
background: "transparent",
|
|
51
|
+
lineHeight: "1.4",
|
|
52
|
+
padding: "0",
|
|
53
|
+
margin: 0
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
if (!Array.isArray(value)) {
|
|
59
|
+
return renderMap(value, options, nested);
|
|
60
|
+
}
|
|
42
61
|
}
|
|
43
62
|
if (Array.isArray(value)) {
|
|
44
63
|
return renderList(value, options, nested);
|
|
@@ -60,9 +79,10 @@ function mapToItems(info, options) {
|
|
|
60
79
|
return Object.keys(info).map((key) => /* @__PURE__ */ React__default.createElement(TableItem, { key, title: key, value: info[key], options }));
|
|
61
80
|
}
|
|
62
81
|
function StructuredMetadataTable(props) {
|
|
63
|
-
const { metadata, dense = true, options
|
|
82
|
+
const { metadata, dense = true, options } = props;
|
|
64
83
|
const metadataItems = mapToItems(metadata, {
|
|
65
84
|
titleFormat: startCase,
|
|
85
|
+
nestedValuesAsYaml: options?.nestedValuesAsYaml ?? false,
|
|
66
86
|
...options
|
|
67
87
|
});
|
|
68
88
|
return /* @__PURE__ */ React__default.createElement(MetadataTable, { dense }, metadataItems);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StructuredMetadataTable.esm.js","sources":["../../../src/components/StructuredMetadataTable/StructuredMetadataTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment, ReactElement } from 'react';\nimport {\n
|
|
1
|
+
{"version":3,"file":"StructuredMetadataTable.esm.js","sources":["../../../src/components/StructuredMetadataTable/StructuredMetadataTable.tsx"],"sourcesContent":["/*\n * Copyright 2020 The Backstage Authors\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { Fragment, ReactElement } from 'react';\nimport startCase from 'lodash/startCase';\nimport Typography from '@material-ui/core/Typography';\n\nimport {\n MetadataList,\n MetadataListItem,\n MetadataTable,\n MetadataTableItem,\n} from './MetadataTable';\nimport { CodeSnippet } from '../CodeSnippet';\nimport jsyaml from 'js-yaml';\nimport {\n Theme,\n createStyles,\n WithStyles,\n withStyles,\n} from '@material-ui/core/styles';\n\nexport type StructuredMetadataTableListClassKey = 'root';\n\nconst listStyle = createStyles({\n root: {\n margin: '0 0',\n listStyleType: 'none',\n },\n});\n\nexport type StructuredMetadataTableNestedListClassKey = 'root';\nconst nestedListStyle = (theme: Theme) =>\n createStyles({\n root: {\n ...listStyle.root,\n paddingLeft: theme.spacing(1),\n },\n });\n\ninterface StyleProps extends WithStyles {\n children?: React.ReactNode;\n}\n// Sub Components\nconst StyledList = withStyles(listStyle, {\n name: 'BackstageStructuredMetadataTableList',\n})(({ classes, children }: StyleProps) => (\n <MetadataList classes={classes}>{children}</MetadataList>\n));\nconst StyledNestedList = withStyles(nestedListStyle, {\n name: 'BackstageStructuredMetadataTableNestedList',\n})(({ classes, children }: StyleProps) => (\n <MetadataList classes={classes}>{children}</MetadataList>\n));\n\nfunction renderList(list: Array<any>, options: Options, nested: boolean) {\n const values = list.map((item: any, index: number) => (\n <MetadataListItem key={index}>\n {toValue(item, options, nested)}\n </MetadataListItem>\n ));\n return nested ? (\n <StyledNestedList>{values}</StyledNestedList>\n ) : (\n <StyledList>{values}</StyledList>\n );\n}\n\nfunction renderMap(\n map: { [key: string]: any },\n options: Options,\n nested: boolean,\n) {\n const values = Object.keys(map).map(key => {\n const value = toValue(map[key], options, true);\n return (\n <MetadataListItem key={key}>\n <Typography variant=\"body2\" component=\"span\">\n {`${options.titleFormat(key)}: `}\n </Typography>\n {value}\n </MetadataListItem>\n );\n });\n\n return nested ? (\n <StyledNestedList>{values}</StyledNestedList>\n ) : (\n <StyledList>{values}</StyledList>\n );\n}\n\nfunction toValue(\n value: ReactElement | object | Array<any> | boolean,\n options: Options,\n nested: boolean,\n) {\n if (React.isValidElement(value)) {\n return <Fragment>{value}</Fragment>;\n }\n if (value !== null && typeof value === 'object') {\n if (options.nestedValuesAsYaml) {\n return (\n <CodeSnippet\n language=\"yaml\"\n text={jsyaml.dump(value)}\n customStyle={{\n background: 'transparent',\n lineHeight: '1.4',\n padding: '0',\n margin: 0,\n }}\n />\n );\n }\n if (!Array.isArray(value)) {\n return renderMap(value, options, nested);\n }\n }\n\n if (Array.isArray(value)) {\n return renderList(value, options, nested);\n }\n\n if (typeof value === 'boolean') {\n return <Fragment>{value ? '✅' : '❌'}</Fragment>;\n }\n return (\n <Typography variant=\"body2\" component=\"span\">\n {value}\n </Typography>\n );\n}\nconst ItemValue = ({ value, options }: { value: any; options: Options }) => (\n <Fragment>{toValue(value, options, false)}</Fragment>\n);\n\nconst TableItem = ({\n title,\n value,\n options,\n}: {\n title: string;\n value: any;\n options: Options;\n}) => {\n return (\n <MetadataTableItem title={options.titleFormat(title)}>\n <ItemValue value={value} options={options} />\n </MetadataTableItem>\n );\n};\n\nfunction mapToItems(info: { [key: string]: string }, options: Options) {\n return Object.keys(info).map(key => (\n <TableItem key={key} title={key} value={info[key]} options={options} />\n ));\n}\n\n/** @public */\nexport interface StructuredMetadataTableProps {\n metadata: { [key: string]: any };\n dense?: boolean;\n options?: {\n /**\n * Function to format the keys from the `metadata` object. Defaults to\n * startCase from the lodash library.\n * @param key - A key within the `metadata`\n * @returns Formatted key\n */\n titleFormat?: (key: string) => string;\n nestedValuesAsYaml?: boolean;\n };\n}\n\ntype Options = Required<NonNullable<StructuredMetadataTableProps['options']>>;\n\n/** @public */\nexport function StructuredMetadataTable(props: StructuredMetadataTableProps) {\n const { metadata, dense = true, options } = props;\n const metadataItems = mapToItems(metadata, {\n titleFormat: startCase,\n nestedValuesAsYaml: options?.nestedValuesAsYaml ?? false,\n ...options,\n });\n return <M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AA,CAAK,GAAG,CAAA,EAAG,SAAkB,CACtE,CAAA;AACH;AAqBO,SAAS,wBAAwB,KAAqC,EAAA;AAC3E,EAAA,MAAM,EAAE,QAAA,EAAU,KAAQ,GAAA,IAAA,EAAM,SAAY,GAAA,KAAA;AAC5C,EAAM,MAAA,aAAA,GAAgB,WAAW,QAAU,EAAA;AAAA,IACzC,WAAa,EAAA,SAAA;AAAA,IACb,kBAAA,EAAoB,SAAS,kBAAsB,IAAA,KAAA;AAAA,IACnD,GAAG;AAAA,GACJ,CAAA;AACD,EAAO,uBAAAA,cAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,KAAA,EAAA,EAAe,aAAc,CAAA;AACrD;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ import '@material-ui/icons/AddCircleOutline';
|
|
|
27
27
|
import 'd3-zoom';
|
|
28
28
|
import 'd3-selection';
|
|
29
29
|
import '@material-ui/core/styles/useTheme';
|
|
30
|
-
import 'dagre';
|
|
30
|
+
import '@dagrejs/dagre';
|
|
31
31
|
import 'lodash/debounce';
|
|
32
32
|
import '../../components/DependencyGraph/types.esm.js';
|
|
33
33
|
import '../../components/DependencyGraph/Node.esm.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/core-components",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4-next.1",
|
|
4
4
|
"description": "Core components used by Backstage plugins and apps",
|
|
5
5
|
"backstage": {
|
|
6
6
|
"role": "web-library"
|
|
@@ -66,11 +66,12 @@
|
|
|
66
66
|
"test": "backstage-cli package test"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@backstage/config": "
|
|
70
|
-
"@backstage/core-plugin-api": "
|
|
71
|
-
"@backstage/errors": "
|
|
72
|
-
"@backstage/theme": "
|
|
73
|
-
"@backstage/version-bridge": "
|
|
69
|
+
"@backstage/config": "1.3.2",
|
|
70
|
+
"@backstage/core-plugin-api": "1.10.4-next.0",
|
|
71
|
+
"@backstage/errors": "1.2.7",
|
|
72
|
+
"@backstage/theme": "0.6.4-next.0",
|
|
73
|
+
"@backstage/version-bridge": "1.0.11-next.0",
|
|
74
|
+
"@dagrejs/dagre": "^1.1.4",
|
|
74
75
|
"@date-io/core": "^1.3.13",
|
|
75
76
|
"@material-table/core": "^3.1.0",
|
|
76
77
|
"@material-ui/core": "^4.12.2",
|
|
@@ -84,7 +85,7 @@
|
|
|
84
85
|
"d3-selection": "^3.0.0",
|
|
85
86
|
"d3-shape": "^3.0.0",
|
|
86
87
|
"d3-zoom": "^3.0.0",
|
|
87
|
-
"
|
|
88
|
+
"js-yaml": "^4.1.0",
|
|
88
89
|
"linkify-react": "4.1.3",
|
|
89
90
|
"linkifyjs": "4.1.3",
|
|
90
91
|
"lodash": "^4.17.21",
|
|
@@ -105,10 +106,10 @@
|
|
|
105
106
|
"zod": "^3.22.4"
|
|
106
107
|
},
|
|
107
108
|
"devDependencies": {
|
|
108
|
-
"@backstage/app-defaults": "
|
|
109
|
-
"@backstage/cli": "
|
|
110
|
-
"@backstage/core-app-api": "
|
|
111
|
-
"@backstage/test-utils": "
|
|
109
|
+
"@backstage/app-defaults": "1.5.17-next.1",
|
|
110
|
+
"@backstage/cli": "0.30.0-next.2",
|
|
111
|
+
"@backstage/core-app-api": "1.15.5-next.0",
|
|
112
|
+
"@backstage/test-utils": "1.7.5-next.0",
|
|
112
113
|
"@testing-library/dom": "^10.0.0",
|
|
113
114
|
"@testing-library/jest-dom": "^6.0.0",
|
|
114
115
|
"@testing-library/user-event": "^14.0.0",
|
|
@@ -117,7 +118,6 @@
|
|
|
117
118
|
"@types/d3-selection": "^3.0.1",
|
|
118
119
|
"@types/d3-shape": "^3.0.1",
|
|
119
120
|
"@types/d3-zoom": "^3.0.1",
|
|
120
|
-
"@types/dagre": "^0.7.44",
|
|
121
121
|
"@types/google-protobuf": "^3.7.2",
|
|
122
122
|
"@types/react": "^18.0.0",
|
|
123
123
|
"@types/react-helmet": "^6.1.0",
|
|
@@ -133,10 +133,10 @@
|
|
|
133
133
|
"react-router-dom": "^6.3.0"
|
|
134
134
|
},
|
|
135
135
|
"peerDependencies": {
|
|
136
|
-
"@types/react": "^
|
|
137
|
-
"react": "^
|
|
138
|
-
"react-dom": "^
|
|
139
|
-
"react-router-dom": "
|
|
136
|
+
"@types/react": "^17.0.0 || ^18.0.0",
|
|
137
|
+
"react": "^17.0.0 || ^18.0.0",
|
|
138
|
+
"react-dom": "^17.0.0 || ^18.0.0",
|
|
139
|
+
"react-router-dom": "^6.3.0"
|
|
140
140
|
},
|
|
141
141
|
"peerDependenciesMeta": {
|
|
142
142
|
"@types/react": {
|