Skip to content

Commit 2a97573

Browse files
authored
Merge pull request #1274 from RedisInsight/feature/RI-2664_params-redis-auto-btn
Feature/ri 2664 params redis auto btn
2 parents 096db2b + 82dd01a commit 2a97573

File tree

19 files changed

+166
-88
lines changed

19 files changed

+166
-88
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { RunQueryMode, ResultsMode, ResultsSummary } from 'uiSrc/slices/interfac
99
import {
1010
getWBQueryType,
1111
getVisualizationsByCommand,
12-
Maybe
12+
Maybe,
13+
isGroupMode
1314
} from 'uiSrc/utils'
1415
import { appPluginsSelector } from 'uiSrc/slices/app/plugins'
1516
import { CommandExecutionResult, IPluginVisualization } from 'uiSrc/slices/interfaces'
@@ -32,7 +33,7 @@ export interface Props {
3233
mode?: RunQueryMode
3334
activeResultsMode?: ResultsMode
3435
resultsMode?: ResultsMode
35-
emptyCommand: boolean
36+
emptyCommand?: boolean
3637
summary?: ResultsSummary
3738
createdAt?: Date
3839
loading?: boolean
@@ -179,7 +180,7 @@ const QueryCard = (props: Props) => {
179180
? <QueryCardCommonResult loading={loading} result={commonError} />
180181
: (
181182
<>
182-
{resultsMode === ResultsMode.GroupMode && (
183+
{isGroupMode(resultsMode) && (
183184
<QueryCardCliResultWrapper
184185
loading={loading}
185186
query={command}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { isArray } from 'lodash'
55

66
import { CommandExecutionResult } from 'uiSrc/slices/interfaces'
77
import { ResultsMode } from 'uiSrc/slices/interfaces/workbench'
8-
import { formatToText, Maybe } from 'uiSrc/utils'
8+
import { formatToText, isGroupMode, Maybe } from 'uiSrc/utils'
99

1010
import QueryCardCliDefaultResult from '../QueryCardCliDefaultResult'
1111
import QueryCardCliGroupResult from '../QueryCardCliGroupResult'
@@ -34,7 +34,7 @@ const QueryCardCliResultWrapper = (props: Props) => {
3434
The result is too big to be saved. It will be deleted after the application is closed.
3535
</EuiText>
3636
)}
37-
{resultsMode === ResultsMode.GroupMode && isArray(result[0]?.response)
37+
{isGroupMode(resultsMode) && isArray(result[0]?.response)
3838
? <QueryCardCliGroupResult result={result} isFullScreen={isFullScreen} />
3939
: (
4040
<QueryCardCliDefaultResult

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ import { useParams } from 'react-router-dom'
1616
import { findIndex } from 'lodash'
1717

1818
import { Theme } from 'uiSrc/constants'
19-
import { getCommandNameFromQuery, getVisualizationsByCommand, truncateText, urlForAsset } from 'uiSrc/utils'
19+
import {
20+
getCommandNameFromQuery,
21+
getVisualizationsByCommand,
22+
isGroupMode,
23+
truncateText,
24+
urlForAsset
25+
} from 'uiSrc/utils'
2026
import { ThemeContext } from 'uiSrc/contexts/themeContext'
2127
import { appPluginsSelector } from 'uiSrc/slices/app/plugins'
2228
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
@@ -45,7 +51,7 @@ export interface Props {
4551
queryType: WBQueryType
4652
selectedValue: string
4753
loading?: boolean
48-
emptyCommand: boolean
54+
emptyCommand?: boolean
4955
toggleOpen: () => void
5056
toggleFullScreen: () => void
5157
setSelectedValue: (type: WBQueryType, value: string) => void
@@ -68,7 +74,7 @@ const QueryCardHeader = (props: Props) => {
6874
summary,
6975
activeMode,
7076
selectedValue,
71-
emptyCommand,
77+
emptyCommand = false,
7278
setSelectedValue,
7379
onQueryDelete,
7480
onQueryReRun,
@@ -92,7 +98,7 @@ const QueryCardHeader = (props: Props) => {
9298
databaseId: instanceId,
9399
command: getCommandNameFromQuery(query, COMMANDS_SPEC),
94100
rawMode: activeMode === RunQueryMode.Raw,
95-
group: activeResultsMode === ResultsMode.GroupMode,
101+
group: isGroupMode(activeResultsMode),
96102
...additionalData
97103
}
98104
})

redisinsight/ui/src/components/query/Query/Query.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
getRedisCompletionProvider,
2626
getRedisMonarchTokensProvider,
2727
getRedisSignatureHelpProvider,
28+
isGroupMode,
2829
MonacoAction,
2930
Nullable,
3031
toModelDeltaDecoration
@@ -543,7 +544,7 @@ const Query = (props: Props) => {
543544
color="secondary"
544545
onClick={() => onChangeGroupMode()}
545546
disabled={isLoading}
546-
className={cx(styles.textBtn, { [styles.activeBtn]: resultsMode === ResultsMode.GroupMode })}
547+
className={cx(styles.textBtn, { [styles.activeBtn]: isGroupMode(resultsMode) })}
547548
data-testid="btn-change-group-mode"
548549
>
549550
<EuiIcon type={GroupModeIcon} />

redisinsight/ui/src/components/query/QueryWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useParams } from 'react-router-dom'
66

77
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
88
import { appRedisCommandsSelector } from 'uiSrc/slices/app/redis-commands'
9-
import { getMultiCommands, removeMonacoComments, splitMonacoValuePerLines } from 'uiSrc/utils'
9+
import { getMultiCommands, isGroupMode, removeMonacoComments, splitMonacoValuePerLines } from 'uiSrc/utils'
1010
import { userSettingsConfigSelector } from 'uiSrc/slices/user/user-settings'
1111
import { RunQueryMode, ResultsMode } from 'uiSrc/slices/interfaces/workbench'
1212
import { PIPELINE_COUNT_DEFAULT } from 'uiSrc/constants/api'
@@ -81,7 +81,7 @@ const QueryWrapper = (props: Props) => {
8181
multiple: multiCommands ? 'Multiple' : 'Single',
8282
pipeline: batchSize > 1,
8383
rawMode: state.activeMode === RunQueryMode.Raw,
84-
group: state.resultsMode === ResultsMode.GroupMode
84+
group: isGroupMode(state.resultsMode)
8585
}
8686
})()
8787

redisinsight/ui/src/constants/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ export * from './browser'
2323
export * from './durationUnits'
2424
export * from './streamViews'
2525
export * from './bulkActions'
26+
export * from './workbench'
2627
export { ApiEndpoints, BrowserStorageItem, ApiStatusCode, apiErrors }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { ResultsMode, RunQueryMode } from 'uiSrc/slices/interfaces'
2+
3+
export const CodeButtonResults = {
4+
group: ResultsMode.GroupMode,
5+
single: ResultsMode.Default
6+
}
7+
8+
export const CodeButtonRunQueryMode = {
9+
raw: RunQueryMode.Raw,
10+
ascii: RunQueryMode.ASCII
11+
}

redisinsight/ui/src/mocks/handlers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ import content from './content'
44
import app from './app'
55
import analytics from './analytics'
66

7+
// @ts-ignore
78
export const handlers: RestHandler<MockedRequest>[] = [].concat(instances, content, app, analytics)

redisinsight/ui/src/pages/workbench/components/enablement-area/EnablementAreaWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export interface Props {
2323
setIsMinimized: (value: boolean) => void
2424
scriptEl: Nullable<monacoEditor.editor.IStandaloneCodeEditor>
2525
setScript: (script: string) => void
26-
onSubmit: (query: string, commandId?: Nullable<string>, clearEditor?: boolean) => void
26+
onSubmit: (query: string, commandId?: Nullable<string>, executeParams?: CodeButtonParams) => void
2727
isCodeBtnDisabled?: boolean
2828
}
2929

@@ -60,7 +60,7 @@ const EnablementAreaWrapper = (props: Props) => {
6060
sendEventButtonClickedTelemetry(file)
6161

6262
if (execute.mode === ExecuteButtonMode.Auto) {
63-
onSubmit(script, null, false)
63+
onSubmit(script, null, { ...execute.params, clearEditor: false })
6464
return
6565
}
6666

redisinsight/ui/src/pages/workbench/components/enablement-area/interfaces.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import { CodeButtonResults, CodeButtonRunQueryMode } from 'uiSrc/constants'
2+
13
export interface CodeButtonParams {
2-
//
4+
clearEditor?: boolean
5+
pipeline?: string
6+
results?: keyof typeof CodeButtonResults
7+
mode?: keyof typeof CodeButtonRunQueryMode
38
}
49

510
export enum ExecuteButtonMode {

0 commit comments

Comments
 (0)