Skip to content

Commit c6b88c5

Browse files
authored
RI-7839: standardize loader behavior in pipeline and analytics pages (#5319)
remove multiple loaders on pipeline page, unified the looks of the loader on pipeline and statistics page References: #RI-7839
1 parent bfcf059 commit c6b88c5

File tree

9 files changed

+90
-92
lines changed

9 files changed

+90
-92
lines changed

redisinsight/ui/src/pages/rdi/instance/components/header/components/buttons/deploy-pipeline-button/DeployPipelineButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { Modal } from 'uiSrc/components/base/display/modal'
2323
import { UploadWarningBanner } from 'uiSrc/components/upload-warning/styles'
2424

2525
export interface Props {
26-
loading: boolean
26+
loading?: boolean
2727
disabled: boolean
2828
onReset: () => void
2929
}

redisinsight/ui/src/pages/rdi/instance/components/header/components/pipeline-actions/PipelineActions.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useCallback, useEffect } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import { useParams } from 'react-router-dom'
44

5+
import styled from 'styled-components'
56
import {
67
getPipelineStatusAction,
78
rdiPipelineActionSelector,
@@ -23,13 +24,12 @@ import {
2324
} from 'uiSrc/slices/interfaces'
2425

2526
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
27+
import { Theme } from 'uiSrc/components/base/theme/types'
2628
import DeployPipelineButton from '../buttons/deploy-pipeline-button'
2729
import ResetPipelineButton from '../buttons/reset-pipeline-button'
2830
import RdiConfigFileActionMenu from '../rdi-config-file-action-menu'
2931
import StopPipelineButton from '../buttons/stop-pipeline-button'
3032
import StartPipelineButton from '../buttons/start-pipeline-button/StartPipelineButton'
31-
import styled from 'styled-components'
32-
import { Theme } from 'uiSrc/components/base/theme/types'
3333

3434
const VerticalDelimiter = styled(FlexItem)`
3535
border: ${({ theme }: { theme: Theme }) => theme.components.appBar.separator};
@@ -183,11 +183,7 @@ const PipelineActions = ({ collectorStatus, pipelineStatus }: Props) => {
183183
) : null}
184184
</FlexItem>
185185
<FlexItem>
186-
<DeployPipelineButton
187-
loading={deployLoading}
188-
disabled={disabled}
189-
onReset={resetPipeline}
190-
/>
186+
<DeployPipelineButton disabled={disabled} onReset={resetPipeline} />
191187
</FlexItem>
192188
<FlexItem>
193189
<RdiConfigFileActionMenu />

redisinsight/ui/src/pages/rdi/pipeline-management/components/navigation/Navigation.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { useHistory, useLocation, useParams } from 'react-router-dom'
55
import { Nullable } from 'uiSrc/utils'
66
import { PageNames, Pages } from 'uiSrc/constants'
77
import { Title } from 'uiSrc/components/base/text'
8-
import { Loader } from 'uiSrc/components/base/display'
98
import { Col } from 'uiSrc/components/base/layout/flex'
9+
import { LoadingContent } from 'uiSrc/components/base'
1010
import { RdiPipelineTabs } from 'uiSrc/slices/interfaces/rdi'
1111
import { rdiPipelineSelector } from 'uiSrc/slices/rdi/pipeline'
1212

@@ -55,7 +55,7 @@ const Navigation = () => {
5555
Pipeline management
5656
</Title>
5757

58-
{loading && <Loader size="xl" />}
58+
{loading && <LoadingContent lines={4} />}
5959

6060
{!loading && (
6161
<>

redisinsight/ui/src/pages/rdi/pipeline-management/pages/config/Config.spec.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ describe('Config', () => {
239239
expect(screen.getByTestId('rdi-config-loading')).toBeInTheDocument()
240240
})
241241

242-
it('should render loader on btn', () => {
242+
it('should not render loader on btn for pipeline loading', () => {
243243
const rdiPipelineSelectorMock = jest.fn().mockReturnValue({
244244
loading: true,
245245
})
@@ -251,10 +251,11 @@ describe('Config', () => {
251251

252252
// check is btn has loader
253253
const child = getByTestId('rdi-test-connection-btn')
254-
expect(child.querySelector('svg')).toBeTruthy()
254+
const icon = child.querySelector('svg')
255+
expect(icon).not.toBeInTheDocument()
255256
})
256257

257-
it('should render loader on btn', () => {
258+
it('should render loader on btn when testing connection', () => {
258259
const rdiTestConnectionsSelectorMock = jest.fn().mockReturnValue({
259260
loading: true,
260261
})

redisinsight/ui/src/pages/rdi/pipeline-management/pages/config/Config.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ const Config = () => {
202202
<Row grow={false} justify="end">
203203
<PrimaryButton
204204
onClick={testConnections}
205-
loading={testingConnections || pipelineLoading}
205+
loading={testingConnections}
206+
disabled={pipelineLoading}
206207
aria-labelledby="test target connections"
207208
data-testid="rdi-test-connection-btn"
208209
>

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ jest.mock('uiSrc/slices/rdi/statistics', () => ({
108108
loading: false,
109109
results: {
110110
status: 'success',
111-
data: CONNECTIONS_DATA
111+
data: CONNECTIONS_DATA,
112112
},
113113
}),
114114
}))
@@ -151,7 +151,7 @@ describe('StatisticsPage', () => {
151151
loading: false,
152152
results: {
153153
status: null,
154-
data: CONNECTIONS_DATA
154+
data: CONNECTIONS_DATA,
155155
},
156156
})
157157
render(<StatisticsPage />)
@@ -170,12 +170,14 @@ describe('StatisticsPage', () => {
170170
expect(screen.getByTestId('empty-pipeline')).toBeInTheDocument()
171171
})
172172

173-
it('renders statistics sections when status is success and data exists', () => {
173+
it('renders statistics sections when status is success and data exists', async () => {
174174
render(<StatisticsPage />)
175175

176176
// Check that statistics sections are rendered instead of empty state
177177
expect(screen.queryByTestId('empty-pipeline')).not.toBeInTheDocument()
178-
expect(screen.getByTestId('processing-performance-info-refresh-btn')).toBeInTheDocument()
178+
expect(
179+
await screen.findByTestId('processing-performance-info-refresh-btn'),
180+
).toBeInTheDocument()
179181
})
180182

181183
it('should call proper telemetry on page view', () => {
@@ -189,11 +191,11 @@ describe('StatisticsPage', () => {
189191
})
190192
})
191193

192-
it('should call proper telemetry event when refresh is clicked for processing performance section', () => {
194+
it('should call proper telemetry event when refresh is clicked for processing performance section', async () => {
193195
render(<StatisticsPage />)
194196

195197
fireEvent.click(
196-
screen.getByTestId('processing-performance-info-refresh-btn'),
198+
await screen.findByTestId('processing-performance-info-refresh-btn'),
197199
)
198200

199201
expect(sendEventTelemetry).toBeCalledWith({
@@ -238,7 +240,9 @@ describe('StatisticsPage', () => {
238240

239241
const testid = 'processing-performance-info'
240242

241-
await userEvent.click(screen.getByTestId(`${testid}-auto-refresh-config-btn`))
243+
await userEvent.click(
244+
await screen.findByTestId(`${testid}-auto-refresh-config-btn`),
245+
)
242246
await waitForRiPopoverVisible()
243247
await userEvent.click(screen.getByTestId(`${testid}-auto-refresh-switch`)) // disabled
244248

@@ -258,7 +262,9 @@ describe('StatisticsPage', () => {
258262

259263
const testid = 'processing-performance-info'
260264

261-
await userEvent.click(screen.getByTestId(`${testid}-auto-refresh-config-btn`))
265+
await userEvent.click(
266+
await screen.findByTestId(`${testid}-auto-refresh-config-btn`),
267+
)
262268
await waitForRiPopoverVisible()
263269
await userEvent.click(screen.getByTestId(`${testid}-auto-refresh-switch`)) // disabled
264270
await userEvent.click(screen.getByTestId(`${testid}-auto-refresh-switch`)) // enabled
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import styled from 'styled-components'
2+
import { Col } from 'uiSrc/components/base/layout/flex'
3+
4+
export const Container = styled(Col)`
5+
overflow: auto;
6+
position: relative;
7+
`
8+
export const ContentWrapper = styled(Col)`
9+
padding: ${({ theme }) => theme.core.space.space200};
10+
`
11+
12+
export const LoadingState = styled(Col)`
13+
z-index: 2;
14+
`

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

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ import { formatLongName, Nullable, setTitle } from 'uiSrc/utils'
1919
import { setLastPageContext } from 'uiSrc/slices/app/context'
2020
import { PageNames } from 'uiSrc/constants'
2121
import { Loader } from 'uiSrc/components/base/display'
22-
import { IRdiStatistics, RdiPipelineStatus } from 'uiSrc/slices/interfaces'
22+
import { type IRdiStatistics, RdiPipelineStatus } from 'uiSrc/slices/interfaces'
2323

24+
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
25+
import { AutoRefresh } from 'uiSrc/components'
2426
import Clients from './clients'
2527
import DataStreams from './data-streams'
2628
import Empty from './empty'
2729
import ProcessingPerformance from './processing-performance'
2830
import Status from './status'
2931
import TargetConnections from './target-connections'
30-
31-
import styles from './styles.module.scss'
32-
import { Col, FlexItem, Row } from 'uiSrc/components/base/layout/flex'
33-
import { AutoRefresh } from 'uiSrc/components'
32+
import * as S from './StatisticsPage.styles'
3433

3534
const shouldShowStatistics = (data: Nullable<IRdiStatistics>) =>
3635
data?.status === RdiPipelineStatus.Success && !!data?.data
@@ -123,60 +122,61 @@ const StatisticsPage = () => {
123122

124123
const { data: statisticsData } = statisticsResults
125124

126-
127125
return (
128-
<div className={styles.pageContainer}>
129-
<Col gap="xxl" style={{ padding: 16 }}>
126+
<S.Container>
127+
<S.ContentWrapper gap="xxl">
130128
{pageLoading && (
131-
<div className={styles.cover}>
129+
<S.LoadingState centered>
132130
<Loader size="xl" />
133-
</div>
131+
</S.LoadingState>
134132
)}
135133
{!shouldShowStatistics(statisticsResults) ? (
136134
// TODO add loader
137135
<Empty rdiInstanceId={rdiInstanceId} />
138136
) : (
139-
<>
140-
<Row justify="end">
141-
<FlexItem>
142-
<AutoRefresh
143-
postfix="processing-performance-info"
144-
displayText
145-
loading={isStatisticsLoading}
146-
lastRefreshTime={lastRefreshTime}
147-
enableAutoRefreshDefault
148-
testid="processing-performance-info"
149-
onRefresh={() => {
150-
setLastRefreshTime(Date.now())
151-
onRefresh('processing_performance')
152-
}}
153-
onRefreshClicked={() =>
154-
onRefreshClicked('processing_performance')
155-
}
156-
onEnableAutoRefresh={(
157-
enableAutoRefresh: boolean,
158-
refreshRate: string,
159-
) =>
160-
onChangeAutoRefresh(
161-
'processing_performance',
162-
enableAutoRefresh,
163-
refreshRate,
164-
)
165-
}
166-
/>
167-
</FlexItem>
168-
</Row>
169-
<Status data={statisticsData.rdiPipelineStatus} />
170-
<ProcessingPerformance
171-
data={statisticsData.processingPerformance}
172-
/>
173-
<TargetConnections data={statisticsData.connections} />
174-
<DataStreams data={statisticsData.dataStreams} />
175-
<Clients data={statisticsData.clients} />
176-
</>
137+
!pageLoading && (
138+
<>
139+
<Row justify="end">
140+
<FlexItem>
141+
<AutoRefresh
142+
postfix="processing-performance-info"
143+
displayText
144+
loading={isStatisticsLoading}
145+
lastRefreshTime={lastRefreshTime}
146+
enableAutoRefreshDefault
147+
testid="processing-performance-info"
148+
onRefresh={() => {
149+
setLastRefreshTime(Date.now())
150+
onRefresh('processing_performance')
151+
}}
152+
onRefreshClicked={() =>
153+
onRefreshClicked('processing_performance')
154+
}
155+
onEnableAutoRefresh={(
156+
enableAutoRefresh: boolean,
157+
refreshRate: string,
158+
) =>
159+
onChangeAutoRefresh(
160+
'processing_performance',
161+
enableAutoRefresh,
162+
refreshRate,
163+
)
164+
}
165+
/>
166+
</FlexItem>
167+
</Row>
168+
<Status data={statisticsData.rdiPipelineStatus} />
169+
<ProcessingPerformance
170+
data={statisticsData.processingPerformance}
171+
/>
172+
<TargetConnections data={statisticsData.connections} />
173+
<DataStreams data={statisticsData.dataStreams} />
174+
<Clients data={statisticsData.clients} />
175+
</>
176+
)
177177
)}
178-
</Col>
179-
</div>
178+
</S.ContentWrapper>
179+
</S.Container>
180180
)
181181
}
182182

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

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)