Skip to content

Commit 98d72c6

Browse files
Merge pull request #3545 from RedisInsight/fe/bugfix/RI-5872_dry_run_job
#RI-5872 - add tooltip, remove array check
2 parents 76e3a19 + 6ccbec1 commit 98d72c6

File tree

3 files changed

+42
-16
lines changed

3 files changed

+42
-16
lines changed

redisinsight/ui/src/pages/rdi/pipeline-management/components/dry-run-job-commands/DryRunJobCommands.spec.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ describe('DryRunJobCommands', () => {
2929
expect(screen.getByTestId('commands-output')).toHaveTextContent('No Redis commands provided.')
3030
})
3131

32+
it('should render no commands message if there is no commands', async () => {
33+
const rdiDryRunJobSelectorMock = jest.fn().mockReturnValue({
34+
results: {
35+
output: [{ name: 1 }],
36+
}
37+
});
38+
(rdiDryRunJobSelector as jest.Mock).mockImplementationOnce(rdiDryRunJobSelectorMock)
39+
40+
await act(async () => {
41+
render(<DryRunJobCommands />)
42+
})
43+
44+
expect(screen.getByTestId('commands-output')).toHaveTextContent('No Redis commands provided.')
45+
})
46+
3247
it('should render transformations', async () => {
3348
const rdiDryRunJobSelectorMock = jest.fn().mockReturnValue({
3449
results: {

redisinsight/ui/src/pages/rdi/pipeline-management/components/dry-run-job-commands/DryRunJobCommands.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ const DryRunJobCommands = ({ target }: Props) => {
2727
?.find((el) => el.connection === target)
2828
?.commands
2929

30+
if (!targetCommands) {
31+
setCommands(NO_COMMANDS_MESSAGE)
32+
return
33+
}
3034
monaco.editor.colorize((targetCommands ?? []).join('\n').trim(), MonacoLanguage.Redis, {})
3135
.then((data) => {
3236
setCommands(data)

redisinsight/ui/src/pages/rdi/pipeline-management/components/jobs-panel/Panel.tsx

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
EuiFlexGroup,
1010
EuiFlexItem,
1111
EuiSuperSelect,
12-
keys, EuiSuperSelectOption,
12+
keys, EuiSuperSelectOption, EuiToolTip,
1313
} from '@elastic/eui'
1414
import { useDispatch, useSelector } from 'react-redux'
1515
import { useParams } from 'react-router-dom'
@@ -65,8 +65,8 @@ const DryRunJobPanel = (props: Props) => {
6565

6666
useEffect(() => {
6767
try {
68-
const jsonValue = JSON.parse(input)
69-
setIsFormValid(isArray(jsonValue))
68+
JSON.parse(input)
69+
setIsFormValid(true)
7070
} catch (e) {
7171
setIsFormValid(false)
7272
}
@@ -110,7 +110,9 @@ const DryRunJobPanel = (props: Props) => {
110110
id: rdiInstanceId,
111111
},
112112
})
113-
dispatch(rdiDryRunJob(rdiInstanceId, JSON.parse(input), job))
113+
const JSONInput = JSON.parse(input)
114+
const formattedValue = isArray(JSONInput) ? JSONInput : [JSONInput]
115+
dispatch(rdiDryRunJob(rdiInstanceId, formattedValue, job))
114116
}
115117

116118
const isSelectAvailable = selectedTab === PipelineJobsTabs.Output
@@ -184,19 +186,24 @@ const DryRunJobPanel = (props: Props) => {
184186
/>
185187
<EuiFlexGroup gutterSize="none" justifyContent="flexEnd">
186188
<EuiFlexItem grow={false}>
187-
<EuiButton
188-
onClick={handleDryRun}
189-
iconType="play"
190-
iconSide="right"
191-
color="success"
192-
size="s"
193-
disabled={isDryRunning || !isFormValid}
194-
isLoading={isDryRunning}
195-
className={cx(styles.actionBtn, styles.runBtn)}
196-
data-testid="dry-run-btn"
189+
<EuiToolTip
190+
content={isFormValid ? null : 'Input should have JSON format'}
191+
position="top"
197192
>
198-
Dry run
199-
</EuiButton>
193+
<EuiButton
194+
onClick={handleDryRun}
195+
iconType="play"
196+
iconSide="right"
197+
color="success"
198+
size="s"
199+
disabled={isDryRunning || !isFormValid}
200+
isLoading={isDryRunning}
201+
className={cx(styles.actionBtn, styles.runBtn)}
202+
data-testid="dry-run-btn"
203+
>
204+
Dry run
205+
</EuiButton>
206+
</EuiToolTip>
200207
</EuiFlexItem>
201208
</EuiFlexGroup>
202209
<div className={cx(styles.tabsWrapper, styles.codeLabel)}>

0 commit comments

Comments
 (0)