@centreon/ui 24.4.72 → 24.4.74
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 +24 -23
- package/src/Checkbox/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/Dashboard/Item.tsx +2 -11
- package/src/Dashboard/Layout.tsx +2 -4
- package/src/Dashboard/utils.ts +1 -1
- package/src/Form/Inputs/Grid.tsx +8 -4
- package/src/Form/Inputs/models.ts +15 -14
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +87 -9
- package/src/Graph/BarStack/BarStack.stories.tsx +4 -2
- package/src/Graph/BarStack/BarStack.styles.ts +59 -30
- package/src/Graph/BarStack/Graph.tsx +176 -0
- package/src/Graph/BarStack/GraphAndLegend.tsx +119 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +62 -157
- package/src/Graph/BarStack/constants.ts +5 -0
- package/src/Graph/BarStack/models.ts +1 -1
- package/src/Graph/BarStack/useGraphAndLegend.ts +86 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +74 -99
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +19 -2
- package/src/Graph/HeatMap/model.ts +5 -1
- package/src/Graph/Legend/Legend.styles.ts +10 -0
- package/src/Graph/Legend/Legend.tsx +6 -1
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +3 -4
- package/src/Graph/LineChart/Icons/Downtime.tsx +3 -3
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/index.tsx +2 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +16 -5
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +4 -1
- package/src/Graph/LineChart/Legend/index.tsx +12 -5
- package/src/Graph/LineChart/LineChart.cypress.spec.tsx +53 -0
- package/src/Graph/LineChart/LineChart.tsx +10 -9
- package/src/Graph/LineChart/index.stories.tsx +13 -0
- package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +252 -0
- package/src/Graph/LineChart/useLineChartData.ts +68 -18
- package/src/Graph/PieChart/ResponsivePie.tsx +3 -1
- package/src/Graph/PieChart/models.ts +1 -0
- 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 +51 -2
- package/src/Icon/BaseIcon.tsx +32 -0
- package/src/Icon/DowntimeIcon.tsx +14 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +21 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +10 -7
- package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
- package/src/InputField/Text/index.tsx +7 -5
- package/src/Listing/ActionBar/index.tsx +1 -0
- package/src/PopoverMenu/index.tsx +4 -4
- package/src/RichTextEditor/ContentEditable.tsx +195 -195
- package/src/StoryBookThemeProvider/index.tsx +35 -36
- package/src/ThemeProvider/index.tsx +12 -12
- package/src/ThemeProvider/palettes.ts +11 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +2 -3
- package/src/TimePeriods/DateTimePickerInput.tsx +4 -1
- package/src/TopCounterElements/TopCounterLayout.tsx +4 -3
- package/src/TopCounterElements/useCloseOnLegacyPage.tsx +9 -6
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
- package/src/api/buildListingEndpoint/models.ts +1 -0
- package/src/api/useGraphQuery/index.ts +1 -7
- 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/models.ts +3 -0
- package/src/components/Form/AccessRights/storiesData.ts +3 -0
- package/src/components/List/Item/ListItem.styles.ts +2 -2
- 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/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/fonts/roboto-bold-webfont.woff +0 -0
- package/src/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/fonts/roboto-light-webfont.ttf +0 -0
- package/src/fonts/roboto-light-webfont.woff +0 -0
- package/src/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/fonts/roboto-medium-webfont.woff +0 -0
- package/src/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/fonts/roboto-regular-webfont.woff +0 -0
- package/src/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/index.ts +1 -0
- package/src/utils/index.ts +25 -25
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +3 -0
- package/src/utils/useInfiniteScrollListing.ts +6 -1
- package/src/utils/useLocale/index.ts +10 -0
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +40 -0
- package/src/utils/useLocaleDateTimeFormat/index.ts +5 -2
- package/src/utils/usePluralizedTranslation.ts +4 -21
- package/src/@assets/icons/downtime.icon.svg +0 -1
- 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
- /package/{public → src/Button}/fonts/roboto-bold-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff2 +0 -0
|
@@ -18,10 +18,10 @@ export const useStyles = makeStyles()((theme) => ({
|
|
|
18
18
|
display: 'flex',
|
|
19
19
|
flexGrow: 1,
|
|
20
20
|
gap: theme.spacing(2),
|
|
21
|
+
maxWidth: '520px',
|
|
21
22
|
overflow: 'hidden',
|
|
22
23
|
paddingBottom: theme.spacing(1),
|
|
23
|
-
paddingTop: theme.spacing(1)
|
|
24
|
-
width: '100%'
|
|
24
|
+
paddingTop: theme.spacing(1)
|
|
25
25
|
},
|
|
26
26
|
secondary: {
|
|
27
27
|
alignItems: 'center',
|
|
@@ -16,7 +16,6 @@ interface Props extends Omit<UseMinimapProps, 'minimapScale' | 'scale'> {
|
|
|
16
16
|
left: number;
|
|
17
17
|
top: number;
|
|
18
18
|
};
|
|
19
|
-
id?: number | string;
|
|
20
19
|
isDraggingFromContainer: boolean;
|
|
21
20
|
}
|
|
22
21
|
|
|
@@ -27,8 +26,7 @@ const Minimap = ({
|
|
|
27
26
|
width,
|
|
28
27
|
contentClientRect,
|
|
29
28
|
isDraggingFromContainer,
|
|
30
|
-
diffBetweenContentAndSvg
|
|
31
|
-
id
|
|
29
|
+
diffBetweenContentAndSvg
|
|
32
30
|
}: Props): JSX.Element => {
|
|
33
31
|
const { classes } = useZoomStyles();
|
|
34
32
|
|
|
@@ -84,7 +82,7 @@ const Minimap = ({
|
|
|
84
82
|
);
|
|
85
83
|
|
|
86
84
|
return (
|
|
87
|
-
<g className={classes.minimap} clipPath=
|
|
85
|
+
<g className={classes.minimap} clipPath="url(#zoom-clip)">
|
|
88
86
|
<rect
|
|
89
87
|
className={classes.minimapBackground}
|
|
90
88
|
height={finalHeight}
|
|
@@ -63,7 +63,7 @@ describe('Zoom', () => {
|
|
|
63
63
|
it('displays the minimap when the prop is set', () => {
|
|
64
64
|
initialize({ showMinimap: true });
|
|
65
65
|
|
|
66
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
66
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
67
67
|
|
|
68
68
|
cy.makeSnapshot();
|
|
69
69
|
});
|
|
@@ -72,7 +72,7 @@ describe('Zoom', () => {
|
|
|
72
72
|
initialize({ showMinimap: true });
|
|
73
73
|
|
|
74
74
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
75
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
75
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
76
76
|
|
|
77
77
|
cy.findByTestId('zoom in').click();
|
|
78
78
|
cy.findByTestId('zoom-content')
|
|
@@ -86,7 +86,7 @@ describe('Zoom', () => {
|
|
|
86
86
|
initialize({ showMinimap: true });
|
|
87
87
|
|
|
88
88
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
89
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
89
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
90
90
|
|
|
91
91
|
cy.findByTestId('zoom out').click();
|
|
92
92
|
|
|
@@ -101,7 +101,7 @@ describe('Zoom', () => {
|
|
|
101
101
|
initialize({ showMinimap: true });
|
|
102
102
|
|
|
103
103
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
104
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
104
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
105
105
|
|
|
106
106
|
cy.findByTestId('zoom-content').realMouseWheel({ deltaY: 20 });
|
|
107
107
|
|
|
@@ -116,7 +116,7 @@ describe('Zoom', () => {
|
|
|
116
116
|
initialize({ showMinimap: true });
|
|
117
117
|
|
|
118
118
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
119
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
119
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
120
120
|
|
|
121
121
|
cy.findByTestId('zoom-content').realMouseWheel({ deltaY: -20 });
|
|
122
122
|
|
|
@@ -131,7 +131,7 @@ describe('Zoom', () => {
|
|
|
131
131
|
initialize({ showMinimap: true });
|
|
132
132
|
|
|
133
133
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
134
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
134
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
135
135
|
|
|
136
136
|
cy.findByTestId('zoom-content').realMouseWheel({ deltaY: -20 });
|
|
137
137
|
|
|
@@ -150,7 +150,7 @@ describe('Zoom', () => {
|
|
|
150
150
|
initialize({ showMinimap: false });
|
|
151
151
|
|
|
152
152
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
153
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
153
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('not.exist');
|
|
154
154
|
|
|
155
155
|
cy.makeSnapshot();
|
|
156
156
|
});
|
|
@@ -158,7 +158,7 @@ describe('Zoom', () => {
|
|
|
158
158
|
it('zooms in when the minimap is scrolled up', () => {
|
|
159
159
|
initialize({ showMinimap: true });
|
|
160
160
|
|
|
161
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
161
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
162
162
|
|
|
163
163
|
cy.findByTestId('minimap-interaction').realMouseWheel({ deltaY: -20 });
|
|
164
164
|
|
|
@@ -172,7 +172,7 @@ describe('Zoom', () => {
|
|
|
172
172
|
it('zooms out when the minimap is scrolled down', () => {
|
|
173
173
|
initialize({ showMinimap: true });
|
|
174
174
|
|
|
175
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
175
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
176
176
|
|
|
177
177
|
cy.findByTestId('minimap-interaction').realMouseWheel({ deltaY: 20 });
|
|
178
178
|
|
|
@@ -186,7 +186,7 @@ describe('Zoom', () => {
|
|
|
186
186
|
it('moves the view when the mouse is hover the content with the corresponding button pressed down', () => {
|
|
187
187
|
initialize({ showMinimap: true });
|
|
188
188
|
|
|
189
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
189
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
190
190
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
191
191
|
|
|
192
192
|
cy.findByTestId('zoom-container')
|
|
@@ -205,7 +205,7 @@ describe('Zoom', () => {
|
|
|
205
205
|
it('displays the minimap in the bottom right when the prop to the corresponding value', () => {
|
|
206
206
|
initialize({ minimapPosition: 'bottom-right', showMinimap: true });
|
|
207
207
|
|
|
208
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
208
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
209
209
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
210
210
|
|
|
211
211
|
cy.makeSnapshot();
|
|
@@ -214,7 +214,7 @@ describe('Zoom', () => {
|
|
|
214
214
|
it('applies a scale down on the minimap when the content is higher than the original height', () => {
|
|
215
215
|
initialize({ showMinimap: true, template: ContentWithMultipleShapes });
|
|
216
216
|
|
|
217
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
217
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
218
218
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
219
219
|
|
|
220
220
|
cy.findByTestId('minimap-interaction')
|
|
@@ -232,7 +232,7 @@ describe('Zoom', () => {
|
|
|
232
232
|
template: ContentWithMultipleShapesWithNegativeTranslations
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
cy.get('g[clip-path="url(#zoom-clip
|
|
235
|
+
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
236
236
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
237
237
|
|
|
238
238
|
cy.findByTestId('minimap-interaction')
|
|
@@ -7,7 +7,6 @@ import { MinimapPosition } from './models';
|
|
|
7
7
|
|
|
8
8
|
export interface ZoomProps {
|
|
9
9
|
children: JSX.Element | (({ width, height }) => JSX.Element);
|
|
10
|
-
id?: number | string;
|
|
11
10
|
minimapPosition?: MinimapPosition;
|
|
12
11
|
scaleMax?: number;
|
|
13
12
|
scaleMin?: number;
|
|
@@ -28,8 +27,7 @@ const Zoom = ({
|
|
|
28
27
|
scaleMin = 0.5,
|
|
29
28
|
scaleMax = 4,
|
|
30
29
|
showMinimap = false,
|
|
31
|
-
minimapPosition = 'top-left'
|
|
32
|
-
id = 0
|
|
30
|
+
minimapPosition = 'top-left'
|
|
33
31
|
}: ZoomProps): JSX.Element => {
|
|
34
32
|
return (
|
|
35
33
|
<ParentSize>
|
|
@@ -46,7 +44,6 @@ const Zoom = ({
|
|
|
46
44
|
{(zoom) => (
|
|
47
45
|
<ZoomContent
|
|
48
46
|
height={height}
|
|
49
|
-
id={id}
|
|
50
47
|
minimapPosition={minimapPosition}
|
|
51
48
|
showMinimap={showMinimap}
|
|
52
49
|
width={width}
|
|
@@ -18,7 +18,6 @@ import { ChildrenProps, MinimapPosition, ZoomState } from './models';
|
|
|
18
18
|
export interface Props {
|
|
19
19
|
children: ({ width, height, transformMatrix }: ChildrenProps) => JSX.Element;
|
|
20
20
|
height: number;
|
|
21
|
-
id?: number | string;
|
|
22
21
|
minimapPosition: MinimapPosition;
|
|
23
22
|
showMinimap?: boolean;
|
|
24
23
|
width: number;
|
|
@@ -31,8 +30,7 @@ const ZoomContent = ({
|
|
|
31
30
|
height,
|
|
32
31
|
children,
|
|
33
32
|
showMinimap,
|
|
34
|
-
minimapPosition
|
|
35
|
-
id
|
|
33
|
+
minimapPosition
|
|
36
34
|
}: Props): JSX.Element => {
|
|
37
35
|
const { classes } = useZoomStyles();
|
|
38
36
|
const contentRef = useRef<SVGGElement | null>(null);
|
|
@@ -94,7 +92,7 @@ const ZoomContent = ({
|
|
|
94
92
|
>
|
|
95
93
|
<RectClipPath
|
|
96
94
|
height={Math.max(contentClientRect?.height || 0, height)}
|
|
97
|
-
id=
|
|
95
|
+
id="zoom-clip"
|
|
98
96
|
rx={radius}
|
|
99
97
|
width={Math.max(contentClientRect?.width || 0, width)}
|
|
100
98
|
/>
|
|
@@ -126,7 +124,6 @@ const ZoomContent = ({
|
|
|
126
124
|
diffBetweenContentAndSvg || { left: 0, top: 0 }
|
|
127
125
|
}
|
|
128
126
|
height={height}
|
|
129
|
-
id={id}
|
|
130
127
|
isDraggingFromContainer={isDragging}
|
|
131
128
|
width={width}
|
|
132
129
|
zoom={zoom}
|
package/src/components/index.ts
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/index.ts
CHANGED
|
@@ -168,3 +168,4 @@ export * from './ParentSize';
|
|
|
168
168
|
export { default as Subtitle } from './Typography/Subtitle';
|
|
169
169
|
export { default as TablePagination } from './Listing/ActionBar/Pagination';
|
|
170
170
|
export { default as PaginationActions } from './Listing/ActionBar/PaginationActions';
|
|
171
|
+
export { DowntimeIcon } from './Icon/DowntimeIcon';
|
package/src/utils/index.ts
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export * from './useLocaleDateTimeFormat';
|
|
2
|
-
export * from './getNormalizedId';
|
|
3
|
-
export * from './statuses';
|
|
4
|
-
export * from './typedMemo';
|
|
5
|
-
export * from './useCopyToClipboard';
|
|
6
|
-
export * from './useDebounce';
|
|
7
|
-
export * from './useDeepCallback';
|
|
8
|
-
export * from './useDeepMemo';
|
|
9
|
-
export * from './useIntersectionObserver';
|
|
10
|
-
export * from './useKeyObserver';
|
|
11
|
-
export * from './useLoadImage';
|
|
12
|
-
export * from './useMemoComponent';
|
|
13
|
-
export * from './useThemeMode';
|
|
14
|
-
export * from './useViewportIntersection';
|
|
15
|
-
export * from './panelSize';
|
|
16
|
-
export * from './sanitizedHTML';
|
|
17
|
-
export * from './docsURL';
|
|
18
|
-
export * from './useInfiniteScrollListing';
|
|
19
|
-
export * from './useLicenseExpirationWarning';
|
|
20
|
-
export * from './useRefreshInterval';
|
|
21
|
-
export * from './centreonBaseURL';
|
|
22
|
-
export * from './usePluralizedTranslation';
|
|
23
|
-
export * from './useResizeObserver';
|
|
24
|
-
export * from './useFullscreen';
|
|
25
|
-
export * from './
|
|
1
|
+
export * from './useLocaleDateTimeFormat';
|
|
2
|
+
export * from './getNormalizedId';
|
|
3
|
+
export * from './statuses';
|
|
4
|
+
export * from './typedMemo';
|
|
5
|
+
export * from './useCopyToClipboard';
|
|
6
|
+
export * from './useDebounce';
|
|
7
|
+
export * from './useDeepCallback';
|
|
8
|
+
export * from './useDeepMemo';
|
|
9
|
+
export * from './useIntersectionObserver';
|
|
10
|
+
export * from './useKeyObserver';
|
|
11
|
+
export * from './useLoadImage';
|
|
12
|
+
export * from './useMemoComponent';
|
|
13
|
+
export * from './useThemeMode';
|
|
14
|
+
export * from './useViewportIntersection';
|
|
15
|
+
export * from './panelSize';
|
|
16
|
+
export * from './sanitizedHTML';
|
|
17
|
+
export * from './docsURL';
|
|
18
|
+
export * from './useInfiniteScrollListing';
|
|
19
|
+
export * from './useLicenseExpirationWarning';
|
|
20
|
+
export * from './useRefreshInterval';
|
|
21
|
+
export * from './centreonBaseURL';
|
|
22
|
+
export * from './usePluralizedTranslation';
|
|
23
|
+
export * from './useResizeObserver';
|
|
24
|
+
export * from './useFullscreen';
|
|
25
|
+
export * from './useLocale';
|
|
@@ -72,6 +72,9 @@ describe('Fullscreen', () => {
|
|
|
72
72
|
it('exits fullscreen mode when the button is clicked', () => {
|
|
73
73
|
initialize();
|
|
74
74
|
|
|
75
|
+
cy.contains(labelEnterFullscreen).click();
|
|
76
|
+
cy.contains(labelExitFullscreen).click();
|
|
77
|
+
|
|
75
78
|
cy.get('#test')
|
|
76
79
|
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
77
80
|
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
@@ -60,7 +60,12 @@ export const useInfiniteScrollListing = <T>({
|
|
|
60
60
|
customQueryParameters,
|
|
61
61
|
parameters: { limit, page: params?.page || page, ...parameters }
|
|
62
62
|
}),
|
|
63
|
-
getQueryKey: () => [
|
|
63
|
+
getQueryKey: () => [
|
|
64
|
+
queryKeyName,
|
|
65
|
+
page,
|
|
66
|
+
JSON.stringify(parameters),
|
|
67
|
+
JSON.stringify(customQueryParameters)
|
|
68
|
+
],
|
|
64
69
|
isPaginated: true,
|
|
65
70
|
queryOptions: {
|
|
66
71
|
enabled,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useAtomValue } from 'jotai';
|
|
2
|
+
|
|
3
|
+
import { browserLocaleAtom, userAtom } from '@centreon/ui-context';
|
|
4
|
+
|
|
5
|
+
export const useLocale = (): string => {
|
|
6
|
+
const user = useAtomValue(userAtom);
|
|
7
|
+
const browserLocale = useAtomValue(browserLocaleAtom);
|
|
8
|
+
|
|
9
|
+
return user.locale || browserLocale;
|
|
10
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Provider, createStore } from 'jotai';
|
|
2
|
+
|
|
3
|
+
import { browserLocaleAtom, userAtom } from '@centreon/ui-context';
|
|
4
|
+
|
|
5
|
+
import { useLocale } from '.';
|
|
6
|
+
|
|
7
|
+
const TestComponent = (): JSX.Element => {
|
|
8
|
+
const locale = useLocale();
|
|
9
|
+
|
|
10
|
+
return <p>{locale}</p>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const initialize = ({ userLocale, browserLocale }): void => {
|
|
14
|
+
const store = createStore();
|
|
15
|
+
|
|
16
|
+
store.set(userAtom, { locale: userLocale });
|
|
17
|
+
store.set(browserLocaleAtom, browserLocale);
|
|
18
|
+
|
|
19
|
+
cy.mount({
|
|
20
|
+
Component: (
|
|
21
|
+
<Provider store={store}>
|
|
22
|
+
<TestComponent />
|
|
23
|
+
</Provider>
|
|
24
|
+
)
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe('useLocale', () => {
|
|
29
|
+
it('displays the user locale when the corresponding atom is set', () => {
|
|
30
|
+
initialize({ browserLocale: 'en', userLocale: 'fi' });
|
|
31
|
+
|
|
32
|
+
cy.contains('fi').should('be.visible');
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('displays the browser locale when the user locale is not set', () => {
|
|
36
|
+
initialize({ browserLocale: 'de', userLocale: null });
|
|
37
|
+
|
|
38
|
+
cy.contains('de').should('be.visible');
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -5,6 +5,8 @@ import localizedFormat from 'dayjs/plugin/localizedFormat';
|
|
|
5
5
|
|
|
6
6
|
import { userAtom } from '@centreon/ui-context';
|
|
7
7
|
|
|
8
|
+
import { useLocale } from '../useLocale';
|
|
9
|
+
|
|
8
10
|
import shortLocales from './sortLocales';
|
|
9
11
|
|
|
10
12
|
interface FormatParameters {
|
|
@@ -28,10 +30,11 @@ const timeFormat = 'LT';
|
|
|
28
30
|
const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
29
31
|
|
|
30
32
|
const useLocaleDateTimeFormat = (): LocaleDateTimeFormat => {
|
|
31
|
-
const
|
|
33
|
+
const locale = useLocale();
|
|
34
|
+
const { timezone } = useAtomValue(userAtom);
|
|
32
35
|
|
|
33
36
|
const format = ({ date, formatString }: FormatParameters): string => {
|
|
34
|
-
const normalizedLocale = locale
|
|
37
|
+
const normalizedLocale = locale?.substring(0, 2);
|
|
35
38
|
|
|
36
39
|
const timezoneDate = dayjs(
|
|
37
40
|
new Date(date).toLocaleString('en', { timeZone: timezone })
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useTranslation } from 'react-i18next';
|
|
4
1
|
import pluralize from 'pluralize';
|
|
5
|
-
import {
|
|
6
|
-
import { equals, includes } from 'ramda';
|
|
7
|
-
|
|
8
|
-
import { userAtom } from '@centreon/ui-context';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
9
3
|
|
|
10
4
|
interface TProps {
|
|
11
5
|
count: number;
|
|
@@ -16,21 +10,10 @@ export const usePluralizedTranslation = (): {
|
|
|
16
10
|
pluralizedT: (props: TProps) => string;
|
|
17
11
|
} => {
|
|
18
12
|
const translation = useTranslation();
|
|
19
|
-
const { locale } = useAtomValue(userAtom);
|
|
20
13
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
({ label, count }: TProps): string => {
|
|
25
|
-
const isZero = equals(count, 0);
|
|
26
|
-
|
|
27
|
-
return pluralize(
|
|
28
|
-
translation.t(label),
|
|
29
|
-
isZero && isNotPartitiveLocale ? 1 : count
|
|
30
|
-
);
|
|
31
|
-
},
|
|
32
|
-
[isNotPartitiveLocale]
|
|
33
|
-
);
|
|
14
|
+
const pluralizedT = ({ label, count }: TProps): string => {
|
|
15
|
+
return pluralize(translation.t(label), count);
|
|
16
|
+
};
|
|
34
17
|
|
|
35
18
|
return {
|
|
36
19
|
pluralizedT
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><defs><style>.a{fill:none;}.b{opacity:1;}</style></defs><g transform="translate(-94.852 -137.365)"><rect class="a" width="24" height="24" transform="translate(94.852 137.365)"/><g class="b" transform="translate(97.108 140.129)"><path d="M103.476,143.64a1.692,1.692,0,1,0-1.692-1.692A1.692,1.692,0,0,0,103.476,143.64Z" transform="translate(-97.132 -140.255)"/><path d="M114.266,150.2a1.05,1.05,0,0,0-.968-.647s-2.067-.275-2.68.125a2.464,2.464,0,0,0-.644.8l-3.454-.547c-.265-.874-1.4-4.183-1.4-4.183l-.846-1.353a1.743,1.743,0,0,0-1.438-.846,4.571,4.571,0,0,0-.677.084l-4.4,1.867v3.976H98l2.222.352-1.61,8.107h1.777l1.522-6.768,1.777,1.692v5.076h1.692v-6.345l-1.19-1.135,5.428.859-3.084,6.815,10.976-.11Zm-10.206-2.611s.577,1.356.88,2.089l-1.259-.2Zm-4.606,1.22v-2.212l1.522-.592-.586,2.952Z" transform="translate(-97.762 -139.74)"/></g></g></svg>
|
|
@@ -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
|
-
});
|