@centreon/ui 24.7.0 → 24.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/package.json +66 -85
  2. package/public/mockServiceWorker.js +1 -1
  3. package/src/Graph/BarChart/BarChart.cypress.spec.tsx +85 -2
  4. package/src/Graph/BarChart/BarStack.tsx +8 -6
  5. package/src/Graph/BarChart/SingleBar.tsx +2 -2
  6. package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +3 -3
  7. package/src/Graph/LineChart/Icons/Downtime.tsx +1 -1
  8. package/src/Graph/LineChart/LineChart.tsx +2 -0
  9. package/src/Graph/LineChart/helpers/index.ts +3 -0
  10. package/src/Graph/LineChart/index.tsx +2 -1
  11. package/src/Graph/LineChart/models.ts +1 -0
  12. package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -4
  13. package/src/Graph/common/Axes/index.tsx +3 -5
  14. package/src/Graph/common/BaseChart/BaseChart.tsx +5 -1
  15. package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +2 -2
  16. package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +7 -2
  17. package/src/Graph/index.ts +5 -0
  18. package/src/{Home.stories.mdx → Home.mdx} +41 -39
  19. package/src/Image/index.stories.tsx +101 -101
  20. package/src/RichTextEditor/index.stories.tsx +102 -102
  21. package/src/ThemeProvider/index.tsx +5 -4
  22. package/src/TimePeriods/DateTimePickerInput.tsx +1 -1
  23. package/src/TimePeriods/index.tsx +10 -2
  24. package/src/TimePeriods/models.ts +1 -0
  25. package/src/Typography/FluidTypography/index.stories.tsx +63 -63
  26. package/src/components/Form/AccessRights/AccessRights.stories.tsx +5 -5
  27. package/src/index.ts +0 -2
  28. package/test/setupTests.js +1 -0
  29. package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +0 -60
  30. package/src/Listing/index.test.tsx +0 -234
  31. /package/{public → src}/fonts/roboto-bold-webfont.ttf +0 -0
  32. /package/{public → src}/fonts/roboto-bold-webfont.woff +0 -0
  33. /package/{public → src}/fonts/roboto-bold-webfont.woff2 +0 -0
  34. /package/{public → src}/fonts/roboto-light-webfont.ttf +0 -0
  35. /package/{public → src}/fonts/roboto-light-webfont.woff +0 -0
  36. /package/{public → src}/fonts/roboto-light-webfont.woff2 +0 -0
  37. /package/{public → src}/fonts/roboto-medium-webfont.ttf +0 -0
  38. /package/{public → src}/fonts/roboto-medium-webfont.woff +0 -0
  39. /package/{public → src}/fonts/roboto-medium-webfont.woff2 +0 -0
  40. /package/{public → src}/fonts/roboto-regular-webfont.ttf +0 -0
  41. /package/{public → src}/fonts/roboto-regular-webfont.woff +0 -0
  42. /package/{public → src}/fonts/roboto-regular-webfont.woff2 +0 -0
@@ -1,63 +1,63 @@
1
- import { ComponentMeta } from '@storybook/react';
2
-
3
- import { Box } from '@mui/material';
4
-
5
- import FluidTypography, { FluidTypographyProps } from '.';
6
-
7
- interface Props extends FluidTypographyProps {
8
- height?: string | number;
9
- width?: string | number;
10
- }
11
-
12
- const FluidTypographyTemplate = ({
13
- width = '900px',
14
- height = '700px',
15
- text,
16
- variant
17
- }: Props): JSX.Element => {
18
- return (
19
- <Box sx={{ height, width }}>
20
- <FluidTypography text={text} variant={variant} />
21
- </Box>
22
- );
23
- };
24
-
25
- export default {
26
- argTypes: {
27
- height: { control: 'text' },
28
- text: { control: 'text' },
29
- variant: { control: 'text' },
30
- width: { control: 'text' }
31
- },
32
- component: FluidTypographyTemplate,
33
- title: 'Fluid Typography'
34
- } as ComponentMeta<typeof FluidTypographyTemplate>;
35
-
36
- export const basic = FluidTypographyTemplate.bind({});
37
- basic.args = {
38
- text: 'Hello world'
39
- };
40
-
41
- export const with200pxWidth = FluidTypographyTemplate.bind({});
42
- with200pxWidth.args = {
43
- height: '50%',
44
- text: 'Hello world',
45
- width: '50%'
46
- };
47
-
48
- export const with20pxHeight = FluidTypographyTemplate.bind({});
49
- with20pxHeight.args = {
50
- height: '20px',
51
- text: 'Hello world'
52
- };
53
-
54
- export const withLongText = FluidTypographyTemplate.bind({});
55
- withLongText.args = {
56
- text: 'This is a very long text becaaaaaaause it has a lot to sayyyyy !!!!!!!!'
57
- };
58
-
59
- export const withHeading5Variant = FluidTypographyTemplate.bind({});
60
- withHeading5Variant.args = {
61
- text: 'Hello world',
62
- variant: 'h5'
63
- };
1
+ import { ComponentMeta } from '@storybook/react';
2
+
3
+ import { Box } from '@mui/material';
4
+
5
+ import FluidTypography, { FluidTypographyProps } from '.';
6
+
7
+ interface Props extends FluidTypographyProps {
8
+ height?: string | number;
9
+ width?: string | number;
10
+ }
11
+
12
+ const FluidTypographyTemplate = ({
13
+ width = '900px',
14
+ height = '700px',
15
+ text,
16
+ variant
17
+ }: Props): JSX.Element => {
18
+ return (
19
+ <Box sx={{ height, width }}>
20
+ <FluidTypography text={text} variant={variant} />
21
+ </Box>
22
+ );
23
+ };
24
+
25
+ export default {
26
+ argTypes: {
27
+ height: { control: 'text' },
28
+ text: { control: 'text' },
29
+ variant: { control: 'text' },
30
+ width: { control: 'text' }
31
+ },
32
+ component: FluidTypographyTemplate,
33
+ title: 'Fluid Typography'
34
+ } as ComponentMeta<typeof FluidTypographyTemplate>;
35
+
36
+ export const basic = FluidTypographyTemplate.bind({});
37
+ basic.args = {
38
+ text: 'Hello world'
39
+ };
40
+
41
+ export const with200pxWidth = FluidTypographyTemplate.bind({});
42
+ with200pxWidth.args = {
43
+ height: '50%',
44
+ text: 'Hello world',
45
+ width: '50%'
46
+ };
47
+
48
+ export const with20pxHeight = FluidTypographyTemplate.bind({});
49
+ with20pxHeight.args = {
50
+ height: '20px',
51
+ text: 'Hello world'
52
+ };
53
+
54
+ export const withLongText = FluidTypographyTemplate.bind({});
55
+ withLongText.args = {
56
+ text: 'This is a very long text becaaaaaaause it has a lot to sayyyyy !!!!!!!!'
57
+ };
58
+
59
+ export const withHeading5Variant = FluidTypographyTemplate.bind({});
60
+ withHeading5Variant.args = {
61
+ text: 'Hello world',
62
+ variant: 'h5'
63
+ };
@@ -1,5 +1,5 @@
1
1
  import { Meta, StoryObj } from '@storybook/react';
2
- import { rest } from 'msw';
2
+ import { http, HttpResponse } from 'msw';
3
3
 
4
4
  import { SnackbarProvider } from '../../..';
5
5
 
@@ -18,11 +18,11 @@ const meta: Meta<typeof AccessRightsForm> = {
18
18
  parameters: {
19
19
  msw: {
20
20
  handlers: [
21
- rest.get('api/latest/contact?**', (req, res, ctx) => {
22
- return res(ctx.json(buildResult(false)));
21
+ http.get('api/latest/contact?**', () => {
22
+ return HttpResponse.json(buildResult(false));
23
23
  }),
24
- rest.get('api/latest/contactGroup?**', (req, res, ctx) => {
25
- return res(ctx.json(buildResult(true)));
24
+ http.get('api/latest/contactGroup?**', () => {
25
+ return HttpResponse.json(buildResult(true));
26
26
  })
27
27
  ]
28
28
  }
package/src/index.ts CHANGED
@@ -158,8 +158,6 @@ export { default as FluidTypography } from './Typography/FluidTypography';
158
158
  export { default as EllipsisTypography } from './Typography/EllipsisTypography';
159
159
  export * from './Dashboard';
160
160
  export * from './Graph';
161
- export type { LineChartData } from './Graph/common/models';
162
- export * from './Graph/common/timeSeries';
163
161
 
164
162
  export { default as TimePeriods } from './TimePeriods';
165
163
  export { default as SimpleCustomTimePeriod } from './TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod';
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
2
  /* eslint-disable no-undef */
3
3
 
4
+ import '@testing-library/jest-dom';
4
5
  import i18n from 'i18next';
5
6
  import { initReactI18next } from 'react-i18next';
6
7
  import fetchMock from 'jest-fetch-mock';
@@ -1,60 +0,0 @@
1
- import { Dispatch, SetStateAction, useEffect } from 'react';
2
-
3
- import { equals, propEq, reject } from 'ramda';
4
-
5
- import { Line } from '../../common/timeSeries/models';
6
-
7
- import {
8
- findLineOfOriginMetricThreshold,
9
- lowerLineName,
10
- upperLineName
11
- } from './Lines/Threshold/models';
12
-
13
- interface UseFilterLines {
14
- displayThreshold?: boolean;
15
- lines: Array<Line>;
16
- linesGraph: Array<Line> | null;
17
- setLinesGraph: Dispatch<SetStateAction<Array<Line> | null>>;
18
- }
19
-
20
- interface Result {
21
- displayedLines: Array<Line>;
22
- newLines: Array<Line>;
23
- }
24
-
25
- const useFilterLines = ({
26
- displayThreshold = false,
27
- lines,
28
- linesGraph,
29
- setLinesGraph
30
- }: UseFilterLines): Result => {
31
- const displayedLines = reject(propEq(false, 'display'), linesGraph ?? lines);
32
- const filterLines = (): Array<Line> => {
33
- const lineOriginMetric = findLineOfOriginMetricThreshold(lines);
34
-
35
- const findLinesUpperLower = lines.map((line) =>
36
- equals(line.name, lowerLineName) || equals(line.name, upperLineName)
37
- ? line
38
- : null
39
- );
40
-
41
- const linesUpperLower = reject((element) => !element, findLinesUpperLower);
42
-
43
- return [...lineOriginMetric, ...linesUpperLower] as Array<Line>;
44
- };
45
-
46
- useEffect(() => {
47
- const filteredLines = filterLines();
48
- if (!lines || !displayThreshold) {
49
- setLinesGraph(lines);
50
-
51
- return;
52
- }
53
-
54
- setLinesGraph(filteredLines);
55
- }, [lines, displayThreshold]);
56
-
57
- return { displayedLines, newLines: linesGraph ?? lines };
58
- };
59
-
60
- export default useFilterLines;
@@ -1,234 +0,0 @@
1
- import { useState } from 'react';
2
-
3
- import { prop } from 'ramda';
4
-
5
- import { render, fireEvent, within } from '../../test/testRenderer';
6
-
7
- import { ColumnType } from './models';
8
- import { labelAddColumns } from './translatedLabels';
9
-
10
- import Listing from '.';
11
-
12
- describe('Listing', () => {
13
- const getAllCheckboxes = (container): Array<HTMLElement> => {
14
- return container.querySelectorAll('[type = "checkbox"]');
15
- };
16
-
17
- const columns = [
18
- {
19
- getFormattedString: ({ name }): string => name,
20
- id: 'name',
21
- label: 'name',
22
- sortable: true,
23
- type: ColumnType.string
24
- },
25
- {
26
- getFormattedString: ({ description }): string => description,
27
- id: 'description',
28
- label: 'description',
29
- sortField: 'descriptionField',
30
- sortable: true,
31
- type: ColumnType.string
32
- }
33
- ];
34
-
35
- const rows = [
36
- { description: 'first row description', id: 0, name: 'My First Row' },
37
- { description: 'second row description', id: 1, name: 'My Second Row' },
38
- { description: 'third row description', id: 2, name: 'My Third Row' },
39
- { description: 'fourth row description', id: 3, name: 'My Fourth Row' }
40
- ];
41
-
42
- const onSelectRows = jest.fn();
43
- const onSort = jest.fn();
44
-
45
- const oneHundredElements = new Array(100).fill(0);
46
-
47
- const oneHundredTableData = [...oneHundredElements].map((_, index) => ({
48
- active: index % 2 === 0,
49
- description: `Entity ${index}`,
50
- disableCheckbox: index % 4 === 0,
51
- id: index,
52
- name: `E${index}`,
53
- selected: index % 3 === 0
54
- }));
55
-
56
- const PaginationTable = (): JSX.Element => {
57
- const [limit, setLimit] = useState(10);
58
- const [page, setPage] = useState(4);
59
-
60
- return (
61
- <Listing
62
- columns={columns}
63
- currentPage={page}
64
- limit={limit}
65
- rows={oneHundredTableData}
66
- totalRows={oneHundredTableData.length}
67
- onLimitChange={setLimit}
68
- onPaginate={setPage}
69
- onSort={onSort}
70
- />
71
- );
72
- };
73
-
74
- it('selects a row when the corresponding checkbox is clicked', () => {
75
- const { container } = render(
76
- <Listing
77
- checkable
78
- columns={columns}
79
- rows={rows}
80
- onSelectRows={onSelectRows}
81
- />
82
- );
83
-
84
- // The first visible checkbox is the 'select all' one
85
- const firstRowCheckbox = getAllCheckboxes(container)[1];
86
-
87
- fireEvent.click(firstRowCheckbox);
88
-
89
- const firstRow = rows[0];
90
- expect(onSelectRows).toHaveBeenCalledWith([firstRow]);
91
- });
92
-
93
- it('unselects a row when it is currently selected and the corresponding checkbox is clicked', () => {
94
- const firstRow = rows[0];
95
- const selectedRows = [firstRow];
96
-
97
- const { container } = render(
98
- <Listing
99
- checkable
100
- columns={columns}
101
- rows={rows}
102
- selectedRows={selectedRows}
103
- onSelectRows={onSelectRows}
104
- />
105
- );
106
- const firstRowCheckbox = getAllCheckboxes(container)[1];
107
-
108
- fireEvent.click(firstRowCheckbox);
109
-
110
- expect(onSelectRows).toHaveBeenCalledWith([]);
111
- });
112
-
113
- it('selects all rows when the "select all" checkbox is clicked', () => {
114
- const { container } = render(
115
- <Listing
116
- checkable
117
- columns={columns}
118
- rows={rows}
119
- totalRows={4}
120
- onSelectRows={onSelectRows}
121
- />
122
- );
123
-
124
- const selectAllCheckbox = getAllCheckboxes(container)[0];
125
-
126
- fireEvent.click(selectAllCheckbox);
127
-
128
- expect(onSelectRows).toHaveBeenLastCalledWith(rows);
129
- });
130
-
131
- it('unselects all rows when all rows are selected and the "select all" checkbox is clicked', () => {
132
- const { container } = render(
133
- <Listing
134
- checkable
135
- columns={columns}
136
- rows={rows}
137
- selectedRows={rows}
138
- onSelectRows={onSelectRows}
139
- />
140
- );
141
-
142
- const selectAllCheckbox = getAllCheckboxes(container)[0];
143
-
144
- fireEvent.click(selectAllCheckbox);
145
-
146
- expect(onSelectRows).toHaveBeenCalledWith([]);
147
- });
148
-
149
- it('unselects selected rows when some rows are selected and the "select all" checkbox is clicked', () => {
150
- const selectedRows = rows.filter(({ id }) => id % 2 === 0);
151
- const { container } = render(
152
- <Listing
153
- checkable
154
- columns={columns}
155
- rows={rows}
156
- selectedRows={selectedRows}
157
- onSelectRows={onSelectRows}
158
- />
159
- );
160
-
161
- const selectAllCheckbox = getAllCheckboxes(container)[0];
162
-
163
- fireEvent.click(selectAllCheckbox);
164
-
165
- expect(onSelectRows).toHaveBeenCalledWith([]);
166
- });
167
-
168
- it('sorts on on column id when the column header is clicked and sortField is not defined', () => {
169
- const columnWithoutSortField = columns[0];
170
-
171
- const { getByLabelText } = render(
172
- <Listing columns={columns} rows={rows} onSort={onSort} />
173
- );
174
-
175
- fireEvent.click(getByLabelText(`Column ${columnWithoutSortField.label}`));
176
-
177
- expect(onSort).toHaveBeenCalledWith({
178
- sortField: columnWithoutSortField.id,
179
- sortOrder: 'desc'
180
- });
181
- });
182
-
183
- it('sorts on on column sortField when the column header is clicked and sortField is defined', () => {
184
- const columnWithSortField = columns[1];
185
-
186
- const { getByLabelText } = render(
187
- <Listing columns={columns} rows={rows} onSort={onSort} />
188
- );
189
-
190
- fireEvent.click(getByLabelText(`Column ${columnWithSortField.label}`));
191
-
192
- expect(onSort).toHaveBeenCalledWith({
193
- sortField: columnWithSortField.sortField,
194
- sortOrder: 'desc'
195
- });
196
- });
197
-
198
- it('resets the page number to 0 when changing the limit and the current page is different than 0', () => {
199
- const { getByRole, getByText } = render(<PaginationTable />);
200
-
201
- expect(getByText('41-50 of 100'));
202
-
203
- fireEvent.mouseDown(getByText('10'));
204
-
205
- const listbox = within(getByRole('listbox'));
206
-
207
- fireEvent.click(listbox.getByText('90'));
208
-
209
- expect(getByText('1-90 of 100'));
210
- });
211
-
212
- it(`unselects a column when the "selectable" parameter is set and a column is unselected from the corresponding menu`, () => {
213
- const onSelectColumns = jest.fn();
214
-
215
- const { getAllByText, getByLabelText } = render(
216
- <Listing
217
- columnConfiguration={{
218
- selectedColumnIds: columns.map(prop('id')),
219
- sortable: true
220
- }}
221
- columns={columns}
222
- rows={rows}
223
- onSelectColumns={onSelectColumns}
224
- onSort={onSort}
225
- />
226
- );
227
-
228
- fireEvent.click(getByLabelText(labelAddColumns).firstChild as HTMLElement);
229
-
230
- fireEvent.click(getAllByText('description')[1]);
231
-
232
- expect(onSelectColumns).toHaveBeenCalledWith(['name']);
233
- });
234
- });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes