@reltio/graph 1.4.1586-mui5 → 1.4.1586-mui5-2

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.
Files changed (162) hide show
  1. package/package.json +9 -26
  2. package/index.ts +0 -1
  3. package/public/package.json +0 -29
  4. package/scripts/build/index.js +0 -20
  5. package/src/__tests__/GraphView.test.tsx +0 -25
  6. package/src/components/CircleLayout/CircleLayout.tsx +0 -76
  7. package/src/components/CircleLayout/__tests__/CircleLayout.test.tsx +0 -194
  8. package/src/components/GotoButton/GotoButton.tsx +0 -23
  9. package/src/components/GotoButton/__tests__/GotoButton.test.tsx +0 -33
  10. package/src/components/GotoButton/styles.ts +0 -15
  11. package/src/components/GraphArea/GraphArea.tsx +0 -113
  12. package/src/components/GraphArea/__tests__/GraphArea.test.tsx +0 -202
  13. package/src/components/GraphArea/styles.ts +0 -30
  14. package/src/components/GraphLayoutSelector/GraphLayoutSelector.tsx +0 -43
  15. package/src/components/GraphLayoutSelector/__tests__/GraphLayoutSelector.spec.tsx +0 -44
  16. package/src/components/GraphLayoutSelector/styles.ts +0 -15
  17. package/src/components/GraphPerspectiveView/GraphPerspectiveView.tsx +0 -58
  18. package/src/components/GraphPerspectiveView/__tests__/GraphPerspectiveView.test.tsx +0 -115
  19. package/src/components/GraphPerspectiveView/__tests__/useGraphLoader.test.tsx +0 -1519
  20. package/src/components/GraphPerspectiveView/__tests__/useRelationshipTable.test.tsx +0 -1003
  21. package/src/components/GraphPerspectiveView/__tests__/useSelectedEntity.test.tsx +0 -373
  22. package/src/components/GraphPerspectiveView/styles.ts +0 -34
  23. package/src/components/GraphRightSidePanel/GraphRightSidePanel.tsx +0 -27
  24. package/src/components/GraphRightSidePanel/__tests__/GraphRightSidePanel.test.tsx +0 -18
  25. package/src/components/GraphRightSidePanel/icons/relationship-icon.svg +0 -3
  26. package/src/components/GraphRightSidePanel/styles.ts +0 -8
  27. package/src/components/GraphTypeSelector/GraphTypeSelector.tsx +0 -56
  28. package/src/components/GraphTypeSelector/__tests__/GraphTypeSelector.test.tsx +0 -109
  29. package/src/components/GraphTypeSelector/styles.ts +0 -17
  30. package/src/components/HierarchyLayout/HierarchyLayout.ts +0 -102
  31. package/src/components/HierarchyLayout/__tests__/HierarchyLayout.spec.tsx +0 -241
  32. package/src/components/HierarchyLayout/__tests__/buildHierarchy.spec.ts +0 -130
  33. package/src/components/HierarchyLayout/__tests__/calculations.spec.ts +0 -230
  34. package/src/components/HierarchyLayout/buildHierarchy.ts +0 -109
  35. package/src/components/HierarchyLayout/calculations.ts +0 -86
  36. package/src/components/RightPanelEntityDetails/RightPanelEntityDetails.tsx +0 -33
  37. package/src/components/RightPanelEntityDetails/__tests__/RightPanelEntityDetails.test.tsx +0 -39
  38. package/src/components/RightPanelEntityDetails/styles.ts +0 -12
  39. package/src/components/RightPanelProfileBand/RightPanelProfileBand.tsx +0 -33
  40. package/src/components/RightPanelProfileBand/__tests__/RightPanelProfileBand.test.tsx +0 -67
  41. package/src/components/RightPanelProfileBand/styles.ts +0 -8
  42. package/src/components/RightPanelRelationship/RightPanelRelationship.tsx +0 -25
  43. package/src/components/RightPanelRelationship/__tests__/RightPanelRelationship.test.tsx +0 -18
  44. package/src/components/RightPanelRelationship/components/CollapsibleTable/CollapsibleTable.tsx +0 -100
  45. package/src/components/RightPanelRelationship/components/CollapsibleTable/TableHead.tsx +0 -38
  46. package/src/components/RightPanelRelationship/components/CollapsibleTable/__tests__/CollapsibleTable.test.tsx +0 -169
  47. package/src/components/RightPanelRelationship/components/CollapsibleTable/__tests__/TableHead.test.tsx +0 -107
  48. package/src/components/RightPanelRelationship/components/CollapsibleTable/styles.ts +0 -38
  49. package/src/components/RightPanelRelationship/components/CollapsibleTable/types.ts +0 -20
  50. package/src/components/RightPanelRelationship/components/DeleteRelationDialog/DeleteRelationDialog.tsx +0 -34
  51. package/src/components/RightPanelRelationship/components/DeleteRelationDialog/__tests__/DeleteRelationDialog.test.tsx +0 -46
  52. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/GraphAddRelationButton.tsx +0 -43
  53. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/GraphAddRelationDialog.tsx +0 -121
  54. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/__tests__/GraphAddRelationButton.test.tsx +0 -80
  55. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/__tests__/GraphAddRelationDialog.test.tsx +0 -262
  56. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/__tests__/mockdata.ts +0 -75
  57. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/styles.ts +0 -25
  58. package/src/components/RightPanelRelationship/components/GraphAddRelationDialog/useCreatableInOutRelationTypes.ts +0 -13
  59. package/src/components/RightPanelRelationship/components/RelationshipTable/RelationshipTable.tsx +0 -126
  60. package/src/components/RightPanelRelationship/components/RelationshipTable/__tests__/RelationshipTable.test.tsx +0 -176
  61. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/ControlsCellRenderer.tsx +0 -59
  62. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/DefaultCellRenderer.tsx +0 -29
  63. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/ExpandedRowRenderer.tsx +0 -94
  64. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/HeadCellRenderer.tsx +0 -34
  65. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/ProfileCellRenderer.tsx +0 -41
  66. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/__tests__/ControlsCellRenderer.test.tsx +0 -80
  67. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/__tests__/DefaultCellRenderer.test.tsx +0 -47
  68. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/__tests__/ExpandedRowRenderer.test.tsx +0 -166
  69. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/__tests__/HeadCellRenderer.test.tsx +0 -23
  70. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/__tests__/ProfileCellRenderer.test.tsx +0 -47
  71. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/components/DeleteRelationButton.tsx +0 -32
  72. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/components/__tests__/DeleteRelationButton.test.tsx +0 -28
  73. package/src/components/RightPanelRelationship/components/RelationshipTable/cell-renderers/styles.ts +0 -113
  74. package/src/components/RightPanelRelationship/components/RelationshipTable/styles.ts +0 -36
  75. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsFilters.tsx +0 -41
  76. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsFiltersDialog/RelationshipsFiltersDialog.tsx +0 -91
  77. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsFiltersDialog/__tests__/RelationshipsFilterDialog.test.tsx +0 -192
  78. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsFiltersDialog/styles.ts +0 -34
  79. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsSearchTextField/RelationshipsSearchTextField.tsx +0 -31
  80. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsSearchTextField/__tests__/RelationshipsSearchTextField.test.tsx +0 -43
  81. package/src/components/RightPanelRelationship/components/RelationshipsFilters/RelationshipsSearchTextField/styles.ts +0 -17
  82. package/src/components/RightPanelRelationship/components/RelationshipsFilters/__tests__/RelationshipsFilters.test.tsx +0 -76
  83. package/src/components/RightPanelRelationship/components/RelationshipsFilters/styles.ts +0 -19
  84. package/src/components/RightPanelRelationship/styles.ts +0 -20
  85. package/src/components/SigmaCustomRenderers/SigmaCustomRenderersContainer.tsx +0 -16
  86. package/src/components/SigmaGraphContainer/SigmaGraphContainer.tsx +0 -55
  87. package/src/components/SigmaGraphContainer/__tests__/SigmaGraphContainer.test.tsx +0 -25
  88. package/src/components/SigmaGraphResizer/SigmaGraphResizer.tsx +0 -13
  89. package/src/components/SigmaGraphResizer/__tests__/SigmaGraphResizer.test.tsx +0 -28
  90. package/src/components/TreeLayout/TreeLayout.tsx +0 -33
  91. package/src/components/TreeLayout/__tests__/TreeLayout.test.tsx +0 -42
  92. package/src/components/TreeLayout/styles.ts +0 -10
  93. package/src/components/ZoomSlider/ZoomSlider.tsx +0 -90
  94. package/src/components/ZoomSlider/__tests__/ZoomSlider.test.tsx +0 -84
  95. package/src/components/ZoomSlider/styles.ts +0 -57
  96. package/src/constants/index.ts +0 -1
  97. package/src/contexts/GraphStateContext.tsx +0 -19
  98. package/src/contexts/SigmaCustomRenderersContext.ts +0 -20
  99. package/src/helpers/relationsHelpers.ts +0 -9
  100. package/src/hooks/__tests__/useGraphLayout.test.tsx +0 -825
  101. package/src/hooks/__tests__/useGraphLayoutSelector.test.tsx +0 -19
  102. package/src/hooks/__tests__/useSelfRelationLoopsRenderer.test.ts +0 -198
  103. package/src/hooks/__tests__/useSigmaCustomRenderers.test.ts +0 -273
  104. package/src/hooks/__tests__/useTooltipRenderer.test.ts +0 -289
  105. package/src/hooks/useGraphLayout.ts +0 -308
  106. package/src/hooks/useGraphLayoutSelector.ts +0 -19
  107. package/src/hooks/useGraphLoader.ts +0 -279
  108. package/src/hooks/useGraphRightSidePanelElements.tsx +0 -36
  109. package/src/hooks/useGraphState.ts +0 -40
  110. package/src/hooks/useGraphType.ts +0 -32
  111. package/src/hooks/useRelationshipTable.ts +0 -212
  112. package/src/hooks/useRelationshipTableFilters.ts +0 -43
  113. package/src/hooks/useSelectedEntity.ts +0 -89
  114. package/src/hooks/useSelfRelationLoopsRenderer.ts +0 -52
  115. package/src/hooks/useSigmaCustomRenderers.ts +0 -112
  116. package/src/hooks/useTooltipRenderer.ts +0 -80
  117. package/src/index.tsx +0 -37
  118. package/src/rendering/canvas/__tests__/hover.spec.ts +0 -31
  119. package/src/rendering/canvas/__tests__/label.spec.ts +0 -64
  120. package/src/rendering/canvas/__tests__/nodeBackground.spec.ts +0 -99
  121. package/src/rendering/canvas/__tests__/selfRelationLoop.spec.ts +0 -88
  122. package/src/rendering/canvas/__tests__/tooltip.spec.ts +0 -33
  123. package/src/rendering/canvas/hover.ts +0 -13
  124. package/src/rendering/canvas/label.ts +0 -33
  125. package/src/rendering/canvas/nodeBackground.ts +0 -61
  126. package/src/rendering/canvas/selfRelationLoop.ts +0 -108
  127. package/src/rendering/canvas/tooltip.ts +0 -38
  128. package/src/rendering/icons/collapseIcon.inline.svg.ts +0 -6
  129. package/src/rendering/icons/expandIcon.inline.svg.ts +0 -5
  130. package/src/rendering/icons/no_photo.inline.svg.ts +0 -13
  131. package/src/rendering/webgl/edge.arrowHead.ts +0 -87
  132. package/src/rendering/webgl/edge.clamped.ts +0 -246
  133. package/src/rendering/webgl/edge.reversedArrowHead.ts +0 -14
  134. package/src/rendering/webgl/helpers/__tests__/imageHelper.spec.ts +0 -36
  135. package/src/rendering/webgl/helpers/imageHelper.ts +0 -13
  136. package/src/rendering/webgl/image.ts +0 -115
  137. package/src/rendering/webgl/node.border.ts +0 -78
  138. package/src/rendering/webgl/node.buttons.ts +0 -241
  139. package/src/rendering/webgl/node.image.ts +0 -169
  140. package/src/rendering/webgl/shaders/edge.clamped.vert.glsl.ts +0 -55
  141. package/src/rendering/webgl/shaders/node.border.frag.glsl.ts +0 -30
  142. package/src/rendering/webgl/shaders/node.border.vert.glsl.ts +0 -37
  143. package/src/rendering/webgl/shaders/node.buttons.frag.glsl.ts +0 -32
  144. package/src/rendering/webgl/shaders/node.buttons.vert.glsl.ts +0 -49
  145. package/src/rendering/webgl/shaders/node.image.frag.glsl.ts +0 -46
  146. package/src/rendering/webgl/shaders/node.image.vert.glsl.ts +0 -42
  147. package/src/types/graphDataTypes.ts +0 -143
  148. package/src/types/sigmaCustomRenderersTypes.ts +0 -13
  149. package/src/utils/__tests__/graph.spec.ts +0 -152
  150. package/src/utils/__tests__/graphLayout.spec.ts +0 -125
  151. package/src/utils/__tests__/hopsData.spec.ts +0 -456
  152. package/src/utils/__tests__/processResponceToGraph.spec.ts +0 -165
  153. package/src/utils/graph.ts +0 -83
  154. package/src/utils/graphLayout.ts +0 -70
  155. package/src/utils/hopsData.ts +0 -198
  156. package/src/utils/processResponseToGraph.ts +0 -32
  157. package/tsconfig.json +0 -4
  158. package/webpack.config.js +0 -10
  159. /package/{public/5271a9e7b6651c852e93.png → 5271a9e7b6651c852e93.png} +0 -0
  160. /package/{public/bundle.js → bundle.js} +0 -0
  161. /package/{public/bundle.js.LICENSE.txt → bundle.js.LICENSE.txt} +0 -0
  162. /package/{public/main.css → main.css} +0 -0
package/package.json CHANGED
@@ -1,30 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/graph",
3
- "version": "1.4.1586-mui5",
4
- "description": "",
5
- "main": "index.ts",
6
- "author": "",
3
+ "version": "1.4.1586-mui5-2",
7
4
  "license": "SEE LICENSE IN LICENSE FILE",
8
- "scripts": {
9
- "build": "cross-env NODE_ENV=production webpack && node ./scripts/build",
10
- "postinstall": "cross-env NODE_ENV=production webpack",
11
- "prepublishOnly": "npm run build",
12
- "watch": "webpack -w",
13
- "dev": "webpack serve",
14
- "test": "tsc && jest --config=../../jest.config.js",
15
- "test:ci": "tsc && jest --config=../../jest.config.js --maxWorkers=50%",
16
- "i18n": "ui-i18n bundle --src=./src/**/*.js --out=./baseline.json",
17
- "analyze": "cross-env NODE_ENV=production webpack --analyze"
18
- },
19
- "publishConfig": {
20
- "access": "public"
21
- },
5
+ "main": "bundle.js",
22
6
  "dependencies": {
23
7
  "@date-io/moment": "^1.3.13",
24
8
  "@react-sigma/core": "^3.1.0",
25
- "@reltio/hierarchy-tree": "^1.4.1586-mui5",
26
- "@reltio/mdm-module": "^1.4.1586-mui5",
27
- "@reltio/mdm-sdk": "^1.4.1586-mui5",
9
+ "@reltio/hierarchy-tree": "^1.4.1586-mui5-2",
10
+ "@reltio/mdm-module": "^1.4.1586-mui5-2",
11
+ "@reltio/mdm-sdk": "^1.4.1586-mui5-2",
28
12
  "classnames": "^2.2.5",
29
13
  "graphology": "^0.25.1",
30
14
  "graphology-layout": "^0.6.1",
@@ -39,8 +23,7 @@
39
23
  "sigma": "^2.4.0",
40
24
  "ui-i18n": "bitbucket:reltio-ondemand/ui-i18n#v1.4.0"
41
25
  },
42
- "devDependencies": {
43
- "@reltio/components": "^1.4.1586-mui5"
44
- },
45
- "gitHead": "746e04a2ebbd1e190caf6e7b504eede0fd54d100"
46
- }
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }
package/index.ts DELETED
@@ -1 +0,0 @@
1
- export {default as GraphView} from './src';
@@ -1,29 +0,0 @@
1
- {
2
- "name": "@reltio/graph",
3
- "version": "1.4.1586-mui5",
4
- "license": "SEE LICENSE IN LICENSE FILE",
5
- "main": "bundle.js",
6
- "dependencies": {
7
- "@date-io/moment": "^1.3.13",
8
- "@react-sigma/core": "^3.1.0",
9
- "@reltio/hierarchy-tree": "^1.4.1586-mui5",
10
- "@reltio/mdm-module": "^1.4.1586-mui5",
11
- "@reltio/mdm-sdk": "^1.4.1586-mui5",
12
- "classnames": "^2.2.5",
13
- "graphology": "^0.25.1",
14
- "graphology-layout": "^0.6.1",
15
- "graphology-layout-forceatlas2": "^0.10.1",
16
- "graphology-operators": "^1.6.0",
17
- "graphology-shortest-path": "^2.0.1",
18
- "graphology-types": "^0.24.5",
19
- "ramda": "^0.28.0",
20
- "react-redux": "^7.2.3",
21
- "react-resize-detector": "^4.2.0",
22
- "redux": "^4.1.2",
23
- "sigma": "^2.4.0",
24
- "ui-i18n": "bitbucket:reltio-ondemand/ui-i18n#v1.4.0"
25
- },
26
- "publishConfig": {
27
- "access": "public"
28
- }
29
- }
@@ -1,20 +0,0 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
-
4
- const outputDir = path.resolve(process.cwd(), 'public');
5
- const generatePackageJson = () => {
6
- const packageJson = require('../../package.json');
7
- const result = {
8
- name: packageJson.name,
9
- version: packageJson.version,
10
- license: 'SEE LICENSE IN LICENSE FILE',
11
- main: 'bundle.js',
12
- dependencies: packageJson.dependencies,
13
- peerDependencies: packageJson.peerDependencies,
14
- publishConfig: packageJson.publishConfig
15
- };
16
- const source = JSON.stringify(result, null, 2);
17
- fs.writeFileSync(path.join(outputDir, 'package.json'), source);
18
- };
19
-
20
- generatePackageJson();
@@ -1,25 +0,0 @@
1
- import GraphView from '../';
2
- import {shallow} from 'enzyme';
3
- import {Store} from 'redux';
4
- import React from 'react';
5
- import {Provider} from 'react-redux';
6
- import {ErrorPopup} from '@reltio/components';
7
- import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider';
8
- import {AdapterMoment} from '@mui/x-date-pickers/AdapterMoment';
9
- import GraphPerspectiveView from '../components/GraphPerspectiveView/GraphPerspectiveView';
10
-
11
- const store = {} as Store;
12
- const setUp = () => shallow(<GraphView store={store} />);
13
-
14
- describe('graph view test', () => {
15
- it('should render redux provider, StylesProvider, LocalizationProvider', () => {
16
- const component = setUp();
17
- expect(component.find(Provider)).toHaveLength(1);
18
- expect(component.find(Provider).prop('store')).toBe(store);
19
- expect(component.find(GraphPerspectiveView)).toHaveLength(1);
20
- expect(component.find(ErrorPopup)).toHaveLength(1);
21
- expect(component.find(ErrorPopup).prop('showErrorFromStore')).toBe(true);
22
- expect(component.find(LocalizationProvider)).toHaveLength(1);
23
- expect(component.find(LocalizationProvider).prop('dateAdapter')).toBe(AdapterMoment);
24
- });
25
- });
@@ -1,76 +0,0 @@
1
- import {useMemo} from 'react';
2
- import circular from 'graphology-layout/circular';
3
- import forceAtlas2 from 'graphology-layout-forceatlas2';
4
- import FA2Layout from 'graphology-layout-forceatlas2/worker';
5
- import Graph from 'graphology';
6
- import {difference, prop} from 'ramda';
7
- import {HopsResponse, GraphLayout} from '@reltio/mdm-sdk';
8
- import {useDidUpdateEffect, usePrevious} from '@reltio/components';
9
-
10
- import {useGraphLayout} from '../../hooks/useGraphLayout';
11
- import {GraphPathType, Filters} from '../../types/graphDataTypes';
12
-
13
- type CircleLayoutProps = {
14
- data: HopsResponse;
15
- graph: Graph;
16
- selectedNode: string;
17
- onNodeClick: (node: string) => void;
18
- onNodeCollapse: (node: string, path: GraphPathType) => void;
19
- onNodeExpand: (node: string) => void;
20
- layout: GraphLayout;
21
- filters?: Filters;
22
- };
23
-
24
- export const CircleLayout = ({
25
- data,
26
- graph,
27
- selectedNode,
28
- layout,
29
- onNodeClick,
30
- onNodeCollapse,
31
- onNodeExpand,
32
- filters
33
- }: CircleLayoutProps) => {
34
- const prevData: HopsResponse = usePrevious(data);
35
-
36
- useDidUpdateEffect(() => {
37
- if (prevData) {
38
- const newNodesIds = difference(data.entities.map(prop('uri')), prevData.entities.map(prop('uri')));
39
- if (newNodesIds.length) {
40
- const tempGraph = graph.copy();
41
- circular.assign(tempGraph);
42
- newNodesIds.forEach((id) => {
43
- graph.setNodeAttribute(id, 'x', tempGraph.getNodeAttribute(id, 'x'));
44
- graph.setNodeAttribute(id, 'y', tempGraph.getNodeAttribute(id, 'y'));
45
- });
46
- }
47
- }
48
- }, [data]);
49
-
50
- const layoutSettings = useMemo(() => {
51
- circular.assign(graph);
52
- return {
53
- settings: {
54
- ...forceAtlas2.inferSettings(graph),
55
- gravity: 1
56
- }
57
- };
58
- }, [graph]);
59
-
60
- useGraphLayout({
61
- workerLayout: FA2Layout,
62
- layoutSettings,
63
- data,
64
- graph,
65
- selectedNode,
66
- onNodeClick,
67
- isDirected: layout === GraphLayout.DIRECTED_NETWORK,
68
- onNodeCollapse,
69
- onNodeExpand,
70
- filters
71
- });
72
-
73
- return null;
74
- };
75
-
76
- export default CircleLayout;
@@ -1,194 +0,0 @@
1
- import React from 'react';
2
- import {mount} from 'enzyme';
3
- import {MultiGraph} from 'graphology';
4
- import FA2Layout from 'graphology-layout-forceatlas2/worker';
5
- import {HopsResponse, GraphLayout} from '@reltio/mdm-sdk';
6
-
7
- import CircleLayout from '../CircleLayout';
8
- import * as useGraphLayoutImport from '../../../hooks/useGraphLayout';
9
- import {useGraphLayout} from '../../../hooks/useGraphLayout';
10
- import {fillGraphWithHopsResponse} from '../../../utils/graph';
11
-
12
- jest.mock('../../../hooks/useGraphLayout', () => ({
13
- ...(jest.requireActual('../../../hooks/useGraphLayout') as Record<string, unknown>),
14
- useGraphLayout: jest.fn()
15
- }));
16
-
17
- describe('CircleLayout tests', () => {
18
- const data: HopsResponse = {
19
- entities: [
20
- {uri: 'node1', type: ''},
21
- {uri: 'node2', type: ''},
22
- {uri: 'node3', type: ''},
23
- {uri: 'node4', type: ''}
24
- ],
25
- relations: [
26
- {
27
- uri: 'r1',
28
- type: '',
29
- startObject: {
30
- objectURI: 'node1'
31
- },
32
- endObject: {
33
- objectURI: 'node2'
34
- }
35
- },
36
- {
37
- uri: 'r2',
38
- type: '',
39
- startObject: {
40
- objectURI: 'node2'
41
- },
42
- endObject: {
43
- objectURI: 'node3'
44
- }
45
- },
46
- {
47
- uri: 'r3',
48
- type: '',
49
- startObject: {
50
- objectURI: 'node2'
51
- },
52
- endObject: {
53
- objectURI: 'node4'
54
- }
55
- }
56
- ]
57
- };
58
- const graph = new MultiGraph();
59
- fillGraphWithHopsResponse(graph, data);
60
- const basicProps = {
61
- data,
62
- graph,
63
- selectedNode: 'entities/uri1',
64
- onNodeClick: jest.fn(),
65
- onNodeCollapse: jest.fn(),
66
- onNodeExpand: jest.fn(),
67
- filters: {entityTypesUris: ['hcp'], relationTypesUris: []}
68
- };
69
-
70
- beforeAll(() => {
71
- jest.spyOn(useGraphLayoutImport, 'useGraphLayout').mockReturnValue(undefined);
72
- });
73
-
74
- afterEach(() => {
75
- jest.clearAllMocks();
76
- });
77
-
78
- it('should call useGraphLayout with correctly params if layout is not directed network', () => {
79
- const props = {
80
- ...basicProps,
81
- layout: GraphLayout.SIMPLE_NETWORK
82
- };
83
- mount(<CircleLayout {...props} />);
84
- expect(useGraphLayout).toHaveBeenCalledWith({
85
- workerLayout: FA2Layout,
86
- layoutSettings: {
87
- settings: {
88
- barnesHutOptimize: false,
89
- gravity: 1,
90
- scalingRatio: 10,
91
- slowDown: expect.any(Number),
92
- strongGravityMode: true
93
- }
94
- },
95
- isDirected: false,
96
- filters: {
97
- entityTypesUris: ['hcp'],
98
- relationTypesUris: []
99
- },
100
- graph,
101
- data: props.data,
102
- onNodeClick: props.onNodeClick,
103
- onNodeCollapse: props.onNodeCollapse,
104
- onNodeExpand: props.onNodeExpand,
105
- selectedNode: props.selectedNode
106
- });
107
- });
108
-
109
- it('should call useGraphLayout with correctly params if layout is directed network', () => {
110
- const props = {
111
- ...basicProps,
112
- layout: GraphLayout.DIRECTED_NETWORK
113
- };
114
- mount(<CircleLayout {...props} />);
115
- expect(useGraphLayout).toHaveBeenCalledWith({
116
- workerLayout: FA2Layout,
117
- layoutSettings: {
118
- settings: {
119
- barnesHutOptimize: false,
120
- gravity: 1,
121
- scalingRatio: 10,
122
- slowDown: expect.any(Number),
123
- strongGravityMode: true
124
- }
125
- },
126
- isDirected: true,
127
- graph,
128
- data: props.data,
129
- onNodeClick: props.onNodeClick,
130
- onNodeExpand: props.onNodeExpand,
131
- onNodeCollapse: props.onNodeCollapse,
132
- selectedNode: props.selectedNode,
133
- filters: props.filters
134
- });
135
- });
136
-
137
- it('should assign circular layout for new nodes if new nodes were added to data', () => {
138
- const props = {
139
- ...basicProps,
140
- layout: GraphLayout.SIMPLE_NETWORK
141
- };
142
- const component = mount(<CircleLayout {...props} />);
143
-
144
- const newData = {
145
- entities: [...data.entities, {uri: 'node5', type: ''}, {uri: 'node6', type: ''}],
146
- relations: [
147
- ...data.relations,
148
- {
149
- uri: 'r4',
150
- type: '',
151
- startObject: {
152
- objectURI: 'node4'
153
- },
154
- endObject: {
155
- objectURI: 'node5'
156
- }
157
- },
158
- {
159
- uri: 'r5',
160
- type: '',
161
- startObject: {
162
- objectURI: 'node4'
163
- },
164
- endObject: {
165
- objectURI: 'node6'
166
- }
167
- }
168
- ]
169
- };
170
-
171
- const newGraph = new MultiGraph();
172
- fillGraphWithHopsResponse(newGraph, newData);
173
- expect(newGraph.getNodeAttributes('node5')).toMatchObject({
174
- x: 1,
175
- y: 1
176
- });
177
- expect(newGraph.getNodeAttributes('node6')).toMatchObject({
178
- x: 1,
179
- y: 1
180
- });
181
-
182
- component.setProps({...props, data: newData, graph: newGraph});
183
- component.update();
184
-
185
- expect(newGraph.getNodeAttributes('node5')).toMatchObject({
186
- x: -0.5000000000000004,
187
- y: -0.8660254037844385
188
- });
189
- expect(newGraph.getNodeAttributes('node6')).toMatchObject({
190
- x: 0.5000000000000001,
191
- y: -0.8660254037844386
192
- });
193
- });
194
- });
@@ -1,23 +0,0 @@
1
- import React from 'react';
2
- import {useCamera} from '@react-sigma/core';
3
- import MyLocationIcon from '@mui/icons-material/MyLocation';
4
- import IconButton from '@mui/material/IconButton';
5
-
6
- import {useStyles} from './styles';
7
-
8
- type Props = {
9
- node: string;
10
- };
11
-
12
- const GotoButton = ({node}: Props) => {
13
- const styles = useStyles();
14
- const {gotoNode} = useCamera();
15
-
16
- return (
17
- <IconButton className={styles.button} onClick={() => gotoNode(node)} size="large">
18
- <MyLocationIcon className={styles.icon} />
19
- </IconButton>
20
- );
21
- };
22
-
23
- export default GotoButton;
@@ -1,33 +0,0 @@
1
- import React from 'react';
2
- import {shallow} from 'enzyme';
3
- import {act} from 'react-dom/test-utils';
4
- import {useCamera} from '@react-sigma/core';
5
- import IconButton from '@mui/material/IconButton';
6
- import MyLocationIcon from '@mui/icons-material/MyLocation';
7
- import GotoButton from '../GotoButton';
8
-
9
- jest.mock('@react-sigma/core', () => ({
10
- ...jest.requireActual<Record<string, unknown>>('@react-sigma/core'),
11
- useCamera: jest.fn().mockReturnValue({
12
- gotoNode: jest.fn()
13
- })
14
- }));
15
-
16
- describe('GotoButton tests', () => {
17
- it('should render main parts', () => {
18
- const component = shallow(<GotoButton node={undefined} />);
19
- expect(component.find(IconButton)).toHaveLength(1);
20
- expect(component.find(MyLocationIcon)).toHaveLength(1);
21
- });
22
-
23
- it('should call gotoNode on click', () => {
24
- const nodeUri = 'testUri';
25
- const component = shallow(<GotoButton node={nodeUri} />);
26
- expect(component.find(IconButton)).toHaveLength(1);
27
- act(() => {
28
- component.find(IconButton).simulate('click');
29
- });
30
-
31
- expect(useCamera().gotoNode).toHaveBeenCalledWith(nodeUri);
32
- });
33
- });
@@ -1,15 +0,0 @@
1
- import {makeStyles} from '@mui/styles';
2
-
3
- export const useStyles = makeStyles({
4
- button: {
5
- background: '#FFFFFF',
6
- boxShadow: '0 1px 1px rgba(0,0,0,0.14), 0 2px 1px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.2)',
7
- width: '28px',
8
- height: '28px',
9
- borderRadius: '4px'
10
- },
11
- icon: {
12
- width: '18px',
13
- height: '18px'
14
- }
15
- });
@@ -1,113 +0,0 @@
1
- import React from 'react';
2
- import Graph from 'graphology';
3
- import {withContext} from '@reltio/components';
4
- import {HopsResponse, GraphLayout} from '@reltio/mdm-sdk';
5
- import {SigmaGraphContainer} from '../SigmaGraphContainer/SigmaGraphContainer';
6
- import CircleLayout from '../CircleLayout/CircleLayout';
7
- import HierarchyLayout from '../HierarchyLayout/HierarchyLayout';
8
- import {GraphStateContext} from '../../contexts/GraphStateContext';
9
- import {Filters, GraphPathType} from '../../types/graphDataTypes';
10
- import GraphTypeSelector from '../GraphTypeSelector/GraphTypeSelector';
11
- import GraphLayoutSelector from '../GraphLayoutSelector/GraphLayoutSelector';
12
- import SigmaGraphResizer from '../SigmaGraphResizer/SigmaGraphResizer';
13
- import ZoomSlider from '../ZoomSlider/ZoomSlider';
14
- import GotoButton from '../GotoButton/GotoButton';
15
- import TreeLayout from '../TreeLayout/TreeLayout';
16
- import {useStyles} from './styles';
17
-
18
- type Props = {
19
- data?: HopsResponse;
20
- graph?: Graph;
21
- selectedNode?: string;
22
- onNodeSelect?: (uri: string) => void;
23
- onNodeCollapse?: (uri: string, path: GraphPathType) => void;
24
- onNodeExpand?: (uri: string) => void;
25
- filters?: Filters;
26
- graphTypeUri?: string;
27
- layout?: GraphLayout;
28
- setLayout?: (layout: GraphLayout) => void;
29
- };
30
-
31
- const GraphArea = ({
32
- data,
33
- graph,
34
- selectedNode,
35
- onNodeSelect,
36
- onNodeCollapse,
37
- onNodeExpand,
38
- filters,
39
- graphTypeUri,
40
- layout,
41
- setLayout
42
- }: Props) => {
43
- const styles = useStyles();
44
-
45
- const commonProps = {
46
- data,
47
- graph,
48
- selectedNode,
49
- layout,
50
- onNodeClick: onNodeSelect,
51
- onNodeCollapse,
52
- onNodeExpand,
53
- filters
54
- };
55
- return (
56
- <div className={styles.wrapper}>
57
- <div className={styles.selectors}>
58
- <GraphTypeSelector />
59
- <GraphLayoutSelector value={layout} onChangeHandler={setLayout} graphTypeUri={graphTypeUri} />
60
- </div>
61
- <div className={styles.graph}>
62
- {layout === GraphLayout.TREE ? (
63
- <TreeLayout graphTypeUri={graphTypeUri} />
64
- ) : (
65
- graph && (
66
- <SigmaGraphContainer>
67
- <>
68
- <SigmaGraphResizer />
69
- {layout === GraphLayout.SIMPLE_NETWORK || layout === GraphLayout.DIRECTED_NETWORK ? (
70
- <CircleLayout {...commonProps} />
71
- ) : (
72
- <HierarchyLayout {...commonProps} />
73
- )}
74
- <div className={styles.rightBottomControls}>
75
- <ZoomSlider className={styles.zoomSlider} min={30} max={300} />
76
- <GotoButton node={selectedNode} />
77
- </div>
78
- </>
79
- </SigmaGraphContainer>
80
- )
81
- )}
82
- </div>
83
- </div>
84
- );
85
- };
86
-
87
- export default withContext(
88
- GraphStateContext,
89
- ({
90
- data,
91
- graphologyGraph,
92
- selectedEntity,
93
- onEntitySelect,
94
- onCollapseEntity,
95
- onExpandEntity,
96
- relationshipTable: {filters},
97
- graphTypeUri,
98
- layout,
99
- setLayout
100
- }) => ({
101
- data,
102
- graph: graphologyGraph,
103
- selectedNode: selectedEntity?.uri,
104
- onNodeSelect: onEntitySelect,
105
- onNodeCollapse: onCollapseEntity,
106
- onNodeExpand: onExpandEntity,
107
- filters,
108
- graphTypeUri,
109
- layout,
110
- setLayout
111
- }),
112
- GraphArea
113
- );