@centreon/ui 24.5.8 → 24.5.9

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 (78) hide show
  1. package/package.json +4 -8
  2. package/public/mockServiceWorker.js +100 -81
  3. package/src/ActionsList/index.stories.tsx +1 -7
  4. package/src/Dashboard/Dashboard.styles.ts +2 -3
  5. package/src/Dashboard/Item.tsx +5 -39
  6. package/src/Dashboard/Layout.tsx +2 -4
  7. package/src/Dashboard/utils.ts +1 -1
  8. package/src/Graph/BarStack/BarStack.stories.tsx +6 -8
  9. package/src/Graph/BarStack/ResponsiveBarStack.tsx +3 -3
  10. package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -20
  11. package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +8 -12
  12. package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +8 -8
  13. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/BasicThreshold.tsx +2 -1
  14. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +2 -1
  15. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +2 -1
  16. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +2 -1
  17. package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +2 -1
  18. package/src/Graph/LineChart/BasicComponents/Lines/models.ts +3 -0
  19. package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -4
  20. package/src/Graph/LineChart/LineChart.cypress.spec.tsx +0 -53
  21. package/src/Graph/LineChart/LineChart.tsx +2 -1
  22. package/src/Graph/LineChart/common/index.ts +1 -15
  23. package/src/Graph/LineChart/index.stories.tsx +3 -15
  24. package/src/Graph/LineChart/index.tsx +4 -2
  25. package/src/Graph/LineChart/useLineChartData.ts +18 -57
  26. package/src/Graph/PieChart/PieChart.stories.tsx +15 -11
  27. package/src/Graph/PieChart/ResponsivePie.tsx +1 -1
  28. package/src/Graph/Tree/DescendantNodes.tsx +0 -1
  29. package/src/Graph/Tree/Links.tsx +2 -15
  30. package/src/Graph/Tree/Tree.cypress.spec.tsx +0 -24
  31. package/src/Graph/Tree/Tree.stories.tsx +1 -17
  32. package/src/Graph/Tree/models.ts +0 -3
  33. package/src/Graph/common/utils.ts +1 -49
  34. package/src/Listing/Cell/index.tsx +23 -17
  35. package/src/TimePeriods/index.stories.tsx +12 -7
  36. package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
  37. package/src/api/QueryProvider.tsx +1 -1
  38. package/src/api/useFetchQuery/index.test.ts +5 -0
  39. package/src/api/useFetchQuery/index.ts +7 -12
  40. package/src/api/useGraphQuery/index.ts +2 -9
  41. package/src/api/useMutationQuery/index.ts +5 -2
  42. package/src/api/useRequest/index.test.ts +3 -0
  43. package/src/api/useRequest/index.ts +6 -3
  44. package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -27
  45. package/src/components/Form/AccessRights/AccessRights.stories.tsx +19 -0
  46. package/src/components/Form/AccessRights/AccessRights.styles.ts +1 -1
  47. package/src/components/Form/AccessRights/AccessRights.tsx +5 -6
  48. package/src/components/Form/AccessRights/Actions/Actions.styles.ts +7 -3
  49. package/src/components/Form/AccessRights/Actions/Actions.tsx +32 -15
  50. package/src/components/Form/AccessRights/Actions/useActions.ts +37 -4
  51. package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
  52. package/src/components/Form/AccessRights/models.ts +3 -0
  53. package/src/components/Form/AccessRights/storiesData.ts +3 -0
  54. package/src/components/Form/Dashboard/DashboardForm.stories.ts +39 -0
  55. package/src/components/Form/Dashboard/translatedLabels.ts +1 -0
  56. package/src/components/List/Item/ListItem.styles.ts +2 -2
  57. package/src/components/Modal/Modal.styles.ts +5 -5
  58. package/src/components/Zoom/Minimap.tsx +2 -4
  59. package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
  60. package/src/components/Zoom/Zoom.tsx +1 -4
  61. package/src/components/Zoom/ZoomContent.tsx +2 -5
  62. package/src/components/index.ts +0 -1
  63. package/src/index.ts +1 -1
  64. package/src/utils/index.ts +0 -1
  65. package/src/utils/usePluralizedTranslation.ts +3 -20
  66. package/src/Dashboard/Dashboard.cypress.spec.tsx +0 -68
  67. package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +0 -252
  68. package/src/api/logger.ts +0 -11
  69. package/src/components/Form/AccessRights/useAccessRightsChange.ts +0 -30
  70. package/src/components/Form/AccessRights/utils.ts +0 -18
  71. package/src/components/Tabs/Tab.styles.ts +0 -25
  72. package/src/components/Tabs/TabPanel.tsx +0 -22
  73. package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -70
  74. package/src/components/Tabs/Tabs.stories.tsx +0 -55
  75. package/src/components/Tabs/Tabs.tsx +0 -55
  76. package/src/components/Tabs/index.ts +0 -6
  77. package/src/utils/resourcesStatusURL.ts +0 -166
  78. package/src/utils/usePluralizedTranslation.test.ts +0 -159
@@ -1,9 +1,10 @@
1
1
  import { Threshold } from '@visx/threshold';
2
2
 
3
3
  import { TimeValue } from '../../../../common/timeSeries/models';
4
+ import { CurveType } from '../models';
4
5
 
5
6
  interface Props {
6
- curve: 'linear' | 'natural' | 'step';
7
+ curve: CurveType;
7
8
  fillAboveArea: string;
8
9
  fillBelowArea: string;
9
10
  fillOpacity?: number;
@@ -5,13 +5,14 @@ import { useTheme } from '@mui/material/styles';
5
5
 
6
6
  import { adjustGraphData } from '../../../helpers/index';
7
7
  import { PatternOrientation } from '../../../models';
8
+ import { CurveType } from '../models';
8
9
  import { LineChartData } from '../../../../common/models';
9
10
 
10
11
  import BasicThreshold from './BasicThreshold';
11
12
  import useScaleThreshold from './useScaleThreshold';
12
13
 
13
14
  interface Props {
14
- curve: 'linear' | 'natural' | 'step';
15
+ curve: CurveType;
15
16
  data: LineChartData;
16
17
  graphHeight: number;
17
18
  id: string;
@@ -4,11 +4,12 @@ import { LinePath } from '@visx/shape';
4
4
  import { useTheme } from '@mui/material/styles';
5
5
 
6
6
  import { TimeValue } from '../../../../common/timeSeries/models';
7
+ import { CurveType } from '../models';
7
8
 
8
9
  import BasicThreshold from './BasicThreshold';
9
10
 
10
11
  interface Props {
11
- curve: 'linear' | 'natural' | 'step';
12
+ curve: CurveType;
12
13
  getX: (timeValue: TimeValue) => number;
13
14
  getY0Variation: (timeValue: TimeValue) => number;
14
15
  getY1Variation: (timeValue: TimeValue) => number;
@@ -7,6 +7,7 @@ import {
7
7
  VariationThreshold
8
8
  } from '../../../models';
9
9
  import { TimeValue } from '../../../../common/timeSeries/models';
10
+ import { CurveType } from '../models';
10
11
 
11
12
  import BasicThreshold from './BasicThreshold';
12
13
  import Circle from './Circle';
@@ -16,7 +17,7 @@ import { WrapperThresholdLinesModel } from './models';
16
17
  import useScaleThreshold from './useScaleThreshold';
17
18
 
18
19
  interface Props extends WrapperThresholdLinesModel {
19
- curve: 'linear' | 'natural' | 'step';
20
+ curve: CurveType;
20
21
  graphHeight: number;
21
22
  timeSeries: Array<TimeValue>;
22
23
  }
@@ -23,9 +23,10 @@ import {
23
23
  canDisplayThreshold,
24
24
  requiredNumberLinesThreshold
25
25
  } from './Threshold/models';
26
+ import { CurveType } from './models';
26
27
 
27
28
  interface Props extends GlobalAreaLines {
28
- curve: 'linear' | 'step' | 'natural';
29
+ curve: CurveType;
29
30
  displayAnchor?: DisplayAnchor;
30
31
  displayedLines: Array<Line>;
31
32
  graphSvgRef: MutableRefObject<SVGSVGElement | null>;
@@ -1,4 +1,5 @@
1
1
  import { ScaleLinear } from 'd3-scale';
2
+ import { curveBasis } from '@visx/curve';
2
3
 
3
4
  import { Line, TimeValue } from '../../../common/timeSeries/models';
4
5
  import { LineChartData } from '../../../common/models';
@@ -40,3 +41,5 @@ export interface Shape {
40
41
  areaStackedLines: AreaStackedLines;
41
42
  areaThreshold: AreaThreshold;
42
43
  }
44
+
45
+ export type CurveType = typeof curveBasis;
@@ -63,10 +63,7 @@ const LegendHeader = ({
63
63
  placement="top"
64
64
  >
65
65
  <div className={classes.markerAndLegendName}>
66
- <div
67
- data-icon
68
- className={cx(classes.icon, { [classes.disabled]: disabled })}
69
- />
66
+ <div className={cx(classes.icon, { [classes.disabled]: disabled })} />
70
67
  <EllipsisTypography
71
68
  className={cx(classes.text, classes.legendName)}
72
69
  data-mode={
@@ -3,7 +3,6 @@ import { LineChartData } from '../common/models';
3
3
  import dataLastDay from './mockedData/lastDay.json';
4
4
  import dataLastDayWithNullValues from './mockedData/lastDayWithNullValues.json';
5
5
  import dataLastDayWithIncompleteValues from './mockedData/lastDayWithIncompleteValues.json';
6
- import dataCurvesWithSameColor from './mockedData/curvesWithSameColor.json';
7
6
  import { args as argumentsData } from './helpers/doc';
8
7
 
9
8
  import WrapperLineChart from '.';
@@ -89,56 +88,4 @@ describe('Line chart', () => {
89
88
  cy.makeSnapshot();
90
89
  });
91
90
  });
92
-
93
- it('displays the curves with different shades when curves have same color', () => {
94
- initialize(dataCurvesWithSameColor);
95
-
96
- cy.findByLabelText('Centreon-Server: Round-Trip Average Time')
97
- .find('[data-icon="true"]')
98
- .should('have.css', 'background-color', 'rgb(41, 175, 238)');
99
- cy.findByLabelText('Centreon-Server_5: Round-Trip Average Time')
100
- .find('[data-icon="true"]')
101
- .should('have.css', 'background-color', 'rgb(83, 191, 241)');
102
- cy.findByLabelText('Centreon-Server_4: Round-Trip Average Time')
103
- .find('[data-icon="true"]')
104
- .should('have.css', 'background-color', 'rgb(8, 34, 47)');
105
- cy.findByLabelText('Centreon-Server_3: Round-Trip Average Time')
106
- .find('[data-icon="true"]')
107
- .should('have.css', 'background-color', 'rgb(16, 70, 95)');
108
- cy.findByLabelText('Centreon-Server_2: Round-Trip Average Time')
109
- .find('[data-icon="true"]')
110
- .should('have.css', 'background-color', 'rgb(24, 105, 142)');
111
- cy.findByLabelText('Centreon-Server_1: Round-Trip Average Time')
112
- .find('[data-icon="true"]')
113
- .should('have.css', 'background-color', 'rgb(32, 140, 190)');
114
-
115
- cy.get('[data-metric="1"]').should(
116
- 'have.attr',
117
- 'stroke',
118
- 'rgb(41, 175, 238)'
119
- );
120
- cy.get('[data-metric="21"]').should(
121
- 'have.attr',
122
- 'stroke',
123
- 'rgb(32, 140, 190)'
124
- );
125
- cy.get('[data-metric="17"]').should(
126
- 'have.attr',
127
- 'stroke',
128
- 'rgb(24, 105, 142)'
129
- );
130
- cy.get('[data-metric="13"]').should(
131
- 'have.attr',
132
- 'stroke',
133
- 'rgb(16, 70, 95)'
134
- );
135
- cy.get('[data-metric="9"]').should('have.attr', 'stroke', 'rgb(8, 34, 47)');
136
- cy.get('[data-metric="5"]').should(
137
- 'have.attr',
138
- 'stroke',
139
- 'rgb(83, 191, 241)'
140
- );
141
-
142
- cy.makeSnapshot();
143
- });
144
91
  });
@@ -30,6 +30,7 @@ import {
30
30
  LegendModel
31
31
  } from './models';
32
32
  import { useIntersection } from './useLineChartIntersection';
33
+ import { CurveType } from './BasicComponents/Lines/models';
33
34
  import Thresholds from './BasicComponents/Thresholds';
34
35
  import { legendWidth } from './Legend/Legend.styles';
35
36
  import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphValueTooltip';
@@ -37,7 +38,7 @@ import GraphValueTooltip from './InteractiveComponents/GraphValueTooltip/GraphVa
37
38
  const extraMargin = 10;
38
39
 
39
40
  interface Props extends LineChartProps {
40
- curve: 'linear' | 'step' | 'natural';
41
+ curve: CurveType;
41
42
  graphData: Data;
42
43
  graphInterval: GraphInterval;
43
44
  graphRef: MutableRefObject<HTMLDivElement | null>;
@@ -1,6 +1,3 @@
1
- import * as Curve from '@visx/curve';
2
- import { always, cond, equals } from 'ramda';
3
-
4
1
  import { alpha } from '@mui/material';
5
2
 
6
3
  const commonTickLabelProps = {
@@ -27,16 +24,6 @@ const timeFormat = 'LT';
27
24
  const dateTimeFormat = `${dateFormat} ${timeFormat}`;
28
25
  const maxLinesDisplayedLegend = 11;
29
26
 
30
- const getCurveFactory = (
31
- curve: 'linear' | 'step' | 'natural'
32
- ): typeof Curve.curveLinear => {
33
- return cond([
34
- [equals('linear'), always(Curve.curveLinear)],
35
- [equals('step'), always(Curve.curveStep)],
36
- [equals('natural'), always(Curve.curveCatmullRom)]
37
- ])(curve);
38
- };
39
-
40
27
  export {
41
28
  commonTickLabelProps,
42
29
  margin,
@@ -44,6 +31,5 @@ export {
44
31
  dateFormat,
45
32
  timeFormat,
46
33
  dateTimeFormat,
47
- maxLinesDisplayedLegend,
48
- getCurveFactory
34
+ maxLinesDisplayedLegend
49
35
  };
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useState } from 'react';
2
2
 
3
3
  import { Meta, StoryObj } from '@storybook/react';
4
+ import { Curve } from '@visx/visx';
4
5
 
5
6
  import { Button } from '@mui/material';
6
7
  import ButtonGroup from '@mui/material/ButtonGroup';
@@ -33,7 +34,6 @@ import dataLastMonth from './mockedData/lastMonth.json';
33
34
  import dataLastWeek from './mockedData/lastWeek.json';
34
35
  import dataZoomPreview from './mockedData/zoomPreview.json';
35
36
  import dataLastDay from './mockedData/lastDay.json';
36
- import dataCurvesSameColor from './mockedData/curvesWithSameColor.json';
37
37
  import { Interval, ThresholdType, TooltipData } from './models';
38
38
 
39
39
  import WrapperLineChart from './index';
@@ -342,7 +342,7 @@ export const LineChartWithStepCurve: Story = {
342
342
  argTypes,
343
343
  args: {
344
344
  ...argumentsData,
345
- curve: 'step'
345
+ curve: Curve.curveStep
346
346
  }
347
347
  };
348
348
 
@@ -354,7 +354,7 @@ export const LineChartWithTimePeriod: Story = {
354
354
  start: defaultStart
355
355
  },
356
356
  parameters: {
357
- chromatic: { disableSnapshot: true }
357
+ chromatic: { diffThreshold: 0.1 }
358
358
  }
359
359
  };
360
360
 
@@ -478,15 +478,3 @@ export const thresholdsRange: Story = {
478
478
  />
479
479
  )
480
480
  };
481
-
482
- export const LineChartWithSameColorCurves: Story = {
483
- ...Template,
484
- argTypes,
485
- args: argumentsData,
486
- render: (args) => (
487
- <WrapperLineChart
488
- {...args}
489
- data={dataCurvesSameColor as unknown as LineChartData}
490
- />
491
- )
492
- };
@@ -1,5 +1,6 @@
1
1
  import { MutableRefObject, useRef } from 'react';
2
2
 
3
+ import { Curve } from '@visx/visx';
3
4
  import dayjs from 'dayjs';
4
5
  import 'dayjs/locale/en';
5
6
  import 'dayjs/locale/es';
@@ -16,13 +17,14 @@ import LineChart from './LineChart';
16
17
  import LoadingSkeleton from './LoadingSkeleton';
17
18
  import { GlobalAreaLines, LineChartProps, LegendModel } from './models';
18
19
  import useLineChartData from './useLineChartData';
20
+ import { CurveType } from './BasicComponents/Lines/models';
19
21
 
20
22
  dayjs.extend(localizedFormat);
21
23
  dayjs.extend(utcPlugin);
22
24
  dayjs.extend(timezonePlugin);
23
25
 
24
26
  interface Props extends Partial<LineChartProps> {
25
- curve?: 'linear' | 'step' | 'natural';
27
+ curve?: CurveType;
26
28
  data?: LineChartData;
27
29
  end: string;
28
30
  legend: LegendModel;
@@ -50,7 +52,7 @@ const WrapperLineChart = ({
50
52
  annotationEvent,
51
53
  legend,
52
54
  header,
53
- curve = 'linear',
55
+ curve = Curve.curveLinear,
54
56
  thresholds,
55
57
  thresholdUnit,
56
58
  limitLegend
@@ -1,20 +1,8 @@
1
- import { useCallback, useMemo, useRef } from 'react';
1
+ import { useEffect, useState } from 'react';
2
2
 
3
- import {
4
- compose,
5
- flatten,
6
- groupBy,
7
- isNil,
8
- lensPath,
9
- pipe,
10
- prop,
11
- set,
12
- sortBy,
13
- toLower
14
- } from 'ramda';
3
+ import { compose, prop, sortBy, toLower } from 'ramda';
15
4
 
16
5
  import { LineChartData } from '../common/models';
17
- import { emphasizeCurveColor } from '../common/utils';
18
6
 
19
7
  import { adjustGraphData } from './helpers';
20
8
  import { Data } from './models';
@@ -30,59 +18,32 @@ interface Props {
30
18
  }
31
19
 
32
20
  const useGraphData = ({ data, end, start }: Props): GraphDataResult => {
33
- const adjustedDataRef = useRef<Data>();
21
+ const [adjustedData, setAdjustedData] = useState<Data>();
34
22
 
35
- const dataWithAdjustedMetricsColor = useMemo(() => {
36
- if (isNil(data)) {
37
- return data;
38
- }
39
- const metricsGroupedByColor = groupBy(
40
- (metric) => metric.ds_data.ds_color_line
41
- )(data?.metrics || []);
42
-
43
- const newMetrics = Object.entries(metricsGroupedByColor).map(
44
- ([color, value]) => {
45
- return value?.map((metric, index) =>
46
- set(
47
- lensPath(['ds_data', 'ds_color_line']),
48
- emphasizeCurveColor({ color, index }),
49
- metric
50
- )
51
- );
52
- }
53
- );
54
-
55
- const sortedMetrics = pipe(flatten, sortBy(prop('metric')))(newMetrics);
56
-
57
- return {
58
- ...data,
59
- metrics: sortedMetrics
60
- };
61
- }, [data]);
62
-
63
- const prepareData = useCallback((): void => {
64
- if (isNil(dataWithAdjustedMetricsColor)) {
65
- return;
66
- }
67
-
68
- const { timeSeries } = adjustGraphData(dataWithAdjustedMetricsColor);
69
- const baseAxis = dataWithAdjustedMetricsColor.global.base;
70
- const { title } = dataWithAdjustedMetricsColor.global;
23
+ const prepareData = (dataToAdjust: LineChartData): void => {
24
+ const { timeSeries } = adjustGraphData(dataToAdjust);
25
+ const baseAxis = dataToAdjust.global.base;
26
+ const { title } = dataToAdjust.global;
71
27
 
72
- const newLineData = adjustGraphData(dataWithAdjustedMetricsColor).lines;
28
+ const newLineData = adjustGraphData(dataToAdjust).lines;
73
29
  const sortedLines = sortBy(compose(toLower, prop('name')), newLineData);
74
30
 
75
- adjustedDataRef.current = {
31
+ setAdjustedData({
76
32
  baseAxis,
77
33
  lines: sortedLines,
78
34
  timeSeries,
79
35
  title
80
- };
81
- }, [dataWithAdjustedMetricsColor, end, start]);
36
+ });
37
+ };
82
38
 
83
- prepareData();
39
+ useEffect(() => {
40
+ if (!data) {
41
+ return;
42
+ }
43
+ prepareData(data);
44
+ }, [end, start, data]);
84
45
 
85
- return { adjustedData: adjustedDataRef.current };
46
+ return { adjustedData };
86
47
  };
87
48
 
88
49
  export default useGraphData;
@@ -1,7 +1,8 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
2
 
3
3
  import { ArcType } from './models';
4
- import ResponsivePie from './ResponsivePie';
4
+
5
+ import { PieChart } from '.';
5
6
 
6
7
  const data = [
7
8
  { color: '#88B922', label: 'Ok', value: 148 },
@@ -17,20 +18,19 @@ const dataWithBigNumbers = [
17
18
  { color: '#FF6666', label: 'Down', value: 122222 }
18
19
  ];
19
20
 
20
- const meta: Meta<typeof ResponsivePie> = {
21
- component: ResponsivePie,
22
- parameters: {
23
- chromatic: {
24
- delay: 1000
25
- }
26
- }
21
+ const meta: Meta<typeof PieChart> = {
22
+ component: PieChart
27
23
  };
28
24
 
29
25
  export default meta;
30
- type Story = StoryObj<typeof ResponsivePie>;
26
+ type Story = StoryObj<typeof PieChart>;
31
27
 
32
28
  const Template = (args): JSX.Element => {
33
- return <ResponsivePie height={350} width={350} {...args} />;
29
+ return (
30
+ <div style={{ height: '350px', width: '350px' }}>
31
+ <PieChart {...args} />
32
+ </div>
33
+ );
34
34
  };
35
35
 
36
36
  export const Pie: Story = {
@@ -141,7 +141,11 @@ export const DonutWithTooltip: Story = {
141
141
  };
142
142
 
143
143
  const TemplateForSmallDimensions = (args): JSX.Element => {
144
- return <ResponsivePie height={130} width={130} {...args} />;
144
+ return (
145
+ <div style={{ height: '130px', width: '130px' }}>
146
+ <PieChart {...args} />
147
+ </div>
148
+ );
145
149
  };
146
150
 
147
151
  export const PieWithSmallDimensions: Story = {
@@ -93,7 +93,7 @@ const ResponsivePie = ({
93
93
  <div
94
94
  className={classes.svgWrapper}
95
95
  style={{
96
- minHeight: height,
96
+ height,
97
97
  width: svgWrapperWidth
98
98
  }}
99
99
  >
@@ -65,7 +65,6 @@ const DescendantNodes = <TData extends BaseProp>({
65
65
  <Group key={key} left={left} top={top}>
66
66
  <foreignObject
67
67
  height={nodeSize.height}
68
- style={{ userSelect: 'none' }}
69
68
  width={nodeSize.width}
70
69
  x={-nodeSize.width / 2}
71
70
  y={-nodeSize.height / 2}
@@ -1,10 +1,5 @@
1
- import {
2
- LinkHorizontal,
3
- LinkHorizontalStep,
4
- LinkHorizontalLine
5
- } from '@visx/shape';
1
+ import { LinkHorizontal } from '@visx/shape';
6
2
  import { HierarchyPointLink } from '@visx/hierarchy/lib/types';
7
- import { always, cond, equals, T } from 'ramda';
8
3
 
9
4
  import { useTheme } from '@mui/material';
10
5
 
@@ -14,12 +9,6 @@ interface Props<TData> extends Pick<TreeProps<TData>, 'treeLink'> {
14
9
  links: Array<HierarchyPointLink<Node<TData>>>;
15
10
  }
16
11
 
17
- const getLinkComponent = cond([
18
- [equals('line'), always(LinkHorizontalLine)],
19
- [equals('step'), always(LinkHorizontalStep)],
20
- [T, always(LinkHorizontal)]
21
- ]);
22
-
23
12
  const Links = <TData extends BaseProp>({
24
13
  links,
25
14
  treeLink
@@ -35,12 +24,10 @@ const Links = <TData extends BaseProp>({
35
24
  .descendants()
36
25
  .map((ancestor) => ancestor.data.data.id);
37
26
 
38
- const LinkComponent = getLinkComponent(treeLink?.type);
39
-
40
27
  const key = `${link.source.data.data.id}-${link.source.data.data.name}-${ancestorIds}_${link.target.data.data.id}-${link.target.data.data.name}-${descendantIds}`;
41
28
 
42
29
  return (
43
- <LinkComponent
30
+ <LinkHorizontal
44
31
  data={link}
45
32
  data-testid={`${link.source.data.data.id}_to_${link.target.data.data.id}`}
46
33
  fill="none"
@@ -168,28 +168,4 @@ describe('Complex data tree', () => {
168
168
 
169
169
  cy.makeSnapshot();
170
170
  });
171
-
172
- it('displays the tree with step links when a prop is set', () => {
173
- initializeStandaloneTree({
174
- treeLink: {
175
- type: 'step'
176
- }
177
- });
178
-
179
- cy.contains('T').should('be.visible');
180
-
181
- cy.makeSnapshot();
182
- });
183
-
184
- it('displays the tree with line links when a prop is set', () => {
185
- initializeStandaloneTree({
186
- treeLink: {
187
- type: 'line'
188
- }
189
- });
190
-
191
- cy.contains('T').should('be.visible');
192
-
193
- cy.makeSnapshot();
194
- });
195
171
  });
@@ -82,21 +82,6 @@ export const WithDefaultExpandFilter: Story = {
82
82
  render: StandaloneTreeTemplate
83
83
  };
84
84
 
85
- export const WithStepLink: Story = {
86
- args: {
87
- children: SimpleContent,
88
- node: {
89
- height: 90,
90
- width: 90
91
- },
92
- tree: simpleData,
93
- treeLink: {
94
- type: 'step'
95
- }
96
- },
97
- render: StandaloneTreeTemplate
98
- };
99
-
100
85
  export const WithCustomLinks: Story = {
101
86
  args: {
102
87
  children: SimpleContent,
@@ -110,8 +95,7 @@ export const WithCustomLinks: Story = {
110
95
  getStrokeDasharray: ({ target }) =>
111
96
  target.status === 'ok' ? '5,5' : '0',
112
97
  getStrokeOpacity: ({ target }) => (target.status === 'ok' ? 0.8 : 1),
113
- getStrokeWidth: ({ target }) => (target.status === 'ok' ? 1 : 2),
114
- type: 'line'
98
+ getStrokeWidth: ({ target }) => (target.status === 'ok' ? 1 : 2)
115
99
  }
116
100
  },
117
101
  render: StandaloneTreeTemplate
@@ -14,8 +14,6 @@ export interface BaseProp {
14
14
  name: string;
15
15
  }
16
16
 
17
- export type Link = 'curve' | 'line' | 'step';
18
-
19
17
  export interface ChildrenProps<TData> {
20
18
  ancestors: Array<Node<TData>>;
21
19
  depth: number;
@@ -50,6 +48,5 @@ export interface TreeProps<TData> {
50
48
  ) => string | number | undefined;
51
49
  getStrokeOpacity?: (props: LinkProps<TData>) => string | number | undefined;
52
50
  getStrokeWidth?: (props: LinkProps<TData>) => string | number | undefined;
53
- type?: Link;
54
51
  };
55
52
  }
@@ -13,7 +13,7 @@ import {
13
13
  } from 'ramda';
14
14
  import numeral from 'numeral';
15
15
 
16
- import { darken, getLuminance, lighten, Theme } from '@mui/material';
16
+ import { Theme } from '@mui/material';
17
17
 
18
18
  import { Thresholds } from './models';
19
19
 
@@ -92,51 +92,3 @@ export const getValueByUnit = ({
92
92
 
93
93
  return `${((value * 100) / total).toFixed(1)}%`;
94
94
  };
95
-
96
- interface NormalizeLevelProps {
97
- factor: number;
98
- level: number;
99
- }
100
-
101
- const normalizeLevel = ({ level, factor }: NormalizeLevelProps): number =>
102
- (level * factor) / 10;
103
-
104
- interface EmphasizeCurveColorProps {
105
- color: string;
106
- index: number;
107
- }
108
-
109
- export const emphasizeCurveColor = ({
110
- color,
111
- index
112
- }: EmphasizeCurveColorProps): string => {
113
- const totalLevels = 5;
114
- const levels = [...Array(totalLevels).keys()];
115
- const factor = 10 / totalLevels;
116
-
117
- if (gte(getLuminance(color), 0.5)) {
118
- if (gte(index, totalLevels * 2)) {
119
- return darken(color, normalizeLevel({ factor, level: last(levels) }));
120
- }
121
- if (gte(index, totalLevels)) {
122
- return darken(
123
- color,
124
- normalizeLevel({ factor, level: levels[totalLevels + 1 - index] })
125
- );
126
- }
127
-
128
- return lighten(color, normalizeLevel({ factor, level: levels[index] }));
129
- }
130
-
131
- if (gte(index, totalLevels * 2)) {
132
- return lighten(color, normalizeLevel({ factor, level: last(levels) }));
133
- }
134
- if (gte(index, totalLevels)) {
135
- return lighten(
136
- color,
137
- normalizeLevel({ factor, level: levels[totalLevels + 1 - index] })
138
- );
139
- }
140
-
141
- return darken(color, normalizeLevel({ factor, level: levels[index] }));
142
- };