@backstage/plugin-catalog-graph 0.4.7 → 0.4.8-next.0

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,20 @@
1
1
  # @backstage/plugin-catalog-graph
2
2
 
3
+ ## 0.4.8-next.0
4
+
5
+ ### Patch Changes
6
+
7
+ - fba7537: Memoize entity graph nodes when applying an `entityFilter` to prevent repeated redraws
8
+ - Updated dependencies
9
+ - @backstage/frontend-plugin-api@0.6.8-next.0
10
+ - @backstage/plugin-catalog-react@1.12.3-next.0
11
+ - @backstage/core-components@0.14.10-next.0
12
+ - @backstage/catalog-client@1.6.5
13
+ - @backstage/catalog-model@1.5.0
14
+ - @backstage/core-compat-api@0.2.8-next.0
15
+ - @backstage/core-plugin-api@1.9.3
16
+ - @backstage/types@1.1.1
17
+
3
18
  ## 0.4.7
4
19
 
5
20
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-graph__alpha",
3
- "version": "0.4.7",
3
+ "version": "0.4.8-next.0",
4
4
  "main": "../dist/alpha.esm.js",
5
5
  "module": "../dist/alpha.esm.js",
6
6
  "types": "../dist/alpha.d.ts"
@@ -1,4 +1,4 @@
1
- import { useEffect } from 'react';
1
+ import { useEffect, useMemo } from 'react';
2
2
  import { useEntityStore } from './useEntityStore.esm.js';
3
3
  import { pickBy } from 'lodash';
4
4
 
@@ -54,7 +54,10 @@ function useEntityRelationGraph({
54
54
  entityFilter,
55
55
  requestEntities
56
56
  ]);
57
- const filteredEntities = entityFilter ? pickBy(entities, (value, _key) => entityFilter(value)) : entities;
57
+ const filteredEntities = useMemo(
58
+ () => entityFilter ? pickBy(entities, (value, _key) => entityFilter(value)) : entities,
59
+ [entities, entityFilter]
60
+ );
58
61
  return {
59
62
  entities: filteredEntities,
60
63
  loading,
@@ -1 +1 @@
1
- {"version":3,"file":"useEntityRelationGraph.esm.js","sources":["../../../src/components/EntityRelationsGraph/useEntityRelationGraph.ts"],"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 { Entity } from '@backstage/catalog-model';\nimport { useEffect } from 'react';\nimport { useEntityStore } from './useEntityStore';\nimport { pickBy } from 'lodash';\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: {\n maxDepth = Number.POSITIVE_INFINITY,\n relations,\n kinds,\n entityFilter,\n } = {},\n}: {\n rootEntityRefs: string[];\n filter?: {\n maxDepth?: number;\n relations?: string[];\n kinds?: string[];\n entityFilter?: (entity: Entity) => boolean;\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 // If the entity is filtered out then no need to check any\n // of its outgoing relationships to other entities\n if (entityFilter && !entityFilter(entity)) {\n continue;\n }\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 requestEntities([...expectedEntities]);\n }, [\n entities,\n rootEntityRefs,\n maxDepth,\n relations,\n kinds,\n entityFilter,\n requestEntities,\n ]);\n\n const filteredEntities = entityFilter\n ? pickBy(entities, (value, _key) => entityFilter(value))\n : entities;\n\n return {\n entities: filteredEntities,\n loading,\n error,\n };\n}\n"],"names":[],"mappings":";;;;AAyBO,SAAS,sBAAuB,CAAA;AAAA,EACrC,cAAA;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,WAAW,MAAO,CAAA,iBAAA;AAAA,IAClB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAA;AAAA,MACE,EAAC;AACP,CAYE,EAAA;AACA,EAAA,MAAM,EAAE,QAAU,EAAA,OAAA,EAAS,KAAO,EAAA,eAAA,KAAoB,cAAe,EAAA,CAAA;AAErE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,mCAAuB,IAAA,GAAA,CAAI,CAAC,GAAG,cAAc,CAAC,CAAA,CAAA;AACpD,IAAM,MAAA,mBAAA,uBAA0B,GAAY,EAAA,CAAA;AAE5C,IAAI,IAAA,iBAAA,GAAoB,CAAC,GAAG,cAAc,CAAA,CAAA;AAC1C,IAAA,IAAI,KAAQ,GAAA,CAAA,CAAA;AAEZ,IACE,OAAA,iBAAA,CAAkB,SAAS,CAC1B,KAAA,CAAC,SAAS,QAAQ,CAAA,IAAK,QAAQ,QAChC,CAAA,EAAA;AACA,MAAA,MAAM,cAAiB,GAAA,iBAAA,CAAA;AACvB,MAAA,iBAAA,GAAoB,EAAC,CAAA;AAErB,MAAO,OAAA,cAAA,CAAe,SAAS,CAAG,EAAA;AAChC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,EAAA,CAAC,OAAO,IAAS,KAAA,YAAA,CAAa,KAAK,CAAC,CACrD,GAAA,QAAA,CAAA;AAEJ,EAAO,OAAA;AAAA,IACL,QAAU,EAAA,gBAAA;AAAA,IACV,OAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"useEntityRelationGraph.esm.js","sources":["../../../src/components/EntityRelationsGraph/useEntityRelationGraph.ts"],"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 { Entity } from '@backstage/catalog-model';\nimport { useEffect, useMemo } from 'react';\nimport { useEntityStore } from './useEntityStore';\nimport { pickBy } from 'lodash';\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: {\n maxDepth = Number.POSITIVE_INFINITY,\n relations,\n kinds,\n entityFilter,\n } = {},\n}: {\n rootEntityRefs: string[];\n filter?: {\n maxDepth?: number;\n relations?: string[];\n kinds?: string[];\n entityFilter?: (entity: Entity) => boolean;\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 // If the entity is filtered out then no need to check any\n // of its outgoing relationships to other entities\n if (entityFilter && !entityFilter(entity)) {\n continue;\n }\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 requestEntities([...expectedEntities]);\n }, [\n entities,\n rootEntityRefs,\n maxDepth,\n relations,\n kinds,\n entityFilter,\n requestEntities,\n ]);\n\n const filteredEntities = useMemo(\n () =>\n entityFilter\n ? pickBy(entities, (value, _key) => entityFilter(value))\n : entities,\n [entities, entityFilter],\n );\n\n return {\n entities: filteredEntities,\n loading,\n error,\n };\n}\n"],"names":[],"mappings":";;;;AAyBO,SAAS,sBAAuB,CAAA;AAAA,EACrC,cAAA;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,WAAW,MAAO,CAAA,iBAAA;AAAA,IAClB,SAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAA;AAAA,MACE,EAAC;AACP,CAYE,EAAA;AACA,EAAA,MAAM,EAAE,QAAU,EAAA,OAAA,EAAS,KAAO,EAAA,eAAA,KAAoB,cAAe,EAAA,CAAA;AAErE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,mCAAuB,IAAA,GAAA,CAAI,CAAC,GAAG,cAAc,CAAC,CAAA,CAAA;AACpD,IAAM,MAAA,mBAAA,uBAA0B,GAAY,EAAA,CAAA;AAE5C,IAAI,IAAA,iBAAA,GAAoB,CAAC,GAAG,cAAc,CAAA,CAAA;AAC1C,IAAA,IAA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,eAAA,CAAA,CAAC,GAAG,gBAAgB,CAAC,CAAA,CAAA;AAAA,GACpC,EAAA;AAAA,IACD,QAAA;AAAA,IACA,cAAA;AAAA,IACA,QAAA;AAAA,IACA,SAAA;AAAA,IACA,KAAA;AAAA,IACA,YAAA;AAAA,IACA,eAAA;AAAA,GACD,CAAA,CAAA;AAED,EAAA,MAAM,gBAAmB,GAAA,OAAA;AAAA,IACvB,MACE,YACI,GAAA,MAAA,CAAO,QAAU,EAAA,CAAC,OAAO,IAAS,KAAA,YAAA,CAAa,KAAK,CAAC,CACrD,GAAA,QAAA;AAAA,IACN,CAAC,UAAU,YAAY,CAAA;AAAA,GACzB,CAAA;AAEA,EAAO,OAAA;AAAA,IACL,QAAU,EAAA,gBAAA;AAAA,IACV,OAAA;AAAA,IACA,KAAA;AAAA,GACF,CAAA;AACF;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@backstage/plugin-catalog-graph",
3
- "version": "0.4.7",
3
+ "version": "0.4.8-next.0",
4
4
  "backstage": {
5
5
  "role": "frontend-plugin",
6
6
  "pluginId": "catalog-graph",
@@ -50,11 +50,11 @@
50
50
  "dependencies": {
51
51
  "@backstage/catalog-client": "^1.6.5",
52
52
  "@backstage/catalog-model": "^1.5.0",
53
- "@backstage/core-compat-api": "^0.2.7",
54
- "@backstage/core-components": "^0.14.9",
53
+ "@backstage/core-compat-api": "^0.2.8-next.0",
54
+ "@backstage/core-components": "^0.14.10-next.0",
55
55
  "@backstage/core-plugin-api": "^1.9.3",
56
- "@backstage/frontend-plugin-api": "^0.6.7",
57
- "@backstage/plugin-catalog-react": "^1.12.2",
56
+ "@backstage/frontend-plugin-api": "^0.6.8-next.0",
57
+ "@backstage/plugin-catalog-react": "^1.12.3-next.0",
58
58
  "@backstage/types": "^1.1.1",
59
59
  "@material-ui/core": "^4.12.2",
60
60
  "@material-ui/icons": "^4.9.1",
@@ -67,11 +67,11 @@
67
67
  "react-use": "^17.2.4"
68
68
  },
69
69
  "devDependencies": {
70
- "@backstage/cli": "^0.26.11",
71
- "@backstage/core-app-api": "^1.14.0",
72
- "@backstage/dev-utils": "^1.0.35",
73
- "@backstage/plugin-catalog": "^1.21.1",
74
- "@backstage/test-utils": "^1.5.8",
70
+ "@backstage/cli": "^0.27.0-next.0",
71
+ "@backstage/core-app-api": "^1.14.1-next.0",
72
+ "@backstage/dev-utils": "^1.0.36-next.0",
73
+ "@backstage/plugin-catalog": "^1.21.2-next.0",
74
+ "@backstage/test-utils": "^1.5.9-next.0",
75
75
  "@testing-library/dom": "^10.0.0",
76
76
  "@testing-library/jest-dom": "^6.0.0",
77
77
  "@testing-library/react": "^15.0.0",