Skip to content

Commit 3476c58

Browse files
Fe/feature/ri 7687 rdi page pipeline header (#5128)
* RI-7687: use tabs for navigation in RDI (poc) * RI-7687: add tests and remove navigation from the left bar * RI-7687: rework pipeline header * RI-7687: rework pipeline header - fix tests
1 parent 658639a commit 3476c58

File tree

11 files changed

+87
-86
lines changed

11 files changed

+87
-86
lines changed

redisinsight/ui/src/pages/rdi/instance/components/header/RdiPipelineHeader.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
1111
import CurrentPipelineStatus from './components/current-pipeline-status'
1212

1313
import PipelineActions from './components/pipeline-actions'
14-
import styles from './styles.module.scss'
14+
import styled from 'styled-components'
15+
import { Theme } from 'uiSrc/components/base/theme/types'
16+
17+
const StyledRdiPipelineHeader = styled(Row)`
18+
padding: 0 16px;
19+
border-bottom: 4px solid
20+
${({ theme }: { theme: Theme }) =>
21+
theme.components.tabs.variants.default.tabsLine.color};
22+
height: 58px;
23+
`
1524

1625
const RdiPipelineHeader = () => {
1726
const [headerLoading, setHeaderLoading] = useState(true)
@@ -50,11 +59,7 @@ const RdiPipelineHeader = () => {
5059
: undefined
5160

5261
return (
53-
<Row
54-
className={styles.wrapper}
55-
align="center"
56-
justify="between"
57-
>
62+
<StyledRdiPipelineHeader align="center" justify="between">
5863
<FlexItem grow>
5964
<CurrentPipelineStatus
6065
pipelineState={pipelineState}
@@ -66,7 +71,7 @@ const RdiPipelineHeader = () => {
6671
collectorStatus={collectorStatus}
6772
pipelineStatus={pipelineStatus}
6873
/>
69-
</Row>
74+
</StyledRdiPipelineHeader>
7075
)
7176
}
7277

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,13 @@ const DeployPipelineButton = ({ loading, disabled, onReset }: Props) => {
117117
}}
118118
button={
119119
<PrimaryButton
120-
size="s"
121120
onClick={handleClickDeploy}
122121
icon={RiRocketIcon}
123122
disabled={disabled}
124123
loading={loading}
125124
data-testid="deploy-rdi-pipeline"
126125
>
127-
Deploy Pipeline
126+
Deploy
128127
</PrimaryButton>
129128
}
130129
>

redisinsight/ui/src/pages/rdi/instance/components/header/components/buttons/reset-pipeline-button/ResetPipelineButton.spec.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import React from 'react'
22

3-
import { fireEvent, render, screen, waitFor } from 'uiSrc/utils/test-utils'
3+
import {
4+
fireEvent,
5+
render,
6+
screen,
7+
userEvent,
8+
waitFor,
9+
} from 'uiSrc/utils/test-utils'
410
import ResetPipelineButton, { PipelineButtonProps } from './ResetPipelineButton'
511

612
const mockedProps: PipelineButtonProps = {
@@ -46,7 +52,7 @@ describe('ResetPipelineButton', () => {
4652
const onClick = jest.fn()
4753
render(<ResetPipelineButton {...mockedProps} loading onClick={onClick} />)
4854

49-
fireEvent.click(screen.getByTestId('reset-pipeline-btn'))
55+
userEvent.click(screen.getByTestId('reset-pipeline-btn'))
5056
expect(onClick).not.toHaveBeenCalled()
5157
})
5258
})

redisinsight/ui/src/pages/rdi/instance/components/header/components/buttons/reset-pipeline-button/ResetPipelineButton.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react'
22

3-
import { RiResetIcon } from 'uiSrc/components/base/icons'
43
import { Spacer } from 'uiSrc/components/base/layout/spacer'
5-
import { SecondaryButton } from 'uiSrc/components/base/forms/buttons'
64
import { RiTooltip } from 'uiSrc/components'
75
import styles from '../styles.module.scss'
6+
import { Button, TextButton } from '@redis-ui/components'
7+
import { ResetIcon } from '@redis-ui/icons'
88

99
export interface PipelineButtonProps {
1010
onClick: () => void
@@ -35,17 +35,15 @@ const ResetPipelineButton = ({
3535
}
3636
anchorClassName={disabled || loading ? styles.disabled : styles.tooltip}
3737
>
38-
<SecondaryButton
38+
<TextButton
3939
aria-label="Reset pipeline button"
40-
size="s"
41-
icon={RiResetIcon}
4240
data-testid="reset-pipeline-btn"
4341
onClick={onClick}
4442
disabled={disabled}
45-
loading={loading}
4643
>
47-
Reset Pipeline
48-
</SecondaryButton>
44+
<Button.Icon icon={ResetIcon} />
45+
Reset
46+
</TextButton>
4947
</RiTooltip>
5048
)
5149

redisinsight/ui/src/pages/rdi/instance/components/header/components/buttons/start-pipeline-button/StartPipelineButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ const StartPipelineButton = ({
1717
>
1818
<SecondaryButton
1919
aria-label="Start running pipeline"
20-
size="s"
2120
icon={PlayFilledIcon}
2221
data-testid="start-pipeline-btn"
2322
disabled={disabled}
2423
loading={loading}
2524
onClick={onClick}
2625
>
27-
Start Pipeline
26+
Start
2827
</SecondaryButton>
2928
</RiTooltip>
3029
)

redisinsight/ui/src/pages/rdi/instance/components/header/components/buttons/stop-pipeline-button/StopPipelineButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,13 @@ const StopPipelineButton = ({
1717
>
1818
<SecondaryButton
1919
aria-label="Stop running pipeline"
20-
size="s"
2120
loading={loading}
2221
disabled={disabled}
2322
icon={RiStopIcon}
2423
data-testid="stop-pipeline-btn"
2524
onClick={onClick}
2625
>
27-
Stop Pipeline
26+
Stop
2827
</SecondaryButton>
2928
</RiTooltip>
3029
)

redisinsight/ui/src/pages/rdi/instance/components/header/components/current-pipeline-status/CurrentPipelineStatus.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { IconProps } from 'uiSrc/components/base/icons'
66
import { Title } from 'uiSrc/components/base/text/Title'
77
import { Loader } from 'uiSrc/components/base/display'
88
import { RiTooltip } from 'uiSrc/components'
9-
import styles from './styles.module.scss'
9+
import { FlexItem, Row } from 'uiSrc/components/base/layout/flex'
10+
import { Text } from 'uiSrc/components/base/text'
1011

1112
export interface Props {
1213
pipelineState?: PipelineState
@@ -57,22 +58,30 @@ const CurrentPipelineStatus = ({
5758
const errorTooltipContent = statusError && formatLongName(statusError)
5859

5960
return (
60-
<div className={styles.stateWrapper}>
61-
<Title size="XS">Pipeline State:</Title>
62-
{headerLoading ? (
63-
<Loader size="m" style={{ marginLeft: '8px' }} />
64-
) : (
65-
<RiTooltip
66-
content={errorTooltipContent}
67-
anchorClassName={statusError && styles.tooltip}
68-
>
69-
<div className={styles.stateBadge} data-testid="pipeline-state-badge">
70-
<RiIcon type={stateInfo.icon} color={stateInfo.iconColor} />
71-
<span>{stateInfo.label}</span>
72-
</div>
73-
</RiTooltip>
74-
)}
75-
</div>
61+
<Row align="center" gap="m">
62+
<FlexItem>
63+
<Title size="XS">Pipeline state:</Title>
64+
</FlexItem>
65+
<FlexItem>
66+
{headerLoading ? (
67+
<Loader size="m" style={{ marginLeft: '8px' }} />
68+
) : (
69+
<RiTooltip
70+
content={errorTooltipContent}
71+
anchorClassName={statusError}
72+
>
73+
<Row data-testid="pipeline-state-badge" gap="s">
74+
<RiIcon
75+
type={stateInfo.icon}
76+
color={stateInfo.iconColor}
77+
size="m"
78+
/>
79+
<Text size="s">{stateInfo.label}</Text>
80+
</Row>
81+
</RiTooltip>
82+
)}
83+
</FlexItem>
84+
</Row>
7685
)
7786
}
7887

redisinsight/ui/src/pages/rdi/instance/components/header/components/current-pipeline-status/styles.module.scss

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

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('PipelineActions', () => {
7171
collectorStatus={CollectorStatus.Ready}
7272
/>,
7373
)
74-
expect(screen.getByText('Stop Pipeline')).toBeInTheDocument()
74+
expect(screen.getByText('Stop')).toBeInTheDocument()
7575
})
7676

7777
it('should display startBtn if collectorStatus is not ready', () => {
@@ -81,7 +81,7 @@ describe('PipelineActions', () => {
8181
collectorStatus={CollectorStatus.NotReady}
8282
/>,
8383
)
84-
expect(screen.getByText('Start Pipeline')).toBeInTheDocument()
84+
expect(screen.getByText('Start')).toBeInTheDocument()
8585
})
8686

8787
it('should display startBtn if collectorStatus is not ready', () => {
@@ -91,7 +91,7 @@ describe('PipelineActions', () => {
9191
collectorStatus={CollectorStatus.NotReady}
9292
/>,
9393
)
94-
expect(screen.getByText('Start Pipeline')).toBeInTheDocument()
94+
expect(screen.getByText('Start')).toBeInTheDocument()
9595
})
9696

9797
it('should validate pipeline when schema, config, or jobs change', () => {
@@ -211,9 +211,15 @@ describe('PipelineActions', () => {
211211

212212
describe('validation with new schema parameters', () => {
213213
it('should pass monacoJobsSchema and jobNameSchema to validatePipeline when available', () => {
214-
const mockMonacoJobsSchema = { type: 'object', properties: { task: { type: 'string' } } }
215-
const mockJobNameSchema = { type: 'string', pattern: '^[a-zA-Z][a-zA-Z0-9_]*$' }
216-
214+
const mockMonacoJobsSchema = {
215+
type: 'object',
216+
properties: { task: { type: 'string' } },
217+
}
218+
const mockJobNameSchema = {
219+
type: 'string',
220+
pattern: '^[a-zA-Z][a-zA-Z0-9_]*$',
221+
}
222+
217223
;(validatePipeline as jest.Mock).mockReturnValue({
218224
result: true,
219225
configValidationErrors: [],
@@ -268,7 +274,7 @@ describe('PipelineActions', () => {
268274
it('should include monacoJobsSchema and jobNameSchema in dependency array for validation effect', () => {
269275
// This test verifies that the useEffect dependency array includes the new schema parameters
270276
// by checking that different schema values trigger different validatePipeline calls
271-
277+
272278
;(validatePipeline as jest.Mock).mockReturnValue({
273279
result: true,
274280
configValidationErrors: [],
@@ -279,7 +285,10 @@ describe('PipelineActions', () => {
279285
;(rdiPipelineSelector as jest.Mock).mockReturnValueOnce({
280286
loading: false,
281287
schema: 'test-schema',
282-
monacoJobsSchema: { type: 'object', properties: { task: { type: 'string' } } },
288+
monacoJobsSchema: {
289+
type: 'object',
290+
properties: { task: { type: 'string' } },
291+
},
283292
jobNameSchema: { type: 'string', pattern: '^[a-zA-Z]+$' },
284293
config: 'test-config',
285294
jobs: 'test-jobs',
@@ -290,7 +299,10 @@ describe('PipelineActions', () => {
290299
// Verify that validatePipeline was called with all the correct parameters including schemas
291300
expect(validatePipeline).toHaveBeenCalledWith({
292301
schema: 'test-schema',
293-
monacoJobsSchema: { type: 'object', properties: { task: { type: 'string' } } },
302+
monacoJobsSchema: {
303+
type: 'object',
304+
properties: { task: { type: 'string' } },
305+
},
294306
jobNameSchema: { type: 'string', pattern: '^[a-zA-Z]+$' },
295307
config: 'test-config',
296308
jobs: 'test-jobs',

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ import ResetPipelineButton from '../buttons/reset-pipeline-button'
2828
import RdiConfigFileActionMenu from '../rdi-config-file-action-menu'
2929
import StopPipelineButton from '../buttons/stop-pipeline-button'
3030
import StartPipelineButton from '../buttons/start-pipeline-button/StartPipelineButton'
31+
import styled from 'styled-components'
32+
import { Theme } from 'uiSrc/components/base/theme/types'
33+
34+
const VerticalDelimiter = styled(FlexItem)`
35+
border: ${({ theme }: { theme: Theme }) =>
36+
theme.components.appBar.separator};
37+
align-self: stretch;
38+
`
3139

3240
export interface Props {
3341
collectorStatus?: CollectorStatus
@@ -149,14 +157,15 @@ const PipelineActions = ({ collectorStatus, pipelineStatus }: Props) => {
149157
const disabled = deployLoading || actionLoading
150158

151159
return (
152-
<Row gap="m" justify="end" align="center">
160+
<Row gap="l" justify="end" align="center">
153161
<FlexItem>
154162
<ResetPipelineButton
155163
onClick={onReset}
156164
disabled={disabled}
157165
loading={isLoadingBtn(PipelineAction.Reset)}
158166
/>
159167
</FlexItem>
168+
<VerticalDelimiter />
160169
<FlexItem>
161170
{collectorStatus === CollectorStatus.Ready ? (
162171
<StopPipelineButton
@@ -179,7 +188,7 @@ const PipelineActions = ({ collectorStatus, pipelineStatus }: Props) => {
179188
onReset={resetPipeline}
180189
/>
181190
</FlexItem>
182-
<FlexItem style={{ margin: 0 }}>
191+
<FlexItem>
183192
<RdiConfigFileActionMenu />
184193
</FlexItem>
185194
</Row>

0 commit comments

Comments
 (0)