@backstage/plugin-catalog-graph 0.2.1 → 0.2.5
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 +42 -0
- package/dist/esm/{index-af58b1b6.esm.js → index-b85eaf0a.esm.js} +16 -14
- package/dist/esm/index-b85eaf0a.esm.js.map +1 -0
- package/dist/esm/{index-755cebab.esm.js → index-d308609c.esm.js} +27 -27
- package/dist/esm/index-d308609c.esm.js.map +1 -0
- package/dist/esm/{index-ed95c1b2.esm.js → index-e657c147.esm.js} +9 -8
- package/dist/esm/{index-ed95c1b2.esm.js.map → index-e657c147.esm.js.map} +1 -1
- package/dist/index.esm.js +3 -2
- package/dist/index.esm.js.map +1 -1
- package/package.json +16 -15
- package/dist/esm/index-755cebab.esm.js.map +0 -1
- package/dist/esm/index-af58b1b6.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-graph
|
|
2
2
|
|
|
3
|
+
## 0.2.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4ce51ab0f1: Internal refactor of the `react-use` imports to use `react-use/lib/*` instead.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @backstage/core-plugin-api@0.4.1
|
|
10
|
+
- @backstage/plugin-catalog-react@0.6.10
|
|
11
|
+
- @backstage/core-components@0.8.3
|
|
12
|
+
|
|
13
|
+
## 0.2.4
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- @backstage/core-plugin-api@0.4.0
|
|
19
|
+
- @backstage/plugin-catalog-react@0.6.8
|
|
20
|
+
- @backstage/core-components@0.8.2
|
|
21
|
+
- @backstage/catalog-client@0.5.3
|
|
22
|
+
|
|
23
|
+
## 0.2.3
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- cd450844f6: Moved React dependencies to `peerDependencies` and allow both React v16 and v17 to be used.
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
- @backstage/core-components@0.8.0
|
|
30
|
+
- @backstage/core-plugin-api@0.3.0
|
|
31
|
+
- @backstage/plugin-catalog-react@0.6.5
|
|
32
|
+
|
|
33
|
+
## 0.2.2
|
|
34
|
+
|
|
35
|
+
### Patch Changes
|
|
36
|
+
|
|
37
|
+
- a125278b81: Refactor out the deprecated path and icon from RouteRefs
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @backstage/catalog-client@0.5.2
|
|
40
|
+
- @backstage/catalog-model@0.9.7
|
|
41
|
+
- @backstage/plugin-catalog-react@0.6.4
|
|
42
|
+
- @backstage/core-components@0.7.4
|
|
43
|
+
- @backstage/core-plugin-api@0.2.0
|
|
44
|
+
|
|
3
45
|
## 0.2.1
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
|
@@ -8,18 +8,20 @@ import ZoomOutMap from '@material-ui/icons/ZoomOutMap';
|
|
|
8
8
|
import { Autocomplete, ToggleButton } from '@material-ui/lab';
|
|
9
9
|
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
|
10
10
|
import { useLocation, useNavigate } from 'react-router';
|
|
11
|
-
import { D as Direction, A as ALL_RELATION_PAIRS, c as catalogEntityRouteRef, E as EntityRelationsGraph } from './index-
|
|
11
|
+
import { D as Direction, A as ALL_RELATION_PAIRS, c as catalogEntityRouteRef, E as EntityRelationsGraph } from './index-d308609c.esm.js';
|
|
12
12
|
import ClearIcon from '@material-ui/icons/Clear';
|
|
13
13
|
import CheckBoxIcon from '@material-ui/icons/CheckBox';
|
|
14
14
|
import CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';
|
|
15
15
|
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
|
|
16
16
|
import qs from 'qs';
|
|
17
|
-
import
|
|
17
|
+
import usePrevious from 'react-use/lib/usePrevious';
|
|
18
18
|
import 'classnames';
|
|
19
19
|
import '@material-ui/core/styles/makeStyles';
|
|
20
20
|
import '@material-ui/core/styles';
|
|
21
21
|
import '@material-ui/icons/Work';
|
|
22
|
+
import 'react-use/lib/useDebounce';
|
|
22
23
|
import 'p-limit';
|
|
24
|
+
import 'react-use/lib/useAsyncFn';
|
|
23
25
|
|
|
24
26
|
const DIRECTION_DISPLAY_NAMES = {
|
|
25
27
|
[Direction.LEFT_RIGHT]: "Left to right",
|
|
@@ -27,7 +29,7 @@ const DIRECTION_DISPLAY_NAMES = {
|
|
|
27
29
|
[Direction.TOP_BOTTOM]: "Top to bottom",
|
|
28
30
|
[Direction.BOTTOM_TOP]: "Bottom to top"
|
|
29
31
|
};
|
|
30
|
-
const DirectionFilter = ({value, onChange}) => {
|
|
32
|
+
const DirectionFilter = ({ value, onChange }) => {
|
|
31
33
|
const handleChange = useCallback((v) => onChange(v), [onChange]);
|
|
32
34
|
return /* @__PURE__ */ React.createElement(Box, {
|
|
33
35
|
pb: 1,
|
|
@@ -49,7 +51,7 @@ const useStyles$4 = makeStyles({
|
|
|
49
51
|
maxWidth: 300
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
|
-
const MaxDepthFilter = ({value, onChange}) => {
|
|
54
|
+
const MaxDepthFilter = ({ value, onChange }) => {
|
|
53
55
|
const classes = useStyles$4();
|
|
54
56
|
const handleChange = useCallback((event) => {
|
|
55
57
|
const v = Number(event.target.value);
|
|
@@ -90,10 +92,10 @@ const useStyles$3 = makeStyles({
|
|
|
90
92
|
maxWidth: 300
|
|
91
93
|
}
|
|
92
94
|
});
|
|
93
|
-
const SelectedKindsFilter = ({value, onChange}) => {
|
|
95
|
+
const SelectedKindsFilter = ({ value, onChange }) => {
|
|
94
96
|
const classes = useStyles$3();
|
|
95
97
|
const alertApi = useApi(alertApiRef);
|
|
96
|
-
const {error, kinds} = useEntityKinds();
|
|
98
|
+
const { error, kinds } = useEntityKinds();
|
|
97
99
|
useEffect(() => {
|
|
98
100
|
if (error) {
|
|
99
101
|
alertApi.post({
|
|
@@ -131,7 +133,7 @@ const SelectedKindsFilter = ({value, onChange}) => {
|
|
|
131
133
|
},
|
|
132
134
|
onChange: handleChange,
|
|
133
135
|
onBlur: handleEmpty,
|
|
134
|
-
renderOption: (option, {selected}) => {
|
|
136
|
+
renderOption: (option, { selected }) => {
|
|
135
137
|
var _a;
|
|
136
138
|
return /* @__PURE__ */ React.createElement(FormControlLabel, {
|
|
137
139
|
control: /* @__PURE__ */ React.createElement(Checkbox, {
|
|
@@ -190,7 +192,7 @@ const SelectedRelationsFilter = ({
|
|
|
190
192
|
value: value != null ? value : relations,
|
|
191
193
|
onChange: handleChange,
|
|
192
194
|
onBlur: handleEmpty,
|
|
193
|
-
renderOption: (option, {selected}) => /* @__PURE__ */ React.createElement(FormControlLabel, {
|
|
195
|
+
renderOption: (option, { selected }) => /* @__PURE__ */ React.createElement(FormControlLabel, {
|
|
194
196
|
control: /* @__PURE__ */ React.createElement(Checkbox, {
|
|
195
197
|
icon: /* @__PURE__ */ React.createElement(CheckBoxOutlineBlankIcon, {
|
|
196
198
|
fontSize: "small"
|
|
@@ -219,7 +221,7 @@ const useStyles$1 = makeStyles({
|
|
|
219
221
|
maxWidth: 300
|
|
220
222
|
}
|
|
221
223
|
});
|
|
222
|
-
const SwitchFilter = ({label, value, onChange}) => {
|
|
224
|
+
const SwitchFilter = ({ label, value, onChange }) => {
|
|
223
225
|
const classes = useStyles$1();
|
|
224
226
|
const handleChange = useCallback((event) => {
|
|
225
227
|
onChange(event.target.checked);
|
|
@@ -243,7 +245,7 @@ function useCatalogGraphPage({
|
|
|
243
245
|
initialState = {}
|
|
244
246
|
}) {
|
|
245
247
|
const location = useLocation();
|
|
246
|
-
const query = useMemo(() => qs.parse(location.search, {arrayLimit: 0, ignoreQueryPrefix: true}) || {}, [location.search]);
|
|
248
|
+
const query = useMemo(() => qs.parse(location.search, { arrayLimit: 0, ignoreQueryPrefix: true }) || {}, [location.search]);
|
|
247
249
|
const [rootEntityNames, setRootEntityNames] = useState(() => {
|
|
248
250
|
var _a;
|
|
249
251
|
return (Array.isArray(query.rootEntityRefs) ? query.rootEntityRefs : (_a = initialState == null ? void 0 : initialState.rootEntityRefs) != null ? _a : []).map((r) => parseEntityRef(r));
|
|
@@ -328,7 +330,7 @@ function useCatalogGraphPage({
|
|
|
328
330
|
mergeRelations,
|
|
329
331
|
direction,
|
|
330
332
|
showFilters
|
|
331
|
-
}, {arrayFormat: "brackets", addQueryPrefix: true});
|
|
333
|
+
}, { arrayFormat: "brackets", addQueryPrefix: true });
|
|
332
334
|
const newUrl = `${window.location.pathname}${newParams}`;
|
|
333
335
|
if (!previousRootEntityRefs || rootEntityRefs.length === previousRootEntityRefs.length && rootEntityRefs.every((v, i) => v === previousRootEntityRefs[i])) {
|
|
334
336
|
window.history.replaceState(null, document.title, newUrl);
|
|
@@ -444,7 +446,7 @@ const CatalogGraphPage = ({
|
|
|
444
446
|
setRootEntityNames,
|
|
445
447
|
showFilters,
|
|
446
448
|
toggleShowFilters
|
|
447
|
-
} = useCatalogGraphPage({initialState});
|
|
449
|
+
} = useCatalogGraphPage({ initialState });
|
|
448
450
|
const analytics = useAnalytics();
|
|
449
451
|
const onNodeClick = useCallback((node, event) => {
|
|
450
452
|
var _a, _b;
|
|
@@ -455,7 +457,7 @@ const CatalogGraphPage = ({
|
|
|
455
457
|
namespace: nodeEntityName.namespace.toLocaleLowerCase("en-US"),
|
|
456
458
|
name: nodeEntityName.name
|
|
457
459
|
});
|
|
458
|
-
analytics.captureEvent("click", (_a = node.title) != null ? _a : formatEntityRefTitle(nodeEntityName), {attributes: {to: path}});
|
|
460
|
+
analytics.captureEvent("click", (_a = node.title) != null ? _a : formatEntityRefTitle(nodeEntityName), { attributes: { to: path } });
|
|
459
461
|
navigate(path);
|
|
460
462
|
} else {
|
|
461
463
|
analytics.captureEvent("click", (_b = node.title) != null ? _b : formatEntityRefTitle(nodeEntityName));
|
|
@@ -535,4 +537,4 @@ const CatalogGraphPage = ({
|
|
|
535
537
|
};
|
|
536
538
|
|
|
537
539
|
export { CatalogGraphPage };
|
|
538
|
-
//# sourceMappingURL=index-
|
|
540
|
+
//# sourceMappingURL=index-b85eaf0a.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-b85eaf0a.esm.js","sources":["../../src/components/CatalogGraphPage/DirectionFilter.tsx","../../src/components/CatalogGraphPage/MaxDepthFilter.tsx","../../src/components/CatalogGraphPage/SelectedKindsFilter.tsx","../../src/components/CatalogGraphPage/SelectedRelationsFilter.tsx","../../src/components/CatalogGraphPage/SwitchFilter.tsx","../../src/components/CatalogGraphPage/useCatalogGraphPage.ts","../../src/components/CatalogGraphPage/CatalogGraphPage.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 */\nimport { Select } from '@backstage/core-components';\nimport { Box } from '@material-ui/core';\nimport React, { useCallback } from 'react';\nimport { Direction } from '../EntityRelationsGraph';\n\nconst DIRECTION_DISPLAY_NAMES = {\n [Direction.LEFT_RIGHT]: 'Left to right',\n [Direction.RIGHT_LEFT]: 'Right to left',\n [Direction.TOP_BOTTOM]: 'Top to bottom',\n [Direction.BOTTOM_TOP]: 'Bottom to top',\n};\n\nexport type Props = {\n value: Direction;\n onChange: (value: Direction) => void;\n};\n\nexport const DirectionFilter = ({ value, onChange }: Props) => {\n const handleChange = useCallback(v => onChange(v as Direction), [onChange]);\n\n return (\n <Box pb={1} pt={1}>\n <Select\n label=\"Direction\"\n selected={value}\n items={Object.values(Direction).map(v => ({\n label: DIRECTION_DISPLAY_NAMES[v],\n value: v,\n }))}\n onChange={handleChange}\n />\n </Box>\n );\n};\n","/*\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 */\nimport {\n Box,\n FormControl,\n IconButton,\n InputAdornment,\n makeStyles,\n OutlinedInput,\n Typography,\n} from '@material-ui/core';\nimport ClearIcon from '@material-ui/icons/Clear';\nimport React, { useCallback } from 'react';\n\nexport type Props = {\n value: number;\n onChange: (value: number) => void;\n};\n\nconst useStyles = makeStyles({\n formControl: {\n width: '100%',\n maxWidth: 300,\n },\n});\n\nexport const MaxDepthFilter = ({ value, onChange }: Props) => {\n const classes = useStyles();\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const v = Number(event.target.value);\n onChange(v <= 0 ? Number.POSITIVE_INFINITY : v);\n },\n [onChange],\n );\n\n const reset = useCallback(() => {\n onChange(Number.POSITIVE_INFINITY);\n }, [onChange]);\n\n return (\n <Box pb={1} pt={1}>\n <FormControl variant=\"outlined\" className={classes.formControl}>\n <Typography variant=\"button\">Max Depth</Typography>\n <OutlinedInput\n type=\"number\"\n placeholder=\"∞ Infinite\"\n value={isFinite(value) ? value : ''}\n onChange={handleChange}\n endAdornment={\n <InputAdornment position=\"end\">\n <IconButton\n aria-label=\"clear max depth\"\n onClick={reset}\n edge=\"end\"\n >\n <ClearIcon />\n </IconButton>\n </InputAdornment>\n }\n inputProps={{\n 'aria-label': 'maxp',\n }}\n labelWidth={0}\n />\n </FormControl>\n </Box>\n );\n};\n","/*\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 */\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEntityKinds } from '@backstage/plugin-catalog-react';\nimport {\n Box,\n Checkbox,\n FormControlLabel,\n makeStyles,\n TextField,\n Typography,\n} from '@material-ui/core';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { Autocomplete } from '@material-ui/lab';\nimport React, { useCallback, useEffect, useMemo } from 'react';\n\nconst useStyles = makeStyles({\n formControl: {\n maxWidth: 300,\n },\n});\n\nexport type Props = {\n value: string[] | undefined;\n onChange: (value: string[] | undefined) => void;\n};\n\nexport const SelectedKindsFilter = ({ value, onChange }: Props) => {\n const classes = useStyles();\n const alertApi = useApi(alertApiRef);\n const { error, kinds } = useEntityKinds();\n\n useEffect(() => {\n if (error) {\n alertApi.post({\n message: `Failed to load entity kinds`,\n severity: 'error',\n });\n }\n }, [error, alertApi]);\n\n const normalizedKinds = useMemo(\n () => (kinds ? kinds.map(k => k.toLocaleLowerCase('en-US')) : kinds),\n [kinds],\n );\n\n const handleChange = useCallback(\n (_: unknown, v: string[]) => {\n onChange(\n normalizedKinds && normalizedKinds.every(r => v.includes(r))\n ? undefined\n : v,\n );\n },\n [normalizedKinds, onChange],\n );\n\n const handleEmpty = useCallback(() => {\n onChange(value?.length ? value : undefined);\n }, [value, onChange]);\n\n if (!kinds?.length || !normalizedKinds?.length || error) {\n return <></>;\n }\n\n return (\n <Box pb={1} pt={1}>\n <Typography variant=\"button\">Kinds</Typography>\n <Autocomplete\n className={classes.formControl}\n multiple\n limitTags={4}\n disableCloseOnSelect\n aria-label=\"Kinds\"\n options={normalizedKinds}\n value={value ?? normalizedKinds}\n getOptionLabel={k => kinds[normalizedKinds.indexOf(k)] ?? k}\n onChange={handleChange}\n onBlur={handleEmpty}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={<CheckBoxOutlineBlankIcon fontSize=\"small\" />}\n checkedIcon={<CheckBoxIcon fontSize=\"small\" />}\n checked={selected}\n />\n }\n label={kinds[normalizedKinds.indexOf(option)] ?? option}\n />\n )}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"selected-kinds-expand\" />}\n renderInput={params => <TextField {...params} variant=\"outlined\" />}\n />\n </Box>\n );\n};\n","/*\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 */\nimport {\n Box,\n Checkbox,\n FormControlLabel,\n makeStyles,\n TextField,\n Typography,\n} from '@material-ui/core';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { Autocomplete } from '@material-ui/lab';\nimport React, { useCallback, useMemo } from 'react';\nimport { RelationPairs } from '../EntityRelationsGraph';\n\nconst useStyles = makeStyles({\n formControl: {\n maxWidth: 300,\n },\n});\n\nexport type Props = {\n relationPairs: RelationPairs;\n value: string[] | undefined;\n onChange: (value: string[] | undefined) => void;\n};\n\nexport const SelectedRelationsFilter = ({\n relationPairs,\n value,\n onChange,\n}: Props) => {\n const classes = useStyles();\n const relations = useMemo(() => relationPairs.flat(), [relationPairs]);\n\n const handleChange = useCallback(\n (_: unknown, v: string[]) => {\n onChange(relations.every(r => v.includes(r)) ? undefined : v);\n },\n [relations, onChange],\n );\n\n const handleEmpty = useCallback(() => {\n onChange(value?.length ? value : undefined);\n }, [value, onChange]);\n\n return (\n <Box pb={1} pt={1}>\n <Typography variant=\"button\">Relations</Typography>\n <Autocomplete\n className={classes.formControl}\n multiple\n limitTags={4}\n disableCloseOnSelect\n aria-label=\"Relations\"\n options={relations}\n value={value ?? relations}\n onChange={handleChange}\n onBlur={handleEmpty}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={<CheckBoxOutlineBlankIcon fontSize=\"small\" />}\n checkedIcon={<CheckBoxIcon fontSize=\"small\" />}\n checked={selected}\n />\n }\n label={option}\n />\n )}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"selected-relations-expand\" />}\n renderInput={params => <TextField {...params} variant=\"outlined\" />}\n />\n </Box>\n );\n};\n","/*\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 */\nimport { Box, FormControlLabel, makeStyles, Switch } from '@material-ui/core';\nimport React, { useCallback } from 'react';\n\nexport type Props = {\n label: string;\n value: boolean;\n onChange: (value: boolean) => void;\n};\n\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n maxWidth: 300,\n },\n});\n\nexport const SwitchFilter = ({ label, value, onChange }: Props) => {\n const classes = useStyles();\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(event.target.checked);\n },\n [onChange],\n );\n\n return (\n <Box pb={1} pt={1}>\n <FormControlLabel\n control={\n <Switch\n checked={value}\n onChange={handleChange}\n name={label}\n color=\"primary\"\n />\n }\n label={label}\n className={classes.root}\n />\n </Box>\n );\n};\n","/*\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 */\nimport {\n EntityName,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport qs from 'qs';\nimport {\n Dispatch,\n DispatchWithoutAction,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { useLocation } from 'react-router';\nimport usePrevious from 'react-use/lib/usePrevious';\nimport { Direction } from '../EntityRelationsGraph';\n\nexport type CatalogGraphPageValue = {\n rootEntityNames: EntityName[];\n setRootEntityNames: Dispatch<React.SetStateAction<EntityName[]>>;\n maxDepth: number;\n setMaxDepth: Dispatch<React.SetStateAction<number>>;\n selectedRelations: string[] | undefined;\n setSelectedRelations: Dispatch<React.SetStateAction<string[] | undefined>>;\n selectedKinds: string[] | undefined;\n setSelectedKinds: Dispatch<React.SetStateAction<string[] | undefined>>;\n unidirectional: boolean;\n setUnidirectional: Dispatch<React.SetStateAction<boolean>>;\n mergeRelations: boolean;\n setMergeRelations: Dispatch<React.SetStateAction<boolean>>;\n direction: Direction;\n setDirection: Dispatch<React.SetStateAction<Direction>>;\n showFilters: boolean;\n toggleShowFilters: DispatchWithoutAction;\n};\n\nexport function useCatalogGraphPage({\n initialState = {},\n}: {\n initialState?: {\n selectedRelations?: string[] | undefined;\n selectedKinds?: string[] | undefined;\n rootEntityRefs?: string[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n direction?: Direction;\n showFilters?: boolean;\n };\n}): CatalogGraphPageValue {\n const location = useLocation();\n const query = useMemo(\n () =>\n (qs.parse(location.search, { arrayLimit: 0, ignoreQueryPrefix: true }) ||\n {}) as {\n selectedRelations?: string[] | string;\n selectedKinds?: string[] | string;\n rootEntityRefs?: string[] | string;\n maxDepth?: string[] | string;\n unidirectional?: string[] | string;\n mergeRelations?: string[] | string;\n direction?: string[] | Direction;\n showFilters?: string[] | string;\n },\n [location.search],\n );\n\n // Initial state\n const [rootEntityNames, setRootEntityNames] = useState<EntityName[]>(() =>\n (Array.isArray(query.rootEntityRefs)\n ? query.rootEntityRefs\n : initialState?.rootEntityRefs ?? []\n ).map(r => parseEntityRef(r)),\n );\n const [maxDepth, setMaxDepth] = useState<number>(() =>\n typeof query.maxDepth === 'string'\n ? parseMaxDepth(query.maxDepth)\n : initialState?.maxDepth ?? Number.POSITIVE_INFINITY,\n );\n const [selectedRelations, setSelectedRelations] = useState<\n string[] | undefined\n >(() =>\n Array.isArray(query.selectedRelations)\n ? query.selectedRelations\n : initialState?.selectedRelations,\n );\n const [selectedKinds, setSelectedKinds] = useState<string[] | undefined>(() =>\n (Array.isArray(query.selectedKinds)\n ? query.selectedKinds\n : initialState?.selectedKinds\n )?.map(k => k.toLocaleLowerCase('en-US')),\n );\n const [unidirectional, setUnidirectional] = useState<boolean>(() =>\n typeof query.unidirectional === 'string'\n ? query.unidirectional === 'true'\n : initialState?.unidirectional ?? true,\n );\n const [mergeRelations, setMergeRelations] = useState<boolean>(() =>\n typeof query.mergeRelations === 'string'\n ? query.mergeRelations === 'true'\n : initialState?.mergeRelations ?? true,\n );\n const [direction, setDirection] = useState<Direction>(() =>\n typeof query.direction === 'string'\n ? query.direction\n : initialState?.direction ?? Direction.LEFT_RIGHT,\n );\n const [showFilters, setShowFilters] = useState<boolean>(() =>\n typeof query.showFilters === 'string'\n ? query.showFilters === 'true'\n : initialState?.showFilters ?? true,\n );\n const toggleShowFilters = useCallback(\n () => setShowFilters(s => !s),\n [setShowFilters],\n );\n\n // Update from query parameters\n const prevQueryParams = usePrevious(location.search);\n useEffect(() => {\n // Only respond to changes to url query params\n if (location.search === prevQueryParams) {\n return;\n }\n\n if (Array.isArray(query.rootEntityRefs)) {\n setRootEntityNames(query.rootEntityRefs.map(r => parseEntityRef(r)));\n }\n\n if (typeof query.maxDepth === 'string') {\n setMaxDepth(parseMaxDepth(query.maxDepth));\n }\n\n if (Array.isArray(query.selectedKinds)) {\n setSelectedKinds(query.selectedKinds);\n }\n\n if (Array.isArray(query.selectedRelations)) {\n setSelectedRelations(query.selectedRelations);\n }\n\n if (typeof query.unidirectional === 'string') {\n setUnidirectional(query.unidirectional === 'true');\n }\n\n if (typeof query.mergeRelations === 'string') {\n setMergeRelations(query.mergeRelations === 'true');\n }\n\n if (typeof query.direction === 'string') {\n setDirection(query.direction);\n }\n\n if (typeof query.showFilters === 'string') {\n setShowFilters(query.showFilters === 'true');\n }\n }, [\n prevQueryParams,\n location.search,\n query,\n setRootEntityNames,\n setMaxDepth,\n setSelectedKinds,\n setSelectedRelations,\n setUnidirectional,\n setMergeRelations,\n setDirection,\n setShowFilters,\n ]);\n\n // Update query parameters\n const previousRootEntityRefs = usePrevious(\n rootEntityNames.map(e => stringifyEntityRef(e)),\n );\n\n useEffect(() => {\n const rootEntityRefs = rootEntityNames.map(e => stringifyEntityRef(e));\n const newParams = qs.stringify(\n {\n rootEntityRefs,\n maxDepth: isFinite(maxDepth) ? maxDepth : '∞',\n selectedKinds,\n selectedRelations,\n unidirectional,\n mergeRelations,\n direction,\n showFilters,\n },\n { arrayFormat: 'brackets', addQueryPrefix: true },\n );\n const newUrl = `${window.location.pathname}${newParams}`;\n\n // We directly manipulate window history here in order to not re-render\n // infinitely (state => location => state => etc). The intention of this\n // code is just to ensure the right query/filters are loaded when a user\n // clicks the \"back\" button after clicking a result.\n // Only push a new history entry if we switched to another entity, but not\n // if we just changed a viewer setting.\n if (\n !previousRootEntityRefs ||\n (rootEntityRefs.length === previousRootEntityRefs.length &&\n rootEntityRefs.every((v, i) => v === previousRootEntityRefs[i]))\n ) {\n window.history.replaceState(null, document.title, newUrl);\n } else {\n window.history.pushState(null, document.title, newUrl);\n }\n }, [\n rootEntityNames,\n maxDepth,\n selectedKinds,\n selectedRelations,\n unidirectional,\n mergeRelations,\n direction,\n showFilters,\n previousRootEntityRefs,\n ]);\n\n return {\n rootEntityNames,\n setRootEntityNames,\n maxDepth,\n setMaxDepth,\n selectedRelations,\n setSelectedRelations,\n selectedKinds,\n setSelectedKinds,\n unidirectional,\n setUnidirectional,\n mergeRelations,\n setMergeRelations,\n direction,\n setDirection,\n showFilters,\n toggleShowFilters,\n };\n}\n\nfunction parseMaxDepth(value: string): number {\n return value === '∞' ? Number.POSITIVE_INFINITY : Number(value);\n}\n","/*\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 */\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport {\n Content,\n ContentHeader,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport { useAnalytics, useRouteRef } from '@backstage/core-plugin-api';\nimport { formatEntityRefTitle } from '@backstage/plugin-catalog-react';\nimport { Grid, makeStyles, Paper, Typography } from '@material-ui/core';\nimport FilterListIcon from '@material-ui/icons/FilterList';\nimport ZoomOutMap from '@material-ui/icons/ZoomOutMap';\nimport { ToggleButton } from '@material-ui/lab';\nimport React, { MouseEvent, useCallback } from 'react';\nimport { useNavigate } from 'react-router';\nimport { catalogEntityRouteRef } from '../../routes';\nimport {\n ALL_RELATION_PAIRS,\n Direction,\n EntityNode,\n EntityRelationsGraph,\n RelationPairs,\n} from '../EntityRelationsGraph';\nimport { DirectionFilter } from './DirectionFilter';\nimport { MaxDepthFilter } from './MaxDepthFilter';\nimport { SelectedKindsFilter } from './SelectedKindsFilter';\nimport { SelectedRelationsFilter } from './SelectedRelationsFilter';\nimport { SwitchFilter } from './SwitchFilter';\nimport { useCatalogGraphPage } from './useCatalogGraphPage';\n\nconst useStyles = makeStyles(theme => ({\n content: {\n minHeight: 0,\n },\n container: {\n height: '100%',\n maxHeight: '100%',\n minHeight: 0,\n },\n fullHeight: {\n maxHeight: '100%',\n display: 'flex',\n minHeight: 0,\n },\n graphWrapper: {\n position: 'relative',\n flex: 1,\n minHeight: 0,\n display: 'flex',\n },\n graph: {\n flex: 1,\n minHeight: 0,\n },\n legend: {\n position: 'absolute',\n bottom: 0,\n right: 0,\n padding: theme.spacing(1),\n '& .icon': {\n verticalAlign: 'bottom',\n },\n },\n filters: {\n display: 'grid',\n gridGap: theme.spacing(1),\n gridAutoRows: 'auto',\n [theme.breakpoints.up('lg')]: {\n display: 'block',\n },\n [theme.breakpoints.only('md')]: {\n gridTemplateColumns: 'repeat(3, 1fr)',\n },\n [theme.breakpoints.only('sm')]: {\n gridTemplateColumns: 'repeat(2, 1fr)',\n },\n [theme.breakpoints.down('xs')]: {\n gridTemplateColumns: 'repeat(1, 1fr)',\n },\n },\n}));\n\nexport const CatalogGraphPage = ({\n relationPairs = ALL_RELATION_PAIRS,\n initialState,\n}: {\n relationPairs?: RelationPairs;\n initialState?: {\n selectedRelations?: string[];\n selectedKinds?: string[];\n rootEntityRefs?: string[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n direction?: Direction;\n showFilters?: boolean;\n };\n}) => {\n const navigate = useNavigate();\n const classes = useStyles();\n const catalogEntityRoute = useRouteRef(catalogEntityRouteRef);\n const {\n maxDepth,\n setMaxDepth,\n selectedKinds,\n setSelectedKinds,\n selectedRelations,\n setSelectedRelations,\n unidirectional,\n setUnidirectional,\n mergeRelations,\n setMergeRelations,\n direction,\n setDirection,\n rootEntityNames,\n setRootEntityNames,\n showFilters,\n toggleShowFilters,\n } = useCatalogGraphPage({ initialState });\n const analytics = useAnalytics();\n const onNodeClick = useCallback(\n (node: EntityNode, event: MouseEvent<unknown>) => {\n const nodeEntityName = parseEntityRef(node.id);\n\n if (event.shiftKey) {\n const path = catalogEntityRoute({\n kind: nodeEntityName.kind.toLocaleLowerCase('en-US'),\n namespace: nodeEntityName.namespace.toLocaleLowerCase('en-US'),\n name: nodeEntityName.name,\n });\n\n analytics.captureEvent(\n 'click',\n node.title ?? formatEntityRefTitle(nodeEntityName),\n { attributes: { to: path } },\n );\n navigate(path);\n } else {\n analytics.captureEvent(\n 'click',\n node.title ?? formatEntityRefTitle(nodeEntityName),\n );\n setRootEntityNames([nodeEntityName]);\n }\n },\n [catalogEntityRoute, navigate, setRootEntityNames, analytics],\n );\n\n return (\n <Page themeId=\"home\">\n <Header\n title=\"Catalog Graph\"\n subtitle={rootEntityNames.map(e => formatEntityRefTitle(e)).join(', ')}\n />\n <Content stretch className={classes.content}>\n <ContentHeader\n titleComponent={\n <ToggleButton\n value=\"show filters\"\n selected={showFilters}\n onChange={() => toggleShowFilters()}\n >\n <FilterListIcon /> Filters\n </ToggleButton>\n }\n >\n <SupportButton>\n Start tracking your component in by adding it to the software\n catalog.\n </SupportButton>\n </ContentHeader>\n <Grid container alignItems=\"stretch\" className={classes.container}>\n {showFilters && (\n <Grid item xs={12} lg={2} className={classes.filters}>\n <MaxDepthFilter value={maxDepth} onChange={setMaxDepth} />\n <SelectedKindsFilter\n value={selectedKinds}\n onChange={setSelectedKinds}\n />\n <SelectedRelationsFilter\n value={selectedRelations}\n onChange={setSelectedRelations}\n relationPairs={relationPairs}\n />\n <DirectionFilter value={direction} onChange={setDirection} />\n <SwitchFilter\n value={unidirectional}\n onChange={setUnidirectional}\n label=\"Simplified\"\n />\n <SwitchFilter\n value={mergeRelations}\n onChange={setMergeRelations}\n label=\"Merge Relations\"\n />\n </Grid>\n )}\n <Grid item xs className={classes.fullHeight}>\n <Paper className={classes.graphWrapper}>\n <Typography\n variant=\"caption\"\n color=\"textSecondary\"\n display=\"block\"\n className={classes.legend}\n >\n <ZoomOutMap className=\"icon\" /> Use pinch & zoom to move\n around the diagram. Click to change active node, shift click to\n navigate to entity.\n </Typography>\n <EntityRelationsGraph\n rootEntityNames={rootEntityNames}\n maxDepth={maxDepth}\n kinds={\n selectedKinds && selectedKinds.length > 0\n ? selectedKinds\n : undefined\n }\n relations={\n selectedRelations && selectedRelations.length > 0\n ? selectedRelations\n : undefined\n }\n mergeRelations={mergeRelations}\n unidirectional={unidirectional}\n onNodeClick={onNodeClick}\n direction={direction}\n relationPairs={relationPairs}\n className={classes.graph}\n zoom=\"enabled\"\n />\n </Paper>\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["useStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,0BAA0B;AAAA,GAC7B,UAAU,aAAa;AAAA,GACvB,UAAU,aAAa;AAAA,GACvB,UAAU,aAAa;AAAA,GACvB,UAAU,aAAa;AAAA;MAQb,kBAAkB,CAAC,EAAE,OAAO,eAAsB;AAC7D,QAAM,eAAe,YAAY,OAAK,SAAS,IAAiB,CAAC;AAEjE,6CACG,KAAD;AAAA,IAAK,IAAI;AAAA,IAAG,IAAI;AAAA,yCACb,QAAD;AAAA,IACE,OAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO,OAAO,OAAO,WAAW,IAAI;AAAM,MACxC,OAAO,wBAAwB;AAAA,MAC/B,OAAO;AAAA;AAAA,IAET,UAAU;AAAA;AAAA;;ACZlB,MAAMA,cAAY,WAAW;AAAA,EAC3B,aAAa;AAAA,IACX,OAAO;AAAA,IACP,UAAU;AAAA;AAAA;MAID,iBAAiB,CAAC,EAAE,OAAO,eAAsB;AAC5D,QAAM,UAAUA;AAEhB,QAAM,eAAe,YACnB,CAAC,UAA+C;AAC9C,UAA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;AAAA,IACnB,MAAK;AAAA;AAAA;;;;"}
|
|
@@ -8,8 +8,9 @@ import makeStyles from '@material-ui/core/styles/makeStyles';
|
|
|
8
8
|
import { formatEntityRefTitle, catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
9
9
|
import { makeStyles as makeStyles$1 } from '@material-ui/core/styles';
|
|
10
10
|
import WorkIcon from '@material-ui/icons/Work';
|
|
11
|
-
import
|
|
11
|
+
import useDebounce from 'react-use/lib/useDebounce';
|
|
12
12
|
import limiterFactory from 'p-limit';
|
|
13
|
+
import useAsyncFn from 'react-use/lib/useAsyncFn';
|
|
13
14
|
|
|
14
15
|
const useStyles$2 = makeStyles((theme) => ({
|
|
15
16
|
text: {
|
|
@@ -20,7 +21,7 @@ const useStyles$2 = makeStyles((theme) => ({
|
|
|
20
21
|
}
|
|
21
22
|
}));
|
|
22
23
|
function CustomLabel({
|
|
23
|
-
edge: {relations}
|
|
24
|
+
edge: { relations }
|
|
24
25
|
}) {
|
|
25
26
|
const classes = useStyles$2();
|
|
26
27
|
return /* @__PURE__ */ React.createElement("text", {
|
|
@@ -91,7 +92,7 @@ function CustomNode({
|
|
|
91
92
|
const idRef = useRef(null);
|
|
92
93
|
useLayoutEffect(() => {
|
|
93
94
|
if (idRef.current) {
|
|
94
|
-
let {height: renderedHeight, width: renderedWidth} = idRef.current.getBBox();
|
|
95
|
+
let { height: renderedHeight, width: renderedWidth } = idRef.current.getBBox();
|
|
95
96
|
renderedHeight = Math.round(renderedHeight);
|
|
96
97
|
renderedWidth = Math.round(renderedWidth);
|
|
97
98
|
if (renderedHeight !== height || renderedWidth !== width) {
|
|
@@ -105,7 +106,7 @@ function CustomNode({
|
|
|
105
106
|
const paddedIconWidth = kind ? iconSize + padding : 0;
|
|
106
107
|
const paddedWidth = paddedIconWidth + width + padding * 2;
|
|
107
108
|
const paddedHeight = height + padding * 2;
|
|
108
|
-
const displayTitle = title != null ? title : kind && name && namespace ? formatEntityRefTitle({kind, name, namespace}) : id;
|
|
109
|
+
const displayTitle = title != null ? title : kind && name && namespace ? formatEntityRefTitle({ kind, name, namespace }) : id;
|
|
109
110
|
return /* @__PURE__ */ React.createElement("g", {
|
|
110
111
|
onClick,
|
|
111
112
|
className: classNames(onClick && classes.clickable)
|
|
@@ -141,25 +142,25 @@ const ALL_RELATION_PAIRS = [
|
|
|
141
142
|
[RELATION_DEPENDS_ON, RELATION_DEPENDENCY_OF]
|
|
142
143
|
];
|
|
143
144
|
|
|
144
|
-
var Direction
|
|
145
|
-
(function(Direction2) {
|
|
145
|
+
var Direction = /* @__PURE__ */ ((Direction2) => {
|
|
146
146
|
Direction2["TOP_BOTTOM"] = "TB";
|
|
147
147
|
Direction2["BOTTOM_TOP"] = "BT";
|
|
148
148
|
Direction2["LEFT_RIGHT"] = "LR";
|
|
149
149
|
Direction2["RIGHT_LEFT"] = "RL";
|
|
150
|
-
|
|
150
|
+
return Direction2;
|
|
151
|
+
})(Direction || {});
|
|
151
152
|
|
|
152
153
|
const limiter = limiterFactory(10);
|
|
153
154
|
function useEntityStore() {
|
|
154
155
|
const catalogClient = useApi(catalogApiRef);
|
|
155
156
|
const state = useRef({
|
|
156
|
-
requestedEntities: new Set(),
|
|
157
|
-
outstandingEntities: new Map(),
|
|
158
|
-
cachedEntities: new Map()
|
|
157
|
+
requestedEntities: /* @__PURE__ */ new Set(),
|
|
158
|
+
outstandingEntities: /* @__PURE__ */ new Map(),
|
|
159
|
+
cachedEntities: /* @__PURE__ */ new Map()
|
|
159
160
|
});
|
|
160
161
|
const [entities, setEntities] = useState({});
|
|
161
162
|
const updateEntities = useCallback(() => {
|
|
162
|
-
const {cachedEntities, requestedEntities} = state.current;
|
|
163
|
+
const { cachedEntities, requestedEntities } = state.current;
|
|
163
164
|
const filteredEntities = {};
|
|
164
165
|
requestedEntities.forEach((entityRef) => {
|
|
165
166
|
const entity = cachedEntities.get(entityRef);
|
|
@@ -170,7 +171,7 @@ function useEntityStore() {
|
|
|
170
171
|
setEntities(filteredEntities);
|
|
171
172
|
}, [state, setEntities]);
|
|
172
173
|
const [asyncState, fetch] = useAsyncFn(async () => {
|
|
173
|
-
const {requestedEntities, outstandingEntities, cachedEntities} = state.current;
|
|
174
|
+
const { requestedEntities, outstandingEntities, cachedEntities } = state.current;
|
|
174
175
|
await Promise.all(Array.from(requestedEntities).map((entityRef) => limiter(async () => {
|
|
175
176
|
if (cachedEntities.has(entityRef)) {
|
|
176
177
|
return;
|
|
@@ -192,10 +193,10 @@ function useEntityStore() {
|
|
|
192
193
|
}
|
|
193
194
|
})));
|
|
194
195
|
}, [state, updateEntities]);
|
|
195
|
-
const {loading, error} = asyncState;
|
|
196
|
+
const { loading, error } = asyncState;
|
|
196
197
|
const requestEntities = useCallback((entityRefs) => {
|
|
197
198
|
const n = new Set(entityRefs);
|
|
198
|
-
const {requestedEntities} = state.current;
|
|
199
|
+
const { requestedEntities } = state.current;
|
|
199
200
|
if (n.size !== requestedEntities.size || Array.from(n).some((e) => !requestedEntities.has(e))) {
|
|
200
201
|
state.current.requestedEntities = n;
|
|
201
202
|
fetch();
|
|
@@ -212,12 +213,12 @@ function useEntityStore() {
|
|
|
212
213
|
|
|
213
214
|
function useEntityRelationGraph({
|
|
214
215
|
rootEntityRefs,
|
|
215
|
-
filter: {maxDepth = Number.POSITIVE_INFINITY, relations, kinds} = {}
|
|
216
|
+
filter: { maxDepth = Number.POSITIVE_INFINITY, relations, kinds } = {}
|
|
216
217
|
}) {
|
|
217
|
-
const {entities, loading, error, requestEntities} = useEntityStore();
|
|
218
|
+
const { entities, loading, error, requestEntities } = useEntityStore();
|
|
218
219
|
useEffect(() => {
|
|
219
|
-
const expectedEntities = new Set([...rootEntityRefs]);
|
|
220
|
-
const processedEntityRefs = new Set();
|
|
220
|
+
const expectedEntities = /* @__PURE__ */ new Set([...rootEntityRefs]);
|
|
221
|
+
const processedEntityRefs = /* @__PURE__ */ new Set();
|
|
221
222
|
let nextDepthRefQueue = [...rootEntityRefs];
|
|
222
223
|
let depth = 0;
|
|
223
224
|
while (nextDepthRefQueue.length > 0 && (!isFinite(maxDepth) || depth < maxDepth)) {
|
|
@@ -261,7 +262,7 @@ function useEntityRelationNodesAndEdges({
|
|
|
261
262
|
relationPairs = ALL_RELATION_PAIRS
|
|
262
263
|
}) {
|
|
263
264
|
const [nodesAndEdges, setNodesAndEdges] = useState({});
|
|
264
|
-
const {entities, loading, error} = useEntityRelationGraph({
|
|
265
|
+
const { entities, loading, error } = useEntityRelationGraph({
|
|
265
266
|
rootEntityRefs,
|
|
266
267
|
filter: {
|
|
267
268
|
maxDepth,
|
|
@@ -293,7 +294,7 @@ function useEntityRelationNodesAndEdges({
|
|
|
293
294
|
return node;
|
|
294
295
|
});
|
|
295
296
|
const edges = [];
|
|
296
|
-
const visitedNodes = new Set();
|
|
297
|
+
const visitedNodes = /* @__PURE__ */ new Set();
|
|
297
298
|
const nodeQueue = [...rootEntityRefs];
|
|
298
299
|
while (nodeQueue.length > 0) {
|
|
299
300
|
const entityRef = nodeQueue.pop();
|
|
@@ -338,7 +339,7 @@ function useEntityRelationNodesAndEdges({
|
|
|
338
339
|
});
|
|
339
340
|
}
|
|
340
341
|
}
|
|
341
|
-
setNodesAndEdges({nodes, edges});
|
|
342
|
+
setNodesAndEdges({ nodes, edges });
|
|
342
343
|
}, 100, [
|
|
343
344
|
entities,
|
|
344
345
|
rootEntityRefs,
|
|
@@ -401,7 +402,7 @@ const EntityRelationsGraph = ({
|
|
|
401
402
|
const classes = useStyles();
|
|
402
403
|
const rootEntityRefs = useMemo(() => (Array.isArray(rootEntityNames) ? rootEntityNames : [rootEntityNames]).map((e) => stringifyEntityRef(e)), [rootEntityNames]);
|
|
403
404
|
const errorApi = useApi(errorApiRef);
|
|
404
|
-
const {loading, error, nodes, edges} = useEntityRelationNodesAndEdges({
|
|
405
|
+
const { loading, error, nodes, edges } = useEntityRelationNodesAndEdges({
|
|
405
406
|
rootEntityRefs,
|
|
406
407
|
maxDepth,
|
|
407
408
|
unidirectional,
|
|
@@ -436,8 +437,7 @@ const EntityRelationsGraph = ({
|
|
|
436
437
|
};
|
|
437
438
|
|
|
438
439
|
const catalogGraphRouteRef = createRouteRef({
|
|
439
|
-
|
|
440
|
-
title: "Catalog Graph"
|
|
440
|
+
id: "catalog-graph"
|
|
441
441
|
});
|
|
442
442
|
const catalogEntityRouteRef = createExternalRouteRef({
|
|
443
443
|
id: "catalog-entity",
|
|
@@ -457,14 +457,14 @@ const catalogGraphPlugin = createPlugin({
|
|
|
457
457
|
const EntityCatalogGraphCard = catalogGraphPlugin.provide(createComponentExtension({
|
|
458
458
|
name: "EntityCatalogGraphCard",
|
|
459
459
|
component: {
|
|
460
|
-
lazy: () => import('./index-
|
|
460
|
+
lazy: () => import('./index-e657c147.esm.js').then((m) => m.CatalogGraphCard)
|
|
461
461
|
}
|
|
462
462
|
}));
|
|
463
463
|
const CatalogGraphPage = catalogGraphPlugin.provide(createRoutableExtension({
|
|
464
464
|
name: "CatalogGraphPage",
|
|
465
|
-
component: () => import('./index-
|
|
465
|
+
component: () => import('./index-b85eaf0a.esm.js').then((m) => m.CatalogGraphPage),
|
|
466
466
|
mountPoint: catalogGraphRouteRef
|
|
467
467
|
}));
|
|
468
468
|
|
|
469
469
|
export { ALL_RELATION_PAIRS as A, CatalogGraphPage as C, Direction as D, EntityRelationsGraph as E, catalogGraphRouteRef as a, EntityCatalogGraphCard as b, catalogEntityRouteRef as c, catalogGraphPlugin as d };
|
|
470
|
-
//# sourceMappingURL=index-
|
|
470
|
+
//# sourceMappingURL=index-d308609c.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-d308609c.esm.js","sources":["../../src/components/EntityRelationsGraph/CustomLabel.tsx","../../src/components/EntityRelationsGraph/EntityKindIcon.tsx","../../src/components/EntityRelationsGraph/CustomNode.tsx","../../src/components/EntityRelationsGraph/relations.ts","../../src/components/EntityRelationsGraph/types.ts","../../src/components/EntityRelationsGraph/useEntityStore.ts","../../src/components/EntityRelationsGraph/useEntityRelationGraph.ts","../../src/components/EntityRelationsGraph/useEntityRelationNodesAndEdges.ts","../../src/components/EntityRelationsGraph/EntityRelationsGraph.tsx","../../src/routes.ts","../../src/plugin.ts","../../src/extensions.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 */\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { BackstageTheme } from '@backstage/theme';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\nimport React from 'react';\nimport { EntityEdgeData } from './types';\nimport classNames from 'classnames';\n\nconst useStyles = makeStyles((theme: BackstageTheme) => ({\n text: {\n fill: theme.palette.textContrast,\n },\n secondary: {\n fill: theme.palette.textSubtle,\n },\n}));\n\nexport function CustomLabel({\n edge: { relations },\n}: DependencyGraphTypes.RenderLabelProps<EntityEdgeData>) {\n const classes = useStyles();\n return (\n <text className={classes.text} textAnchor=\"middle\">\n {relations.map((r, i) => (\n <tspan key={r} className={classNames(i > 0 && classes.secondary)}>\n {i > 0 && <tspan> / </tspan>}\n {r}\n </tspan>\n ))}\n </text>\n );\n}\n","/*\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 */\nimport { useApp } from '@backstage/core-plugin-api';\nimport WorkIcon from '@material-ui/icons/Work';\nimport React from 'react';\n\nexport function EntityKindIcon({\n kind,\n ...props\n}: {\n kind: string;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n className?: string;\n}) {\n const app = useApp();\n const Icon =\n app.getSystemIcon(`kind:${kind.toLocaleLowerCase('en-US')}`) ?? WorkIcon;\n return <Icon {...props} />;\n}\n","/*\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 */\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { formatEntityRefTitle } from '@backstage/plugin-catalog-react';\nimport { BackstageTheme } from '@backstage/theme';\nimport { makeStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { EntityKindIcon } from './EntityKindIcon';\nimport { EntityNodeData } from './types';\n\nconst useStyles = makeStyles((theme: BackstageTheme) => ({\n node: {\n fill: theme.palette.grey[300],\n stroke: theme.palette.grey[300],\n\n '&.primary': {\n fill: theme.palette.primary.light,\n stroke: theme.palette.primary.light,\n },\n '&.secondary': {\n fill: theme.palette.secondary.light,\n stroke: theme.palette.secondary.light,\n },\n },\n text: {\n fill: theme.palette.getContrastText(theme.palette.grey[300]),\n\n '&.primary': {\n fill: theme.palette.primary.contrastText,\n },\n '&.secondary': {\n fill: theme.palette.secondary.contrastText,\n },\n '&.focused': {\n fontWeight: 'bold',\n },\n },\n clickable: {\n cursor: 'pointer',\n },\n}));\n\nexport function CustomNode({\n node: {\n id,\n kind,\n namespace,\n name,\n color = 'default',\n focused,\n title,\n onClick,\n },\n}: DependencyGraphTypes.RenderNodeProps<EntityNodeData>) {\n const classes = useStyles();\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const idRef = useRef<SVGTextElement | null>(null);\n\n useLayoutEffect(() => {\n // set the width to the length of the ID\n if (idRef.current) {\n let { height: renderedHeight, width: renderedWidth } =\n idRef.current.getBBox();\n renderedHeight = Math.round(renderedHeight);\n renderedWidth = Math.round(renderedWidth);\n\n if (renderedHeight !== height || renderedWidth !== width) {\n setWidth(renderedWidth);\n setHeight(renderedHeight);\n }\n }\n }, [width, height]);\n\n const padding = 10;\n const iconSize = height;\n const paddedIconWidth = kind ? iconSize + padding : 0;\n const paddedWidth = paddedIconWidth + width + padding * 2;\n const paddedHeight = height + padding * 2;\n\n const displayTitle =\n title ??\n (kind && name && namespace\n ? formatEntityRefTitle({ kind, name, namespace })\n : id);\n\n return (\n <g onClick={onClick} className={classNames(onClick && classes.clickable)}>\n <rect\n className={classNames(\n classes.node,\n color === 'primary' && 'primary',\n color === 'secondary' && 'secondary',\n )}\n width={paddedWidth}\n height={paddedHeight}\n rx={10}\n />\n {kind && (\n <EntityKindIcon\n kind={kind}\n y={padding}\n x={padding}\n width={iconSize}\n height={iconSize}\n className={classNames(\n classes.text,\n focused && 'focused',\n color === 'primary' && 'primary',\n color === 'secondary' && 'secondary',\n )}\n />\n )}\n <text\n ref={idRef}\n className={classNames(\n classes.text,\n focused && 'focused',\n color === 'primary' && 'primary',\n color === 'secondary' && 'secondary',\n )}\n y={paddedHeight / 2}\n x={paddedIconWidth + (width + padding * 2) / 2}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {displayTitle}\n </text>\n </g>\n );\n}\n","/*\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 */\nimport {\n RELATION_API_CONSUMED_BY,\n RELATION_API_PROVIDED_BY,\n RELATION_CHILD_OF,\n RELATION_CONSUMES_API,\n RELATION_DEPENDENCY_OF,\n RELATION_DEPENDS_ON,\n RELATION_HAS_MEMBER,\n RELATION_HAS_PART,\n RELATION_MEMBER_OF,\n RELATION_OWNED_BY,\n RELATION_OWNER_OF,\n RELATION_PARENT_OF,\n RELATION_PART_OF,\n RELATION_PROVIDES_API,\n} from '@backstage/catalog-model';\n\n/**\n * A pair of two relations that describe the opposite of each other. The first\n * relation is considered as the primary relation.\n *\n * @public\n */\nexport type RelationPairs = [string, string][];\n\n// TODO: This file only contains the pairs for the build-in relations.\n// How to implement this when custom relations are used? Right now you can pass\n// the relations everywhere.\n// Another option is to move this into @backstage/catalog-model\n\n/**\n * A list of pairs of entity relations, used to define which relations are\n * merged together and which the primary relation is.\n *\n * @public\n */\nexport const ALL_RELATION_PAIRS: RelationPairs = [\n [RELATION_OWNER_OF, RELATION_OWNED_BY],\n [RELATION_CONSUMES_API, RELATION_API_CONSUMED_BY],\n [RELATION_API_PROVIDED_BY, RELATION_PROVIDES_API],\n [RELATION_HAS_PART, RELATION_PART_OF],\n [RELATION_PARENT_OF, RELATION_CHILD_OF],\n [RELATION_HAS_MEMBER, RELATION_MEMBER_OF],\n [RELATION_DEPENDS_ON, RELATION_DEPENDENCY_OF],\n];\n","/*\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 */\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { MouseEventHandler } from 'react';\n\n/**\n * Additional Data for entities\n */\nexport type EntityEdgeData = {\n /**\n * Up to two relations that are connecting an entity.\n */\n relations: string[];\n /**\n * Whether the entity is visible or not.\n */\n // Not used, but has to be non empty to draw a label at all!\n label: 'visible';\n};\n\n/**\n * Edge between two entities.\n *\n * @public\n */\nexport type EntityEdge = DependencyGraphTypes.DependencyEdge<EntityEdgeData>;\n\n/**\n * Additional data for Entity Node\n */\nexport type EntityNodeData = {\n /**\n * Name of the entity.\n */\n name: string;\n /**\n * Optional kind of the entity.\n */\n kind?: string;\n /**\n * Optional title of the entity.\n */\n title?: string;\n /**\n * Namespace of the entity.\n */\n namespace: string;\n /**\n * Whether the entity is focused, optional, defaults to false. Focused\n * entities are highlighted in the graph.\n */\n focused?: boolean;\n /**\n * Optional color of the entity, defaults to 'default'.\n */\n color?: 'primary' | 'secondary' | 'default';\n /**\n * Optional click handler.\n */\n onClick?: MouseEventHandler<unknown>;\n};\n\n/**\n * Node representing an entity.\n *\n * @public\n */\nexport type EntityNode = DependencyGraphTypes.DependencyNode<EntityNodeData>;\n\n/**\n * Render direction of the graph.\n *\n * @public\n */\nexport enum Direction {\n /**\n * Top to bottom.\n */\n TOP_BOTTOM = 'TB',\n /**\n * Bottom to top.\n */\n BOTTOM_TOP = 'BT',\n /**\n * Left to right.\n */\n LEFT_RIGHT = 'LR',\n /**\n * Right to left.\n */\n RIGHT_LEFT = 'RL',\n}\n","/*\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 */\nimport { Entity, parseEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport limiterFactory from 'p-limit';\nimport { Dispatch, useCallback, useRef, useState } from 'react';\nimport useAsyncFn from 'react-use/lib/useAsyncFn';\n\n// TODO: This is a good use case for a graphql API, once it is available in the\n// future.\n\nconst limiter = limiterFactory(10);\n\n/**\n * Ensures that a set of requested entities is loaded.\n */\nexport function useEntityStore(): {\n entities: { [ref: string]: Entity };\n loading: boolean;\n error?: Error;\n requestEntities: Dispatch<string[]>;\n} {\n const catalogClient = useApi(catalogApiRef);\n const state = useRef({\n requestedEntities: new Set<string>(),\n outstandingEntities: new Map<string, Promise<Entity | undefined>>(),\n cachedEntities: new Map<string, Entity>(),\n });\n const [entities, setEntities] = useState<{\n [ref: string]: Entity;\n }>({});\n\n const updateEntities = useCallback(() => {\n const { cachedEntities, requestedEntities } = state.current;\n const filteredEntities: { [ref: string]: Entity } = {};\n requestedEntities.forEach(entityRef => {\n const entity = cachedEntities.get(entityRef);\n\n if (entity) {\n filteredEntities[entityRef] = entity;\n }\n });\n setEntities(filteredEntities);\n }, [state, setEntities]);\n\n const [asyncState, fetch] = useAsyncFn(async () => {\n const { requestedEntities, outstandingEntities, cachedEntities } =\n state.current;\n\n await Promise.all(\n Array.from(requestedEntities).map(entityRef =>\n limiter(async () => {\n if (cachedEntities.has(entityRef)) {\n return;\n }\n\n if (outstandingEntities.has(entityRef)) {\n await outstandingEntities.get(entityRef);\n return;\n }\n\n const promise = catalogClient.getEntityByName(\n parseEntityRef(entityRef),\n );\n\n outstandingEntities.set(entityRef, promise);\n\n try {\n const entity = await promise;\n\n if (entity) {\n cachedEntities.set(entityRef, entity);\n updateEntities();\n }\n } finally {\n outstandingEntities.delete(entityRef);\n }\n }),\n ),\n );\n }, [state, updateEntities]);\n const { loading, error } = asyncState;\n\n const requestEntities = useCallback(\n (entityRefs: string[]) => {\n const n = new Set(entityRefs);\n const { requestedEntities } = state.current;\n\n if (\n n.size !== requestedEntities.size ||\n Array.from(n).some(e => !requestedEntities.has(e))\n ) {\n state.current.requestedEntities = n;\n fetch();\n updateEntities();\n }\n },\n [state, fetch, updateEntities],\n );\n\n return {\n entities,\n loading,\n error,\n requestEntities,\n };\n}\n","/*\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 */\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useEffect } from 'react';\nimport { useEntityStore } from './useEntityStore';\n\n/**\n * Discover the graph of entities connected by relations, starting from a set of\n * root entities. Filters are used to select which relations to includes.\n * Returns all discovered entities once they are loaded.\n */\nexport function useEntityRelationGraph({\n rootEntityRefs,\n filter: { maxDepth = Number.POSITIVE_INFINITY, relations, kinds } = {},\n}: {\n rootEntityRefs: string[];\n filter?: {\n maxDepth?: number;\n relations?: string[];\n kinds?: string[];\n };\n}): {\n entities?: { [ref: string]: Entity };\n loading: boolean;\n error?: Error;\n} {\n const { entities, loading, error, requestEntities } = useEntityStore();\n\n useEffect(() => {\n const expectedEntities = new Set([...rootEntityRefs]);\n const processedEntityRefs = new Set<string>();\n\n let nextDepthRefQueue = [...rootEntityRefs];\n let depth = 0;\n\n while (\n nextDepthRefQueue.length > 0 &&\n (!isFinite(maxDepth) || depth < maxDepth)\n ) {\n const entityRefQueue = nextDepthRefQueue;\n nextDepthRefQueue = [];\n\n while (entityRefQueue.length > 0) {\n const entityRef = entityRefQueue.shift()!;\n const entity = entities[entityRef];\n\n processedEntityRefs.add(entityRef);\n\n if (entity && entity.relations) {\n for (const rel of entity.relations) {\n if (\n (!relations || relations.includes(rel.type)) &&\n (!kinds ||\n kinds.includes(rel.target.kind.toLocaleLowerCase('en-US')))\n ) {\n const relationEntityRef = stringifyEntityRef(rel.target);\n\n if (!processedEntityRefs.has(relationEntityRef)) {\n nextDepthRefQueue.push(relationEntityRef);\n expectedEntities.add(relationEntityRef);\n }\n }\n }\n }\n }\n\n ++depth;\n }\n\n requestEntities([...expectedEntities]);\n }, [entities, rootEntityRefs, maxDepth, relations, kinds, requestEntities]);\n\n return {\n entities,\n loading,\n error,\n };\n}\n","/*\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 */\nimport {\n ENTITY_DEFAULT_NAMESPACE,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { MouseEvent, useState } from 'react';\nimport useDebounce from 'react-use/lib/useDebounce';\nimport { RelationPairs, ALL_RELATION_PAIRS } from './relations';\nimport { EntityEdge, EntityNode } from './types';\nimport { useEntityRelationGraph } from './useEntityRelationGraph';\n\n/**\n * Generate nodes and edges to render the entity graph.\n */\nexport function useEntityRelationNodesAndEdges({\n rootEntityRefs,\n maxDepth = Number.POSITIVE_INFINITY,\n unidirectional = true,\n mergeRelations = true,\n kinds,\n relations,\n onNodeClick,\n relationPairs = ALL_RELATION_PAIRS,\n}: {\n rootEntityRefs: string[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n kinds?: string[];\n relations?: string[];\n onNodeClick?: (value: EntityNode, event: MouseEvent<unknown>) => void;\n relationPairs?: RelationPairs;\n}): {\n loading: boolean;\n nodes?: EntityNode[];\n edges?: EntityEdge[];\n error?: Error;\n} {\n const [nodesAndEdges, setNodesAndEdges] = useState<{\n nodes?: EntityNode[];\n edges?: EntityEdge[];\n }>({});\n const { entities, loading, error } = useEntityRelationGraph({\n rootEntityRefs,\n filter: {\n maxDepth,\n kinds,\n relations,\n },\n });\n\n useDebounce(\n () => {\n if (!entities || Object.keys(entities).length === 0) {\n setNodesAndEdges({});\n return;\n }\n\n const nodes = Object.entries(entities).map(([entityRef, entity]) => {\n const focused = rootEntityRefs.includes(entityRef);\n const node: EntityNode = {\n id: entityRef,\n title: entity.metadata?.title ?? undefined,\n kind: entity.kind,\n name: entity.metadata.name,\n namespace: entity.metadata.namespace ?? ENTITY_DEFAULT_NAMESPACE,\n focused,\n color: focused ? 'secondary' : 'primary',\n };\n\n if (onNodeClick) {\n node.onClick = event => onNodeClick(node, event);\n }\n\n return node;\n });\n\n const edges: EntityEdge[] = [];\n const visitedNodes = new Set<string>();\n const nodeQueue = [...rootEntityRefs];\n\n while (nodeQueue.length > 0) {\n const entityRef = nodeQueue.pop()!;\n const entity = entities[entityRef];\n visitedNodes.add(entityRef);\n\n if (entity) {\n entity?.relations?.forEach(rel => {\n const targetRef = stringifyEntityRef(rel.target);\n\n // Check if the related entity should be displayed, if not, ignore\n // the relation too\n if (!entities[targetRef]) {\n return;\n }\n\n if (relations && !relations.includes(rel.type)) {\n return;\n }\n\n if (\n kinds &&\n !kinds.includes(rel.target.kind.toLocaleLowerCase('en-US'))\n ) {\n return;\n }\n\n if (!unidirectional || !visitedNodes.has(targetRef)) {\n if (mergeRelations) {\n const pair = relationPairs.find(\n ([l, r]) => l === rel.type || r === rel.type,\n ) ?? [rel.type];\n const [left] = pair;\n\n edges.push({\n from: left === rel.type ? entityRef : targetRef,\n to: left === rel.type ? targetRef : entityRef,\n relations: pair,\n label: 'visible',\n });\n } else {\n edges.push({\n from: entityRef,\n to: targetRef,\n relations: [rel.type],\n label: 'visible',\n });\n }\n }\n\n if (!visitedNodes.has(targetRef)) {\n nodeQueue.push(targetRef);\n visitedNodes.add(targetRef);\n }\n });\n }\n }\n\n setNodesAndEdges({ nodes, edges });\n },\n 100,\n [\n entities,\n rootEntityRefs,\n kinds,\n relations,\n unidirectional,\n mergeRelations,\n onNodeClick,\n relationPairs,\n ],\n );\n\n return {\n loading,\n error,\n ...nodesAndEdges,\n };\n}\n","/*\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 */\nimport { EntityName, stringifyEntityRef } from '@backstage/catalog-model';\nimport {\n DependencyGraph,\n DependencyGraphTypes,\n} from '@backstage/core-components';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { CircularProgress, makeStyles, useTheme } from '@material-ui/core';\nimport classNames from 'classnames';\nimport React, { MouseEvent, useEffect, useMemo } from 'react';\nimport { CustomLabel } from './CustomLabel';\nimport { CustomNode } from './CustomNode';\nimport { ALL_RELATION_PAIRS, RelationPairs } from './relations';\nimport { Direction, EntityNode } from './types';\nimport { useEntityRelationNodesAndEdges } from './useEntityRelationNodesAndEdges';\n\nconst useStyles = makeStyles(theme => ({\n progress: {\n position: 'absolute',\n left: '50%',\n top: '50%',\n marginLeft: '-20px',\n marginTop: '-20px',\n },\n container: {\n position: 'relative',\n width: '100%',\n display: 'flex',\n flexDirection: 'column',\n },\n graph: {\n width: '100%',\n flex: 1,\n // Right now there is no good way to style edges between nodes, we have to\n // fallback to these hacks:\n '& path[marker-end]': {\n transition: 'filter 0.1s ease-in-out',\n },\n '& path[marker-end]:hover': {\n filter: `drop-shadow(2px 2px 4px ${theme.palette.primary.dark});`,\n },\n '& g[data-testid=label]': {\n transition: 'transform 0s',\n },\n },\n}));\n\n/**\n * Core building block for custom entity relations diagrams.\n *\n * @public\n */\nexport const EntityRelationsGraph = ({\n rootEntityNames,\n maxDepth = Number.POSITIVE_INFINITY,\n unidirectional = true,\n mergeRelations = true,\n kinds,\n relations,\n direction = Direction.LEFT_RIGHT,\n onNodeClick,\n relationPairs = ALL_RELATION_PAIRS,\n className,\n zoom = 'enabled',\n}: {\n rootEntityNames: EntityName | EntityName[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n kinds?: string[];\n relations?: string[];\n direction?: Direction;\n onNodeClick?: (value: EntityNode, event: MouseEvent<unknown>) => void;\n relationPairs?: RelationPairs;\n className?: string;\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n}) => {\n const theme = useTheme();\n const classes = useStyles();\n const rootEntityRefs = useMemo(\n () =>\n (Array.isArray(rootEntityNames)\n ? rootEntityNames\n : [rootEntityNames]\n ).map(e => stringifyEntityRef(e)),\n [rootEntityNames],\n );\n const errorApi = useApi(errorApiRef);\n const { loading, error, nodes, edges } = useEntityRelationNodesAndEdges({\n rootEntityRefs,\n maxDepth,\n unidirectional,\n mergeRelations,\n kinds,\n relations,\n onNodeClick,\n relationPairs,\n });\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [errorApi, error]);\n\n return (\n <div className={classNames(classes.container, className)}>\n {loading && <CircularProgress className={classes.progress} />}\n {nodes && edges && (\n <DependencyGraph\n nodes={nodes}\n edges={edges}\n renderNode={CustomNode}\n renderLabel={CustomLabel}\n direction={direction}\n className={classes.graph}\n paddingX={theme.spacing(4)}\n paddingY={theme.spacing(4)}\n labelPosition={DependencyGraphTypes.LabelPosition.RIGHT}\n labelOffset={theme.spacing(1)}\n zoom={zoom}\n />\n )}\n </div>\n );\n};\n","/*\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 */\nimport {\n createExternalRouteRef,\n createRouteRef,\n} from '@backstage/core-plugin-api';\n\n/**\n * Route pointing to the standalone catalog graph page.\n *\n * @public\n */\nexport const catalogGraphRouteRef = createRouteRef({\n id: 'catalog-graph',\n});\n\n/**\n * Route pointing to the entity page.\n * Used to navigate from the graph to an entity.\n *\n * @public\n */\nexport const catalogEntityRouteRef = createExternalRouteRef({\n id: 'catalog-entity',\n params: ['namespace', 'kind', 'name'],\n});\n","/*\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 */\nimport { createPlugin } from '@backstage/core-plugin-api';\nimport { catalogEntityRouteRef, catalogGraphRouteRef } from './routes';\n\n/**\n * Catalog Graph Plugin instance.\n * @public\n */\nexport const catalogGraphPlugin = createPlugin({\n id: 'catalog-graph',\n routes: {\n catalogGraph: catalogGraphRouteRef,\n },\n externalRoutes: {\n catalogEntity: catalogEntityRouteRef,\n },\n});\n","/*\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 */\nimport {\n createComponentExtension,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\nimport { catalogGraphPlugin } from './plugin';\nimport { catalogGraphRouteRef } from './routes';\n\n/**\n * A card that displays the directly related entities to the current entity.\n *\n * @public\n */\nexport const EntityCatalogGraphCard = catalogGraphPlugin.provide(\n createComponentExtension({\n name: 'EntityCatalogGraphCard',\n component: {\n lazy: () =>\n import('./components/CatalogGraphCard').then(m => m.CatalogGraphCard),\n },\n }),\n);\n\n/**\n * A standalone page that can be added to your application providing a viewer\n * for your entities and their relations.\n *\n * @public\n */\nexport const CatalogGraphPage = catalogGraphPlugin.provide(\n createRoutableExtension({\n name: 'CatalogGraphPage',\n component: () =>\n import('./components/CatalogGraphPage').then(m => m.CatalogGraphPage),\n mountPoint: catalogGraphRouteRef,\n }),\n);\n"],"names":["useStyles","makeStyles"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAMA,cAAY,WAAW,CAAC;AAA2B,EACvD,MAAM;AAAA,IACJ,MAAM,MAAM,QAAQ;AAAA;AAAA,EAEtB,WAAW;AAAA,IACT,MAAM,MAAM,QAAQ;AAAA;AAAA;qBAII;AAAA,EAC1B,MAAM,EAAE;AAAA,GACgD;AACxD,QAAM,UAAUA;AAChB,6CACG,QAAD;AAAA,IAAM,WAAW,QAAQ;AAAA,IAAM,YAAW;AAAA,KACvC,UAAU,IAAI,CAAC,GAAG,0CAChB,SAAD;AAAA,IAAO,KAAK;AAAA,IAAG,WAAW,WAAW,IAAI,KAAK,QAAQ;AAAA,KACnD,IAAI,yCAAM,SAAD,MAAO,QAChB;AAAA;;wBCrBoB;AAAA,EAC7B;AAAA,KACG;AAAA,GAQF;AA7BH;AA8BE,QAAM,MAAM;AACZ,QAAM,OACJ,UAAI,cAAc,QAAQ,KAAK,kBAAkB,gBAAjD,YAAgE;AAClE,6CAAQ,MAAD;AAAA,OAAU;AAAA;AAAA;;ACTnB,MAAMA,cAAYC,aAAW,CAAC;AAA2B,EACvD,MAAM;AAAA,IACJ,MAAM,MAAM,QAAQ,KAAK;AAAA,IACzB,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';
|
|
8
8
|
import { useNavigate } from 'react-router';
|
|
9
|
-
import { A as ALL_RELATION_PAIRS, D as Direction, c as catalogEntityRouteRef, a as catalogGraphRouteRef, E as EntityRelationsGraph } from './index-
|
|
9
|
+
import { A as ALL_RELATION_PAIRS, D as Direction, c as catalogEntityRouteRef, a as catalogGraphRouteRef, E as EntityRelationsGraph } from './index-d308609c.esm.js';
|
|
10
10
|
import 'classnames';
|
|
11
11
|
import '@material-ui/core/styles/makeStyles';
|
|
12
12
|
import '@material-ui/core/styles';
|
|
13
13
|
import '@material-ui/icons/Work';
|
|
14
|
-
import 'react-use';
|
|
14
|
+
import 'react-use/lib/useDebounce';
|
|
15
15
|
import 'p-limit';
|
|
16
|
+
import 'react-use/lib/useAsyncFn';
|
|
16
17
|
|
|
17
18
|
const useStyles = makeStyles({
|
|
18
|
-
card: ({height}) => ({
|
|
19
|
+
card: ({ height }) => ({
|
|
19
20
|
display: "flex",
|
|
20
21
|
flexDirection: "column",
|
|
21
22
|
maxHeight: height,
|
|
@@ -39,12 +40,12 @@ const CatalogGraphCard = ({
|
|
|
39
40
|
title = "Relations",
|
|
40
41
|
zoom = "enable-on-click"
|
|
41
42
|
}) => {
|
|
42
|
-
const {entity} = useEntity();
|
|
43
|
+
const { entity } = useEntity();
|
|
43
44
|
const entityName = getEntityName(entity);
|
|
44
45
|
const catalogEntityRoute = useRouteRef(catalogEntityRouteRef);
|
|
45
46
|
const catalogGraphRoute = useRouteRef(catalogGraphRouteRef);
|
|
46
47
|
const navigate = useNavigate();
|
|
47
|
-
const classes = useStyles({height});
|
|
48
|
+
const classes = useStyles({ height });
|
|
48
49
|
const analytics = useAnalytics();
|
|
49
50
|
const onNodeClick = useCallback((node, _) => {
|
|
50
51
|
var _a;
|
|
@@ -54,10 +55,10 @@ const CatalogGraphCard = ({
|
|
|
54
55
|
namespace: nodeEntityName.namespace.toLocaleLowerCase("en-US"),
|
|
55
56
|
name: nodeEntityName.name
|
|
56
57
|
});
|
|
57
|
-
analytics.captureEvent("click", (_a = node.title) != null ? _a : formatEntityRefTitle(nodeEntityName), {attributes: {to: path}});
|
|
58
|
+
analytics.captureEvent("click", (_a = node.title) != null ? _a : formatEntityRefTitle(nodeEntityName), { attributes: { to: path } });
|
|
58
59
|
navigate(path);
|
|
59
60
|
}, [catalogEntityRoute, navigate, analytics]);
|
|
60
|
-
const catalogGraphParams = qs.stringify({rootEntityRefs: [stringifyEntityRef(entity)]}, {arrayFormat: "brackets", addQueryPrefix: true});
|
|
61
|
+
const catalogGraphParams = qs.stringify({ rootEntityRefs: [stringifyEntityRef(entity)] }, { arrayFormat: "brackets", addQueryPrefix: true });
|
|
61
62
|
const catalogGraphUrl = `${catalogGraphRoute()}${catalogGraphParams}`;
|
|
62
63
|
return /* @__PURE__ */ React.createElement(InfoCard, {
|
|
63
64
|
title,
|
|
@@ -84,4 +85,4 @@ const CatalogGraphCard = ({
|
|
|
84
85
|
};
|
|
85
86
|
|
|
86
87
|
export { CatalogGraphCard };
|
|
87
|
-
//# sourceMappingURL=index-
|
|
88
|
+
//# sourceMappingURL=index-e657c147.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-e657c147.esm.js","sources":["../../src/components/CatalogGraphCard/CatalogGraphCard.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 */\nimport {\n getEntityName,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { InfoCard, InfoCardVariants } from '@backstage/core-components';\nimport { useAnalytics, useRouteRef } from '@backstage/core-plugin-api';\nimport {\n formatEntityRefTitle,\n useEntity,\n} from '@backstage/plugin-catalog-react';\nimport { makeStyles, Theme } from '@material-ui/core';\nimport qs from 'qs';\nimport React, { MouseEvent, useCallback } from 'react';\nimport { useNavigate } from 'react-router';\nimport { catalogEntityRouteRef, catalogGraphRouteRef } from '../../routes';\nimport {\n ALL_RELATION_PAIRS,\n Direction,\n EntityNode,\n EntityRelationsGraph,\n RelationPairs,\n} from '../EntityRelationsGraph';\n\nconst useStyles = makeStyles<Theme, { height: number | undefined }>({\n card: ({ height }) => ({\n display: 'flex',\n flexDirection: 'column',\n maxHeight: height,\n minHeight: height,\n }),\n graph: {\n flex: 1,\n minHeight: 0,\n },\n});\n\nexport const CatalogGraphCard = ({\n variant = 'gridItem',\n relationPairs = ALL_RELATION_PAIRS,\n maxDepth = 1,\n unidirectional = true,\n mergeRelations = true,\n kinds,\n relations,\n direction = Direction.LEFT_RIGHT,\n height,\n title = 'Relations',\n zoom = 'enable-on-click',\n}: {\n variant?: InfoCardVariants;\n relationPairs?: RelationPairs;\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n kinds?: string[];\n relations?: string[];\n direction?: Direction;\n height?: number;\n title?: string;\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n}) => {\n const { entity } = useEntity();\n const entityName = getEntityName(entity);\n const catalogEntityRoute = useRouteRef(catalogEntityRouteRef);\n const catalogGraphRoute = useRouteRef(catalogGraphRouteRef);\n const navigate = useNavigate();\n const classes = useStyles({ height });\n const analytics = useAnalytics();\n\n const onNodeClick = useCallback(\n (node: EntityNode, _: MouseEvent<unknown>) => {\n const nodeEntityName = parseEntityRef(node.id);\n const path = catalogEntityRoute({\n kind: nodeEntityName.kind.toLocaleLowerCase('en-US'),\n namespace: nodeEntityName.namespace.toLocaleLowerCase('en-US'),\n name: nodeEntityName.name,\n });\n analytics.captureEvent(\n 'click',\n node.title ?? formatEntityRefTitle(nodeEntityName),\n { attributes: { to: path } },\n );\n navigate(path);\n },\n [catalogEntityRoute, navigate, analytics],\n );\n\n const catalogGraphParams = qs.stringify(\n { rootEntityRefs: [stringifyEntityRef(entity)] },\n { arrayFormat: 'brackets', addQueryPrefix: true },\n );\n const catalogGraphUrl = `${catalogGraphRoute()}${catalogGraphParams}`;\n\n return (\n <InfoCard\n title={title}\n cardClassName={classes.card}\n variant={variant}\n noPadding\n deepLink={{\n title: 'View graph',\n link: catalogGraphUrl,\n }}\n >\n <EntityRelationsGraph\n rootEntityNames={entityName}\n maxDepth={maxDepth}\n unidirectional={unidirectional}\n mergeRelations={mergeRelations}\n kinds={kinds}\n relations={relations}\n direction={direction}\n onNodeClick={onNodeClick}\n className={classes.graph}\n relationPairs={relationPairs}\n zoom={zoom}\n />\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAM,YAAY,WAAkD;AAAA,EAClE,MAAM,CAAC,EAAE;AAAc,IACrB,SAAS;AAAA,IACT,eAAe;AAAA,IACf,WAAW;AAAA,IACX,WAAW;AAAA;AAAA,EAEb,OAAO;AAAA,IACL,MAAM;AAAA,IACN,WAAW;AAAA;AAAA;MAIF,mBAAmB,CAAC;AAAA,EAC/B,UAAU;AAAA,EACV,gBAAgB;AAAA,EAChB,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,iBAAiB;AAAA,EACjB;AAAA,EACA;AAAA,EACA,YAAY,UAAU;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,EACR,OAAO;AAAA,MAaH;AACJ,QAAM,EAAE,WAAW;AACnB,QAAM,aAAa,cAAc;AACjC,QAAM,qBAAqB,YAAY;AACvC,QAAM,oBAAoB,YAAY;AACtC,QAAM,WAAW;AACjB,QAAM,UAAU,UAAU,EAAE;AAC5B,QAAM,YAAY;AAElB,QAAM,cAAc,YAClB,CAAC,MAAkB,MAA2B;AAtFlD;AAuFM,UAAM,iBAAiB,eAAe,KAAK;AAC3C,UAAM,OAAO,mBAAmB;AAAA,MAC9B,MAAM,eAAe,KAAK,kBAAkB;AAAA,MAC5C,WAAW,eAAe,UAAU,kBAAkB;AAAA,MACtD,MAAM,eAAe;AAAA;AAEvB,cAAU,aACR,SACA,WAAK,UAAL,YAAc,qBAAqB,iBACnC,EAAE,YAAY,EAAE,IAAI;AAEtB,aAAS;AAAA,KAEX,CAAC,oBAAoB,UAAU;AAGjC,QAAM,qBAAqB,GAAG,UAC5B,EAAE,gBAAgB,CAAC,mBAAmB,YACtC,EAAE,aAAa,YAAY,gBAAgB;AAE7C,QAAM,kBAAkB,GAAG,sBAAsB;AAEjD,6CACG,UAAD;AAAA,IACE;AAAA,IACA,eAAe,QAAQ;AAAA,IACvB;AAAA,IACA,WAAS;AAAA,IACT,UAAU;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA;AAAA,yCAGP,sBAAD;AAAA,IACE,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW,QAAQ;AAAA,IACnB;AAAA,IACA;AAAA;AAAA;;;;"}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as ALL_RELATION_PAIRS, C as CatalogGraphPage, D as Direction, b as EntityCatalogGraphCard, E as EntityRelationsGraph, d as catalogGraphPlugin, a as catalogGraphRouteRef } from './esm/index-
|
|
1
|
+
export { A as ALL_RELATION_PAIRS, C as CatalogGraphPage, D as Direction, b as EntityCatalogGraphCard, E as EntityRelationsGraph, d as catalogGraphPlugin, a as catalogGraphRouteRef } from './esm/index-d308609c.esm.js';
|
|
2
2
|
import '@backstage/catalog-model';
|
|
3
3
|
import '@backstage/core-components';
|
|
4
4
|
import '@backstage/core-plugin-api';
|
|
@@ -9,6 +9,7 @@ import '@material-ui/core/styles/makeStyles';
|
|
|
9
9
|
import '@backstage/plugin-catalog-react';
|
|
10
10
|
import '@material-ui/core/styles';
|
|
11
11
|
import '@material-ui/icons/Work';
|
|
12
|
-
import 'react-use';
|
|
12
|
+
import 'react-use/lib/useDebounce';
|
|
13
13
|
import 'p-limit';
|
|
14
|
+
import 'react-use/lib/useAsyncFn';
|
|
14
15
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@backstage/plugin-catalog-graph",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5",
|
|
4
4
|
"main": "dist/index.esm.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,30 +21,31 @@
|
|
|
21
21
|
"clean": "backstage-cli clean"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@backstage/catalog-client": "^0.5.
|
|
25
|
-
"@backstage/catalog-model": "^0.9.
|
|
26
|
-
"@backstage/core-components": "^0.
|
|
27
|
-
"@backstage/core-plugin-api": "^0.1
|
|
28
|
-
"@backstage/plugin-catalog-react": "^0.6.
|
|
29
|
-
"@backstage/theme": "^0.2.
|
|
24
|
+
"@backstage/catalog-client": "^0.5.3",
|
|
25
|
+
"@backstage/catalog-model": "^0.9.7",
|
|
26
|
+
"@backstage/core-components": "^0.8.3",
|
|
27
|
+
"@backstage/core-plugin-api": "^0.4.1",
|
|
28
|
+
"@backstage/plugin-catalog-react": "^0.6.10",
|
|
29
|
+
"@backstage/theme": "^0.2.14",
|
|
30
30
|
"@material-ui/core": "^4.12.2",
|
|
31
31
|
"@material-ui/icons": "^4.9.1",
|
|
32
32
|
"@material-ui/lab": "4.0.0-alpha.57",
|
|
33
|
-
"@types/react": "*",
|
|
34
33
|
"classnames": "^2.3.1",
|
|
35
34
|
"lodash": "^4.17.15",
|
|
36
35
|
"p-limit": "^3.1.0",
|
|
37
36
|
"qs": "^6.9.4",
|
|
38
|
-
"react": "^16.13.1",
|
|
39
|
-
"react-dom": "^16.13.1",
|
|
40
37
|
"react-router": "6.0.0-beta.0",
|
|
41
38
|
"react-use": "^17.2.4"
|
|
42
39
|
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@types/react": "^16.13.1 || ^17.0.0",
|
|
42
|
+
"react": "^16.13.1 || ^17.0.0"
|
|
43
|
+
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@backstage/cli": "^0.
|
|
45
|
-
"@backstage/core-app-api": "^0.1
|
|
46
|
-
"@backstage/dev-utils": "^0.2.
|
|
47
|
-
"@backstage/test-utils": "^0.1
|
|
45
|
+
"@backstage/cli": "^0.10.5",
|
|
46
|
+
"@backstage/core-app-api": "^0.3.1",
|
|
47
|
+
"@backstage/dev-utils": "^0.2.16",
|
|
48
|
+
"@backstage/test-utils": "^0.2.1",
|
|
48
49
|
"@testing-library/jest-dom": "^5.10.1",
|
|
49
50
|
"@testing-library/react": "^11.2.5",
|
|
50
51
|
"@testing-library/react-hooks": "^7.0.2",
|
|
@@ -54,5 +55,5 @@
|
|
|
54
55
|
"files": [
|
|
55
56
|
"dist"
|
|
56
57
|
],
|
|
57
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ffdb98aa2973366d48ff1774a7f892bc0c926e7e"
|
|
58
59
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-755cebab.esm.js","sources":["../../src/components/EntityRelationsGraph/CustomLabel.tsx","../../src/components/EntityRelationsGraph/EntityKindIcon.tsx","../../src/components/EntityRelationsGraph/CustomNode.tsx","../../src/components/EntityRelationsGraph/relations.ts","../../src/components/EntityRelationsGraph/types.ts","../../src/components/EntityRelationsGraph/useEntityStore.ts","../../src/components/EntityRelationsGraph/useEntityRelationGraph.ts","../../src/components/EntityRelationsGraph/useEntityRelationNodesAndEdges.ts","../../src/components/EntityRelationsGraph/EntityRelationsGraph.tsx","../../src/routes.ts","../../src/plugin.ts","../../src/extensions.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 */\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { BackstageTheme } from '@backstage/theme';\nimport makeStyles from '@material-ui/core/styles/makeStyles';\nimport React from 'react';\nimport { EntityEdgeData } from './types';\nimport classNames from 'classnames';\n\nconst useStyles = makeStyles((theme: BackstageTheme) => ({\n text: {\n fill: theme.palette.textContrast,\n },\n secondary: {\n fill: theme.palette.textSubtle,\n },\n}));\n\nexport function CustomLabel({\n edge: { relations },\n}: DependencyGraphTypes.RenderLabelProps<EntityEdgeData>) {\n const classes = useStyles();\n return (\n <text className={classes.text} textAnchor=\"middle\">\n {relations.map((r, i) => (\n <tspan key={r} className={classNames(i > 0 && classes.secondary)}>\n {i > 0 && <tspan> / </tspan>}\n {r}\n </tspan>\n ))}\n </text>\n );\n}\n","/*\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 */\nimport { useApp } from '@backstage/core-plugin-api';\nimport WorkIcon from '@material-ui/icons/Work';\nimport React from 'react';\n\nexport function EntityKindIcon({\n kind,\n ...props\n}: {\n kind: string;\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n className?: string;\n}) {\n const app = useApp();\n const Icon =\n app.getSystemIcon(`kind:${kind.toLocaleLowerCase('en-US')}`) ?? WorkIcon;\n return <Icon {...props} />;\n}\n","/*\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 */\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { formatEntityRefTitle } from '@backstage/plugin-catalog-react';\nimport { BackstageTheme } from '@backstage/theme';\nimport { makeStyles } from '@material-ui/core/styles';\nimport classNames from 'classnames';\nimport React, { useLayoutEffect, useRef, useState } from 'react';\nimport { EntityKindIcon } from './EntityKindIcon';\nimport { EntityNodeData } from './types';\n\nconst useStyles = makeStyles((theme: BackstageTheme) => ({\n node: {\n fill: theme.palette.grey[300],\n stroke: theme.palette.grey[300],\n\n '&.primary': {\n fill: theme.palette.primary.light,\n stroke: theme.palette.primary.light,\n },\n '&.secondary': {\n fill: theme.palette.secondary.light,\n stroke: theme.palette.secondary.light,\n },\n },\n text: {\n fill: theme.palette.getContrastText(theme.palette.grey[300]),\n\n '&.primary': {\n fill: theme.palette.primary.contrastText,\n },\n '&.secondary': {\n fill: theme.palette.secondary.contrastText,\n },\n '&.focused': {\n fontWeight: 'bold',\n },\n },\n clickable: {\n cursor: 'pointer',\n },\n}));\n\nexport function CustomNode({\n node: {\n id,\n kind,\n namespace,\n name,\n color = 'default',\n focused,\n title,\n onClick,\n },\n}: DependencyGraphTypes.RenderNodeProps<EntityNodeData>) {\n const classes = useStyles();\n const [width, setWidth] = useState(0);\n const [height, setHeight] = useState(0);\n const idRef = useRef<SVGTextElement | null>(null);\n\n useLayoutEffect(() => {\n // set the width to the length of the ID\n if (idRef.current) {\n let { height: renderedHeight, width: renderedWidth } =\n idRef.current.getBBox();\n renderedHeight = Math.round(renderedHeight);\n renderedWidth = Math.round(renderedWidth);\n\n if (renderedHeight !== height || renderedWidth !== width) {\n setWidth(renderedWidth);\n setHeight(renderedHeight);\n }\n }\n }, [width, height]);\n\n const padding = 10;\n const iconSize = height;\n const paddedIconWidth = kind ? iconSize + padding : 0;\n const paddedWidth = paddedIconWidth + width + padding * 2;\n const paddedHeight = height + padding * 2;\n\n const displayTitle =\n title ??\n (kind && name && namespace\n ? formatEntityRefTitle({ kind, name, namespace })\n : id);\n\n return (\n <g onClick={onClick} className={classNames(onClick && classes.clickable)}>\n <rect\n className={classNames(\n classes.node,\n color === 'primary' && 'primary',\n color === 'secondary' && 'secondary',\n )}\n width={paddedWidth}\n height={paddedHeight}\n rx={10}\n />\n {kind && (\n <EntityKindIcon\n kind={kind}\n y={padding}\n x={padding}\n width={iconSize}\n height={iconSize}\n className={classNames(\n classes.text,\n focused && 'focused',\n color === 'primary' && 'primary',\n color === 'secondary' && 'secondary',\n )}\n />\n )}\n <text\n ref={idRef}\n className={classNames(\n classes.text,\n focused && 'focused',\n color === 'primary' && 'primary',\n color === 'secondary' && 'secondary',\n )}\n y={paddedHeight / 2}\n x={paddedIconWidth + (width + padding * 2) / 2}\n textAnchor=\"middle\"\n alignmentBaseline=\"middle\"\n >\n {displayTitle}\n </text>\n </g>\n );\n}\n","/*\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 */\nimport {\n RELATION_API_CONSUMED_BY,\n RELATION_API_PROVIDED_BY,\n RELATION_CHILD_OF,\n RELATION_CONSUMES_API,\n RELATION_DEPENDENCY_OF,\n RELATION_DEPENDS_ON,\n RELATION_HAS_MEMBER,\n RELATION_HAS_PART,\n RELATION_MEMBER_OF,\n RELATION_OWNED_BY,\n RELATION_OWNER_OF,\n RELATION_PARENT_OF,\n RELATION_PART_OF,\n RELATION_PROVIDES_API,\n} from '@backstage/catalog-model';\n\n/**\n * A pair of two relations that describe the opposite of each other. The first\n * relation is considered as the primary relation.\n *\n * @public\n */\nexport type RelationPairs = [string, string][];\n\n// TODO: This file only contains the pairs for the build-in relations.\n// How to implement this when custom relations are used? Right now you can pass\n// the relations everywhere.\n// Another option is to move this into @backstage/catalog-model\n\n/**\n * A list of pairs of entity relations, used to define which relations are\n * merged together and which the primary relation is.\n *\n * @public\n */\nexport const ALL_RELATION_PAIRS: RelationPairs = [\n [RELATION_OWNER_OF, RELATION_OWNED_BY],\n [RELATION_CONSUMES_API, RELATION_API_CONSUMED_BY],\n [RELATION_API_PROVIDED_BY, RELATION_PROVIDES_API],\n [RELATION_HAS_PART, RELATION_PART_OF],\n [RELATION_PARENT_OF, RELATION_CHILD_OF],\n [RELATION_HAS_MEMBER, RELATION_MEMBER_OF],\n [RELATION_DEPENDS_ON, RELATION_DEPENDENCY_OF],\n];\n","/*\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 */\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { MouseEventHandler } from 'react';\n\n/**\n * Additional Data for entities\n */\nexport type EntityEdgeData = {\n /**\n * Up to two relations that are connecting an entity.\n */\n relations: string[];\n /**\n * Whether the entity is visible or not.\n */\n // Not used, but has to be non empty to draw a label at all!\n label: 'visible';\n};\n\n/**\n * Edge between two entities.\n *\n * @public\n */\nexport type EntityEdge = DependencyGraphTypes.DependencyEdge<EntityEdgeData>;\n\n/**\n * Additional data for Entity Node\n */\nexport type EntityNodeData = {\n /**\n * Name of the entity.\n */\n name: string;\n /**\n * Optional kind of the entity.\n */\n kind?: string;\n /**\n * Optional title of the entity.\n */\n title?: string;\n /**\n * Namespace of the entity.\n */\n namespace: string;\n /**\n * Whether the entity is focused, optional, defaults to false. Focused\n * entities are highlighted in the graph.\n */\n focused?: boolean;\n /**\n * Optional color of the entity, defaults to 'default'.\n */\n color?: 'primary' | 'secondary' | 'default';\n /**\n * Optional click handler.\n */\n onClick?: MouseEventHandler<unknown>;\n};\n\n/**\n * Node representing an entity.\n *\n * @public\n */\nexport type EntityNode = DependencyGraphTypes.DependencyNode<EntityNodeData>;\n\n/**\n * Render direction of the graph.\n *\n * @public\n */\nexport enum Direction {\n /**\n * Top to bottom.\n */\n TOP_BOTTOM = 'TB',\n /**\n * Bottom to top.\n */\n BOTTOM_TOP = 'BT',\n /**\n * Left to right.\n */\n LEFT_RIGHT = 'LR',\n /**\n * Right to left.\n */\n RIGHT_LEFT = 'RL',\n}\n","/*\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 */\nimport { Entity, parseEntityRef } from '@backstage/catalog-model';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport limiterFactory from 'p-limit';\nimport { Dispatch, useCallback, useRef, useState } from 'react';\nimport { useAsyncFn } from 'react-use';\n\n// TODO: This is a good use case for a graphql API, once it is available in the\n// future.\n\nconst limiter = limiterFactory(10);\n\n/**\n * Ensures that a set of requested entities is loaded.\n */\nexport function useEntityStore(): {\n entities: { [ref: string]: Entity };\n loading: boolean;\n error?: Error;\n requestEntities: Dispatch<string[]>;\n} {\n const catalogClient = useApi(catalogApiRef);\n const state = useRef({\n requestedEntities: new Set<string>(),\n outstandingEntities: new Map<string, Promise<Entity | undefined>>(),\n cachedEntities: new Map<string, Entity>(),\n });\n const [entities, setEntities] = useState<{\n [ref: string]: Entity;\n }>({});\n\n const updateEntities = useCallback(() => {\n const { cachedEntities, requestedEntities } = state.current;\n const filteredEntities: { [ref: string]: Entity } = {};\n requestedEntities.forEach(entityRef => {\n const entity = cachedEntities.get(entityRef);\n\n if (entity) {\n filteredEntities[entityRef] = entity;\n }\n });\n setEntities(filteredEntities);\n }, [state, setEntities]);\n\n const [asyncState, fetch] = useAsyncFn(async () => {\n const { requestedEntities, outstandingEntities, cachedEntities } =\n state.current;\n\n await Promise.all(\n Array.from(requestedEntities).map(entityRef =>\n limiter(async () => {\n if (cachedEntities.has(entityRef)) {\n return;\n }\n\n if (outstandingEntities.has(entityRef)) {\n await outstandingEntities.get(entityRef);\n return;\n }\n\n const promise = catalogClient.getEntityByName(\n parseEntityRef(entityRef),\n );\n\n outstandingEntities.set(entityRef, promise);\n\n try {\n const entity = await promise;\n\n if (entity) {\n cachedEntities.set(entityRef, entity);\n updateEntities();\n }\n } finally {\n outstandingEntities.delete(entityRef);\n }\n }),\n ),\n );\n }, [state, updateEntities]);\n const { loading, error } = asyncState;\n\n const requestEntities = useCallback(\n (entityRefs: string[]) => {\n const n = new Set(entityRefs);\n const { requestedEntities } = state.current;\n\n if (\n n.size !== requestedEntities.size ||\n Array.from(n).some(e => !requestedEntities.has(e))\n ) {\n state.current.requestedEntities = n;\n fetch();\n updateEntities();\n }\n },\n [state, fetch, updateEntities],\n );\n\n return {\n entities,\n loading,\n error,\n requestEntities,\n };\n}\n","/*\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 */\nimport { Entity, stringifyEntityRef } from '@backstage/catalog-model';\nimport { useEffect } from 'react';\nimport { useEntityStore } from './useEntityStore';\n\n/**\n * Discover the graph of entities connected by relations, starting from a set of\n * root entities. Filters are used to select which relations to includes.\n * Returns all discovered entities once they are loaded.\n */\nexport function useEntityRelationGraph({\n rootEntityRefs,\n filter: { maxDepth = Number.POSITIVE_INFINITY, relations, kinds } = {},\n}: {\n rootEntityRefs: string[];\n filter?: {\n maxDepth?: number;\n relations?: string[];\n kinds?: string[];\n };\n}): {\n entities?: { [ref: string]: Entity };\n loading: boolean;\n error?: Error;\n} {\n const { entities, loading, error, requestEntities } = useEntityStore();\n\n useEffect(() => {\n const expectedEntities = new Set([...rootEntityRefs]);\n const processedEntityRefs = new Set<string>();\n\n let nextDepthRefQueue = [...rootEntityRefs];\n let depth = 0;\n\n while (\n nextDepthRefQueue.length > 0 &&\n (!isFinite(maxDepth) || depth < maxDepth)\n ) {\n const entityRefQueue = nextDepthRefQueue;\n nextDepthRefQueue = [];\n\n while (entityRefQueue.length > 0) {\n const entityRef = entityRefQueue.shift()!;\n const entity = entities[entityRef];\n\n processedEntityRefs.add(entityRef);\n\n if (entity && entity.relations) {\n for (const rel of entity.relations) {\n if (\n (!relations || relations.includes(rel.type)) &&\n (!kinds ||\n kinds.includes(rel.target.kind.toLocaleLowerCase('en-US')))\n ) {\n const relationEntityRef = stringifyEntityRef(rel.target);\n\n if (!processedEntityRefs.has(relationEntityRef)) {\n nextDepthRefQueue.push(relationEntityRef);\n expectedEntities.add(relationEntityRef);\n }\n }\n }\n }\n }\n\n ++depth;\n }\n\n requestEntities([...expectedEntities]);\n }, [entities, rootEntityRefs, maxDepth, relations, kinds, requestEntities]);\n\n return {\n entities,\n loading,\n error,\n };\n}\n","/*\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 */\nimport {\n ENTITY_DEFAULT_NAMESPACE,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport { MouseEvent, useState } from 'react';\nimport { useDebounce } from 'react-use';\nimport { RelationPairs, ALL_RELATION_PAIRS } from './relations';\nimport { EntityEdge, EntityNode } from './types';\nimport { useEntityRelationGraph } from './useEntityRelationGraph';\n\n/**\n * Generate nodes and edges to render the entity graph.\n */\nexport function useEntityRelationNodesAndEdges({\n rootEntityRefs,\n maxDepth = Number.POSITIVE_INFINITY,\n unidirectional = true,\n mergeRelations = true,\n kinds,\n relations,\n onNodeClick,\n relationPairs = ALL_RELATION_PAIRS,\n}: {\n rootEntityRefs: string[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n kinds?: string[];\n relations?: string[];\n onNodeClick?: (value: EntityNode, event: MouseEvent<unknown>) => void;\n relationPairs?: RelationPairs;\n}): {\n loading: boolean;\n nodes?: EntityNode[];\n edges?: EntityEdge[];\n error?: Error;\n} {\n const [nodesAndEdges, setNodesAndEdges] = useState<{\n nodes?: EntityNode[];\n edges?: EntityEdge[];\n }>({});\n const { entities, loading, error } = useEntityRelationGraph({\n rootEntityRefs,\n filter: {\n maxDepth,\n kinds,\n relations,\n },\n });\n\n useDebounce(\n () => {\n if (!entities || Object.keys(entities).length === 0) {\n setNodesAndEdges({});\n return;\n }\n\n const nodes = Object.entries(entities).map(([entityRef, entity]) => {\n const focused = rootEntityRefs.includes(entityRef);\n const node: EntityNode = {\n id: entityRef,\n title: entity.metadata?.title ?? undefined,\n kind: entity.kind,\n name: entity.metadata.name,\n namespace: entity.metadata.namespace ?? ENTITY_DEFAULT_NAMESPACE,\n focused,\n color: focused ? 'secondary' : 'primary',\n };\n\n if (onNodeClick) {\n node.onClick = event => onNodeClick(node, event);\n }\n\n return node;\n });\n\n const edges: EntityEdge[] = [];\n const visitedNodes = new Set<string>();\n const nodeQueue = [...rootEntityRefs];\n\n while (nodeQueue.length > 0) {\n const entityRef = nodeQueue.pop()!;\n const entity = entities[entityRef];\n visitedNodes.add(entityRef);\n\n if (entity) {\n entity?.relations?.forEach(rel => {\n const targetRef = stringifyEntityRef(rel.target);\n\n // Check if the related entity should be displayed, if not, ignore\n // the relation too\n if (!entities[targetRef]) {\n return;\n }\n\n if (relations && !relations.includes(rel.type)) {\n return;\n }\n\n if (\n kinds &&\n !kinds.includes(rel.target.kind.toLocaleLowerCase('en-US'))\n ) {\n return;\n }\n\n if (!unidirectional || !visitedNodes.has(targetRef)) {\n if (mergeRelations) {\n const pair = relationPairs.find(\n ([l, r]) => l === rel.type || r === rel.type,\n ) ?? [rel.type];\n const [left] = pair;\n\n edges.push({\n from: left === rel.type ? entityRef : targetRef,\n to: left === rel.type ? targetRef : entityRef,\n relations: pair,\n label: 'visible',\n });\n } else {\n edges.push({\n from: entityRef,\n to: targetRef,\n relations: [rel.type],\n label: 'visible',\n });\n }\n }\n\n if (!visitedNodes.has(targetRef)) {\n nodeQueue.push(targetRef);\n visitedNodes.add(targetRef);\n }\n });\n }\n }\n\n setNodesAndEdges({ nodes, edges });\n },\n 100,\n [\n entities,\n rootEntityRefs,\n kinds,\n relations,\n unidirectional,\n mergeRelations,\n onNodeClick,\n relationPairs,\n ],\n );\n\n return {\n loading,\n error,\n ...nodesAndEdges,\n };\n}\n","/*\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 */\nimport { EntityName, stringifyEntityRef } from '@backstage/catalog-model';\nimport {\n DependencyGraph,\n DependencyGraphTypes,\n} from '@backstage/core-components';\nimport { errorApiRef, useApi } from '@backstage/core-plugin-api';\nimport { CircularProgress, makeStyles, useTheme } from '@material-ui/core';\nimport classNames from 'classnames';\nimport React, { MouseEvent, useEffect, useMemo } from 'react';\nimport { CustomLabel } from './CustomLabel';\nimport { CustomNode } from './CustomNode';\nimport { ALL_RELATION_PAIRS, RelationPairs } from './relations';\nimport { Direction, EntityNode } from './types';\nimport { useEntityRelationNodesAndEdges } from './useEntityRelationNodesAndEdges';\n\nconst useStyles = makeStyles(theme => ({\n progress: {\n position: 'absolute',\n left: '50%',\n top: '50%',\n marginLeft: '-20px',\n marginTop: '-20px',\n },\n container: {\n position: 'relative',\n width: '100%',\n display: 'flex',\n flexDirection: 'column',\n },\n graph: {\n width: '100%',\n flex: 1,\n // Right now there is no good way to style edges between nodes, we have to\n // fallback to these hacks:\n '& path[marker-end]': {\n transition: 'filter 0.1s ease-in-out',\n },\n '& path[marker-end]:hover': {\n filter: `drop-shadow(2px 2px 4px ${theme.palette.primary.dark});`,\n },\n '& g[data-testid=label]': {\n transition: 'transform 0s',\n },\n },\n}));\n\n/**\n * Core building block for custom entity relations diagrams.\n *\n * @public\n */\nexport const EntityRelationsGraph = ({\n rootEntityNames,\n maxDepth = Number.POSITIVE_INFINITY,\n unidirectional = true,\n mergeRelations = true,\n kinds,\n relations,\n direction = Direction.LEFT_RIGHT,\n onNodeClick,\n relationPairs = ALL_RELATION_PAIRS,\n className,\n zoom = 'enabled',\n}: {\n rootEntityNames: EntityName | EntityName[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n kinds?: string[];\n relations?: string[];\n direction?: Direction;\n onNodeClick?: (value: EntityNode, event: MouseEvent<unknown>) => void;\n relationPairs?: RelationPairs;\n className?: string;\n zoom?: 'enabled' | 'disabled' | 'enable-on-click';\n}) => {\n const theme = useTheme();\n const classes = useStyles();\n const rootEntityRefs = useMemo(\n () =>\n (Array.isArray(rootEntityNames)\n ? rootEntityNames\n : [rootEntityNames]\n ).map(e => stringifyEntityRef(e)),\n [rootEntityNames],\n );\n const errorApi = useApi(errorApiRef);\n const { loading, error, nodes, edges } = useEntityRelationNodesAndEdges({\n rootEntityRefs,\n maxDepth,\n unidirectional,\n mergeRelations,\n kinds,\n relations,\n onNodeClick,\n relationPairs,\n });\n\n useEffect(() => {\n if (error) {\n errorApi.post(error);\n }\n }, [errorApi, error]);\n\n return (\n <div className={classNames(classes.container, className)}>\n {loading && <CircularProgress className={classes.progress} />}\n {nodes && edges && (\n <DependencyGraph\n nodes={nodes}\n edges={edges}\n renderNode={CustomNode}\n renderLabel={CustomLabel}\n direction={direction}\n className={classes.graph}\n paddingX={theme.spacing(4)}\n paddingY={theme.spacing(4)}\n labelPosition={DependencyGraphTypes.LabelPosition.RIGHT}\n labelOffset={theme.spacing(1)}\n zoom={zoom}\n />\n )}\n </div>\n );\n};\n","/*\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 */\nimport {\n createExternalRouteRef,\n createRouteRef,\n} from '@backstage/core-plugin-api';\n\n/**\n * Route pointing to the standalone catalog graph page.\n *\n * @public\n */\nexport const catalogGraphRouteRef = createRouteRef({\n path: '/catalog-graph',\n title: 'Catalog Graph',\n});\n\n/**\n * Route pointing to the entity page.\n * Used to navigate from the graph to an entity.\n *\n * @public\n */\nexport const catalogEntityRouteRef = createExternalRouteRef({\n id: 'catalog-entity',\n params: ['namespace', 'kind', 'name'],\n});\n","/*\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 */\nimport { createPlugin } from '@backstage/core-plugin-api';\nimport { catalogEntityRouteRef, catalogGraphRouteRef } from './routes';\n\n/**\n * Catalog Graph Plugin instance.\n * @public\n */\nexport const catalogGraphPlugin = createPlugin({\n id: 'catalog-graph',\n routes: {\n catalogGraph: catalogGraphRouteRef,\n },\n externalRoutes: {\n catalogEntity: catalogEntityRouteRef,\n },\n});\n","/*\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 */\nimport {\n createComponentExtension,\n createRoutableExtension,\n} from '@backstage/core-plugin-api';\nimport { catalogGraphPlugin } from './plugin';\nimport { catalogGraphRouteRef } from './routes';\n\n/**\n * A card that displays the directly related entities to the current entity.\n *\n * @public\n */\nexport const EntityCatalogGraphCard = catalogGraphPlugin.provide(\n createComponentExtension({\n name: 'EntityCatalogGraphCard',\n component: {\n lazy: () =>\n import('./components/CatalogGraphCard').then(m => m.CatalogGraphCard),\n },\n }),\n);\n\n/**\n * A standalone page that can be added to your application providing a viewer\n * for your entities and their relations.\n *\n * @public\n */\nexport const CatalogGraphPage = catalogGraphPlugin.provide(\n createRoutableExtension({\n name: 'CatalogGraphPage',\n component: () =>\n import('./components/CatalogGraphPage').then(m => m.CatalogGraphPage),\n mountPoint: catalogGraphRouteRef,\n }),\n);\n"],"names":["useStyles","makeStyles"],"mappings":";;;;;;;;;;;;;AAsBA,MAAMA,cAAY,WAAW,CAAC;AAA2B,EACvD,MAAM;AAAA,IACJ,MAAM,MAAM,QAAQ;AAAA;AAAA,EAEtB,WAAW;AAAA,IACT,MAAM,MAAM,QAAQ;AAAA;AAAA;qBAII;AAAA,EAC1B,MAAM,CAAE;AAAA,GACgD;AACxD,QAAM,UAAUA;AAChB,6CACG,QAAD;AAAA,IAAM,WAAW,QAAQ;AAAA,IAAM,YAAW;AAAA,KACvC,UAAU,IAAI,CAAC,GAAG,0CAChB,SAAD;AAAA,IAAO,KAAK;AAAA,IAAG,WAAW,WAAW,IAAI,KAAK,QAAQ;AAAA,KACnD,IAAI,yCAAM,SAAD,MAAO,QAChB;AAAA;;wBCrBoB;AAAA,EAC7B;AAAA,KACG;AAAA,GAQF;AA7BH;AA8BE,QAAM,MAAM;AACZ,QAAM,OACJ,UAAI,cAAc,QAAQ,KAAK,kBAAkB,gBAAjD,YAAgE;AAClE,6CAAQ,MAAD;AAAA,OAAU;AAAA;AAAA;;ACTnB,MAAMA,cAAYC,aAAW,CAAC;AAA2B,EACvD,MAAM;AAAA,IACJ,MAAM,MAAM,QAAQ,KAAK;AAAA,IACzB,QAAQ,MAAM,QA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components/CatalogGraphPage/DirectionFilter.tsx","../../src/components/CatalogGraphPage/MaxDepthFilter.tsx","../../src/components/CatalogGraphPage/SelectedKindsFilter.tsx","../../src/components/CatalogGraphPage/SelectedRelationsFilter.tsx","../../src/components/CatalogGraphPage/SwitchFilter.tsx","../../src/components/CatalogGraphPage/useCatalogGraphPage.ts","../../src/components/CatalogGraphPage/CatalogGraphPage.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 */\nimport { Select } from '@backstage/core-components';\nimport { Box } from '@material-ui/core';\nimport React, { useCallback } from 'react';\nimport { Direction } from '../EntityRelationsGraph';\n\nconst DIRECTION_DISPLAY_NAMES = {\n [Direction.LEFT_RIGHT]: 'Left to right',\n [Direction.RIGHT_LEFT]: 'Right to left',\n [Direction.TOP_BOTTOM]: 'Top to bottom',\n [Direction.BOTTOM_TOP]: 'Bottom to top',\n};\n\nexport type Props = {\n value: Direction;\n onChange: (value: Direction) => void;\n};\n\nexport const DirectionFilter = ({ value, onChange }: Props) => {\n const handleChange = useCallback(v => onChange(v as Direction), [onChange]);\n\n return (\n <Box pb={1} pt={1}>\n <Select\n label=\"Direction\"\n selected={value}\n items={Object.values(Direction).map(v => ({\n label: DIRECTION_DISPLAY_NAMES[v],\n value: v,\n }))}\n onChange={handleChange}\n />\n </Box>\n );\n};\n","/*\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 */\nimport {\n Box,\n FormControl,\n IconButton,\n InputAdornment,\n makeStyles,\n OutlinedInput,\n Typography,\n} from '@material-ui/core';\nimport ClearIcon from '@material-ui/icons/Clear';\nimport React, { useCallback } from 'react';\n\nexport type Props = {\n value: number;\n onChange: (value: number) => void;\n};\n\nconst useStyles = makeStyles({\n formControl: {\n width: '100%',\n maxWidth: 300,\n },\n});\n\nexport const MaxDepthFilter = ({ value, onChange }: Props) => {\n const classes = useStyles();\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n const v = Number(event.target.value);\n onChange(v <= 0 ? Number.POSITIVE_INFINITY : v);\n },\n [onChange],\n );\n\n const reset = useCallback(() => {\n onChange(Number.POSITIVE_INFINITY);\n }, [onChange]);\n\n return (\n <Box pb={1} pt={1}>\n <FormControl variant=\"outlined\" className={classes.formControl}>\n <Typography variant=\"button\">Max Depth</Typography>\n <OutlinedInput\n type=\"number\"\n placeholder=\"∞ Infinite\"\n value={isFinite(value) ? value : ''}\n onChange={handleChange}\n endAdornment={\n <InputAdornment position=\"end\">\n <IconButton\n aria-label=\"clear max depth\"\n onClick={reset}\n edge=\"end\"\n >\n <ClearIcon />\n </IconButton>\n </InputAdornment>\n }\n inputProps={{\n 'aria-label': 'maxp',\n }}\n labelWidth={0}\n />\n </FormControl>\n </Box>\n );\n};\n","/*\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 */\nimport { alertApiRef, useApi } from '@backstage/core-plugin-api';\nimport { useEntityKinds } from '@backstage/plugin-catalog-react';\nimport {\n Box,\n Checkbox,\n FormControlLabel,\n makeStyles,\n TextField,\n Typography,\n} from '@material-ui/core';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { Autocomplete } from '@material-ui/lab';\nimport React, { useCallback, useEffect, useMemo } from 'react';\n\nconst useStyles = makeStyles({\n formControl: {\n maxWidth: 300,\n },\n});\n\nexport type Props = {\n value: string[] | undefined;\n onChange: (value: string[] | undefined) => void;\n};\n\nexport const SelectedKindsFilter = ({ value, onChange }: Props) => {\n const classes = useStyles();\n const alertApi = useApi(alertApiRef);\n const { error, kinds } = useEntityKinds();\n\n useEffect(() => {\n if (error) {\n alertApi.post({\n message: `Failed to load entity kinds`,\n severity: 'error',\n });\n }\n }, [error, alertApi]);\n\n const normalizedKinds = useMemo(\n () => (kinds ? kinds.map(k => k.toLocaleLowerCase('en-US')) : kinds),\n [kinds],\n );\n\n const handleChange = useCallback(\n (_: unknown, v: string[]) => {\n onChange(\n normalizedKinds && normalizedKinds.every(r => v.includes(r))\n ? undefined\n : v,\n );\n },\n [normalizedKinds, onChange],\n );\n\n const handleEmpty = useCallback(() => {\n onChange(value?.length ? value : undefined);\n }, [value, onChange]);\n\n if (!kinds?.length || !normalizedKinds?.length || error) {\n return <></>;\n }\n\n return (\n <Box pb={1} pt={1}>\n <Typography variant=\"button\">Kinds</Typography>\n <Autocomplete\n className={classes.formControl}\n multiple\n limitTags={4}\n disableCloseOnSelect\n aria-label=\"Kinds\"\n options={normalizedKinds}\n value={value ?? normalizedKinds}\n getOptionLabel={k => kinds[normalizedKinds.indexOf(k)] ?? k}\n onChange={handleChange}\n onBlur={handleEmpty}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={<CheckBoxOutlineBlankIcon fontSize=\"small\" />}\n checkedIcon={<CheckBoxIcon fontSize=\"small\" />}\n checked={selected}\n />\n }\n label={kinds[normalizedKinds.indexOf(option)] ?? option}\n />\n )}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"selected-kinds-expand\" />}\n renderInput={params => <TextField {...params} variant=\"outlined\" />}\n />\n </Box>\n );\n};\n","/*\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 */\nimport {\n Box,\n Checkbox,\n FormControlLabel,\n makeStyles,\n TextField,\n Typography,\n} from '@material-ui/core';\nimport CheckBoxIcon from '@material-ui/icons/CheckBox';\nimport CheckBoxOutlineBlankIcon from '@material-ui/icons/CheckBoxOutlineBlank';\nimport ExpandMoreIcon from '@material-ui/icons/ExpandMore';\nimport { Autocomplete } from '@material-ui/lab';\nimport React, { useCallback, useMemo } from 'react';\nimport { RelationPairs } from '../EntityRelationsGraph';\n\nconst useStyles = makeStyles({\n formControl: {\n maxWidth: 300,\n },\n});\n\nexport type Props = {\n relationPairs: RelationPairs;\n value: string[] | undefined;\n onChange: (value: string[] | undefined) => void;\n};\n\nexport const SelectedRelationsFilter = ({\n relationPairs,\n value,\n onChange,\n}: Props) => {\n const classes = useStyles();\n const relations = useMemo(() => relationPairs.flat(), [relationPairs]);\n\n const handleChange = useCallback(\n (_: unknown, v: string[]) => {\n onChange(relations.every(r => v.includes(r)) ? undefined : v);\n },\n [relations, onChange],\n );\n\n const handleEmpty = useCallback(() => {\n onChange(value?.length ? value : undefined);\n }, [value, onChange]);\n\n return (\n <Box pb={1} pt={1}>\n <Typography variant=\"button\">Relations</Typography>\n <Autocomplete\n className={classes.formControl}\n multiple\n limitTags={4}\n disableCloseOnSelect\n aria-label=\"Relations\"\n options={relations}\n value={value ?? relations}\n onChange={handleChange}\n onBlur={handleEmpty}\n renderOption={(option, { selected }) => (\n <FormControlLabel\n control={\n <Checkbox\n icon={<CheckBoxOutlineBlankIcon fontSize=\"small\" />}\n checkedIcon={<CheckBoxIcon fontSize=\"small\" />}\n checked={selected}\n />\n }\n label={option}\n />\n )}\n size=\"small\"\n popupIcon={<ExpandMoreIcon data-testid=\"selected-relations-expand\" />}\n renderInput={params => <TextField {...params} variant=\"outlined\" />}\n />\n </Box>\n );\n};\n","/*\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 */\nimport { Box, FormControlLabel, makeStyles, Switch } from '@material-ui/core';\nimport React, { useCallback } from 'react';\n\nexport type Props = {\n label: string;\n value: boolean;\n onChange: (value: boolean) => void;\n};\n\nconst useStyles = makeStyles({\n root: {\n width: '100%',\n maxWidth: 300,\n },\n});\n\nexport const SwitchFilter = ({ label, value, onChange }: Props) => {\n const classes = useStyles();\n\n const handleChange = useCallback(\n (event: React.ChangeEvent<HTMLInputElement>) => {\n onChange(event.target.checked);\n },\n [onChange],\n );\n\n return (\n <Box pb={1} pt={1}>\n <FormControlLabel\n control={\n <Switch\n checked={value}\n onChange={handleChange}\n name={label}\n color=\"primary\"\n />\n }\n label={label}\n className={classes.root}\n />\n </Box>\n );\n};\n","/*\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 */\nimport {\n EntityName,\n parseEntityRef,\n stringifyEntityRef,\n} from '@backstage/catalog-model';\nimport qs from 'qs';\nimport {\n Dispatch,\n DispatchWithoutAction,\n useCallback,\n useEffect,\n useMemo,\n useState,\n} from 'react';\nimport { useLocation } from 'react-router';\nimport { usePrevious } from 'react-use';\nimport { Direction } from '../EntityRelationsGraph';\n\nexport type CatalogGraphPageValue = {\n rootEntityNames: EntityName[];\n setRootEntityNames: Dispatch<React.SetStateAction<EntityName[]>>;\n maxDepth: number;\n setMaxDepth: Dispatch<React.SetStateAction<number>>;\n selectedRelations: string[] | undefined;\n setSelectedRelations: Dispatch<React.SetStateAction<string[] | undefined>>;\n selectedKinds: string[] | undefined;\n setSelectedKinds: Dispatch<React.SetStateAction<string[] | undefined>>;\n unidirectional: boolean;\n setUnidirectional: Dispatch<React.SetStateAction<boolean>>;\n mergeRelations: boolean;\n setMergeRelations: Dispatch<React.SetStateAction<boolean>>;\n direction: Direction;\n setDirection: Dispatch<React.SetStateAction<Direction>>;\n showFilters: boolean;\n toggleShowFilters: DispatchWithoutAction;\n};\n\nexport function useCatalogGraphPage({\n initialState = {},\n}: {\n initialState?: {\n selectedRelations?: string[] | undefined;\n selectedKinds?: string[] | undefined;\n rootEntityRefs?: string[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n direction?: Direction;\n showFilters?: boolean;\n };\n}): CatalogGraphPageValue {\n const location = useLocation();\n const query = useMemo(\n () =>\n (qs.parse(location.search, { arrayLimit: 0, ignoreQueryPrefix: true }) ||\n {}) as {\n selectedRelations?: string[] | string;\n selectedKinds?: string[] | string;\n rootEntityRefs?: string[] | string;\n maxDepth?: string[] | string;\n unidirectional?: string[] | string;\n mergeRelations?: string[] | string;\n direction?: string[] | Direction;\n showFilters?: string[] | string;\n },\n [location.search],\n );\n\n // Initial state\n const [rootEntityNames, setRootEntityNames] = useState<EntityName[]>(() =>\n (Array.isArray(query.rootEntityRefs)\n ? query.rootEntityRefs\n : initialState?.rootEntityRefs ?? []\n ).map(r => parseEntityRef(r)),\n );\n const [maxDepth, setMaxDepth] = useState<number>(() =>\n typeof query.maxDepth === 'string'\n ? parseMaxDepth(query.maxDepth)\n : initialState?.maxDepth ?? Number.POSITIVE_INFINITY,\n );\n const [selectedRelations, setSelectedRelations] = useState<\n string[] | undefined\n >(() =>\n Array.isArray(query.selectedRelations)\n ? query.selectedRelations\n : initialState?.selectedRelations,\n );\n const [selectedKinds, setSelectedKinds] = useState<string[] | undefined>(() =>\n (Array.isArray(query.selectedKinds)\n ? query.selectedKinds\n : initialState?.selectedKinds\n )?.map(k => k.toLocaleLowerCase('en-US')),\n );\n const [unidirectional, setUnidirectional] = useState<boolean>(() =>\n typeof query.unidirectional === 'string'\n ? query.unidirectional === 'true'\n : initialState?.unidirectional ?? true,\n );\n const [mergeRelations, setMergeRelations] = useState<boolean>(() =>\n typeof query.mergeRelations === 'string'\n ? query.mergeRelations === 'true'\n : initialState?.mergeRelations ?? true,\n );\n const [direction, setDirection] = useState<Direction>(() =>\n typeof query.direction === 'string'\n ? query.direction\n : initialState?.direction ?? Direction.LEFT_RIGHT,\n );\n const [showFilters, setShowFilters] = useState<boolean>(() =>\n typeof query.showFilters === 'string'\n ? query.showFilters === 'true'\n : initialState?.showFilters ?? true,\n );\n const toggleShowFilters = useCallback(\n () => setShowFilters(s => !s),\n [setShowFilters],\n );\n\n // Update from query parameters\n const prevQueryParams = usePrevious(location.search);\n useEffect(() => {\n // Only respond to changes to url query params\n if (location.search === prevQueryParams) {\n return;\n }\n\n if (Array.isArray(query.rootEntityRefs)) {\n setRootEntityNames(query.rootEntityRefs.map(r => parseEntityRef(r)));\n }\n\n if (typeof query.maxDepth === 'string') {\n setMaxDepth(parseMaxDepth(query.maxDepth));\n }\n\n if (Array.isArray(query.selectedKinds)) {\n setSelectedKinds(query.selectedKinds);\n }\n\n if (Array.isArray(query.selectedRelations)) {\n setSelectedRelations(query.selectedRelations);\n }\n\n if (typeof query.unidirectional === 'string') {\n setUnidirectional(query.unidirectional === 'true');\n }\n\n if (typeof query.mergeRelations === 'string') {\n setMergeRelations(query.mergeRelations === 'true');\n }\n\n if (typeof query.direction === 'string') {\n setDirection(query.direction);\n }\n\n if (typeof query.showFilters === 'string') {\n setShowFilters(query.showFilters === 'true');\n }\n }, [\n prevQueryParams,\n location.search,\n query,\n setRootEntityNames,\n setMaxDepth,\n setSelectedKinds,\n setSelectedRelations,\n setUnidirectional,\n setMergeRelations,\n setDirection,\n setShowFilters,\n ]);\n\n // Update query parameters\n const previousRootEntityRefs = usePrevious(\n rootEntityNames.map(e => stringifyEntityRef(e)),\n );\n\n useEffect(() => {\n const rootEntityRefs = rootEntityNames.map(e => stringifyEntityRef(e));\n const newParams = qs.stringify(\n {\n rootEntityRefs,\n maxDepth: isFinite(maxDepth) ? maxDepth : '∞',\n selectedKinds,\n selectedRelations,\n unidirectional,\n mergeRelations,\n direction,\n showFilters,\n },\n { arrayFormat: 'brackets', addQueryPrefix: true },\n );\n const newUrl = `${window.location.pathname}${newParams}`;\n\n // We directly manipulate window history here in order to not re-render\n // infinitely (state => location => state => etc). The intention of this\n // code is just to ensure the right query/filters are loaded when a user\n // clicks the \"back\" button after clicking a result.\n // Only push a new history entry if we switched to another entity, but not\n // if we just changed a viewer setting.\n if (\n !previousRootEntityRefs ||\n (rootEntityRefs.length === previousRootEntityRefs.length &&\n rootEntityRefs.every((v, i) => v === previousRootEntityRefs[i]))\n ) {\n window.history.replaceState(null, document.title, newUrl);\n } else {\n window.history.pushState(null, document.title, newUrl);\n }\n }, [\n rootEntityNames,\n maxDepth,\n selectedKinds,\n selectedRelations,\n unidirectional,\n mergeRelations,\n direction,\n showFilters,\n previousRootEntityRefs,\n ]);\n\n return {\n rootEntityNames,\n setRootEntityNames,\n maxDepth,\n setMaxDepth,\n selectedRelations,\n setSelectedRelations,\n selectedKinds,\n setSelectedKinds,\n unidirectional,\n setUnidirectional,\n mergeRelations,\n setMergeRelations,\n direction,\n setDirection,\n showFilters,\n toggleShowFilters,\n };\n}\n\nfunction parseMaxDepth(value: string): number {\n return value === '∞' ? Number.POSITIVE_INFINITY : Number(value);\n}\n","/*\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 */\nimport { parseEntityRef } from '@backstage/catalog-model';\nimport {\n Content,\n ContentHeader,\n Header,\n Page,\n SupportButton,\n} from '@backstage/core-components';\nimport { useAnalytics, useRouteRef } from '@backstage/core-plugin-api';\nimport { formatEntityRefTitle } from '@backstage/plugin-catalog-react';\nimport { Grid, makeStyles, Paper, Typography } from '@material-ui/core';\nimport FilterListIcon from '@material-ui/icons/FilterList';\nimport ZoomOutMap from '@material-ui/icons/ZoomOutMap';\nimport { ToggleButton } from '@material-ui/lab';\nimport React, { MouseEvent, useCallback } from 'react';\nimport { useNavigate } from 'react-router';\nimport { catalogEntityRouteRef } from '../../routes';\nimport {\n ALL_RELATION_PAIRS,\n Direction,\n EntityNode,\n EntityRelationsGraph,\n RelationPairs,\n} from '../EntityRelationsGraph';\nimport { DirectionFilter } from './DirectionFilter';\nimport { MaxDepthFilter } from './MaxDepthFilter';\nimport { SelectedKindsFilter } from './SelectedKindsFilter';\nimport { SelectedRelationsFilter } from './SelectedRelationsFilter';\nimport { SwitchFilter } from './SwitchFilter';\nimport { useCatalogGraphPage } from './useCatalogGraphPage';\n\nconst useStyles = makeStyles(theme => ({\n content: {\n minHeight: 0,\n },\n container: {\n height: '100%',\n maxHeight: '100%',\n minHeight: 0,\n },\n fullHeight: {\n maxHeight: '100%',\n display: 'flex',\n minHeight: 0,\n },\n graphWrapper: {\n position: 'relative',\n flex: 1,\n minHeight: 0,\n display: 'flex',\n },\n graph: {\n flex: 1,\n minHeight: 0,\n },\n legend: {\n position: 'absolute',\n bottom: 0,\n right: 0,\n padding: theme.spacing(1),\n '& .icon': {\n verticalAlign: 'bottom',\n },\n },\n filters: {\n display: 'grid',\n gridGap: theme.spacing(1),\n gridAutoRows: 'auto',\n [theme.breakpoints.up('lg')]: {\n display: 'block',\n },\n [theme.breakpoints.only('md')]: {\n gridTemplateColumns: 'repeat(3, 1fr)',\n },\n [theme.breakpoints.only('sm')]: {\n gridTemplateColumns: 'repeat(2, 1fr)',\n },\n [theme.breakpoints.down('xs')]: {\n gridTemplateColumns: 'repeat(1, 1fr)',\n },\n },\n}));\n\nexport const CatalogGraphPage = ({\n relationPairs = ALL_RELATION_PAIRS,\n initialState,\n}: {\n relationPairs?: RelationPairs;\n initialState?: {\n selectedRelations?: string[];\n selectedKinds?: string[];\n rootEntityRefs?: string[];\n maxDepth?: number;\n unidirectional?: boolean;\n mergeRelations?: boolean;\n direction?: Direction;\n showFilters?: boolean;\n };\n}) => {\n const navigate = useNavigate();\n const classes = useStyles();\n const catalogEntityRoute = useRouteRef(catalogEntityRouteRef);\n const {\n maxDepth,\n setMaxDepth,\n selectedKinds,\n setSelectedKinds,\n selectedRelations,\n setSelectedRelations,\n unidirectional,\n setUnidirectional,\n mergeRelations,\n setMergeRelations,\n direction,\n setDirection,\n rootEntityNames,\n setRootEntityNames,\n showFilters,\n toggleShowFilters,\n } = useCatalogGraphPage({ initialState });\n const analytics = useAnalytics();\n const onNodeClick = useCallback(\n (node: EntityNode, event: MouseEvent<unknown>) => {\n const nodeEntityName = parseEntityRef(node.id);\n\n if (event.shiftKey) {\n const path = catalogEntityRoute({\n kind: nodeEntityName.kind.toLocaleLowerCase('en-US'),\n namespace: nodeEntityName.namespace.toLocaleLowerCase('en-US'),\n name: nodeEntityName.name,\n });\n\n analytics.captureEvent(\n 'click',\n node.title ?? formatEntityRefTitle(nodeEntityName),\n { attributes: { to: path } },\n );\n navigate(path);\n } else {\n analytics.captureEvent(\n 'click',\n node.title ?? formatEntityRefTitle(nodeEntityName),\n );\n setRootEntityNames([nodeEntityName]);\n }\n },\n [catalogEntityRoute, navigate, setRootEntityNames, analytics],\n );\n\n return (\n <Page themeId=\"home\">\n <Header\n title=\"Catalog Graph\"\n subtitle={rootEntityNames.map(e => formatEntityRefTitle(e)).join(', ')}\n />\n <Content stretch className={classes.content}>\n <ContentHeader\n titleComponent={\n <ToggleButton\n value=\"show filters\"\n selected={showFilters}\n onChange={() => toggleShowFilters()}\n >\n <FilterListIcon /> Filters\n </ToggleButton>\n }\n >\n <SupportButton>\n Start tracking your component in by adding it to the software\n catalog.\n </SupportButton>\n </ContentHeader>\n <Grid container alignItems=\"stretch\" className={classes.container}>\n {showFilters && (\n <Grid item xs={12} lg={2} className={classes.filters}>\n <MaxDepthFilter value={maxDepth} onChange={setMaxDepth} />\n <SelectedKindsFilter\n value={selectedKinds}\n onChange={setSelectedKinds}\n />\n <SelectedRelationsFilter\n value={selectedRelations}\n onChange={setSelectedRelations}\n relationPairs={relationPairs}\n />\n <DirectionFilter value={direction} onChange={setDirection} />\n <SwitchFilter\n value={unidirectional}\n onChange={setUnidirectional}\n label=\"Simplified\"\n />\n <SwitchFilter\n value={mergeRelations}\n onChange={setMergeRelations}\n label=\"Merge Relations\"\n />\n </Grid>\n )}\n <Grid item xs className={classes.fullHeight}>\n <Paper className={classes.graphWrapper}>\n <Typography\n variant=\"caption\"\n color=\"textSecondary\"\n display=\"block\"\n className={classes.legend}\n >\n <ZoomOutMap className=\"icon\" /> Use pinch & zoom to move\n around the diagram. Click to change active node, shift click to\n navigate to entity.\n </Typography>\n <EntityRelationsGraph\n rootEntityNames={rootEntityNames}\n maxDepth={maxDepth}\n kinds={\n selectedKinds && selectedKinds.length > 0\n ? selectedKinds\n : undefined\n }\n relations={\n selectedRelations && selectedRelations.length > 0\n ? selectedRelations\n : undefined\n }\n mergeRelations={mergeRelations}\n unidirectional={unidirectional}\n onNodeClick={onNodeClick}\n direction={direction}\n relationPairs={relationPairs}\n className={classes.graph}\n zoom=\"enabled\"\n />\n </Paper>\n </Grid>\n </Grid>\n </Content>\n </Page>\n );\n};\n"],"names":["useStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,0BAA0B;AAAA,GAC7B,UAAU,aAAa;AAAA,GACvB,UAAU,aAAa;AAAA,GACvB,UAAU,aAAa;AAAA,GACvB,UAAU,aAAa;AAAA;MAQb,kBAAkB,CAAC,CAAE,OAAO,cAAsB;AAC7D,QAAM,eAAe,YAAY,OAAK,SAAS,IAAiB,CAAC;AAEjE,6CACG,KAAD;AAAA,IAAK,IAAI;AAAA,IAAG,IAAI;AAAA,yCACb,QAAD;AAAA,IACE,OAAM;AAAA,IACN,UAAU;AAAA,IACV,OAAO,OAAO,OAAO,WAAW,IAAI;AAAM,MACxC,OAAO,wBAAwB;AAAA,MAC/B,OAAO;AAAA;AAAA,IAET,UAAU;AAAA;AAAA;;ACZlB,MAAMA,cAAY,WAAW;AAAA,EAC3B,aAAa;AAAA,IACX,OAAO;AAAA,IACP,UAAU;AAAA;AAAA;MAID,iBAAiB,CAAC,CAAE,OAAO,cAAsB;AAC5D,QAAM,UAAUA;AAEhB,QAAM,eAAe,YACnB,CAAC,UAA+C;AAC9C,UAAM,IAAI,OAAO,MAAM,OAAO;AAC9B,aAAS,KAAK,IAAI,OAAO,oBAAoB;AAAA,KAE/C,CAAC;AAGH,QAAM,QAAQ,YAAY,MAAM;AAC9B,aAAS,OAAO;AAAA,KACf,CAAC;AAEJ,6CACG,KAAD;AAAA,IAAK,IAAI;AAAA,IAAG,IAAI;AAAA,yC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