@backstage/plugin-catalog-graph 0.2.10 → 0.2.13

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 CHANGED
@@ -1,5 +1,49 @@
1
1
  # @backstage/plugin-catalog-graph
2
2
 
3
+ ## 0.2.13
4
+
5
+ ### Patch Changes
6
+
7
+ - 899f196af5: Use `getEntityByRef` instead of `getEntityByName` in the catalog client
8
+ - f41a293231: - **DEPRECATION**: Deprecated `formatEntityRefTitle` in favor of the new `humanizeEntityRef` method instead. Please migrate to using the new method instead.
9
+ - 36aa63022b: Use `CompoundEntityRef` instead of `EntityName`, and `getCompoundEntityRef` instead of `getEntityName`, from `@backstage/catalog-model`.
10
+ - Updated dependencies
11
+ - @backstage/catalog-model@0.12.0
12
+ - @backstage/catalog-client@0.8.0
13
+ - @backstage/core-components@0.9.0
14
+ - @backstage/plugin-catalog-react@0.8.0
15
+ - @backstage/core-plugin-api@0.8.0
16
+
17
+ ## 0.2.12
18
+
19
+ ### Patch Changes
20
+
21
+ - a8331830f1: Remove use of deprecated `useEntityKinds` hook.
22
+ - 6e1cbc12a6: Updated according to the new `getEntityFacets` catalog API method
23
+ - 919cf2f836: Minor updates to match the new `targetRef` field of relations, and to stop consuming the `target` field
24
+ - Updated dependencies
25
+ - @backstage/core-components@0.8.10
26
+ - @backstage/plugin-catalog-react@0.7.0
27
+ - @backstage/catalog-model@0.11.0
28
+ - @backstage/catalog-client@0.7.2
29
+ - @backstage/core-plugin-api@0.7.0
30
+
31
+ ## 0.2.11
32
+
33
+ ### Patch Changes
34
+
35
+ - c77c5c7eb6: Added `backstage.role` to `package.json`
36
+ - 538ca90790: Use updated type names from `@backstage/catalog-client`
37
+ - deaf6065db: Adapt to the new `CatalogApi.getLocationByRef`
38
+ - 7aeb491394: Replace use of deprecated `ENTITY_DEFAULT_NAMESPACE` constant with `DEFAULT_NAMESPACE`.
39
+ - Updated dependencies
40
+ - @backstage/catalog-client@0.7.0
41
+ - @backstage/core-components@0.8.9
42
+ - @backstage/core-plugin-api@0.6.1
43
+ - @backstage/plugin-catalog-react@0.6.15
44
+ - @backstage/catalog-model@0.10.0
45
+ - @backstage/theme@0.2.15
46
+
3
47
  ## 0.2.10
4
48
 
5
49
  ### Patch Changes
@@ -1,7 +1,7 @@
1
1
  import { parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
2
2
  import { Select, Page, Header, Content, ContentHeader, SupportButton } from '@backstage/core-components';
3
3
  import { useApi, alertApiRef, useRouteRef, useAnalytics } from '@backstage/core-plugin-api';
4
- import { useEntityKinds, entityRouteRef, formatEntityRefTitle } from '@backstage/plugin-catalog-react';
4
+ import { catalogApiRef, entityRouteRef, humanizeEntityRef } from '@backstage/plugin-catalog-react';
5
5
  import { Box, makeStyles, FormControl, Typography, OutlinedInput, InputAdornment, IconButton, FormControlLabel, Checkbox, TextField, Switch, Grid, Paper } from '@material-ui/core';
6
6
  import FilterListIcon from '@material-ui/icons/FilterList';
7
7
  import ZoomOutMap from '@material-ui/icons/ZoomOutMap';
@@ -13,6 +13,7 @@ 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
+ import useAsync from 'react-use/lib/useAsync';
16
17
  import qs from 'qs';
17
18
  import usePrevious from 'react-use/lib/usePrevious';
18
19
  import 'classnames';
@@ -95,7 +96,13 @@ const useStyles$3 = makeStyles({
95
96
  const SelectedKindsFilter = ({ value, onChange }) => {
96
97
  const classes = useStyles$3();
97
98
  const alertApi = useApi(alertApiRef);
98
- const { error, kinds } = useEntityKinds();
99
+ const catalogApi = useApi(catalogApiRef);
100
+ const { error, value: kinds } = useAsync(async () => {
101
+ return await catalogApi.getEntityFacets({ facets: ["kind"] }).then((response) => {
102
+ var _a;
103
+ return ((_a = response.facets.kind) == null ? void 0 : _a.map((f) => f.value).sort()) || [];
104
+ });
105
+ });
99
106
  useEffect(() => {
100
107
  if (error) {
101
108
  alertApi.post({
@@ -457,10 +464,10 @@ const CatalogGraphPage = ({
457
464
  namespace: nodeEntityName.namespace.toLocaleLowerCase("en-US"),
458
465
  name: nodeEntityName.name
459
466
  });
460
- analytics.captureEvent("click", (_a = node.title) != null ? _a : formatEntityRefTitle(nodeEntityName), { attributes: { to: path } });
467
+ analytics.captureEvent("click", (_a = node.title) != null ? _a : humanizeEntityRef(nodeEntityName), { attributes: { to: path } });
461
468
  navigate(path);
462
469
  } else {
463
- analytics.captureEvent("click", (_b = node.title) != null ? _b : formatEntityRefTitle(nodeEntityName));
470
+ analytics.captureEvent("click", (_b = node.title) != null ? _b : humanizeEntityRef(nodeEntityName));
464
471
  setRootEntityNames([nodeEntityName]);
465
472
  }
466
473
  }, [catalogEntityRoute, navigate, setRootEntityNames, analytics]);
@@ -468,7 +475,7 @@ const CatalogGraphPage = ({
468
475
  themeId: "home"
469
476
  }, /* @__PURE__ */ React.createElement(Header, {
470
477
  title: "Catalog Graph",
471
- subtitle: rootEntityNames.map((e) => formatEntityRefTitle(e)).join(", ")
478
+ subtitle: rootEntityNames.map((e) => humanizeEntityRef(e)).join(", ")
472
479
  }), /* @__PURE__ */ React.createElement(Content, {
473
480
  stretch: true,
474
481
  className: classes.content
@@ -537,4 +544,4 @@ const CatalogGraphPage = ({
537
544
  };
538
545
 
539
546
  export { CatalogGraphPage };
540
- //# sourceMappingURL=index-5852c637.esm.js.map
547
+ //# sourceMappingURL=index-6ed47188.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-6ed47188.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 { catalogApiRef } 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';\nimport useAsync from 'react-use/lib/useAsync';\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 catalogApi = useApi(catalogApiRef);\n\n const { error, value: kinds } = useAsync(async () => {\n return await catalogApi\n .getEntityFacets({ facets: ['kind'] })\n .then(response => response.facets.kind?.map(f => f.value).sort() || []);\n });\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 CompoundEntityRef,\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: CompoundEntityRef[];\n setRootEntityNames: Dispatch<React.SetStateAction<CompoundEntityRef[]>>;\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<CompoundEntityRef[]>(\n () =>\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 {\n entityRouteRef,\n humanizeEntityRef,\n} 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 {\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(entityRouteRef);\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 ?? humanizeEntityRef(nodeEntityName),\n { attributes: { to: path } },\n );\n navigate(path);\n } else {\n analytics.captureEvent(\n 'click',\n node.title ?? humanizeEntityRef(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 => humanizeEntityRef(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 &amp; 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,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,yCACb,aAAD;AAAA,IA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;;;"}
@@ -1,7 +1,7 @@
1
- import { getEntityName, parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
1
+ import { getCompoundEntityRef, parseEntityRef, stringifyEntityRef } from '@backstage/catalog-model';
2
2
  import { InfoCard } from '@backstage/core-components';
3
3
  import { useRouteRef, useAnalytics } from '@backstage/core-plugin-api';
4
- import { useEntity, entityRouteRef, formatEntityRefTitle } from '@backstage/plugin-catalog-react';
4
+ import { useEntity, entityRouteRef, humanizeEntityRef } from '@backstage/plugin-catalog-react';
5
5
  import { makeStyles } from '@material-ui/core';
6
6
  import qs from 'qs';
7
7
  import React, { useCallback } from 'react';
@@ -41,7 +41,7 @@ const CatalogGraphCard = ({
41
41
  zoom = "enable-on-click"
42
42
  }) => {
43
43
  const { entity } = useEntity();
44
- const entityName = getEntityName(entity);
44
+ const entityName = getCompoundEntityRef(entity);
45
45
  const catalogEntityRoute = useRouteRef(entityRouteRef);
46
46
  const catalogGraphRoute = useRouteRef(catalogGraphRouteRef);
47
47
  const navigate = useNavigate();
@@ -55,7 +55,7 @@ const CatalogGraphCard = ({
55
55
  namespace: nodeEntityName.namespace.toLocaleLowerCase("en-US"),
56
56
  name: nodeEntityName.name
57
57
  });
58
- analytics.captureEvent("click", (_a = node.title) != null ? _a : formatEntityRefTitle(nodeEntityName), { attributes: { to: path } });
58
+ analytics.captureEvent("click", (_a = node.title) != null ? _a : humanizeEntityRef(nodeEntityName), { attributes: { to: path } });
59
59
  navigate(path);
60
60
  }, [catalogEntityRoute, navigate, analytics]);
61
61
  const catalogGraphParams = qs.stringify({ rootEntityRefs: [stringifyEntityRef(entity)] }, { arrayFormat: "brackets", addQueryPrefix: true });
@@ -85,4 +85,4 @@ const CatalogGraphCard = ({
85
85
  };
86
86
 
87
87
  export { CatalogGraphCard };
88
- //# sourceMappingURL=index-169ff2f6.esm.js.map
88
+ //# sourceMappingURL=index-baf36d74.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-baf36d74.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 getCompoundEntityRef,\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 humanizeEntityRef,\n useEntity,\n entityRouteRef,\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 { 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 = getCompoundEntityRef(entity);\n const catalogEntityRoute = useRouteRef(entityRouteRef);\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 ?? humanizeEntityRef(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":";;;;;;;;;;;;;;;;;AAwCA,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,qBAAqB;AACxC,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;AAvFlD;AAwFM,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,kBAAkB,iBAChC,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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { EntityName } from '@backstage/catalog-model';
2
+ import { CompoundEntityRef } from '@backstage/catalog-model';
3
3
  import { MouseEventHandler, MouseEvent } from 'react';
4
4
  import * as _backstage_core_components from '@backstage/core-components';
5
5
  import { DependencyGraphTypes } from '@backstage/core-components';
@@ -113,7 +113,7 @@ declare enum Direction {
113
113
  * @public
114
114
  */
115
115
  declare const EntityRelationsGraph: ({ rootEntityNames, maxDepth, unidirectional, mergeRelations, kinds, relations, direction, onNodeClick, relationPairs, className, zoom, }: {
116
- rootEntityNames: EntityName | EntityName[];
116
+ rootEntityNames: CompoundEntityRef | CompoundEntityRef[];
117
117
  maxDepth?: number | undefined;
118
118
  unidirectional?: boolean | undefined;
119
119
  mergeRelations?: boolean | undefined;
package/dist/index.esm.js CHANGED
@@ -1,11 +1,11 @@
1
- import { RELATION_OWNER_OF, RELATION_OWNED_BY, RELATION_CONSUMES_API, RELATION_API_CONSUMED_BY, RELATION_API_PROVIDED_BY, RELATION_PROVIDES_API, RELATION_HAS_PART, RELATION_PART_OF, RELATION_PARENT_OF, RELATION_CHILD_OF, RELATION_HAS_MEMBER, RELATION_MEMBER_OF, RELATION_DEPENDS_ON, RELATION_DEPENDENCY_OF, parseEntityRef, stringifyEntityRef, ENTITY_DEFAULT_NAMESPACE } from '@backstage/catalog-model';
1
+ import { RELATION_OWNER_OF, RELATION_OWNED_BY, RELATION_CONSUMES_API, RELATION_API_CONSUMED_BY, RELATION_API_PROVIDED_BY, RELATION_PROVIDES_API, RELATION_HAS_PART, RELATION_PART_OF, RELATION_PARENT_OF, RELATION_CHILD_OF, RELATION_HAS_MEMBER, RELATION_MEMBER_OF, RELATION_DEPENDS_ON, RELATION_DEPENDENCY_OF, DEFAULT_NAMESPACE, stringifyEntityRef } from '@backstage/catalog-model';
2
2
  import { DependencyGraph, DependencyGraphTypes } from '@backstage/core-components';
3
3
  import { useApp, useApi, errorApiRef, createRouteRef, createExternalRouteRef, createPlugin, createComponentExtension, createRoutableExtension } from '@backstage/core-plugin-api';
4
4
  import { makeStyles as makeStyles$2, useTheme, CircularProgress } from '@material-ui/core';
5
5
  import classNames from 'classnames';
6
6
  import React, { useState, useRef, useLayoutEffect, useCallback, useEffect, useMemo } from 'react';
7
7
  import makeStyles from '@material-ui/core/styles/makeStyles';
8
- import { formatEntityRefTitle, catalogApiRef } from '@backstage/plugin-catalog-react';
8
+ import { humanizeEntityRef, 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
11
  import useDebounce from 'react-use/lib/useDebounce';
@@ -106,7 +106,7 @@ function CustomNode({
106
106
  const paddedIconWidth = kind ? iconSize + padding : 0;
107
107
  const paddedWidth = paddedIconWidth + width + padding * 2;
108
108
  const paddedHeight = height + padding * 2;
109
- const displayTitle = title != null ? title : kind && name && namespace ? formatEntityRefTitle({ kind, name, namespace }) : id;
109
+ const displayTitle = title != null ? title : kind && name && namespace ? humanizeEntityRef({ kind, name, namespace }) : id;
110
110
  return /* @__PURE__ */ React.createElement("g", {
111
111
  onClick,
112
112
  className: classNames(onClick && classes.clickable)
@@ -180,7 +180,7 @@ function useEntityStore() {
180
180
  await outstandingEntities.get(entityRef);
181
181
  return;
182
182
  }
183
- const promise = catalogClient.getEntityByName(parseEntityRef(entityRef));
183
+ const promise = catalogClient.getEntityByRef(entityRef);
184
184
  outstandingEntities.set(entityRef, promise);
185
185
  try {
186
186
  const entity = await promise;
@@ -230,11 +230,10 @@ function useEntityRelationGraph({
230
230
  processedEntityRefs.add(entityRef);
231
231
  if (entity && entity.relations) {
232
232
  for (const rel of entity.relations) {
233
- if ((!relations || relations.includes(rel.type)) && (!kinds || kinds.includes(rel.target.kind.toLocaleLowerCase("en-US")))) {
234
- const relationEntityRef = stringifyEntityRef(rel.target);
235
- if (!processedEntityRefs.has(relationEntityRef)) {
236
- nextDepthRefQueue.push(relationEntityRef);
237
- expectedEntities.add(relationEntityRef);
233
+ if ((!relations || relations.includes(rel.type)) && (!kinds || kinds.some((kind) => rel.targetRef.startsWith(`${kind.toLocaleLowerCase("en-US")}:`)))) {
234
+ if (!processedEntityRefs.has(rel.targetRef)) {
235
+ nextDepthRefQueue.push(rel.targetRef);
236
+ expectedEntities.add(rel.targetRef);
238
237
  }
239
238
  }
240
239
  }
@@ -284,7 +283,7 @@ function useEntityRelationNodesAndEdges({
284
283
  title: (_b = (_a2 = entity.metadata) == null ? void 0 : _a2.title) != null ? _b : void 0,
285
284
  kind: entity.kind,
286
285
  name: entity.metadata.name,
287
- namespace: (_c = entity.metadata.namespace) != null ? _c : ENTITY_DEFAULT_NAMESPACE,
286
+ namespace: (_c = entity.metadata.namespace) != null ? _c : DEFAULT_NAMESPACE,
288
287
  focused,
289
288
  color: focused ? "secondary" : "primary"
290
289
  };
@@ -303,38 +302,37 @@ function useEntityRelationNodesAndEdges({
303
302
  if (entity) {
304
303
  (_a = entity == null ? void 0 : entity.relations) == null ? void 0 : _a.forEach((rel) => {
305
304
  var _a2;
306
- const targetRef = stringifyEntityRef(rel.target);
307
- if (!entities[targetRef]) {
305
+ if (!entities[rel.targetRef]) {
308
306
  return;
309
307
  }
310
308
  if (relations && !relations.includes(rel.type)) {
311
309
  return;
312
310
  }
313
- if (kinds && !kinds.includes(rel.target.kind.toLocaleLowerCase("en-US"))) {
311
+ if (kinds && !kinds.some((kind) => rel.targetRef.startsWith(`${kind.toLocaleLowerCase("en-US")}:`))) {
314
312
  return;
315
313
  }
316
- if (!unidirectional || !visitedNodes.has(targetRef)) {
314
+ if (!unidirectional || !visitedNodes.has(rel.targetRef)) {
317
315
  if (mergeRelations) {
318
316
  const pair = (_a2 = relationPairs.find(([l, r]) => l === rel.type || r === rel.type)) != null ? _a2 : [rel.type];
319
317
  const [left] = pair;
320
318
  edges.push({
321
- from: left === rel.type ? entityRef : targetRef,
322
- to: left === rel.type ? targetRef : entityRef,
319
+ from: left === rel.type ? entityRef : rel.targetRef,
320
+ to: left === rel.type ? rel.targetRef : entityRef,
323
321
  relations: pair,
324
322
  label: "visible"
325
323
  });
326
324
  } else {
327
325
  edges.push({
328
326
  from: entityRef,
329
- to: targetRef,
327
+ to: rel.targetRef,
330
328
  relations: [rel.type],
331
329
  label: "visible"
332
330
  });
333
331
  }
334
332
  }
335
- if (!visitedNodes.has(targetRef)) {
336
- nodeQueue.push(targetRef);
337
- visitedNodes.add(targetRef);
333
+ if (!visitedNodes.has(rel.targetRef)) {
334
+ nodeQueue.push(rel.targetRef);
335
+ visitedNodes.add(rel.targetRef);
338
336
  }
339
337
  });
340
338
  }
@@ -458,12 +456,12 @@ const catalogGraphPlugin = createPlugin({
458
456
  const EntityCatalogGraphCard = catalogGraphPlugin.provide(createComponentExtension({
459
457
  name: "EntityCatalogGraphCard",
460
458
  component: {
461
- lazy: () => import('./esm/index-169ff2f6.esm.js').then((m) => m.CatalogGraphCard)
459
+ lazy: () => import('./esm/index-baf36d74.esm.js').then((m) => m.CatalogGraphCard)
462
460
  }
463
461
  }));
464
462
  const CatalogGraphPage = catalogGraphPlugin.provide(createRoutableExtension({
465
463
  name: "CatalogGraphPage",
466
- component: () => import('./esm/index-5852c637.esm.js').then((m) => m.CatalogGraphPage),
464
+ component: () => import('./esm/index-6ed47188.esm.js').then((m) => m.CatalogGraphPage),
467
465
  mountPoint: catalogGraphRouteRef
468
466
  }));
469
467
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.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 */\n\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { MouseEventHandler } from 'react';\n\n/**\n * Additional Data for entities.\n *\n * @public\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 *\n * @public\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 * @deprecated This route is no longer used and can be removed\n */\nexport const catalogEntityRouteRef = createExternalRouteRef({\n id: 'catalog-entity',\n params: ['namespace', 'kind', 'name'],\n optional: true,\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,QAAQ,MAAM,QAAQ,KAAK;AAAA,IAE3B,aAAa;AAAA,MACX,MAAM,MAAM,QAAQ,QAAQ;AAAA,MAC5B,QAAQ,MAAM,QAAQ,QAA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,YAAU,MAAM;AACd,QAAI,OAAO;AACT,eAAS,KAAK;AAAA;AAAA,KAEf,CAAC,UAAU;AAEd,6CACG,OAAD;AAAA,IAAK,WAAW,WAAW,QAAQ,WAAW;AAAA,KAC3C,+CAAY,kBAAD;AAAA,IAAkB,WAAW,QAAQ;AAAA,MAChD,SAAS,6CACP,iBAAD;AAAA,IACE;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,aAAa;AAAA,IACb;AAAA,IACA,WAAW,QAAQ;AAAA,IACnB,UAAU,MAAM,QAAQ;AAAA,IACxB,UAAU,MAAM,QAAQ;AAAA,IACxB,eAAe,qBAAqB,cAAc;AAAA,IAClD,aAAa,MAAM,QAAQ;AAAA,IAC3B;AAAA;AAAA;;MC7GG,uBAAuB,eAAe;AAAA,EACjD,IAAI;AAAA;MAUO,wBAAwB,uBAAuB;AAAA,EAC1D,IAAI;AAAA,EACJ,QAAQ,CAAC,aAAa,QAAQ;AAAA,EAC9B,UAAU;AAAA;;MCjBC,qBAAqB,aAAa;AAAA,EAC7C,IAAI;AAAA,EACJ,QAAQ;AAAA,IACN,cAAc;AAAA;AAAA,EAEhB,gBAAgB;AAAA,IACd,eAAe;AAAA;AAAA;;MCDN,yBAAyB,mBAAmB,QACvD,yBAAyB;AAAA,EACvB,MAAM;AAAA,EACN,WAAW;AAAA,IACT,MAAM,MACJ,OAAO,+BAAiC,KAAK,OAAK,EAAE;AAAA;AAAA;MAW/C,mBAAmB,mBAAmB,QACjD,wBAAwB;AAAA,EACtB,MAAM;AAAA,EACN,WAAW,MACT,OAAO,+BAAiC,KAAK,OAAK,EAAE;AAAA,EACtD,YAAY;AAAA;;;;"}
1
+ {"version":3,"file":"index.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 { humanizeEntityRef } 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 ? humanizeEntityRef({ 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 */\n\nimport { DependencyGraphTypes } from '@backstage/core-components';\nimport { MouseEventHandler } from 'react';\n\n/**\n * Additional Data for entities.\n *\n * @public\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 *\n * @public\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 } 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.getEntityByRef(entityRef);\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 } 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.some(kind =>\n rel.targetRef.startsWith(\n `${kind.toLocaleLowerCase('en-US')}:`,\n ),\n ))\n ) {\n if (!processedEntityRefs.has(rel.targetRef)) {\n nextDepthRefQueue.push(rel.targetRef);\n expectedEntities.add(rel.targetRef);\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 { DEFAULT_NAMESPACE } 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 ?? 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 // Check if the related entity should be displayed, if not, ignore\n // the relation too\n if (!entities[rel.targetRef]) {\n return;\n }\n\n if (relations && !relations.includes(rel.type)) {\n return;\n }\n\n if (\n kinds &&\n !kinds.some(kind =>\n rel.targetRef.startsWith(`${kind.toLocaleLowerCase('en-US')}:`),\n )\n ) {\n return;\n }\n\n if (!unidirectional || !visitedNodes.has(rel.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 : rel.targetRef,\n to: left === rel.type ? rel.targetRef : entityRef,\n relations: pair,\n label: 'visible',\n });\n } else {\n edges.push({\n from: entityRef,\n to: rel.targetRef,\n relations: [rel.type],\n label: 'visible',\n });\n }\n }\n\n if (!visitedNodes.has(rel.targetRef)) {\n nodeQueue.push(rel.targetRef);\n visitedNodes.add(rel.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 {\n CompoundEntityRef,\n stringifyEntityRef,\n} 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: CompoundEntityRef | CompoundEntityRef[];\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 * @deprecated This route is no longer used and can be removed\n */\nexport const catalogEntityRouteRef = createExternalRouteRef({\n id: 'catalog-entity',\n params: ['namespace', 'kind', 'name'],\n optional: true,\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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package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-graph",
3
- "version": "0.2.10",
3
+ "version": "0.2.13",
4
4
  "main": "dist/index.esm.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -10,23 +10,26 @@
10
10
  "main": "dist/index.esm.js",
11
11
  "types": "dist/index.d.ts"
12
12
  },
13
+ "backstage": {
14
+ "role": "frontend-plugin"
15
+ },
13
16
  "scripts": {
14
- "build": "backstage-cli plugin:build",
15
- "start": "backstage-cli plugin:serve",
16
- "lint": "backstage-cli lint",
17
- "test": "backstage-cli test",
17
+ "build": "backstage-cli package build",
18
+ "start": "backstage-cli package start",
19
+ "lint": "backstage-cli package lint",
20
+ "test": "backstage-cli package test",
18
21
  "diff": "backstage-cli plugin:diff",
19
- "prepack": "backstage-cli prepack",
20
- "postpack": "backstage-cli postpack",
21
- "clean": "backstage-cli clean"
22
+ "prepack": "backstage-cli package prepack",
23
+ "postpack": "backstage-cli package postpack",
24
+ "clean": "backstage-cli package clean"
22
25
  },
23
26
  "dependencies": {
24
- "@backstage/catalog-client": "^0.6.0",
25
- "@backstage/catalog-model": "^0.9.10",
26
- "@backstage/core-components": "^0.8.8",
27
- "@backstage/core-plugin-api": "^0.6.0",
28
- "@backstage/plugin-catalog-react": "^0.6.14",
29
- "@backstage/theme": "^0.2.14",
27
+ "@backstage/catalog-client": "^0.8.0",
28
+ "@backstage/catalog-model": "^0.12.0",
29
+ "@backstage/core-components": "^0.9.0",
30
+ "@backstage/core-plugin-api": "^0.8.0",
31
+ "@backstage/plugin-catalog-react": "^0.8.0",
32
+ "@backstage/theme": "^0.2.15",
30
33
  "@material-ui/core": "^4.12.2",
31
34
  "@material-ui/icons": "^4.9.1",
32
35
  "@material-ui/lab": "4.0.0-alpha.57",
@@ -42,10 +45,11 @@
42
45
  "react": "^16.13.1 || ^17.0.0"
43
46
  },
44
47
  "devDependencies": {
45
- "@backstage/cli": "^0.13.2",
46
- "@backstage/core-app-api": "^0.5.2",
47
- "@backstage/dev-utils": "^0.2.21",
48
- "@backstage/test-utils": "^0.2.4",
48
+ "@backstage/cli": "^0.15.0",
49
+ "@backstage/core-app-api": "^0.6.0",
50
+ "@backstage/dev-utils": "^0.2.24",
51
+ "@backstage/plugin-catalog": "^0.9.1",
52
+ "@backstage/test-utils": "^0.3.0",
49
53
  "@testing-library/jest-dom": "^5.10.1",
50
54
  "@testing-library/react": "^11.2.5",
51
55
  "@testing-library/react-hooks": "^7.0.2",
@@ -55,5 +59,5 @@
55
59
  "files": [
56
60
  "dist"
57
61
  ],
58
- "gitHead": "4f4bc77a4152d372b10a4e8d97d92f00e23f3b56"
62
+ "gitHead": "04bb0dd824b78f6b57dac62c3015e681f094045c"
59
63
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-169ff2f6.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 entityRouteRef,\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 { 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(entityRouteRef);\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":";;;;;;;;;;;;;;;;;AAwCA,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;AAvFlD;AAwFM,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;;;;"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-5852c637.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 {\n entityRouteRef,\n formatEntityRefTitle,\n} 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 {\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(entityRouteRef);\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 &amp; 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,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