@centreon/ui 24.4.1-MON-37085-fix-fullscreen.0 → 24.4.1-MON-34407-implement-the-status-chart-widget.12
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 +1 -1
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +6 -5
- package/src/Graph/BarStack/models.ts +1 -0
- package/src/Graph/PieChart/ResponsivePie.tsx +6 -4
- package/src/Graph/PieChart/models.ts +1 -0
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +2 -23
- package/src/utils/useFullscreen/useFullscreenListener.ts +2 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.1-MON-
|
|
3
|
+
"version": "24.4.1-MON-34407-implement-the-status-chart-widget.12",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -12,7 +12,7 @@ import { Tooltip } from '../../components';
|
|
|
12
12
|
import { LegendProps } from '../Legend/models';
|
|
13
13
|
import { Legend as LegendComponent } from '../Legend';
|
|
14
14
|
import { getValueByUnit } from '../common/utils';
|
|
15
|
-
import { labelNoDataFound } from '../translatedLabels';
|
|
15
|
+
import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
|
|
16
16
|
|
|
17
17
|
import { BarStackProps } from './models';
|
|
18
18
|
import { useBarStackStyles } from './BarStack.styles';
|
|
@@ -35,7 +35,8 @@ const BarStack = ({
|
|
|
35
35
|
unit = 'number',
|
|
36
36
|
displayValues,
|
|
37
37
|
variant = 'vertical',
|
|
38
|
-
legendDirection = 'column'
|
|
38
|
+
legendDirection = 'column',
|
|
39
|
+
labelNoDataFound = defaultlabelNoDataFound
|
|
39
40
|
}: BarStackProps & { height: number; width: number }): JSX.Element => {
|
|
40
41
|
const { t } = useTranslation();
|
|
41
42
|
const { classes } = useBarStackStyles();
|
|
@@ -90,7 +91,7 @@ const BarStack = ({
|
|
|
90
91
|
>
|
|
91
92
|
{title && (
|
|
92
93
|
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
93
|
-
{`${numeral(total).format('0a').toUpperCase()} `} {title}
|
|
94
|
+
{`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
|
|
94
95
|
</div>
|
|
95
96
|
)}
|
|
96
97
|
<div
|
|
@@ -144,8 +145,9 @@ const BarStack = ({
|
|
|
144
145
|
isVerticalBar ? 'right-start' : 'bottom-start'
|
|
145
146
|
}
|
|
146
147
|
>
|
|
147
|
-
<g data-testid={bar.key}>
|
|
148
|
+
<g data-testid={bar.key} onClick={onClick}>
|
|
148
149
|
<rect
|
|
150
|
+
cursor="pointer"
|
|
149
151
|
fill={bar.color}
|
|
150
152
|
height={
|
|
151
153
|
isVerticalBar ? bar.height - 1 : bar.height
|
|
@@ -155,7 +157,6 @@ const BarStack = ({
|
|
|
155
157
|
width={isVerticalBar ? bar.width : bar.width - 1}
|
|
156
158
|
x={bar.x}
|
|
157
159
|
y={bar.y}
|
|
158
|
-
onClick={onClick}
|
|
159
160
|
/>
|
|
160
161
|
{displayValues &&
|
|
161
162
|
bar.height > 10 &&
|
|
@@ -13,7 +13,7 @@ import { Tooltip } from '../../components';
|
|
|
13
13
|
import { Legend as LegendComponent } from '../Legend';
|
|
14
14
|
import { LegendProps } from '../Legend/models';
|
|
15
15
|
import { getValueByUnit } from '../common/utils';
|
|
16
|
-
import { labelNoDataFound } from '../translatedLabels';
|
|
16
|
+
import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
|
|
17
17
|
|
|
18
18
|
import { PieProps } from './models';
|
|
19
19
|
import { usePieStyles } from './PieChart.styles';
|
|
@@ -54,7 +54,8 @@ const ResponsivePie = ({
|
|
|
54
54
|
onArcClick,
|
|
55
55
|
displayValues,
|
|
56
56
|
TooltipContent,
|
|
57
|
-
legendDirection = 'column'
|
|
57
|
+
legendDirection = 'column',
|
|
58
|
+
labelNoDataFound = defaultlabelNoDataFound
|
|
58
59
|
}: PieProps & { height: number; width: number }): JSX.Element => {
|
|
59
60
|
const { t } = useTranslation();
|
|
60
61
|
const theme = useTheme();
|
|
@@ -109,7 +110,7 @@ const ResponsivePie = ({
|
|
|
109
110
|
>
|
|
110
111
|
{equals(variant, 'pie') && title && (
|
|
111
112
|
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
112
|
-
{`${numeral(total).format('0a').toUpperCase()} `} {title}
|
|
113
|
+
{`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
|
|
113
114
|
</div>
|
|
114
115
|
)}
|
|
115
116
|
<div
|
|
@@ -178,6 +179,7 @@ const ResponsivePie = ({
|
|
|
178
179
|
>
|
|
179
180
|
<g data-testid={arc.data.label} onClick={onClick}>
|
|
180
181
|
<path
|
|
182
|
+
cursor="pointer"
|
|
181
183
|
d={pie.path(arc) as string}
|
|
182
184
|
fill={arc.data.color}
|
|
183
185
|
/>
|
|
@@ -224,7 +226,7 @@ const ResponsivePie = ({
|
|
|
224
226
|
fill={theme.palette.text.primary}
|
|
225
227
|
textAnchor="middle"
|
|
226
228
|
>
|
|
227
|
-
{title}
|
|
229
|
+
{t(title)}
|
|
228
230
|
</Text>
|
|
229
231
|
</>
|
|
230
232
|
)}
|
|
@@ -22,8 +22,6 @@ const ChildComponent = (): JSX.Element => {
|
|
|
22
22
|
<Button onClick={() => toggleFullscreen(document.body)}>
|
|
23
23
|
{isFullscreenActivated ? labelExitFullscreen : labelEnterFullscreen}
|
|
24
24
|
</Button>
|
|
25
|
-
<input id="input" />
|
|
26
|
-
<textarea id="textarea" />
|
|
27
25
|
</div>
|
|
28
26
|
);
|
|
29
27
|
};
|
|
@@ -96,35 +94,16 @@ describe('Fullscreen', () => {
|
|
|
96
94
|
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
97
95
|
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
98
96
|
|
|
99
|
-
cy.get('#test').realPress(['F']);
|
|
97
|
+
cy.get('#test').realPress(['Alt', 'F']);
|
|
100
98
|
|
|
101
99
|
cy.get('#test')
|
|
102
100
|
.should('have.attr', 'data-fullscreenActivated', 'true')
|
|
103
101
|
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
104
102
|
|
|
105
|
-
cy.get('#test').realPress(['F']);
|
|
103
|
+
cy.get('#test').realPress(['Alt', 'F']);
|
|
106
104
|
|
|
107
105
|
cy.get('#test')
|
|
108
106
|
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
109
107
|
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
110
108
|
});
|
|
111
|
-
|
|
112
|
-
['input', 'textarea'].forEach((tag) => {
|
|
113
|
-
it(`cannot toggle fullscreen feature using the shortcut when ${tag === 'input' ? 'an' : 'a'} ${tag} is focused`, () => {
|
|
114
|
-
initialize();
|
|
115
|
-
|
|
116
|
-
cy.get('#test')
|
|
117
|
-
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
118
|
-
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
119
|
-
|
|
120
|
-
cy.get(`#${tag}`).focus();
|
|
121
|
-
|
|
122
|
-
cy.get('#test').realPress(['F']);
|
|
123
|
-
|
|
124
|
-
cy.get('#test')
|
|
125
|
-
.should('have.attr', 'data-fullscreenActivated', 'false')
|
|
126
|
-
.should('have.attr', 'data-fullscreenEnabled', 'true');
|
|
127
|
-
cy.get(`#${tag}`).should('have.value', 'F');
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
109
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
import { equals
|
|
3
|
+
import { equals } from 'ramda';
|
|
4
4
|
import { useSearchParams } from 'react-router-dom';
|
|
5
5
|
|
|
6
6
|
import { useDeepCompare } from '../useMemoComponent';
|
|
@@ -16,10 +16,7 @@ export const useFullscreenListener = (): boolean => {
|
|
|
16
16
|
useFullscreen();
|
|
17
17
|
|
|
18
18
|
const toggle = (event: KeyboardEvent): void => {
|
|
19
|
-
if (
|
|
20
|
-
includes(document.activeElement?.tagName, ['INPUT', 'TEXTAREA']) ||
|
|
21
|
-
!equals(event.code, 'KeyF')
|
|
22
|
-
) {
|
|
19
|
+
if (!event.altKey || !equals(event.code, 'KeyF')) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
22
|
|