@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.
- package/package.json +4 -8
- package/public/mockServiceWorker.js +100 -81
- package/src/ActionsList/index.stories.tsx +1 -7
- package/src/Dashboard/Dashboard.styles.ts +2 -3
- package/src/Dashboard/Item.tsx +5 -39
- package/src/Dashboard/Layout.tsx +2 -4
- package/src/Dashboard/utils.ts +1 -1
- package/src/Graph/BarStack/BarStack.stories.tsx +6 -8
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +3 -3
- package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -20
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +8 -12
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +8 -8
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/BasicThreshold.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/models.ts +3 -0
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -4
- package/src/Graph/LineChart/LineChart.cypress.spec.tsx +0 -53
- package/src/Graph/LineChart/LineChart.tsx +2 -1
- package/src/Graph/LineChart/common/index.ts +1 -15
- package/src/Graph/LineChart/index.stories.tsx +3 -15
- package/src/Graph/LineChart/index.tsx +4 -2
- package/src/Graph/LineChart/useLineChartData.ts +18 -57
- package/src/Graph/PieChart/PieChart.stories.tsx +15 -11
- package/src/Graph/PieChart/ResponsivePie.tsx +1 -1
- package/src/Graph/Tree/DescendantNodes.tsx +0 -1
- package/src/Graph/Tree/Links.tsx +2 -15
- package/src/Graph/Tree/Tree.cypress.spec.tsx +0 -24
- package/src/Graph/Tree/Tree.stories.tsx +1 -17
- package/src/Graph/Tree/models.ts +0 -3
- package/src/Graph/common/utils.ts +1 -49
- package/src/Listing/Cell/index.tsx +23 -17
- package/src/TimePeriods/index.stories.tsx +12 -7
- package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.test.ts +5 -0
- package/src/api/useFetchQuery/index.ts +7 -12
- package/src/api/useGraphQuery/index.ts +2 -9
- package/src/api/useMutationQuery/index.ts +5 -2
- package/src/api/useRequest/index.test.ts +3 -0
- package/src/api/useRequest/index.ts +6 -3
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +13 -27
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +19 -0
- package/src/components/Form/AccessRights/AccessRights.styles.ts +1 -1
- package/src/components/Form/AccessRights/AccessRights.tsx +5 -6
- package/src/components/Form/AccessRights/Actions/Actions.styles.ts +7 -3
- package/src/components/Form/AccessRights/Actions/Actions.tsx +32 -15
- package/src/components/Form/AccessRights/Actions/useActions.ts +37 -4
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
- package/src/components/Form/AccessRights/models.ts +3 -0
- package/src/components/Form/AccessRights/storiesData.ts +3 -0
- package/src/components/Form/Dashboard/DashboardForm.stories.ts +39 -0
- package/src/components/Form/Dashboard/translatedLabels.ts +1 -0
- package/src/components/List/Item/ListItem.styles.ts +2 -2
- package/src/components/Modal/Modal.styles.ts +5 -5
- package/src/components/Zoom/Minimap.tsx +2 -4
- package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
- package/src/components/Zoom/Zoom.tsx +1 -4
- package/src/components/Zoom/ZoomContent.tsx +2 -5
- package/src/components/index.ts +0 -1
- package/src/index.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/usePluralizedTranslation.ts +3 -20
- package/src/Dashboard/Dashboard.cypress.spec.tsx +0 -68
- package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +0 -252
- package/src/api/logger.ts +0 -11
- package/src/components/Form/AccessRights/useAccessRightsChange.ts +0 -30
- package/src/components/Form/AccessRights/utils.ts +0 -18
- package/src/components/Tabs/Tab.styles.ts +0 -25
- package/src/components/Tabs/TabPanel.tsx +0 -22
- package/src/components/Tabs/Tabs.cypress.spec.tsx +0 -70
- package/src/components/Tabs/Tabs.stories.tsx +0 -55
- package/src/components/Tabs/Tabs.tsx +0 -55
- package/src/components/Tabs/index.ts +0 -6
- package/src/utils/resourcesStatusURL.ts +0 -166
- package/src/utils/usePluralizedTranslation.test.ts +0 -159
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"global": {
|
|
3
|
-
"title": "oracle-buffer-hit-ratio graph on srv-oracle-users",
|
|
4
|
-
"start": "2023-06-18T17:04:46+02:00",
|
|
5
|
-
"end": "2023-06-19T17:04:46+02:00",
|
|
6
|
-
"vertical-label": "Value",
|
|
7
|
-
"base": 1000,
|
|
8
|
-
"width": 550,
|
|
9
|
-
"height": 140,
|
|
10
|
-
"scaled": 0,
|
|
11
|
-
"multiple_services": false
|
|
12
|
-
},
|
|
13
|
-
"metrics": [
|
|
14
|
-
{
|
|
15
|
-
"metric_id": 1,
|
|
16
|
-
"metric": "Centreon-Server: rta",
|
|
17
|
-
"metric_legend": "Centreon-Server: rta",
|
|
18
|
-
"unit": "ms",
|
|
19
|
-
"min": 0.0,
|
|
20
|
-
"max": null,
|
|
21
|
-
"ds_data": {
|
|
22
|
-
"ds_color_line": "#29AFEE"
|
|
23
|
-
},
|
|
24
|
-
"legend": "Centreon-Server: Round-Trip Average Time",
|
|
25
|
-
"stack": 0,
|
|
26
|
-
"warning_high_threshold": 200.0,
|
|
27
|
-
"critical_high_threshold": 400.0,
|
|
28
|
-
"warning_low_threshold": 0.0,
|
|
29
|
-
"critical_low_threshold": 0.0,
|
|
30
|
-
"ds_order": 1,
|
|
31
|
-
"data": [
|
|
32
|
-
null,
|
|
33
|
-
null,
|
|
34
|
-
null,
|
|
35
|
-
null,
|
|
36
|
-
null,
|
|
37
|
-
null,
|
|
38
|
-
null,
|
|
39
|
-
null,
|
|
40
|
-
null,
|
|
41
|
-
0.040219730942,
|
|
42
|
-
0.03038,
|
|
43
|
-
0.02108,
|
|
44
|
-
null
|
|
45
|
-
],
|
|
46
|
-
"last_value": 0.02,
|
|
47
|
-
"minimum_value": null,
|
|
48
|
-
"maximum_value": null,
|
|
49
|
-
"average_value": 0.03
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"metric_id": 21,
|
|
53
|
-
"metric": "Centreon-Server_1: rta",
|
|
54
|
-
"metric_legend": "Centreon-Server_1: rta",
|
|
55
|
-
"unit": "ms",
|
|
56
|
-
"min": 0.0,
|
|
57
|
-
"max": null,
|
|
58
|
-
"ds_data": {
|
|
59
|
-
"ds_color_line": "#29AFEE"
|
|
60
|
-
},
|
|
61
|
-
"legend": "Centreon-Server_1: Round-Trip Average Time",
|
|
62
|
-
"stack": 0,
|
|
63
|
-
"warning_high_threshold": 200.0,
|
|
64
|
-
"critical_high_threshold": 400.0,
|
|
65
|
-
"warning_low_threshold": 0.0,
|
|
66
|
-
"critical_low_threshold": 0.0,
|
|
67
|
-
"ds_order": 1,
|
|
68
|
-
"data": [
|
|
69
|
-
null,
|
|
70
|
-
null,
|
|
71
|
-
null,
|
|
72
|
-
null,
|
|
73
|
-
null,
|
|
74
|
-
null,
|
|
75
|
-
null,
|
|
76
|
-
null,
|
|
77
|
-
null,
|
|
78
|
-
null,
|
|
79
|
-
0.046261744966,
|
|
80
|
-
0.033813333333,
|
|
81
|
-
null
|
|
82
|
-
],
|
|
83
|
-
"last_value": 0.03,
|
|
84
|
-
"minimum_value": null,
|
|
85
|
-
"maximum_value": null,
|
|
86
|
-
"average_value": 0.04
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
"metric_id": 17,
|
|
90
|
-
"metric": "Centreon-Server_2: rta",
|
|
91
|
-
"metric_legend": "Centreon-Server_2: rta",
|
|
92
|
-
"unit": "ms",
|
|
93
|
-
"min": 0.0,
|
|
94
|
-
"max": null,
|
|
95
|
-
"ds_data": {
|
|
96
|
-
"ds_color_line": "#29AFEE"
|
|
97
|
-
},
|
|
98
|
-
"legend": "Centreon-Server_2: Round-Trip Average Time",
|
|
99
|
-
"stack": 0,
|
|
100
|
-
"warning_high_threshold": 200.0,
|
|
101
|
-
"critical_high_threshold": 400.0,
|
|
102
|
-
"warning_low_threshold": 0.0,
|
|
103
|
-
"critical_low_threshold": 0.0,
|
|
104
|
-
"ds_order": 1,
|
|
105
|
-
"data": [
|
|
106
|
-
null,
|
|
107
|
-
null,
|
|
108
|
-
null,
|
|
109
|
-
null,
|
|
110
|
-
null,
|
|
111
|
-
null,
|
|
112
|
-
null,
|
|
113
|
-
null,
|
|
114
|
-
null,
|
|
115
|
-
null,
|
|
116
|
-
0.035661073826,
|
|
117
|
-
0.03853,
|
|
118
|
-
null
|
|
119
|
-
],
|
|
120
|
-
"last_value": 0.04,
|
|
121
|
-
"minimum_value": null,
|
|
122
|
-
"maximum_value": null,
|
|
123
|
-
"average_value": 0.04
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
"metric_id": 13,
|
|
127
|
-
"metric": "Centreon-Server_3: rta",
|
|
128
|
-
"metric_legend": "Centreon-Server_3: rta",
|
|
129
|
-
"unit": "ms",
|
|
130
|
-
"min": 0.0,
|
|
131
|
-
"max": null,
|
|
132
|
-
"ds_data": {
|
|
133
|
-
"ds_color_line": "#29AFEE"
|
|
134
|
-
},
|
|
135
|
-
"legend": "Centreon-Server_3: Round-Trip Average Time",
|
|
136
|
-
"stack": 0,
|
|
137
|
-
"warning_high_threshold": 200.0,
|
|
138
|
-
"critical_high_threshold": 400.0,
|
|
139
|
-
"warning_low_threshold": 0.0,
|
|
140
|
-
"critical_low_threshold": 0.0,
|
|
141
|
-
"ds_order": 1,
|
|
142
|
-
"data": [
|
|
143
|
-
null,
|
|
144
|
-
null,
|
|
145
|
-
null,
|
|
146
|
-
null,
|
|
147
|
-
null,
|
|
148
|
-
null,
|
|
149
|
-
null,
|
|
150
|
-
null,
|
|
151
|
-
null,
|
|
152
|
-
null,
|
|
153
|
-
0.055875838926,
|
|
154
|
-
0.03161,
|
|
155
|
-
null
|
|
156
|
-
],
|
|
157
|
-
"last_value": 0.03,
|
|
158
|
-
"minimum_value": null,
|
|
159
|
-
"maximum_value": null,
|
|
160
|
-
"average_value": 0.04
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
"metric_id": 9,
|
|
164
|
-
"metric": "Centreon-Server_4: rta",
|
|
165
|
-
"metric_legend": "Centreon-Server_4: rta",
|
|
166
|
-
"unit": "ms",
|
|
167
|
-
"min": 0.0,
|
|
168
|
-
"max": null,
|
|
169
|
-
"ds_data": {
|
|
170
|
-
"ds_color_line": "#29AFEE"
|
|
171
|
-
},
|
|
172
|
-
"legend": "Centreon-Server_4: Round-Trip Average Time",
|
|
173
|
-
"stack": 0,
|
|
174
|
-
"warning_high_threshold": 200.0,
|
|
175
|
-
"critical_high_threshold": 400.0,
|
|
176
|
-
"warning_low_threshold": 0.0,
|
|
177
|
-
"critical_low_threshold": 0.0,
|
|
178
|
-
"ds_order": 1,
|
|
179
|
-
"data": [
|
|
180
|
-
null,
|
|
181
|
-
null,
|
|
182
|
-
null,
|
|
183
|
-
null,
|
|
184
|
-
null,
|
|
185
|
-
null,
|
|
186
|
-
null,
|
|
187
|
-
null,
|
|
188
|
-
null,
|
|
189
|
-
null,
|
|
190
|
-
0.02077852349,
|
|
191
|
-
0.03634,
|
|
192
|
-
null
|
|
193
|
-
],
|
|
194
|
-
"last_value": 0.04,
|
|
195
|
-
"minimum_value": null,
|
|
196
|
-
"maximum_value": null,
|
|
197
|
-
"average_value": 0.03
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
"metric_id": 5,
|
|
201
|
-
"metric": "Centreon-Server_5: rta",
|
|
202
|
-
"metric_legend": "Centreon-Server_5: rta",
|
|
203
|
-
"unit": "ms",
|
|
204
|
-
"min": 0.0,
|
|
205
|
-
"max": null,
|
|
206
|
-
"ds_data": {
|
|
207
|
-
"ds_color_line": "#29AFEE"
|
|
208
|
-
},
|
|
209
|
-
"legend": "Centreon-Server_5: Round-Trip Average Time",
|
|
210
|
-
"stack": 0,
|
|
211
|
-
"warning_high_threshold": 200.0,
|
|
212
|
-
"critical_high_threshold": 400.0,
|
|
213
|
-
"warning_low_threshold": 0.0,
|
|
214
|
-
"critical_low_threshold": 0.0,
|
|
215
|
-
"ds_order": 1,
|
|
216
|
-
"data": [
|
|
217
|
-
null,
|
|
218
|
-
null,
|
|
219
|
-
null,
|
|
220
|
-
null,
|
|
221
|
-
null,
|
|
222
|
-
null,
|
|
223
|
-
null,
|
|
224
|
-
null,
|
|
225
|
-
null,
|
|
226
|
-
null,
|
|
227
|
-
0.042899328859,
|
|
228
|
-
0.051873333333,
|
|
229
|
-
null
|
|
230
|
-
],
|
|
231
|
-
"last_value": 0.05,
|
|
232
|
-
"minimum_value": null,
|
|
233
|
-
"maximum_value": null,
|
|
234
|
-
"average_value": 0.05
|
|
235
|
-
}
|
|
236
|
-
],
|
|
237
|
-
"times": [
|
|
238
|
-
"2024-05-10T09:20:00+02:00",
|
|
239
|
-
"2024-05-10T09:25:00+02:00",
|
|
240
|
-
"2024-05-10T09:30:00+02:00",
|
|
241
|
-
"2024-05-10T09:35:00+02:00",
|
|
242
|
-
"2024-05-10T09:40:00+02:00",
|
|
243
|
-
"2024-05-10T09:45:00+02:00",
|
|
244
|
-
"2024-05-10T09:50:00+02:00",
|
|
245
|
-
"2024-05-10T09:55:00+02:00",
|
|
246
|
-
"2024-05-10T10:00:00+02:00",
|
|
247
|
-
"2024-05-10T10:05:00+02:00",
|
|
248
|
-
"2024-05-10T10:10:00+02:00",
|
|
249
|
-
"2024-05-10T10:15:00+02:00",
|
|
250
|
-
"2024-05-10T10:20:00+02:00"
|
|
251
|
-
]
|
|
252
|
-
}
|
package/src/api/logger.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useAtomValue } from 'jotai';
|
|
4
|
-
|
|
5
|
-
import { useDeepCompare } from '../../../utils';
|
|
6
|
-
|
|
7
|
-
import { valuesAtom } from './atoms';
|
|
8
|
-
import { formatValueForSubmition } from './utils';
|
|
9
|
-
import { AccessRightInitialValues } from './models';
|
|
10
|
-
|
|
11
|
-
export const useAccessRightsChange = (
|
|
12
|
-
onChange?: (values: Array<AccessRightInitialValues>) => void
|
|
13
|
-
): void => {
|
|
14
|
-
const values = useAtomValue(valuesAtom);
|
|
15
|
-
|
|
16
|
-
useEffect(
|
|
17
|
-
() => {
|
|
18
|
-
if (!onChange) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
onChange(
|
|
23
|
-
values
|
|
24
|
-
.filter(({ isRemoved }) => !isRemoved)
|
|
25
|
-
.map(formatValueForSubmition)
|
|
26
|
-
);
|
|
27
|
-
},
|
|
28
|
-
useDeepCompare([values])
|
|
29
|
-
);
|
|
30
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { omit } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import { AccessRight, AccessRightInitialValues } from './models';
|
|
4
|
-
|
|
5
|
-
export const formatValue = (
|
|
6
|
-
accessRight: AccessRight
|
|
7
|
-
): AccessRightInitialValues => {
|
|
8
|
-
return omit(['isAdded', 'isUpdated', 'isRemoved'], accessRight);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export const formatValueForSubmition = (
|
|
12
|
-
accessRight: AccessRight
|
|
13
|
-
): AccessRightInitialValues => {
|
|
14
|
-
return {
|
|
15
|
-
...formatValue(accessRight),
|
|
16
|
-
id: Number((accessRight.id as string).split('_')[1])
|
|
17
|
-
};
|
|
18
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from 'tss-react/mui';
|
|
2
|
-
|
|
3
|
-
export const useTabsStyles = makeStyles()((theme) => ({
|
|
4
|
-
indicator: {
|
|
5
|
-
bottom: 'unset'
|
|
6
|
-
},
|
|
7
|
-
tab: {
|
|
8
|
-
'&[aria-selected="true"]': {
|
|
9
|
-
color: theme.palette.text.primary,
|
|
10
|
-
fontWeight: theme.typography.fontWeightBold
|
|
11
|
-
},
|
|
12
|
-
color: theme.palette.text.primary,
|
|
13
|
-
fontWeight: theme.typography.fontWeightRegular,
|
|
14
|
-
marginRight: theme.spacing(2),
|
|
15
|
-
minHeight: 0,
|
|
16
|
-
minWidth: 0,
|
|
17
|
-
padding: theme.spacing(0.5, 0)
|
|
18
|
-
},
|
|
19
|
-
tabPanel: {
|
|
20
|
-
padding: theme.spacing(1, 0, 0)
|
|
21
|
-
},
|
|
22
|
-
tabs: {
|
|
23
|
-
minHeight: theme.spacing(4.5)
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { TabPanel as MuiTabPanel } from '@mui/lab';
|
|
2
|
-
|
|
3
|
-
import { useTabsStyles } from './Tab.styles';
|
|
4
|
-
|
|
5
|
-
type Props = {
|
|
6
|
-
children: JSX.Element;
|
|
7
|
-
value: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export const TabPanel = ({ children, value }: Props): JSX.Element => {
|
|
11
|
-
const { classes } = useTabsStyles();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<MuiTabPanel
|
|
15
|
-
className={classes.tabPanel}
|
|
16
|
-
data-tabPanel={value}
|
|
17
|
-
value={value}
|
|
18
|
-
>
|
|
19
|
-
{children}
|
|
20
|
-
</MuiTabPanel>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Typography } from '@mui/material';
|
|
2
|
-
|
|
3
|
-
import { TabPanel } from './TabPanel';
|
|
4
|
-
|
|
5
|
-
import { Tabs } from '.';
|
|
6
|
-
|
|
7
|
-
const initialize = (withTabListProps = false): void => {
|
|
8
|
-
cy.mount({
|
|
9
|
-
Component: (
|
|
10
|
-
<Tabs
|
|
11
|
-
defaultTab="tab 0"
|
|
12
|
-
tabList={
|
|
13
|
-
withTabListProps
|
|
14
|
-
? {
|
|
15
|
-
variant: 'fullWidth'
|
|
16
|
-
}
|
|
17
|
-
: undefined
|
|
18
|
-
}
|
|
19
|
-
tabs={[
|
|
20
|
-
{ label: 'Tab 0', value: 'tab 0' },
|
|
21
|
-
{ label: 'Tab 1', value: 'tab 1' }
|
|
22
|
-
]}
|
|
23
|
-
>
|
|
24
|
-
<TabPanel value="tab 0">
|
|
25
|
-
<Typography>Tab 0</Typography>
|
|
26
|
-
</TabPanel>
|
|
27
|
-
<TabPanel value="tab 1">
|
|
28
|
-
<Typography>Tab 1</Typography>
|
|
29
|
-
</TabPanel>
|
|
30
|
-
</Tabs>
|
|
31
|
-
)
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
describe('Tabs', () => {
|
|
36
|
-
it('displays tabs and their content when a tab is selected', () => {
|
|
37
|
-
initialize();
|
|
38
|
-
|
|
39
|
-
cy.get('[data-TabPanel="tab 0"]').should('not.have.attr', 'hidden');
|
|
40
|
-
cy.get('[data-TabPanel="tab 1"]').should('have.attr', 'hidden');
|
|
41
|
-
cy.findByLabelText('Tab 0')
|
|
42
|
-
.should('have.attr', 'aria-selected')
|
|
43
|
-
.and('equals', 'true');
|
|
44
|
-
cy.findByLabelText('Tab 1')
|
|
45
|
-
.should('have.attr', 'aria-selected')
|
|
46
|
-
.and('equals', 'false');
|
|
47
|
-
|
|
48
|
-
cy.contains('Tab 1').click();
|
|
49
|
-
|
|
50
|
-
cy.get('[data-TabPanel="tab 0"]').should('have.attr', 'hidden');
|
|
51
|
-
cy.get('[data-TabPanel="tab 1"]').should('not.have.attr', 'hidden');
|
|
52
|
-
cy.findByLabelText('Tab 0')
|
|
53
|
-
.should('have.attr', 'aria-selected')
|
|
54
|
-
.and('equals', 'false');
|
|
55
|
-
cy.findByLabelText('Tab 1')
|
|
56
|
-
.should('have.attr', 'aria-selected')
|
|
57
|
-
.and('equals', 'true');
|
|
58
|
-
|
|
59
|
-
cy.makeSnapshot();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('displays tabs when tabList props are set', () => {
|
|
63
|
-
initialize(true);
|
|
64
|
-
|
|
65
|
-
cy.get('[data-TabPanel="tab 0"]').should('not.have.attr', 'hidden');
|
|
66
|
-
cy.get('[data-TabPanel="tab 1"]').should('have.attr', 'hidden');
|
|
67
|
-
|
|
68
|
-
cy.makeSnapshot();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { Typography } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import { TabPanel } from './TabPanel';
|
|
6
|
-
|
|
7
|
-
import { Tabs } from '.';
|
|
8
|
-
|
|
9
|
-
const meta: Meta<typeof Tabs> = {
|
|
10
|
-
component: Tabs
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default meta;
|
|
14
|
-
type Story = StoryObj<typeof Tabs>;
|
|
15
|
-
|
|
16
|
-
const generateTabs = (size: number): Array<{ label: string; value: string }> =>
|
|
17
|
-
Array(size)
|
|
18
|
-
.fill(0)
|
|
19
|
-
.map((_, index) => ({ label: `Tab ${index}`, value: `tab ${index}` }));
|
|
20
|
-
|
|
21
|
-
export const Default: Story = {
|
|
22
|
-
args: {
|
|
23
|
-
defaultTab: 'tab 0',
|
|
24
|
-
tabs: generateTabs(2)
|
|
25
|
-
},
|
|
26
|
-
render: (args) => (
|
|
27
|
-
<Tabs {...args}>
|
|
28
|
-
{generateTabs(2).map(({ value, label }) => (
|
|
29
|
-
<TabPanel key={value} value={value}>
|
|
30
|
-
<Typography>{label}</Typography>
|
|
31
|
-
</TabPanel>
|
|
32
|
-
))}
|
|
33
|
-
</Tabs>
|
|
34
|
-
)
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const WithTabListProps: Story = {
|
|
38
|
-
args: {
|
|
39
|
-
defaultTab: 'tab 0',
|
|
40
|
-
tabList: {
|
|
41
|
-
textColor: 'inherit',
|
|
42
|
-
variant: 'fullWidth'
|
|
43
|
-
},
|
|
44
|
-
tabs: generateTabs(2)
|
|
45
|
-
},
|
|
46
|
-
render: (args) => (
|
|
47
|
-
<Tabs {...args}>
|
|
48
|
-
{generateTabs(2).map(({ value, label }) => (
|
|
49
|
-
<TabPanel key={value} value={value}>
|
|
50
|
-
<Typography>{label}</Typography>
|
|
51
|
-
</TabPanel>
|
|
52
|
-
))}
|
|
53
|
-
</Tabs>
|
|
54
|
-
)
|
|
55
|
-
};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { TabContext, TabList, TabListProps } from '@mui/lab';
|
|
4
|
-
import { Tab } from '@mui/material';
|
|
5
|
-
|
|
6
|
-
import { useTabsStyles } from './Tab.styles';
|
|
7
|
-
|
|
8
|
-
type Props = {
|
|
9
|
-
children: Array<JSX.Element>;
|
|
10
|
-
defaultTab: string;
|
|
11
|
-
tabList?: TabListProps;
|
|
12
|
-
tabs: Array<{
|
|
13
|
-
label: string;
|
|
14
|
-
value: string;
|
|
15
|
-
}>;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const Tabs = ({
|
|
19
|
-
children,
|
|
20
|
-
defaultTab,
|
|
21
|
-
tabs,
|
|
22
|
-
tabList
|
|
23
|
-
}: Props): JSX.Element => {
|
|
24
|
-
const { classes } = useTabsStyles();
|
|
25
|
-
|
|
26
|
-
const [selectedTab, setSelectedTab] = useState(defaultTab);
|
|
27
|
-
|
|
28
|
-
const changeTab = useCallback((_, newValue: string): void => {
|
|
29
|
-
setSelectedTab(newValue);
|
|
30
|
-
}, []);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<TabContext value={selectedTab}>
|
|
34
|
-
<TabList
|
|
35
|
-
classes={{
|
|
36
|
-
indicator: classes.indicator,
|
|
37
|
-
root: classes.tabs
|
|
38
|
-
}}
|
|
39
|
-
onChange={changeTab}
|
|
40
|
-
{...tabList}
|
|
41
|
-
>
|
|
42
|
-
{tabs.map(({ value, label }) => (
|
|
43
|
-
<Tab
|
|
44
|
-
aria-label={label}
|
|
45
|
-
className={classes.tab}
|
|
46
|
-
key={value}
|
|
47
|
-
label={label}
|
|
48
|
-
value={value}
|
|
49
|
-
/>
|
|
50
|
-
))}
|
|
51
|
-
</TabList>
|
|
52
|
-
{children}
|
|
53
|
-
</TabContext>
|
|
54
|
-
);
|
|
55
|
-
};
|