Skip to content

Commit 0f857a4

Browse files
committed
Merge request: translations fixed + Tests messages fixed + em to rem fixed
2 parents d52d5c3 + 29fd71f commit 0f857a4

File tree

4 files changed

+66
-16
lines changed

4 files changed

+66
-16
lines changed

ui/src/components/DashboardPlane.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import React from 'react';
22
import { useIntl } from 'react-intl';
33
import styled from 'styled-components';
4-
54
import {
65
useAlertLibrary,
76
useHighestSeverityAlerts,
87
highestAlertToStatus,
98
} from '../containers/AlertProvider';
10-
import { PageSubtitle } from '../components/style/CommonLayoutStyle';
9+
import { PageSubtitle } from './style/CommonLayoutStyle';
1110
import { PanelActions, NetworkContainer } from './DashboardNetwork';
1211
import HealthItem from './HealthItem.js';
1312
import { spacing } from '@scality/core-ui/dist/style/theme';
@@ -44,13 +43,15 @@ const DashboardPlane = () => {
4443
label={intl.formatMessage({ id: 'control_plane' })}
4544
status={planesStatus}
4645
alerts={planesHighestSecurityAlert}
46+
showArrow={false}
4747
/>
4848
</PlaneContainer>
4949
<PlaneContainer>
5050
<HealthItem
5151
label={intl.formatMessage({ id: 'workload_plane' })}
5252
status={planesStatus}
5353
alerts={planesHighestSecurityAlert}
54+
showArrow={false}
5455
/>
5556
</PlaneContainer>
5657
</PlanesContainer>

ui/src/components/DashboardPlane.test.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,34 @@ jest.mock('../containers/AlertProvider', () => ({
3939
},
4040
}));
4141

42+
jest.mock('../containers/ConfigProvider', () => ({
43+
__esModule: true,
44+
default: ({ children }) => <>{children}</>,
45+
useLinkOpener: () => ({
46+
openLink: jest.fn(),
47+
}),
48+
useDiscoveredViews: () => [
49+
{
50+
app: {
51+
kind: '',
52+
name: '',
53+
version: '',
54+
url: '',
55+
appHistoryBasePath: '',
56+
},
57+
isFederated: true,
58+
view: { path: '/alerts' },
59+
},
60+
],
61+
}));
62+
4263
const NB_ITEMS = 2;
4364

4465
describe("the dashboard network's plane panel", () => {
4566
test('displays 2 green statuses when no alerts are present', async () => {
4667
// Have to any type jest.fn function to avoid Flow warning for mockImplementation()
4768
(useHighestSeverityAlerts: any).mockImplementation(() => noAlerts);
48-
49-
// Render
5069
render(<DashboardPlane />);
51-
52-
// Verify
5370
expect(screen.getAllByLabelText(`status ${STATUS_HEALTH}`)).toHaveLength(
5471
NB_ITEMS,
5572
);
@@ -59,10 +76,7 @@ describe("the dashboard network's plane panel", () => {
5976
// Have to any type jest.fn function to avoid Flow warning for mockImplementation()
6077
(useHighestSeverityAlerts: any).mockImplementation(() => alertsWarning);
6178

62-
// Render
6379
render(<DashboardPlane />);
64-
65-
// Verify
6680
expect(screen.getAllByLabelText(`status ${STATUS_WARNING}`)).toHaveLength(
6781
NB_ITEMS,
6882
);
@@ -73,10 +87,7 @@ describe("the dashboard network's plane panel", () => {
7387
// Have to any type jest.fn function to avoid Flow warning for mockImplementation()
7488
(useHighestSeverityAlerts: any).mockImplementation(() => alertsCritical);
7589

76-
// Render
7790
render(<DashboardPlane />);
78-
79-
// Verify
8091
expect(screen.getAllByLabelText(`status ${STATUS_CRITICAL}`)).toHaveLength(
8192
NB_ITEMS,
8293
);

ui/src/components/DashboardServices.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ jest.mock('../containers/AlertProvider', () => ({
4646
},
4747
}));
4848

49+
jest.mock('../containers/ConfigProvider', () => ({
50+
__esModule: true,
51+
default: ({ children }) => <>{children}</>,
52+
useLinkOpener: () => ({
53+
openLink: jest.fn(),
54+
}),
55+
useDiscoveredViews: () => [
56+
{
57+
app: {
58+
kind: '',
59+
name: '',
60+
version: '',
61+
url: '',
62+
appHistoryBasePath: '',
63+
},
64+
isFederated: true,
65+
view: { path: '/alerts' },
66+
},
67+
],
68+
}));
69+
4970
describe('the dashboard inventory panel', () => {
5071
test('displays the services panel and display all 8 green statuses when no alerts are present', async () => {
5172
// Have to any type jest.fn function to avoid Flow warning for mockImplementation()

ui/src/components/HealthItem.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import styled from 'styled-components';
3-
import { Link } from 'react-router-dom';
43
import { useIntl } from 'react-intl';
54
import { Tooltip, StatusText } from '@scality/core-ui';
65
import {
@@ -14,6 +13,11 @@ import type { Status } from '../containers/AlertProvider';
1413
import CircleStatus from './CircleStatus';
1514
import { STATUS_HEALTH } from '../constants.js';
1615
import { formatDateToMid1 } from '../services/utils';
16+
import {
17+
useDiscoveredViews,
18+
useLinkOpener,
19+
} from '../containers/ConfigProvider';
20+
import { useHistory } from 'react-router';
1721

1822
const ServiceItemLabelWrapper = styled.div`
1923
display: flex;
@@ -87,12 +91,19 @@ const HealthItem = ({
8791
label,
8892
status,
8993
alerts,
94+
showArrow = true,
9095
}: {
9196
label: string,
9297
status: Status,
9398
alerts: Alert[],
9499
}) => {
95100
const intl = useIntl();
101+
const { openLink } = useLinkOpener();
102+
const history = useHistory();
103+
const discoveredViews = useDiscoveredViews();
104+
const alertView = discoveredViews.find(
105+
(view) => view.view.path === '/alerts',
106+
);
96107

97108
if (!alerts.length && status === STATUS_HEALTH)
98109
return (
@@ -132,15 +143,21 @@ const HealthItem = ({
132143
</NonHealthyPopUp>
133144
}
134145
>
135-
<Link to="/alerts" data-testid="alert-link">
146+
<div
147+
onClick={() => {
148+
history.push('/alerts');
149+
openLink(alertView);
150+
}}
151+
data-testid="alert-link"
152+
>
136153
<ClickableServiceItemElement aria-label={label}>
137154
<ServiceItemLabelWrapper>
138155
<CircleStatus status={status} />
139156
<ServiceItemLabel>{label}</ServiceItemLabel>
140157
</ServiceItemLabelWrapper>
141-
<ClickableIcon className="fas fa-angle-right" />
158+
{showArrow && <ClickableIcon className="fas fa-angle-right" />}
142159
</ClickableServiceItemElement>
143-
</Link>
160+
</div>
144161
</Tooltip>
145162
</NonHealthyServiceItemElement>
146163
);

0 commit comments

Comments
 (0)