Skip to content

Commit 5cbda34

Browse files
committed
RI-5977 add loading to statistics, test connection view change
1 parent 36d75af commit 5cbda34

File tree

4 files changed

+47
-44
lines changed

4 files changed

+47
-44
lines changed

redisinsight/ui/src/pages/rdi/pipeline-management/components/test-connections-log/TestConnectionsLog.spec.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,20 @@ describe('TestConnectionsLog', () => {
1010
render(<TestConnectionsLog data={mockedData} />)
1111
})
1212

13-
it('should be all collapsed nav groups', () => {
13+
it('should be a collapsed nav group', () => {
1414
const mockedData: ITestConnection = {
1515
fail: [{ index: 0, status: TestConnectionStatus.Fail, endpoint: 'localhost:1233', error: 'some error' }],
16-
success: [{ index: 1, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' }]
16+
success: []
1717
}
1818
render(<TestConnectionsLog data={mockedData} />)
1919

20-
expect(screen.getByTestId('success-connections-closed')).toBeInTheDocument()
20+
expect(screen.queryByTestId('success-connections-closed')).not.toBeInTheDocument()
2121
expect(screen.getByTestId('failed-connections-closed')).toBeInTheDocument()
2222
})
2323

2424
it('should open and collapse other groups', () => {
2525
const mockedData: ITestConnection = {
26-
fail: [{ index: 0, status: TestConnectionStatus.Fail, endpoint: 'localhost:1233', error: 'some error' }],
26+
fail: [],
2727
success: [{ index: 1, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' }]
2828
}
2929
render(<TestConnectionsLog data={mockedData} />)
@@ -32,19 +32,11 @@ describe('TestConnectionsLog', () => {
3232
within(screen.getByTestId('success-connections-closed')).getByRole('button')
3333
)
3434
expect(screen.getByTestId('success-connections-open')).toBeInTheDocument()
35-
36-
expect(screen.getByTestId('failed-connections-closed')).toBeInTheDocument()
37-
38-
fireEvent.click(
39-
within(screen.getByTestId('failed-connections-closed')).getByRole('button')
40-
)
41-
expect(screen.getByTestId('failed-connections-open')).toBeInTheDocument()
42-
expect(screen.getByTestId('success-connections-closed')).toBeInTheDocument()
4335
})
4436

4537
it('should show proper items length', () => {
4638
const mockedData: ITestConnection = {
47-
fail: [{ index: 0, status: TestConnectionStatus.Fail, endpoint: 'localhost:1233', error: 'some error' }],
39+
fail: [],
4840
success: [
4941
{ index: 1, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' },
5042
{ index: 2, status: TestConnectionStatus.Success, endpoint: 'localhost:1233' }
@@ -55,8 +47,5 @@ describe('TestConnectionsLog', () => {
5547
expect(
5648
within(screen.getByTestId('success-connections-closed')).getByTestId('number-of-connections')
5749
).toHaveTextContent('2')
58-
expect(
59-
within(screen.getByTestId('failed-connections-closed')).getByTestId('number-of-connections')
60-
).toHaveTextContent('1')
6150
})
6251
})

redisinsight/ui/src/pages/rdi/pipeline-management/components/test-connections-log/TestConnectionsLog.tsx

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ export interface Props {
1919

2020
const TestConnectionsLog = (props: Props) => {
2121
const { data } = props
22-
22+
const statusData = data?.fail?.length ? data.fail : data?.success
23+
const status = data?.fail?.length ? ResultsStatus.Failed : ResultsStatus.Success
2324
const [openedNav, setOpenedNav] = useState<string>('')
2425

2526
const onToggle = (length: number = 0, isOpen: boolean, name: string) => {
@@ -34,33 +35,22 @@ const TestConnectionsLog = (props: Props) => {
3435
</div>
3536
)
3637

38+
const navTitle = status === ResultsStatus.Success ? 'Connected successfully' : 'Failed to connect'
39+
3740
const getNavGroupState = (name: ResultsStatus) => (openedNav === name ? 'open' : 'closed')
3841

3942
return (
40-
<>
41-
<EuiCollapsibleNavGroup
42-
title={<CollapsibleNavTitle title="Connected successfully" length={data?.success?.length ?? 0} />}
43-
className={cx(styles.collapsibleNav, ResultsStatus.Success, { [styles.disabled]: !data?.success?.length })}
44-
isCollapsible
45-
initialIsOpen={false}
46-
onToggle={(isOpen) => onToggle(data?.success?.length, isOpen, ResultsStatus.Success)}
47-
forceState={getNavGroupState(ResultsStatus.Success)}
48-
data-testid={`success-connections-${getNavGroupState(ResultsStatus.Success)}`}
49-
>
50-
<TestConnectionsTable data={data?.success ?? []} />
51-
</EuiCollapsibleNavGroup>
52-
<EuiCollapsibleNavGroup
53-
title={<CollapsibleNavTitle title="Failed to connect" length={data?.fail?.length ?? 0} />}
54-
className={cx(styles.collapsibleNav, ResultsStatus.Failed, { [styles.disabled]: !data?.fail?.length })}
55-
isCollapsible
56-
initialIsOpen={false}
57-
onToggle={(isOpen) => onToggle(data?.fail?.length, isOpen, ResultsStatus.Failed)}
58-
forceState={getNavGroupState(ResultsStatus.Failed)}
59-
data-testid={`failed-connections-${getNavGroupState(ResultsStatus.Failed)}`}
60-
>
61-
<TestConnectionsTable data={data?.fail ?? []} />
62-
</EuiCollapsibleNavGroup>
63-
</>
43+
<EuiCollapsibleNavGroup
44+
title={<CollapsibleNavTitle title={navTitle} length={statusData?.length ?? 0} />}
45+
className={cx(styles.collapsibleNav, status, { [styles.disabled]: !statusData?.length })}
46+
isCollapsible
47+
initialIsOpen={false}
48+
onToggle={(isOpen) => onToggle(statusData?.length, isOpen, status)}
49+
forceState={getNavGroupState(status)}
50+
data-testid={`${status}-connections-${getNavGroupState(status)}`}
51+
>
52+
<TestConnectionsTable data={statusData ?? []} />
53+
</EuiCollapsibleNavGroup>
6454
)
6555
}
6656

redisinsight/ui/src/pages/rdi/statistics/StatisticsPage.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { get } from 'lodash'
2-
import React, { useEffect } from 'react'
2+
import React, { useEffect, useState } from 'react'
33
import { useDispatch, useSelector } from 'react-redux'
44
import { useParams } from 'react-router-dom'
5-
import { EuiText } from '@elastic/eui'
5+
import { EuiLoadingSpinner, EuiText } from '@elastic/eui'
66

77
import { connectedInstanceSelector } from 'uiSrc/slices/rdi/instances'
88
import { getPipelineStatusAction, rdiPipelineStatusSelector } from 'uiSrc/slices/rdi/pipeline'
@@ -27,6 +27,7 @@ const isPipelineDeployed = (
2727
) => get(data, ['pipelines', 'default', 'status']) === PipelineStatus.Ready
2828

2929
const StatisticsPage = () => {
30+
const [pageLoading, setPageLoading] = useState(true)
3031
const { rdiInstanceId } = useParams<{ rdiInstanceId: string }>()
3132

3233
const dispatch = useDispatch()
@@ -65,9 +66,13 @@ const StatisticsPage = () => {
6566
})
6667
}
6768

69+
const hideSpinner = () => {
70+
setPageLoading(false)
71+
}
72+
6873
useEffect(() => {
6974
dispatch(getPipelineStatusAction(rdiInstanceId))
70-
dispatch(fetchRdiStatistics(rdiInstanceId))
75+
dispatch(fetchRdiStatistics(rdiInstanceId, undefined, hideSpinner, hideSpinner))
7176

7277
sendPageViewTelemetry({
7378
name: TelemetryPageView.RDI_STATUS,
@@ -97,6 +102,11 @@ const StatisticsPage = () => {
97102
<RdiInstancePageTemplate>
98103
<div className={styles.pageContainer}>
99104
<div className={styles.bodyContainer}>
105+
{pageLoading && (
106+
<div className={styles.cover}>
107+
<EuiLoadingSpinner size="xl" />
108+
</div>
109+
)}
100110
{!isPipelineDeployed(statusData) ? (
101111
// TODO add loader
102112
<Empty rdiInstanceId={rdiInstanceId} />

redisinsight/ui/src/pages/rdi/statistics/styles.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@
55
position: relative;
66
}
77

8+
.cover {
9+
position: absolute;
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
width: 100%;
14+
height: 100%;
15+
top: 0;
16+
left: 0;
17+
z-index: 2;
18+
opacity: 0.8;
19+
background-color: var(--euiColorLightestShade);
20+
}
21+
822
.bodyContainer {
923
:global {
1024
.euiPanel:first-child {

0 commit comments

Comments
 (0)