@reltio/dashboard 1.4.1585 → 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,33 @@
1
+ import React from 'react';
2
+ import {shallow} from 'enzyme';
3
+ import EntityTable from '../EntityTable';
4
+ import {BasicTable} from '@reltio/components';
5
+ import HeadCellRenderer from '../cell-renderers/HeadCellRenderer';
6
+ import EntityLabelRenderer from '../cell-renderers/EntityLabelRenderer';
7
+
8
+ describe('EntityTable tests', () => {
9
+ const data = [
10
+ {label: 'entity 1', uri: 'entities/1'},
11
+ {label: 'entity 2', uri: 'entities/2'},
12
+ {label: 'entity 3', uri: 'entities/3'}
13
+ ];
14
+
15
+ it('should render BasicTable', () => {
16
+ const expectedColumnsData = [
17
+ {
18
+ headCellRenderer: HeadCellRenderer,
19
+ id: 'label',
20
+ label: 'Entity',
21
+ initialWidth: 600,
22
+ resizable: false,
23
+ rowCellValueRenderer: EntityLabelRenderer
24
+ }
25
+ ];
26
+
27
+ const wrapper = shallow(<EntityTable width={600} height={300} data={data} />);
28
+ const tableChart = wrapper.find(BasicTable);
29
+ expect(tableChart).toHaveLength(1);
30
+ expect(tableChart.prop('columnsData')).toEqual(expectedColumnsData);
31
+ expect(tableChart.prop('rowsData')).toEqual(data);
32
+ });
33
+ });
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import {EntityUriLink, ExpandedValueTooltip} from '@reltio/components';
3
+ import {EntityData} from '../../../types/EntityData';
4
+ import {getLabel, getEntityUriForLink} from '@reltio/mdm-sdk';
5
+ import {useStyles} from './styles';
6
+
7
+ type Props = {
8
+ value: string;
9
+ rowValue: EntityData;
10
+ };
11
+
12
+ const EntityLabelRenderer = ({value, rowValue: entity}: Props) => {
13
+ const styles = useStyles();
14
+ const label = getLabel(value);
15
+ return (
16
+ <ExpandedValueTooltip value={label}>
17
+ <EntityUriLink value={getEntityUriForLink(entity)} className={styles.entityLabel}>
18
+ {label}
19
+ </EntityUriLink>
20
+ </ExpandedValueTooltip>
21
+ );
22
+ };
23
+
24
+ export default EntityLabelRenderer;
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import DefaultHeadCellRenderer from 'react-components/dist/Table/DefaultHeadCellRenderer/DefaultHeadCellRenderer';
4
+ import {ExpandedValueTooltip} from '@reltio/components';
5
+ import {useStyles} from './styles';
6
+
7
+ type HeadCellRendererProps = {
8
+ className?: string;
9
+ headCellData: {
10
+ label: string;
11
+ };
12
+ };
13
+
14
+ const HeadCellRenderer = ({className, headCellData, ...otherProps}: HeadCellRendererProps) => {
15
+ const styles = useStyles();
16
+
17
+ return (
18
+ <div className={classnames(styles.headCell, className)}>
19
+ <DefaultHeadCellRenderer
20
+ {...otherProps}
21
+ headCellData={{
22
+ ...headCellData,
23
+ label: (
24
+ <ExpandedValueTooltip value={headCellData.label}>
25
+ <div className={styles.headLabel}>{headCellData.label}</div>
26
+ </ExpandedValueTooltip>
27
+ )
28
+ }}
29
+ />
30
+ </div>
31
+ );
32
+ };
33
+
34
+ export default HeadCellRenderer;
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import {shallow} from 'enzyme';
3
+ import {ExpandedValueTooltip} from '@reltio/components';
4
+ import EntityLabelRenderer from '../EntityLabelRenderer';
5
+
6
+ describe('EntityLabelRenderer tests', () => {
7
+ const props = {
8
+ value: 'entity 1',
9
+ rowValue: {
10
+ label: 'entity 1',
11
+ uri: 'entities/1'
12
+ }
13
+ };
14
+
15
+ it('should render correctly', () => {
16
+ const wrapper = shallow(<EntityLabelRenderer {...props} />);
17
+ const cell = wrapper.find(ExpandedValueTooltip);
18
+ expect(cell).toHaveLength(1);
19
+ expect(cell.prop('value')).toEqual('entity 1');
20
+ expect(cell.find('EntityUriLink').props()).toMatchObject({
21
+ value: 'entities/1',
22
+ children: 'entity 1'
23
+ });
24
+ });
25
+ });
@@ -0,0 +1,46 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ const textOverflow = {
4
+ content: '""',
5
+ position: 'absolute',
6
+ right: 0,
7
+ top: 0,
8
+ width: '40px',
9
+ height: '100%',
10
+ background: 'linear-gradient(to right, rgba(255, 255, 255, 0.2), #fff 100%)',
11
+ pointerEvents: 'none'
12
+ };
13
+
14
+ export const useStyles = makeStyles((theme) => ({
15
+ headCell: {
16
+ display: 'flex',
17
+ alignItems: 'center',
18
+ height: '100%',
19
+ '&>div': {
20
+ padding: '0 16px'
21
+ }
22
+ },
23
+ headLabel: {
24
+ color: theme.palette.text.primary,
25
+ fontSize: '12px',
26
+ fontWeight: 500,
27
+ lineHeight: '16px',
28
+ whiteSpace: 'nowrap',
29
+ overflow: 'hidden',
30
+ '&:after': textOverflow
31
+ },
32
+ entityLabel: {
33
+ color: theme.palette.primary.main,
34
+ textDecoration: 'none',
35
+ fontSize: '13px',
36
+ fontWeight: 500,
37
+ lineHeight: '15px',
38
+ whiteSpace: 'nowrap',
39
+ overflow: 'hidden',
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ height: '100%',
43
+ padding: '0 16px',
44
+ '&:after': textOverflow
45
+ }
46
+ }));
@@ -0,0 +1,19 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ type Dimensions = {
4
+ width: number | string;
5
+ height: number | string;
6
+ };
7
+
8
+ export const useStyles = makeStyles({
9
+ tableContainer: ({width, height}: Dimensions) => ({
10
+ height: height,
11
+ width: width,
12
+ display: 'flex',
13
+ flexDirection: 'column'
14
+ }),
15
+ cellBorder: {
16
+ borderLeft: 'none',
17
+ borderRight: 'none'
18
+ }
19
+ });
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import i18n from 'ui-i18n';
4
+ import {BasicViewContent, ErrorBoundary, RequestStates} from '@reltio/components';
5
+ import {DashboardError, DashboardLinearLoader, DashboardNoData} from '../index';
6
+ import ReactResizeDetector from 'react-resize-detector';
7
+ import {useStyles} from './styles';
8
+
9
+ type ChildrenProps<T> = {data: T[]; width: number; height: number};
10
+
11
+ type Props<T> = {
12
+ loadingState: RequestStates;
13
+ children: (props: ChildrenProps<T>) => React.ReactNode;
14
+ onRefresh: () => void;
15
+ data: T[];
16
+ className?: string;
17
+ EmptyPlaceholder?: React.ReactNode;
18
+ };
19
+
20
+ const LayoutItemContent = <T extends unknown>({
21
+ loadingState,
22
+ onRefresh,
23
+ children,
24
+ data,
25
+ className,
26
+ EmptyPlaceholder
27
+ }: Props<T>) => {
28
+ const styles = useStyles();
29
+
30
+ const renderContent = ({width, height}: {width: number; height: number}) => {
31
+ switch (loadingState) {
32
+ case RequestStates.LOADED:
33
+ if (!data || data.length === 0) {
34
+ return EmptyPlaceholder || <DashboardNoData height={height} />;
35
+ }
36
+ return (
37
+ <ErrorBoundary
38
+ error={<DashboardError message={i18n.text('Something went wrong')} height={height} />}
39
+ >
40
+ {children({data, width, height})}
41
+ </ErrorBoundary>
42
+ );
43
+ case RequestStates.LOADING:
44
+ return <DashboardLinearLoader />;
45
+ case RequestStates.ERROR:
46
+ return (
47
+ <DashboardError message={i18n.text('Error Loading Data')} height={height} onRefresh={onRefresh} />
48
+ );
49
+ default:
50
+ return <div>Loading...</div>;
51
+ }
52
+ };
53
+
54
+ return (
55
+ <BasicViewContent className={classnames(styles.viewContent, className)}>
56
+ <ReactResizeDetector refreshMode="debounce" refreshRate={100} handleWidth handleHeight>
57
+ {renderContent}
58
+ </ReactResizeDetector>
59
+ </BasicViewContent>
60
+ );
61
+ };
62
+
63
+ export default LayoutItemContent;
@@ -0,0 +1,71 @@
1
+ import {mount} from 'enzyme';
2
+ import React from 'react';
3
+ import {ErrorBoundary, RequestStates} from '@reltio/components';
4
+ import {DashboardError, DashboardLinearLoader, DashboardNoData} from '../../index';
5
+ import LayoutItemContent from '../LayoutItemContent';
6
+
7
+ describe('LayoutItemContent', () => {
8
+ const onRefresh = jest.fn();
9
+ const defaultProps = {
10
+ loadingState: RequestStates.LOADED,
11
+ onRefresh,
12
+ data: [1, 2, 3],
13
+ EmptyPlaceholder: undefined
14
+ };
15
+
16
+ const getComponent = (props = defaultProps) => {
17
+ return mount(
18
+ <LayoutItemContent {...props}>
19
+ {({data}) => <div className="childrenComponent" data-data={data} />}
20
+ </LayoutItemContent>
21
+ );
22
+ };
23
+
24
+ afterEach(() => {
25
+ jest.clearAllMocks();
26
+ });
27
+ it('should show loader in "loading" state', () => {
28
+ const wrapper = getComponent({...defaultProps, loadingState: RequestStates.LOADING});
29
+
30
+ expect(wrapper.find('.childrenComponent')).toHaveLength(0);
31
+ expect(wrapper.find(DashboardLinearLoader)).toHaveLength(1);
32
+ });
33
+
34
+ it('should show error component in "error" state and call onRefresh prop', () => {
35
+ const wrapper = getComponent({...defaultProps, loadingState: RequestStates.ERROR});
36
+
37
+ expect(wrapper.find('.childrenComponent')).toHaveLength(0);
38
+ expect(wrapper.find(DashboardError)).toHaveLength(1);
39
+
40
+ wrapper.find(DashboardError).prop('onRefresh')();
41
+ expect(onRefresh).toHaveBeenCalled();
42
+ });
43
+
44
+ it('should show no data component if data is loaded and empty', () => {
45
+ const wrapper = getComponent({...defaultProps, data: []});
46
+
47
+ expect(wrapper.find('.childrenComponent')).toHaveLength(0);
48
+ expect(wrapper.find(DashboardNoData)).toHaveLength(1);
49
+ });
50
+
51
+ it('should show EmptyPlaceholder component if data is loaded, and empty', () => {
52
+ const wrapper = getComponent({
53
+ ...defaultProps,
54
+ data: [],
55
+ EmptyPlaceholder: <div className="placeholder">emptyPlaceholder</div>
56
+ });
57
+
58
+ expect(wrapper.find('.childrenComponent')).toHaveLength(0);
59
+ const placeholder = wrapper.find('.placeholder');
60
+ expect(placeholder).toHaveLength(1);
61
+ expect(placeholder.text()).toBe('emptyPlaceholder');
62
+ });
63
+
64
+ it('should show children component if data is loaded and not empty', () => {
65
+ const wrapper = getComponent({...defaultProps});
66
+
67
+ expect(wrapper.find('.childrenComponent')).toHaveLength(1);
68
+ expect(wrapper.find(ErrorBoundary)).toHaveLength(1);
69
+ expect(wrapper.find('.childrenComponent').prop('data-data')).toEqual(defaultProps.data);
70
+ });
71
+ });
@@ -0,0 +1,36 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ export const useStyles = makeStyles(() => ({
4
+ viewContent: {
5
+ height: '100%',
6
+ overflow: 'hidden',
7
+ position: 'relative',
8
+ padding: '0 16px 16px'
9
+ },
10
+ toolbarRoot: {
11
+ padding: '16px',
12
+ minHeight: '18px',
13
+ lineHeight: '18px',
14
+ marginBottom: '8px',
15
+ '&:hover .viewDraggableHandle': {
16
+ visibility: 'visible'
17
+ }
18
+ },
19
+ title: {
20
+ fontSize: '16px',
21
+ lineHeight: '19px',
22
+ fontWeight: 'normal',
23
+ color: 'rgba(0, 0, 0, 0.87)',
24
+ letterSpacing: '0.15px'
25
+ },
26
+ dragIcon: {
27
+ position: 'absolute',
28
+ left: '50%',
29
+ top: '-3px',
30
+ transform: 'translateX(-50%) rotate(90deg)',
31
+ color: 'rgba(0, 0, 0, 0.3)',
32
+ cursor: 'move',
33
+ zIndex: 8,
34
+ visibility: 'hidden'
35
+ }
36
+ }));
@@ -0,0 +1,86 @@
1
+ import React, {useContext, useMemo} from 'react';
2
+ import {BasicViewHeader} from '@reltio/components';
3
+ import {DashboardViewIdContext} from '../../contexts/DashboardViewIdContext';
4
+ import {DashboardPopupMenu} from '../index';
5
+ import Chip from '@mui/material/Chip';
6
+ import FullscreenIcon from '@mui/icons-material/Fullscreen';
7
+ import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
8
+ import HighlightOffIcon from '@mui/icons-material/HighlightOff';
9
+ import ReplayIcon from '@mui/icons-material/Replay';
10
+ import DragIndicatorIcon from '@mui/icons-material/DragIndicator';
11
+ import i18n from 'ui-i18n';
12
+
13
+ import classnames from 'classnames';
14
+ import {useStyles} from './styles';
15
+
16
+ type Props = {
17
+ title: string;
18
+ onToggleFullscreen: (id: string) => void;
19
+ isFullscreen: boolean;
20
+ isUpdated?: boolean;
21
+ onRefresh?: () => void;
22
+ onRemove?: (id: string) => void;
23
+ children?: React.ReactNode;
24
+ };
25
+
26
+ const LayoutItemHeader = ({
27
+ title,
28
+ onToggleFullscreen,
29
+ isUpdated = false,
30
+ isFullscreen,
31
+ onRemove,
32
+ onRefresh,
33
+ children
34
+ }: Props) => {
35
+ const id = useContext(DashboardViewIdContext);
36
+ const menuItems = useMemo(
37
+ () => [
38
+ {
39
+ id: 'refresh',
40
+ title: i18n.text('Refresh'),
41
+ icon: <ReplayIcon />,
42
+ active: !!onRefresh,
43
+ action: () => onRefresh()
44
+ },
45
+ {
46
+ id: 'fullscreen',
47
+ title: i18n.text('Fullscreen'),
48
+ icon: <FullscreenIcon />,
49
+ active: !isFullscreen,
50
+ action: () => onToggleFullscreen(id)
51
+ },
52
+ {
53
+ id: 'exitFullscreen',
54
+ title: i18n.text('Exit fullscreen'),
55
+ icon: <FullscreenExitIcon />,
56
+ active: isFullscreen,
57
+ action: () => onToggleFullscreen(id)
58
+ },
59
+ {
60
+ id: 'remove',
61
+ title: i18n.text('Remove'),
62
+ icon: <HighlightOffIcon />,
63
+ active: !!onRemove,
64
+ action: () => {
65
+ onRemove(id);
66
+ if (isFullscreen) onToggleFullscreen(id);
67
+ }
68
+ }
69
+ ],
70
+ [id, isFullscreen, onRemove, onToggleFullscreen, onRefresh]
71
+ );
72
+ const styles = useStyles();
73
+
74
+ return (
75
+ <BasicViewHeader title={title} className={styles.toolbarRoot} classes={{title: styles.title}}>
76
+ {isUpdated && <Chip label={i18n.text('Updated')} size="small" className={styles.updatedChip} />}
77
+ <div className={styles.rightMenu}>
78
+ {children}
79
+ <DashboardPopupMenu items={menuItems} />
80
+ </div>
81
+ <DragIndicatorIcon className={classnames('viewDraggableHandle', styles.dragIcon)} />
82
+ </BasicViewHeader>
83
+ );
84
+ };
85
+
86
+ export default LayoutItemHeader;
@@ -0,0 +1,48 @@
1
+ import LayoutItemHeader from '../LayoutItemHeader';
2
+ import React from 'react';
3
+ import {mount, shallow} from 'enzyme';
4
+ import {BasicViewHeader} from '@reltio/components';
5
+ import DashboardPopupMenu from '../../DashboardPopupMenu/DashboardPopupMenu';
6
+ import Chip from '@mui/material/Chip';
7
+ import MenuItem from '@mui/material/MenuItem';
8
+ import IconButton from '@mui/material/IconButton';
9
+
10
+ describe('LayoutItemHeader tests', () => {
11
+ const props = {
12
+ title: 'Test',
13
+ isUpdated: false,
14
+ isFullscreen: false,
15
+ onRemove: jest.fn(),
16
+ onRefresh: jest.fn(),
17
+ onToggleFullscreen: jest.fn()
18
+ };
19
+
20
+ it('should proper render header', () => {
21
+ const wrapper = shallow(<LayoutItemHeader {...props} />);
22
+ const header = wrapper.find(BasicViewHeader);
23
+ expect(header).toHaveLength(1);
24
+ expect(header.prop('title')).toEqual(props.title);
25
+ expect(wrapper.find(DashboardPopupMenu)).toHaveLength(1);
26
+ expect(wrapper.find('.viewDraggableHandle')).toHaveLength(1);
27
+ expect(wrapper.find(Chip)).toHaveLength(0);
28
+ });
29
+
30
+ it('should not render optional menu items when related functions is not passed', () => {
31
+ const props = {
32
+ title: 'Test',
33
+ isUpdated: false,
34
+ isFullscreen: false,
35
+ onToggleFullscreen: jest.fn()
36
+ };
37
+
38
+ const wrapper = mount(<LayoutItemHeader {...props} />);
39
+
40
+ wrapper.find(IconButton).simulate('click');
41
+ expect(wrapper.find(MenuItem)).toHaveLength(1);
42
+ });
43
+
44
+ it('should show "Updated" chip when isUpdated === true', () => {
45
+ const wrapper = shallow(<LayoutItemHeader {...props} isUpdated />);
46
+ expect(wrapper.find(Chip)).toHaveLength(1);
47
+ });
48
+ });
@@ -0,0 +1,44 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ export const useStyles = makeStyles(() => ({
4
+ toolbarRoot: {
5
+ padding: '16px',
6
+ minHeight: '18px',
7
+ lineHeight: '18px',
8
+ marginBottom: '8px'
9
+ },
10
+ title: {
11
+ fontSize: '16px',
12
+ lineHeight: '20px',
13
+ fontWeight: 'normal',
14
+ color: 'rgba(0, 0, 0, 0.87)',
15
+ letterSpacing: '0.15px',
16
+ marginRight: '6px'
17
+ },
18
+ dragIcon: {
19
+ position: 'absolute',
20
+ left: '50%',
21
+ top: '-3px',
22
+ transform: 'translateX(-50%) rotate(90deg)',
23
+ color: 'rgba(0, 0, 0, 0.3)',
24
+ cursor: 'move',
25
+ zIndex: 8,
26
+ visibility: 'hidden',
27
+ '.react-draggable $toolbarRoot:hover &.viewDraggableHandle': {
28
+ visibility: 'visible'
29
+ }
30
+ },
31
+ rightMenu: {
32
+ display: 'flex',
33
+ flexGrow: 1,
34
+ justifyContent: 'flex-end',
35
+ alignItems: 'baseline'
36
+ },
37
+ updatedChip: {
38
+ background: '#FF9E1B',
39
+ height: 20,
40
+ fontSize: '10px',
41
+ color: 'white',
42
+ marginRight: '6px'
43
+ }
44
+ }));
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import {BasicView} from '@reltio/components';
3
+ import {DashboardViewIdContext} from '../../contexts/DashboardViewIdContext';
4
+
5
+ import {useStyles} from './styles';
6
+
7
+ type Props = {
8
+ id: string;
9
+ children: React.ReactNode;
10
+ };
11
+
12
+ const LayoutItemView = ({id, children}: Props) => {
13
+ const styles = useStyles();
14
+
15
+ return (
16
+ <DashboardViewIdContext.Provider value={id}>
17
+ <BasicView className={styles.view} data-reltio-id={`layout-item-${id}`}>
18
+ {children}
19
+ </BasicView>
20
+ </DashboardViewIdContext.Provider>
21
+ );
22
+ };
23
+
24
+ export default LayoutItemView;
@@ -0,0 +1,11 @@
1
+ import {makeStyles} from '@mui/styles';
2
+
3
+ export const useStyles = makeStyles(() => ({
4
+ view: {
5
+ flex: 1,
6
+ width: '100%',
7
+ height: '100%',
8
+ overflow: 'hidden',
9
+ boxShadow: 'none'
10
+ }
11
+ }));
@@ -0,0 +1,77 @@
1
+ import React, {useMemo, useState} from 'react';
2
+ import {CartesianGrid, Legend, Line, LineChart, Tooltip, XAxis, YAxis} from 'recharts';
3
+ import {append, ifElse, includes, pluck, without} from 'ramda';
4
+ import getStatsChartSettings from './getStatsChartSettings';
5
+ import {PeriodStep} from '../../types/PeriodStep';
6
+ import {StatsData} from '../../types/StatsData';
7
+ import {calibrateStatsData, getStatsEventColor, getChartDomain} from '../../services/stats';
8
+ import CustomAxisTick from './customized/CustomAxisTick';
9
+ import CustomTooltip from './customized/CustomTooltip';
10
+ import CustomLegend from './customized/CustomLegend';
11
+
12
+ type Props = {
13
+ data: StatsData[];
14
+ width: number;
15
+ height: number;
16
+ step: PeriodStep;
17
+ };
18
+
19
+ const StatsChart = ({data, width, height, step}: Props) => {
20
+ const [selectedEvents, setSelectedEvents] = useState<string[]>(pluck('event', data));
21
+ const toggleEvent = (event) => {
22
+ setSelectedEvents(ifElse(includes(event), without([event]), append(event)));
23
+ };
24
+
25
+ const [tooltipEvent, setTooltipEvent] = useState<string | null>(null);
26
+
27
+ const tickCount = 8;
28
+ const {cartesianGrid, tooltip, xAxis, yAxis, line, legend} = getStatsChartSettings();
29
+ const chartData = useMemo(() => calibrateStatsData(step, data), [step, data]);
30
+ const domain = useMemo(() => getChartDomain(chartData, tickCount), [chartData]);
31
+
32
+ return (
33
+ <LineChart width={width} height={height}>
34
+ <CartesianGrid {...cartesianGrid} />
35
+ <XAxis {...xAxis} tick={<CustomAxisTick step={step} />} />
36
+ <YAxis {...yAxis} tickCount={tickCount} domain={domain} />
37
+ {chartData.map(({event, data}) => {
38
+ const isSelected = selectedEvents.includes(event);
39
+ return (
40
+ <Line
41
+ key={event}
42
+ stroke={getStatsEventColor(event)}
43
+ name={event}
44
+ data={data}
45
+ dot={isSelected && {r: 5, strokeWidth: 2}}
46
+ activeDot={
47
+ isSelected && {
48
+ r: 5,
49
+ strokeWidth: 2,
50
+ onMouseEnter: () => setTooltipEvent(event),
51
+ onMouseLeave: () => setTooltipEvent(null)
52
+ }
53
+ }
54
+ strokeOpacity={isSelected ? 1 : 0}
55
+ {...line}
56
+ />
57
+ );
58
+ })}
59
+ <Legend
60
+ content={<CustomLegend selectedItems={selectedEvents} onClick={toggleEvent} />}
61
+ payload={chartData.map(({event, total}) => ({
62
+ id: event,
63
+ type: 'square',
64
+ color: getStatsEventColor(event),
65
+ value: total
66
+ }))}
67
+ {...legend}
68
+ />
69
+ <Tooltip
70
+ {...tooltip}
71
+ content={<CustomTooltip step={step} events={tooltipEvent ? [tooltipEvent] : selectedEvents} />}
72
+ />
73
+ </LineChart>
74
+ );
75
+ };
76
+
77
+ export default StatsChart;