@reltio/dashboard 1.4.1584 → 1.4.1586-mui5

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 (263) hide show
  1. package/.DS_Store +0 -0
  2. package/index.ts +12 -0
  3. package/package.json +42 -25
  4. package/public/bundle.js +205 -0
  5. package/public/bundle.js.LICENSE.txt +59 -0
  6. package/public/package.json +26 -0
  7. package/public/types/components/DashboardConfigItem/styles.d.ts +1 -0
  8. package/{types → public/types}/components/DashboardError/styles.d.ts +1 -1
  9. package/public/types/components/DashboardLayout/styles.d.ts +1 -0
  10. package/public/types/components/DashboardLayoutItem/styles.d.ts +1 -0
  11. package/public/types/components/DashboardLayoutPanel/styles.d.ts +1 -0
  12. package/public/types/components/DashboardLinearLoader/styles.d.ts +1 -0
  13. package/{types → public/types}/components/DashboardNoData/styles.d.ts +1 -1
  14. package/public/types/components/DashboardPerspectiveHeader/styles.d.ts +2 -0
  15. package/{types → public/types}/components/DashboardPopupMenu/DashboardPopupMenu.d.ts +1 -1
  16. package/public/types/components/DashboardPopupMenu/styles.d.ts +1 -0
  17. package/public/types/components/EntityTable/cell-renderers/styles.d.ts +1 -0
  18. package/{types → public/types}/components/EntityTable/styles.d.ts +1 -1
  19. package/public/types/components/LayoutItemContent/styles.d.ts +1 -0
  20. package/public/types/components/LayoutItemHeader/styles.d.ts +1 -0
  21. package/public/types/components/LayoutItemView/styles.d.ts +1 -0
  22. package/public/types/components/StatsChart/customized/styles.d.ts +1 -0
  23. package/public/types/components/WorkflowTaskItem/styles.d.ts +1 -0
  24. package/public/types/perspective/styles.d.ts +1 -0
  25. package/public/types/views/chartBased/styles.d.ts +1 -0
  26. package/public/types/views/custom/styles.d.ts +1 -0
  27. package/public/types/views/tableBased/styles.d.ts +1 -0
  28. package/scripts/build/index.js +21 -0
  29. package/src/HOCs/withPagination.tsx +39 -0
  30. package/src/components/DashboardConfigItem/DashboardConfigItem.tsx +101 -0
  31. package/src/components/DashboardConfigItem/__tests__/DashboardConfigItem.specs.tsx +81 -0
  32. package/src/components/DashboardConfigItem/icons/barChart.svg +12 -0
  33. package/src/components/DashboardConfigItem/icons/bubbleChart.svg +18 -0
  34. package/src/components/DashboardConfigItem/icons/customChart.svg +66 -0
  35. package/src/components/DashboardConfigItem/icons/donutChart.svg +33 -0
  36. package/src/components/DashboardConfigItem/icons/geomap.svg +23 -0
  37. package/src/components/DashboardConfigItem/icons/lineChart.svg +16 -0
  38. package/src/components/DashboardConfigItem/icons/pieChart.svg +27 -0
  39. package/src/components/DashboardConfigItem/icons/tableWithBars.svg +27 -0
  40. package/src/components/DashboardConfigItem/icons/treemap.svg +15 -0
  41. package/src/components/DashboardConfigItem/icons/wordCloud.svg +27 -0
  42. package/src/components/DashboardConfigItem/styles.ts +56 -0
  43. package/src/components/DashboardError/DashboardError.tsx +34 -0
  44. package/src/components/DashboardError/__tests__/DashboardError.test.js +34 -0
  45. package/src/components/DashboardError/icons/error.svg +113 -0
  46. package/src/components/DashboardError/styles.ts +30 -0
  47. package/src/components/DashboardLayout/DashboardLayout.tsx +59 -0
  48. package/src/components/DashboardLayout/__tests__/DashboardLayout.specs.tsx +56 -0
  49. package/src/components/DashboardLayout/styles.ts +30 -0
  50. package/src/components/DashboardLayoutItem/DashboardLayoutItem.tsx +59 -0
  51. package/src/components/DashboardLayoutItem/__tests__/DashboardLayoutItem.specs.tsx +145 -0
  52. package/src/components/DashboardLayoutItem/styles.ts +10 -0
  53. package/src/components/DashboardLayoutPanel/DashboardLayoutPanel.tsx +59 -0
  54. package/src/components/DashboardLayoutPanel/__tests__/DashboardLayoutPanel.specs.tsx +58 -0
  55. package/src/components/DashboardLayoutPanel/styles.ts +43 -0
  56. package/src/components/DashboardLinearLoader/DashboardLinearLoader.tsx +10 -0
  57. package/src/components/DashboardLinearLoader/__tests__/DashboardLinearLoader.test.js +12 -0
  58. package/src/components/DashboardLinearLoader/styles.ts +11 -0
  59. package/src/components/DashboardNoData/.DS_Store +0 -0
  60. package/src/components/DashboardNoData/DashboardNoData.tsx +21 -0
  61. package/src/components/DashboardNoData/__tests__/DashboardNoData.test.js +15 -0
  62. package/src/components/DashboardNoData/icons/noData.svg +68 -0
  63. package/src/components/DashboardNoData/styles.ts +21 -0
  64. package/src/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.tsx +43 -0
  65. package/src/components/DashboardPerspectiveHeader/__tests__/DashboardPerspectiveHeader.specs.tsx +41 -0
  66. package/src/components/DashboardPerspectiveHeader/styles.ts +24 -0
  67. package/src/components/DashboardPopupMenu/DashboardPopupMenu.tsx +75 -0
  68. package/src/components/DashboardPopupMenu/__tests__/DashboardPopupMenu.test.tsx +51 -0
  69. package/src/components/DashboardPopupMenu/styles.ts +20 -0
  70. package/src/components/EntityTable/EntityTable.tsx +49 -0
  71. package/src/components/EntityTable/__tests__/EntityTable.test.tsx +33 -0
  72. package/src/components/EntityTable/cell-renderers/EntityLabelRenderer.tsx +24 -0
  73. package/src/components/EntityTable/cell-renderers/HeadCellRenderer.tsx +34 -0
  74. package/src/components/EntityTable/cell-renderers/__tests__/EntityLabelRenderer.test.tsx +25 -0
  75. package/src/components/EntityTable/cell-renderers/styles.ts +46 -0
  76. package/src/components/EntityTable/styles.ts +19 -0
  77. package/src/components/LayoutItemContent/LayoutItemContent.tsx +63 -0
  78. package/src/components/LayoutItemContent/__tests__/LayoutItemContent.test.tsx +71 -0
  79. package/src/components/LayoutItemContent/styles.ts +36 -0
  80. package/src/components/LayoutItemHeader/LayoutItemHeader.tsx +86 -0
  81. package/src/components/LayoutItemHeader/__tests__/LayoutItemHeader.specs.tsx +48 -0
  82. package/src/components/LayoutItemHeader/styles.ts +44 -0
  83. package/src/components/LayoutItemView/LayoutItemView.tsx +24 -0
  84. package/src/components/LayoutItemView/styles.ts +11 -0
  85. package/src/components/StatsChart/StatsChart.tsx +77 -0
  86. package/src/components/StatsChart/__tests__/StatsChart.test.tsx +106 -0
  87. package/src/components/StatsChart/customized/CustomAxisTick.tsx +28 -0
  88. package/src/components/StatsChart/customized/CustomLegend.tsx +37 -0
  89. package/src/components/StatsChart/customized/CustomTooltip.tsx +41 -0
  90. package/src/components/StatsChart/customized/styles.ts +53 -0
  91. package/src/components/StatsChart/getStatsChartSettings.ts +65 -0
  92. package/src/components/WorkflowTaskItem/WorkflowTaskItem.tsx +67 -0
  93. package/src/components/WorkflowTaskItem/WorkflowTaskObject.tsx +54 -0
  94. package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskItem.test.tsx +73 -0
  95. package/src/components/WorkflowTaskItem/__tests__/WorkflowTaskObject.test.tsx +95 -0
  96. package/src/components/WorkflowTaskItem/styles.ts +74 -0
  97. package/src/components/WorkflowTasksList/WorkflowTasksList.tsx +34 -0
  98. package/src/components/WorkflowTasksList/__tests__/WorkflowTasksList.test.tsx +98 -0
  99. package/src/components/index.ts +8 -0
  100. package/src/contexts/DashboardViewIdContext/index.ts +5 -0
  101. package/src/hooks/__tests__/useActivititesRequest.specs.tsx +106 -0
  102. package/src/hooks/__tests__/useEntityByTypeRequest.specs.tsx +280 -0
  103. package/src/hooks/__tests__/useFacetRequest.specs.tsx +437 -0
  104. package/src/hooks/__tests__/useFilteredEntitiesRequest.specs.tsx +103 -0
  105. package/src/hooks/__tests__/useSavedSearchesRequest.specs.tsx +201 -0
  106. package/src/hooks/__tests__/useStatsRequest.specs.tsx +212 -0
  107. package/src/hooks/__tests__/useWorkflowTasksRequest.specs.tsx +388 -0
  108. package/src/hooks/useActivitiesRequest.ts +50 -0
  109. package/src/hooks/useEntityByTypeRequest.ts +67 -0
  110. package/src/hooks/useFacetRequest.ts +117 -0
  111. package/src/hooks/useFilteredEntitiesRequest.ts +57 -0
  112. package/src/hooks/useSavedSearchesRequest.ts +82 -0
  113. package/src/hooks/useStatsRequest.ts +47 -0
  114. package/src/hooks/useWorkflowTasksRequest.ts +66 -0
  115. package/src/index.ts +25 -0
  116. package/src/perspective/DashboardPerspectiveView.tsx +132 -0
  117. package/src/perspective/__tests__/DashboardPerspectiveView.specs.tsx +276 -0
  118. package/src/perspective/__tests__/data/metadata.data.ts +33 -0
  119. package/src/perspective/__tests__/data/store.data.ts +15 -0
  120. package/src/perspective/__tests__/helpers.specs.ts +33 -0
  121. package/src/perspective/helpers.ts +19 -0
  122. package/src/perspective/index.tsx +65 -0
  123. package/src/perspective/styles.ts +16 -0
  124. package/src/services/__tests__/facets.specs.ts +42 -0
  125. package/src/services/__tests__/filters.specs.ts +60 -0
  126. package/src/services/__tests__/period.test.ts +33 -0
  127. package/src/services/__tests__/stats.test.ts +319 -0
  128. package/src/services/entityTypes.ts +66 -0
  129. package/src/services/facets.ts +178 -0
  130. package/src/services/filters.ts +87 -0
  131. package/src/services/period.ts +33 -0
  132. package/src/services/savedSearches.ts +20 -0
  133. package/src/services/stats.ts +191 -0
  134. package/src/services/workflowTasks.ts +116 -0
  135. package/src/types/ActivitiesViewFacetConfig.ts +5 -0
  136. package/src/types/CustomActionViewFacetConfig.ts +5 -0
  137. package/src/types/DashboardPerspectiveConfig.ts +18 -0
  138. package/src/types/DashboardSavedState.ts +7 -0
  139. package/src/types/EntityByTypeViewFacetConfig.ts +7 -0
  140. package/src/types/EntityData.ts +4 -0
  141. package/src/types/FilteredEntitiesFacetConfig.ts +6 -0
  142. package/src/types/FilteredSavedSearchesFacetConfig.ts +6 -0
  143. package/src/types/PeriodStep.ts +4 -0
  144. package/src/types/SavedSearchData.ts +6 -0
  145. package/src/types/SearchOptions.ts +10 -0
  146. package/src/types/StatsData.ts +14 -0
  147. package/src/types/WorkflowTasks.ts +26 -0
  148. package/src/types/index.ts +14 -0
  149. package/src/views/ViewsFactory.tsx +79 -0
  150. package/src/views/__tests__/ViewsFactory.specs.tsx +70 -0
  151. package/src/views/chartBased/DashboardFacet.tsx +71 -0
  152. package/src/views/chartBased/EntitiesByTypeViewFacet.tsx +60 -0
  153. package/src/views/chartBased/ProfileStatsFacet.tsx +54 -0
  154. package/src/views/chartBased/__tests__/DashboardFacet.specs.tsx +358 -0
  155. package/src/views/chartBased/__tests__/EntitiesByTypeViewFacet.specs.tsx +101 -0
  156. package/src/views/chartBased/__tests__/ProfileStatsFacet.specs.tsx +106 -0
  157. package/src/views/chartBased/styles.ts +13 -0
  158. package/src/views/custom/CustomActionViewFacet.tsx +36 -0
  159. package/src/views/custom/NotificationInboxFacet.tsx +86 -0
  160. package/src/views/custom/__tests__/CustomActionViewFacet.specs.tsx +35 -0
  161. package/src/views/custom/__tests__/NotificationInboxFacet.specs.tsx +144 -0
  162. package/src/views/custom/styles.ts +31 -0
  163. package/src/views/tableBased/ActivitiesViewFacet.tsx +79 -0
  164. package/src/views/tableBased/FilteredEntitiesViewFacet.tsx +67 -0
  165. package/src/views/tableBased/FilteredSavedSearchesFacet.tsx +85 -0
  166. package/src/views/tableBased/__tests__/ActivitiesViewFacet.specs.tsx +113 -0
  167. package/src/views/tableBased/__tests__/FIlteredEntitiesViewFacet.specs.tsx +90 -0
  168. package/src/views/tableBased/__tests__/FilteredSavedSearchesFacet.specs.tsx +133 -0
  169. package/src/views/tableBased/helpers.ts +8 -0
  170. package/src/views/tableBased/styles.ts +7 -0
  171. package/stories/Dashboards.stories.js +118 -0
  172. package/stories/utils/dashboardPerspectiveConfig.js +78 -0
  173. package/stories/utils/dashboardsViewConfig.js +17 -0
  174. package/stories/utils/mdmStore.js +73 -0
  175. package/stories/utils/responses.js +10 -0
  176. package/tsconfig.json +14 -0
  177. package/webpack.config.js +10 -0
  178. package/bundle.js +0 -2
  179. package/bundle.js.LICENSE.txt +0 -22
  180. package/types/components/DashboardConfigItem/styles.d.ts +0 -1
  181. package/types/components/DashboardLayout/styles.d.ts +0 -1
  182. package/types/components/DashboardLayoutItem/styles.d.ts +0 -1
  183. package/types/components/DashboardLayoutPanel/styles.d.ts +0 -1
  184. package/types/components/DashboardLinearLoader/styles.d.ts +0 -1
  185. package/types/components/DashboardPerspectiveHeader/styles.d.ts +0 -2
  186. package/types/components/DashboardPopupMenu/styles.d.ts +0 -1
  187. package/types/components/EntityTable/cell-renderers/styles.d.ts +0 -1
  188. package/types/components/LayoutItemContent/styles.d.ts +0 -1
  189. package/types/components/LayoutItemHeader/styles.d.ts +0 -1
  190. package/types/components/LayoutItemView/styles.d.ts +0 -1
  191. package/types/components/StatsChart/customized/styles.d.ts +0 -1
  192. package/types/components/WorkflowTaskItem/styles.d.ts +0 -1
  193. package/types/perspective/styles.d.ts +0 -1
  194. package/types/views/chartBased/styles.d.ts +0 -1
  195. package/types/views/custom/styles.d.ts +0 -1
  196. package/types/views/tableBased/styles.d.ts +0 -1
  197. /package/{types → public/types}/HOCs/withPagination.d.ts +0 -0
  198. /package/{types → public/types}/components/DashboardConfigItem/DashboardConfigItem.d.ts +0 -0
  199. /package/{types → public/types}/components/DashboardError/DashboardError.d.ts +0 -0
  200. /package/{types → public/types}/components/DashboardLayout/DashboardLayout.d.ts +0 -0
  201. /package/{types → public/types}/components/DashboardLayoutItem/DashboardLayoutItem.d.ts +0 -0
  202. /package/{types → public/types}/components/DashboardLayoutPanel/DashboardLayoutPanel.d.ts +0 -0
  203. /package/{types → public/types}/components/DashboardLinearLoader/DashboardLinearLoader.d.ts +0 -0
  204. /package/{types → public/types}/components/DashboardNoData/DashboardNoData.d.ts +0 -0
  205. /package/{types → public/types}/components/DashboardPerspectiveHeader/DashboardPerspectiveHeader.d.ts +0 -0
  206. /package/{types → public/types}/components/EntityTable/EntityTable.d.ts +0 -0
  207. /package/{types → public/types}/components/EntityTable/cell-renderers/EntityLabelRenderer.d.ts +0 -0
  208. /package/{types → public/types}/components/EntityTable/cell-renderers/HeadCellRenderer.d.ts +0 -0
  209. /package/{types → public/types}/components/LayoutItemContent/LayoutItemContent.d.ts +0 -0
  210. /package/{types → public/types}/components/LayoutItemHeader/LayoutItemHeader.d.ts +0 -0
  211. /package/{types → public/types}/components/LayoutItemView/LayoutItemView.d.ts +0 -0
  212. /package/{types → public/types}/components/StatsChart/StatsChart.d.ts +0 -0
  213. /package/{types → public/types}/components/StatsChart/customized/CustomAxisTick.d.ts +0 -0
  214. /package/{types → public/types}/components/StatsChart/customized/CustomLegend.d.ts +0 -0
  215. /package/{types → public/types}/components/StatsChart/customized/CustomTooltip.d.ts +0 -0
  216. /package/{types → public/types}/components/StatsChart/getStatsChartSettings.d.ts +0 -0
  217. /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskItem.d.ts +0 -0
  218. /package/{types → public/types}/components/WorkflowTaskItem/WorkflowTaskObject.d.ts +0 -0
  219. /package/{types → public/types}/components/WorkflowTasksList/WorkflowTasksList.d.ts +0 -0
  220. /package/{types → public/types}/components/index.d.ts +0 -0
  221. /package/{types → public/types}/contexts/DashboardViewIdContext/index.d.ts +0 -0
  222. /package/{types → public/types}/hooks/useActivitiesRequest.d.ts +0 -0
  223. /package/{types → public/types}/hooks/useEntityByTypeRequest.d.ts +0 -0
  224. /package/{types → public/types}/hooks/useFacetRequest.d.ts +0 -0
  225. /package/{types → public/types}/hooks/useFilteredEntitiesRequest.d.ts +0 -0
  226. /package/{types → public/types}/hooks/useSavedSearchesRequest.d.ts +0 -0
  227. /package/{types → public/types}/hooks/useStatsRequest.d.ts +0 -0
  228. /package/{types → public/types}/hooks/useWorkflowTasksRequest.d.ts +0 -0
  229. /package/{types → public/types}/index.d.ts +0 -0
  230. /package/{types → public/types}/perspective/DashboardPerspectiveView.d.ts +0 -0
  231. /package/{types → public/types}/perspective/helpers.d.ts +0 -0
  232. /package/{types → public/types}/perspective/index.d.ts +0 -0
  233. /package/{types → public/types}/services/entityTypes.d.ts +0 -0
  234. /package/{types → public/types}/services/facets.d.ts +0 -0
  235. /package/{types → public/types}/services/filters.d.ts +0 -0
  236. /package/{types → public/types}/services/period.d.ts +0 -0
  237. /package/{types → public/types}/services/savedSearches.d.ts +0 -0
  238. /package/{types → public/types}/services/stats.d.ts +0 -0
  239. /package/{types → public/types}/services/workflowTasks.d.ts +0 -0
  240. /package/{types → public/types}/types/ActivitiesViewFacetConfig.d.ts +0 -0
  241. /package/{types → public/types}/types/CustomActionViewFacetConfig.d.ts +0 -0
  242. /package/{types → public/types}/types/DashboardPerspectiveConfig.d.ts +0 -0
  243. /package/{types → public/types}/types/DashboardSavedState.d.ts +0 -0
  244. /package/{types → public/types}/types/EntityByTypeViewFacetConfig.d.ts +0 -0
  245. /package/{types → public/types}/types/EntityData.d.ts +0 -0
  246. /package/{types → public/types}/types/FilteredEntitiesFacetConfig.d.ts +0 -0
  247. /package/{types → public/types}/types/FilteredSavedSearchesFacetConfig.d.ts +0 -0
  248. /package/{types → public/types}/types/PeriodStep.d.ts +0 -0
  249. /package/{types → public/types}/types/SavedSearchData.d.ts +0 -0
  250. /package/{types → public/types}/types/SearchOptions.d.ts +0 -0
  251. /package/{types → public/types}/types/StatsData.d.ts +0 -0
  252. /package/{types → public/types}/types/WorkflowTasks.d.ts +0 -0
  253. /package/{types → public/types}/types/index.d.ts +0 -0
  254. /package/{types → public/types}/views/ViewsFactory.d.ts +0 -0
  255. /package/{types → public/types}/views/chartBased/DashboardFacet.d.ts +0 -0
  256. /package/{types → public/types}/views/chartBased/EntitiesByTypeViewFacet.d.ts +0 -0
  257. /package/{types → public/types}/views/chartBased/ProfileStatsFacet.d.ts +0 -0
  258. /package/{types → public/types}/views/custom/CustomActionViewFacet.d.ts +0 -0
  259. /package/{types → public/types}/views/custom/NotificationInboxFacet.d.ts +0 -0
  260. /package/{types → public/types}/views/tableBased/ActivitiesViewFacet.d.ts +0 -0
  261. /package/{types → public/types}/views/tableBased/FilteredEntitiesViewFacet.d.ts +0 -0
  262. /package/{types → public/types}/views/tableBased/FilteredSavedSearchesFacet.d.ts +0 -0
  263. /package/{types → public/types}/views/tableBased/helpers.d.ts +0 -0
@@ -0,0 +1,106 @@
1
+ import React from 'react';
2
+ import {act} from 'react-dom/test-utils';
3
+ import {shallow} from 'enzyme';
4
+
5
+ import {PeriodStep} from '../../../types/PeriodStep';
6
+ import StatsChart from '../StatsChart';
7
+ import {CartesianGrid, Legend, Line, LineChart, Tooltip, XAxis, YAxis} from 'recharts';
8
+ import CustomLegend from '../customized/CustomLegend';
9
+ import * as stats from '../../../services/stats';
10
+
11
+ describe('StatsChart tests', () => {
12
+ const props = {
13
+ data: [
14
+ {
15
+ event: 'created',
16
+ total: 12,
17
+ data: [
18
+ {term: '05/01/21', count: 0},
19
+ {term: '05/03/21', count: 12},
20
+ {term: '05/04/21', count: 0}
21
+ ]
22
+ },
23
+ {
24
+ event: 'deleted',
25
+ total: 1,
26
+ data: [
27
+ {term: '05/02/21', count: 0},
28
+ {term: '05/03/21', count: 1},
29
+ {term: '05/04/21', count: 0}
30
+ ]
31
+ }
32
+ ],
33
+ width: 600,
34
+ height: 300,
35
+ step: PeriodStep.DAY
36
+ };
37
+
38
+ beforeAll(() => {
39
+ jest.spyOn(stats, 'calibrateStatsData').mockImplementation((step, data) => data);
40
+ });
41
+
42
+ it('should render LineChart correctly', () => {
43
+ const wrapper = shallow(<StatsChart {...props} />);
44
+ expect(wrapper.find(LineChart).props()).toMatchObject({
45
+ width: props.width,
46
+ height: props.height
47
+ });
48
+ expect(wrapper.find(CartesianGrid)).toHaveLength(1);
49
+ expect(wrapper.find(XAxis).prop('dataKey')).toBe('term');
50
+ expect(wrapper.find(YAxis)).toHaveLength(1);
51
+ const lines = wrapper.find(Line);
52
+ expect(lines.length).toBe(props.data.length);
53
+ lines.forEach((line, i) => {
54
+ expect(line.prop('name')).toBe(props.data[i].event);
55
+ expect(line.prop('data')).toBe(props.data[i].data);
56
+ expect(line.prop('strokeOpacity')).toBe(1);
57
+ expect(line.prop('activeDot')).not.toBe(false);
58
+ expect(line.prop('dot')).not.toBe(false);
59
+ });
60
+ expect(wrapper.find(Tooltip).shallow().find('CustomTooltip').prop('events')).toEqual(['created', 'deleted']);
61
+ expect(wrapper.find(Legend).prop('payload')).toEqual([
62
+ expect.objectContaining({id: 'created', value: 12}),
63
+ expect.objectContaining({id: 'deleted', value: 1})
64
+ ]);
65
+ });
66
+
67
+ it('should render YAxis for big numbers correctly', () => {
68
+ const wrapper = shallow(<StatsChart {...props} />);
69
+ expect(wrapper.find(YAxis)).toHaveLength(1);
70
+ const formatter = wrapper.find(YAxis).prop('tickFormatter');
71
+ expect(formatter(100100)).toBe('100.1K');
72
+ });
73
+
74
+ it('should calibrate stats data by step', () => {
75
+ shallow(<StatsChart {...props} />);
76
+ expect(stats.calibrateStatsData).toBeCalledWith(props.step, props.data);
77
+ });
78
+
79
+ it('should toggle event on legend item click', () => {
80
+ const wrapper = shallow(<StatsChart {...props} />);
81
+ act(() => {
82
+ wrapper.find(Legend).shallow().find(CustomLegend).prop('onClick')('created');
83
+ });
84
+ expect(
85
+ wrapper
86
+ .find(Line)
87
+ .filterWhere((line) => line.prop('name') === 'created')
88
+ .props()
89
+ ).toMatchObject({
90
+ strokeOpacity: 0,
91
+ activeDot: false,
92
+ dot: false
93
+ });
94
+ expect(wrapper.find(Tooltip).shallow().find('CustomTooltip').prop('events')).toEqual(['deleted']);
95
+
96
+ act(() => {
97
+ wrapper.find(Legend).shallow().find(CustomLegend).prop('onClick')('created');
98
+ });
99
+
100
+ const line = wrapper.find(Line).filterWhere((line) => line.prop('name') === 'created');
101
+ expect(line.prop('strokeOpacity')).toBe(1);
102
+ expect(line.prop('activeDot')).not.toBe(false);
103
+ expect(line.prop('dot')).not.toBe(false);
104
+ expect(wrapper.find(Tooltip).shallow().find('CustomTooltip').prop('events')).toEqual(['deleted', 'created']);
105
+ });
106
+ });
@@ -0,0 +1,28 @@
1
+ import React, {SVGProps} from 'react';
2
+ import {PeriodStep} from '../../../types/PeriodStep';
3
+ import {always, cond, equals} from 'ramda';
4
+ import i18n from 'ui-i18n';
5
+
6
+ const getStepValueFormat = cond([
7
+ [equals(PeriodStep.HOUR), always('LT')],
8
+ [equals(PeriodStep.DAY), always('MMM D')]
9
+ ]);
10
+
11
+ type AxisTickProps = SVGProps<SVGElement> & {
12
+ step: PeriodStep;
13
+ payload?: {
14
+ value: string;
15
+ };
16
+ };
17
+
18
+ const CustomAxisTick = ({x, y, payload, step}: AxisTickProps) => {
19
+ return (
20
+ <g transform={`translate(${x},${y})`}>
21
+ <text x={0} y={0} dy={16} textAnchor="middle" fill="#666">
22
+ {i18n.date(payload?.value, getStepValueFormat(step))}
23
+ </text>
24
+ </g>
25
+ );
26
+ };
27
+
28
+ export default CustomAxisTick;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import {LegendProps} from 'recharts';
3
+ import {getStatsEventName} from '../../../services/stats';
4
+ import Tooltip from '@mui/material/Tooltip';
5
+ import i18n from 'ui-i18n';
6
+
7
+ import {useStyles} from './styles';
8
+
9
+ type Props = LegendProps & {
10
+ selectedItems: string[];
11
+ };
12
+
13
+ const CustomLegend = ({payload, selectedItems, onClick}: Props) => {
14
+ const styles = useStyles();
15
+ return (
16
+ <div className={styles.legend}>
17
+ {payload.map(({id, color, value}) => {
18
+ const isSelected = selectedItems.includes(id);
19
+ return (
20
+ <div key={id} className={styles.legendItem}>
21
+ <Tooltip title={isSelected ? i18n.text('Hide') : i18n.text('Show')}>
22
+ <div
23
+ style={isSelected ? {background: color} : {border: `${color} 1px solid`}}
24
+ className={styles.legendItemColor}
25
+ onClick={() => onClick(id)}
26
+ />
27
+ </Tooltip>
28
+ {getStatsEventName(id)}
29
+ <span className={styles.legendItemValue}>{value}</span>
30
+ </div>
31
+ );
32
+ })}
33
+ </div>
34
+ );
35
+ };
36
+
37
+ export default CustomLegend;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import {TooltipProps} from 'recharts';
3
+ import {PeriodStep} from '../../../types/PeriodStep';
4
+ import i18n from 'ui-i18n';
5
+ import {always, cond, equals} from 'ramda';
6
+ import {getStatsEventName} from '../../../services/stats';
7
+
8
+ import {useStyles} from './styles';
9
+
10
+ type Props = TooltipProps & {
11
+ step: PeriodStep;
12
+ events: string[];
13
+ };
14
+
15
+ const getStepValueFormat = cond([
16
+ [equals(PeriodStep.HOUR), always('LT MMM D')],
17
+ [equals(PeriodStep.DAY), always('ll')]
18
+ ]);
19
+
20
+ const CustomTooltip = ({active, payload, label, step, events}: Props) => {
21
+ const styles = useStyles();
22
+ return (
23
+ active && (
24
+ <div className={styles.tooltipWrapper}>
25
+ <p className={styles.tooltipTitle}>{i18n.date(label, getStepValueFormat(step))}</p>
26
+ {payload
27
+ .filter(({name}) => events.includes(name))
28
+ .map(({color, name, value}) => {
29
+ return (
30
+ <p key={name}>
31
+ <span style={{background: color}} className={styles.tooltipItemColor} />
32
+ {`${getStatsEventName(name)}: ${value}`}
33
+ </p>
34
+ );
35
+ })}
36
+ </div>
37
+ )
38
+ );
39
+ };
40
+
41
+ export default CustomTooltip;
@@ -0,0 +1,53 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ export const useStyles = makeStyles({
4
+ tooltipWrapper: {
5
+ borderRadius: '4px',
6
+ background: 'rgba(0, 0, 0, 0.54)',
7
+ padding: '6px 8px 7px 8px',
8
+ color: '#FFFFFF',
9
+ '& p': {
10
+ fontSize: '12px',
11
+ lineHeight: '18px',
12
+ padding: 0,
13
+ margin: 0
14
+ }
15
+ },
16
+ tooltipTitle: {
17
+ fontWeight: 500
18
+ },
19
+ tooltipItemColor: {
20
+ width: 8,
21
+ height: 8,
22
+ marginRight: 10,
23
+ display: 'inline-block'
24
+ },
25
+ legend: {
26
+ display: 'flex',
27
+ flexWrap: 'wrap',
28
+ marginLeft: '20px',
29
+ marginTop: '10px'
30
+ },
31
+ legendItem: {
32
+ display: 'flex',
33
+ alignItems: 'baseline',
34
+ '&:not(:last-child)': {
35
+ marginRight: 10
36
+ },
37
+ width: '140px',
38
+ marginBottom: '5px',
39
+ fontSize: '13px',
40
+ color: 'rgba(0, 0, 0, 0.54)'
41
+ },
42
+ legendItemColor: {
43
+ width: 12,
44
+ height: 12,
45
+ marginRight: 10,
46
+ flexShrink: 0,
47
+ boxSizing: 'border-box'
48
+ },
49
+ legendItemValue: {
50
+ color: 'rgba(0, 0, 0, 0.87)',
51
+ marginLeft: '10px'
52
+ }
53
+ });
@@ -0,0 +1,65 @@
1
+ import {CartesianGridProps, LegendProps, LineProps, TooltipProps, XAxisProps, YAxisProps} from 'recharts';
2
+ import {formatNumberAsMetric} from '@reltio/mdm-sdk';
3
+
4
+ type StatsChartSettings = {
5
+ xAxis: XAxisProps;
6
+ yAxis: YAxisProps;
7
+ cartesianGrid: CartesianGridProps;
8
+ tooltip: TooltipProps;
9
+ line: LineProps;
10
+ legend: LegendProps;
11
+ };
12
+
13
+ const getStatsChartSettings = (): StatsChartSettings => {
14
+ return {
15
+ xAxis: {
16
+ type: 'category',
17
+ dataKey: 'term',
18
+ tick: {
19
+ fill: '#000',
20
+ opacity: '0.54'
21
+ },
22
+ angle: 0,
23
+ textAnchor: 'middle',
24
+ stroke: '#666',
25
+ allowDuplicatedCategory: false
26
+ },
27
+ yAxis: {
28
+ dataKey: '',
29
+ type: 'number',
30
+ tick: {
31
+ fill: '#000',
32
+ opacity: '0.54',
33
+ width: undefined
34
+ },
35
+ stroke: '#666',
36
+ tickFormatter: formatNumberAsMetric,
37
+ width: 50
38
+ },
39
+ cartesianGrid: {
40
+ strokeDasharray: '3 3',
41
+ stroke: '#666',
42
+ strokeOpacity: '0.4'
43
+ },
44
+ tooltip: {
45
+ cursor: {
46
+ fill: '#000',
47
+ opacity: '0.1'
48
+ }
49
+ },
50
+ line: {
51
+ type: 'linear',
52
+ dataKey: 'count',
53
+ strokeWidth: 3
54
+ },
55
+ legend: {
56
+ wrapperStyle: {
57
+ display: 'flex',
58
+ overflowY: 'auto',
59
+ maxHeight: '25%'
60
+ }
61
+ }
62
+ };
63
+ };
64
+
65
+ export default getStatsChartSettings;
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import {useSelector} from 'react-redux';
3
+ import i18n from 'ui-i18n';
4
+ import classnames from 'classnames';
5
+ import {EntityTypeIcon} from '@reltio/components';
6
+ import mdmModule from '@reltio/mdm-module';
7
+ import {getEntityType} from '@reltio/mdm-sdk';
8
+ import FlagIcon from '@mui/icons-material/Flag';
9
+ import Typography from '@mui/material/Typography';
10
+ import {EnrichedWorkflowTaskData} from '../../types';
11
+ import {isOverdueTask} from '../../services/workflowTasks';
12
+ import WorkflowTaskObject from './WorkflowTaskObject';
13
+ import {useStyles} from './styles';
14
+
15
+ type Props = {
16
+ showAssignee: boolean;
17
+ task: EnrichedWorkflowTaskData;
18
+ };
19
+
20
+ const WorkflowTaskItem = ({task, showAssignee}: Props) => {
21
+ const styles = useStyles();
22
+ const objects = task.objects || [];
23
+ const [firstObject] = objects;
24
+ const metadata = useSelector(mdmModule.selectors.getMetadata);
25
+ const entityType = firstObject && getEntityType(metadata, firstObject.type);
26
+
27
+ return (
28
+ <div className={classnames(styles.taskItem, task.priorityClass)}>
29
+ <EntityTypeIcon entityType={entityType} />
30
+ <div className={styles.taskInfo}>
31
+ <Typography className={styles.taskTitle} variant={'subtitle1'}>
32
+ {i18n.text(task.processDefinitionDisplayName)}
33
+ </Typography>
34
+ {objects.map((object) => (
35
+ <p key={object.uri} className={styles.taskDetail}>
36
+ <WorkflowTaskObject object={object} processType={task.processType} metadata={metadata} />
37
+ </p>
38
+ ))}
39
+ <p className={styles.taskDetail}>
40
+ <span className={styles.taskDetailTitle}>{`${i18n.text('Created by')}:`}</span>
41
+ {task.createdBy} {i18n.text('on')} {i18n.date(task.createTime, 'L')}
42
+ </p>
43
+ {showAssignee && task.assignee && (
44
+ <p className={styles.taskDetail}>
45
+ <span className={styles.taskDetailTitle}>{`${i18n.text('Assigned to')}:`}</span>
46
+ {task.assignee}
47
+ </p>
48
+ )}
49
+ <p className={styles.taskDetail}>
50
+ <span className={styles.taskDetailTitle}>{`${i18n.text('Step')}:`}</span>
51
+ {task.displayName}
52
+ </p>
53
+ </div>
54
+ <div
55
+ className={classnames(styles.taskDueDate, {
56
+ [styles.overdue]: isOverdueTask(task),
57
+ [styles.hidden]: !task.dueDate
58
+ })}
59
+ >
60
+ <FlagIcon className={styles.flag} />
61
+ {i18n.date(task.dueDate, 'L')}
62
+ </div>
63
+ </div>
64
+ );
65
+ };
66
+
67
+ export default WorkflowTaskItem;
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import {always, cond, equals, propSatisfies, T} from 'ramda';
3
+ import {EnrichedWorkflowTaskData, WorkflowTaskObjectData} from '../../types/WorkflowTasks';
4
+ import {EntityUriLink} from '@reltio/components';
5
+ import {
6
+ getEntityUriForLink,
7
+ getLabel,
8
+ getRelationType,
9
+ isDCRUri,
10
+ Metadata,
11
+ PredefinedWorkflowProcessType
12
+ } from '@reltio/mdm-sdk';
13
+ import i18n from 'ui-i18n';
14
+ import {useStyles} from './styles';
15
+
16
+ type Props = {
17
+ object: WorkflowTaskObjectData;
18
+ metadata: Metadata;
19
+ processType: EnrichedWorkflowTaskData['processType'];
20
+ };
21
+
22
+ const EntityLink = ({uri, label, screen}: {uri: string; label: string; screen?: string}) => {
23
+ const styles = useStyles();
24
+ return (
25
+ <EntityUriLink value={uri} screen={screen} className={styles.entityLabel}>
26
+ {getLabel(label)}
27
+ </EntityUriLink>
28
+ );
29
+ };
30
+
31
+ const WorkflowTaskObject = ({object, metadata, processType}: Props) => {
32
+ if ('startObjectUri' in object && 'endObjectUri' in object) {
33
+ const relationType = getRelationType(metadata, object.type);
34
+ return (
35
+ <>
36
+ {relationType.label} {i18n.text('from')}{' '}
37
+ <EntityLink uri={object.startObjectUri} label={object.startObjectLabel} /> {i18n.text('to')}{' '}
38
+ <EntityLink uri={object.endObjectUri} label={object.endObjectLabel} />
39
+ </>
40
+ );
41
+ } else {
42
+ const screen = cond([
43
+ [
44
+ always(equals(processType, PredefinedWorkflowProcessType.potentialMatchReview)),
45
+ always('potentialMatches')
46
+ ],
47
+ [propSatisfies(isDCRUri, 'uri'), always('dcrReview')],
48
+ [T, always('profile')]
49
+ ])(object);
50
+ return <EntityLink uri={getEntityUriForLink(object)} label={object.label} screen={screen} />;
51
+ }
52
+ };
53
+
54
+ export default WorkflowTaskObject;
@@ -0,0 +1,73 @@
1
+ import React from 'react';
2
+ import {shallow} from 'enzyme';
3
+ import * as reactRedux from 'react-redux';
4
+
5
+ import WorkflowTaskItem from '../WorkflowTaskItem';
6
+ import {EnrichedWorkflowTaskData} from '../../../types/WorkflowTasks';
7
+ import WorkflowTaskObject from '../WorkflowTaskObject';
8
+ import i18n from 'ui-i18n';
9
+ import {PredefinedWorkflowProcessType} from '@reltio/mdm-sdk';
10
+
11
+ describe('WorkflowTaskItem tests', () => {
12
+ const metadata = {
13
+ entityTypes: [
14
+ {
15
+ uri: 'configuration/entityTypes/HCP'
16
+ }
17
+ ]
18
+ };
19
+
20
+ beforeAll(() => {
21
+ jest.spyOn(reactRedux, 'useSelector').mockReturnValue(metadata);
22
+ });
23
+
24
+ const props = {
25
+ task: {
26
+ assignee: 'johnconnor1131',
27
+ objectURIs: ['changeRequests/7ZotlRoP', 'entities/1aAyKH7k'],
28
+ createdBy: 'sairam.singireesu@reltio.com',
29
+ priorityClass: 'Medium',
30
+ createTime: 1620897479535,
31
+ dueDate: 1621070279536,
32
+ displayName: 'DCR Review',
33
+ processDefinitionDisplayName: 'Data Change Request Review',
34
+ processType: PredefinedWorkflowProcessType.potentialMatchReview,
35
+ objects: [
36
+ {
37
+ uri: 'entities/1aAyKH7k',
38
+ type: 'configuration/entityTypes/HCP',
39
+ label: 'Bahrain'
40
+ }
41
+ ]
42
+ } as EnrichedWorkflowTaskData,
43
+ showAssignee: true
44
+ };
45
+
46
+ it('should render correctly', () => {
47
+ const wrapper = shallow(<WorkflowTaskItem {...props} />);
48
+ expect(wrapper.find('EntityTypeIcon').prop('entityType')).toEqual({
49
+ uri: 'configuration/entityTypes/HCP'
50
+ });
51
+ expect(wrapper.find('.taskTitle').text()).toEqual(props.task.processDefinitionDisplayName);
52
+ const details = wrapper.find('.taskDetail');
53
+ expect(details.length).toBe(4);
54
+ expect(details.at(0).find(WorkflowTaskObject).props()).toEqual({
55
+ metadata,
56
+ object: props.task.objects[0],
57
+ processType: PredefinedWorkflowProcessType.potentialMatchReview
58
+ });
59
+ expect(details.at(1).text()).toBe(
60
+ `Created by:${props.task.createdBy} on ${i18n.date(props.task.createTime, 'L')}`
61
+ );
62
+ expect(details.at(2).text()).toBe(`Assigned to:${props.task.assignee}`);
63
+ expect(details.at(3).text()).toBe(`Step:${props.task.displayName}`);
64
+ expect(wrapper.find('.taskDueDate').text()).toBe(i18n.date(props.task.dueDate, 'L'));
65
+ });
66
+
67
+ it('should render assignee if props.showAssignee is false', () => {
68
+ const wrapper = shallow(<WorkflowTaskItem {...props} showAssignee={false} />);
69
+ expect(
70
+ wrapper.find('.taskDetail').filterWhere((detail) => detail.text().startsWith('Assigned to:'))
71
+ ).toHaveLength(0);
72
+ });
73
+ });
@@ -0,0 +1,95 @@
1
+ import React from 'react';
2
+ import {shallow} from 'enzyme';
3
+ import WorkflowTaskObject from '../WorkflowTaskObject';
4
+ import {PredefinedWorkflowProcessType} from '@reltio/mdm-sdk';
5
+
6
+ describe('WorkflowTaskObject tests', () => {
7
+ const metadata = {
8
+ entityTypes: [
9
+ {
10
+ uri: 'configuration/entityTypes/HCP',
11
+ attributes: []
12
+ }
13
+ ],
14
+ relationTypes: [
15
+ {
16
+ uri: 'configuration/relationTypes/HasAddress',
17
+ label: 'hasAddress',
18
+ attributes: []
19
+ }
20
+ ]
21
+ };
22
+
23
+ it('should render entity link for entity', () => {
24
+ const entity = {
25
+ uri: 'entities/1aAyKH7k',
26
+ type: 'configuration/entityTypes/HCP',
27
+ label: 'Bahrain'
28
+ };
29
+ const wrapper = shallow(<WorkflowTaskObject object={entity} metadata={metadata} processType="some" />);
30
+ expect(wrapper.find('EntityLink').props()).toEqual({
31
+ uri: 'entities/1aAyKH7k',
32
+ label: 'Bahrain',
33
+ screen: 'profile'
34
+ });
35
+ });
36
+
37
+ it('should render entity link leading to entity PM screen if processType is "potentialMatchReview"', () => {
38
+ const entity = {
39
+ uri: 'entities/1aAyKH7k',
40
+ type: 'configuration/entityTypes/HCP',
41
+ label: 'Bahrain'
42
+ };
43
+ const wrapper = shallow(
44
+ <WorkflowTaskObject
45
+ object={entity}
46
+ metadata={metadata}
47
+ processType={PredefinedWorkflowProcessType.potentialMatchReview}
48
+ />
49
+ );
50
+ expect(wrapper.find('EntityLink').props()).toEqual({
51
+ uri: 'entities/1aAyKH7k',
52
+ label: 'Bahrain',
53
+ screen: 'potentialMatches'
54
+ });
55
+ });
56
+
57
+ it('should render entity link leading to entity dcr review if uri is dcr', () => {
58
+ const entity = {
59
+ uri: 'changeRequests/EetzZOl6/changes/entities/3E2sfZkO',
60
+ type: 'configuration/entityTypes/HCP',
61
+ label: 'Bahrain'
62
+ };
63
+ const wrapper = shallow(
64
+ <WorkflowTaskObject object={entity} metadata={metadata} processType="dataChangeRequestReview" />
65
+ );
66
+ expect(wrapper.find('EntityLink').props()).toEqual({
67
+ uri: 'changeRequests/EetzZOl6/changes/entities/3E2sfZkO',
68
+ label: 'Bahrain',
69
+ screen: 'dcrReview'
70
+ });
71
+ });
72
+
73
+ it('should render start entity and end entity links for relation', () => {
74
+ const relation = {
75
+ uri: 'relations/uxQ1bqZ',
76
+ type: 'configuration/relationTypes/HasAddress',
77
+ startObjectUri: 'entities/j8K1vc9',
78
+ startObjectLabel: 'label 1',
79
+ endObjectUri: 'entities/1MXzYxGR',
80
+ endObjectLabel: 'label 2'
81
+ };
82
+ const wrapper = shallow(<WorkflowTaskObject object={relation} metadata={metadata} processType="some" />);
83
+ expect(wrapper.text()).toBe('hasAddress from <EntityLink /> to <EntityLink />');
84
+ const links = wrapper.find('EntityLink');
85
+ expect(links.length).toEqual(2);
86
+ expect(links.at(0).props()).toEqual({
87
+ uri: 'entities/j8K1vc9',
88
+ label: 'label 1'
89
+ });
90
+ expect(links.at(1).props()).toEqual({
91
+ uri: 'entities/1MXzYxGR',
92
+ label: 'label 2'
93
+ });
94
+ });
95
+ });