Skip to content

Commit f088418

Browse files
authored
Merge pull request #394 from RedisInsight/bugfix/RI-2492
#RI-2492 - fix clearing editor on reRun command
2 parents 95fae3c + 5a8daf1 commit f088418

File tree

5 files changed

+40
-39
lines changed

5 files changed

+40
-39
lines changed

redisinsight/ui/src/components/query-card/QueryCardHeader/QueryCardHeader.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ import QueryCardTooltip from '../QueryCardTooltip'
3232
import styles from './styles.module.scss'
3333

3434
export interface Props {
35-
query: string;
36-
isOpen: boolean;
37-
isFullScreen: boolean;
38-
createdAt?: Date;
39-
summaryText?: string;
40-
queryType: WBQueryType;
41-
selectedValue: string;
42-
loading?: boolean;
43-
toggleOpen: () => void;
44-
toggleFullScreen: () => void;
45-
setSelectedValue: (type: WBQueryType, value: string) => void;
46-
onQueryDelete: () => void;
47-
onQueryReRun: () => void;
35+
query: string
36+
isOpen: boolean
37+
isFullScreen: boolean
38+
createdAt?: Date
39+
summaryText?: string
40+
queryType: WBQueryType
41+
selectedValue: string
42+
loading?: boolean
43+
toggleOpen: () => void
44+
toggleFullScreen: () => void
45+
setSelectedValue: (type: WBQueryType, value: string) => void
46+
onQueryDelete: () => void
47+
onQueryReRun: () => void
4848
}
4949

5050
const QueryCardHeader = (props: Props) => {

redisinsight/ui/src/pages/workbench/components/wb-results/WBResults/WBResults.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ import cx from 'classnames'
33
import { EuiIcon, EuiText } from '@elastic/eui'
44

55
import { Theme } from 'uiSrc/constants'
6+
import { Nullable } from 'uiSrc/utils'
67
import QueryCard from 'uiSrc/components/query-card'
7-
import { WBQueryType } from 'uiSrc/pages/workbench/constants'
88
import { CommandExecutionUI } from 'uiSrc/slices/interfaces'
99
import { ThemeContext } from 'uiSrc/contexts/themeContext'
1010
import MultiPlayIconDark from 'uiSrc/assets/img/multi_play_icon_dark.svg'
1111
import MultiPlayIconLight from 'uiSrc/assets/img/multi_play_icon_light.svg'
1212
import styles from './styles.module.scss'
1313

1414
export interface Props {
15-
items: CommandExecutionUI[];
16-
scrollDivRef: React.Ref<HTMLDivElement>;
17-
onQueryReRun: (query: string, commandId?: string, type?: WBQueryType) => void;
15+
items: CommandExecutionUI[]
16+
scrollDivRef: React.Ref<HTMLDivElement>
17+
onQueryReRun: (query: string, commandId?: Nullable<string>, clearEditor?: boolean) => void
1818
onQueryDelete: (commandId: string) => void
1919
onQueryOpen: (commandId: string) => void
2020
}
@@ -48,7 +48,7 @@ const WBResults = ({ items = [], onQueryReRun, onQueryDelete, onQueryOpen, scrol
4848
command={command}
4949
createdAt={createdAt}
5050
onQueryOpen={() => onQueryOpen(id)}
51-
onQueryReRun={() => onQueryReRun(command)}
51+
onQueryReRun={() => onQueryReRun(command, null, false)}
5252
onQueryDelete={() => onQueryDelete(id)}
5353
/>
5454
))}

redisinsight/ui/src/pages/workbench/components/wb-results/WBResultsWrapper.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react'
2+
import { Nullable } from 'uiSrc/utils'
23
import { CommandExecutionUI } from 'uiSrc/slices/interfaces'
34
import WBResults from './WBResults'
4-
import { WBQueryType } from '../../constants'
55

66
export interface Props {
7-
items: CommandExecutionUI[];
8-
scrollDivRef: React.Ref<HTMLDivElement>;
9-
onQueryReRun: (query: string, commandId?: string, type?: WBQueryType) => void;
7+
items: CommandExecutionUI[]
8+
scrollDivRef: React.Ref<HTMLDivElement>
9+
onQueryReRun: (query: string, commandId?: Nullable<string>, clearEditor?: boolean) => void
1010
onQueryOpen: (commandId: string) => void
1111
onQueryDelete: (commandId: string) => void
1212
}

redisinsight/ui/src/pages/workbench/components/wb-view/WBView/WBView.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { BrowserStorageItem } from 'uiSrc/constants'
99
import { localStorageService } from 'uiSrc/services'
1010
import InstanceHeader from 'uiSrc/components/instance-header'
1111
import QueryWrapper from 'uiSrc/components/query'
12-
import { WBQueryType } from 'uiSrc/pages/workbench/constants'
1312
import {
1413
setWorkbenchVerticalPanelSizes,
1514
appContextWorkbench
@@ -27,15 +26,15 @@ const verticalPanelIds = {
2726
}
2827

2928
export interface Props {
30-
script: string;
31-
loading: boolean;
32-
items: CommandExecutionUI[];
33-
setScript: (script: string) => void;
34-
setScriptEl: Function;
35-
scriptEl: Nullable<monacoEditor.editor.IStandaloneCodeEditor>;
36-
scrollDivRef: Ref<HTMLDivElement>;
37-
onSubmit: (query?: string, commandId?: string, type?: WBQueryType) => void;
38-
onQueryOpen: (commandId?: string) => void;
29+
script: string
30+
loading: boolean
31+
items: CommandExecutionUI[]
32+
setScript: (script: string) => void
33+
setScriptEl: Function
34+
scriptEl: Nullable<monacoEditor.editor.IStandaloneCodeEditor>
35+
scrollDivRef: Ref<HTMLDivElement>
36+
onSubmit: (query?: string, commandId?: Nullable<string>, clearEditor?: boolean) => void
37+
onQueryOpen: (commandId?: string) => void
3938
onQueryDelete: (commandId: string) => void
4039
}
4140

redisinsight/ui/src/pages/workbench/components/wb-view/WBViewWrapper.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ const WBViewWrapper = () => {
101101

102102
const handleSubmit = (
103103
commandInit: string = script,
104-
commandId?: string,
104+
commandId?: Nullable<string>,
105+
clearEditor: boolean = true,
105106
) => {
106107
const { loading } = state
107108
const isNewCommand = () => !commandId
@@ -121,19 +122,20 @@ const WBViewWrapper = () => {
121122

122123
isNewCommand() && scrollResults('start')
123124

124-
sendCommand(commandLine, multiCommands)
125+
sendCommand(commandLine, multiCommands, clearEditor)
125126
}
126127

127128
const sendCommand = (
128129
command: string,
129-
multiCommands = ''
130+
multiCommands = '',
131+
clearEditor = true
130132
) => {
131133
const { connectionType, host, port } = state.instance
132134
if (connectionType !== ConnectionType.Cluster) {
133135
dispatch(sendWBCommandAction({
134136
command,
135137
multiCommands,
136-
onSuccessAction: onSuccess,
138+
onSuccessAction: (multiCommands) => onSuccess(multiCommands, clearEditor),
137139
}))
138140
return
139141
}
@@ -152,13 +154,13 @@ const WBViewWrapper = () => {
152154
command,
153155
options,
154156
multiCommands,
155-
onSuccessAction: onSuccess,
157+
onSuccessAction: (multiCommands) => onSuccess(multiCommands, clearEditor),
156158
})
157159
)
158160
}
159161

160-
const onSuccess = (multiCommands = '') => {
161-
resetCommand()
162+
const onSuccess = (multiCommands = '', clearEditor = true) => {
163+
clearEditor && resetCommand()
162164
setMultiCommands(multiCommands)
163165
}
164166

0 commit comments

Comments
 (0)