Skip to content

Commit 7f1a0a7

Browse files
authored
Merge pull request #1421 from RedisInsight/bugfix/RI-3822/3742/3788_regression_bugs
#RI-3822,3742,3788_fixed
2 parents 07dbaee + 093ca43 commit 7f1a0a7

File tree

14 files changed

+167
-32
lines changed

14 files changed

+167
-32
lines changed

redisinsight/api/src/constants/telemetry-events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,5 @@ export enum CommandType {
6161
Core = 'core',
6262
Module = 'module',
6363
}
64+
65+
export const unknownCommand = 'unknown';

redisinsight/api/src/modules/cli/services/cli-business/cli-business.service.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
CommandParsingError,
2929
WrongDatabaseTypeError,
3030
} from 'src/modules/cli/constants/errors';
31+
import { unknownCommand } from 'src/constants';
3132
import { CliAnalyticsService } from 'src/modules/cli/services/cli-analytics/cli-analytics.service';
3233
import { KeytarUnavailableException } from 'src/modules/encryption/exceptions';
3334
import { RedisToolService } from 'src/modules/redis/redis-tool.service';
@@ -330,6 +331,7 @@ describe('CliBusinessService', () => {
330331
ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES(),
331332
),
332333
{
334+
command: unknownCommand,
333335
outputFormat: CliOutputFormatterTypes.Raw,
334336
},
335337
);
@@ -591,6 +593,7 @@ describe('CliBusinessService', () => {
591593
mockClientOptions.instanceId,
592594
new CommandParsingError(ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES()),
593595
{
596+
command: unknownCommand,
594597
outputFormat: CliOutputFormatterTypes.Raw,
595598
},
596599
);
@@ -920,6 +923,7 @@ describe('CliBusinessService', () => {
920923
mockClientOptions.instanceId,
921924
new CommandParsingError(ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES()),
922925
{
926+
command: unknownCommand,
923927
outputFormat: CliOutputFormatterTypes.Raw,
924928
},
925929
);

redisinsight/api/src/modules/cli/services/cli-business/cli-business.service.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
Logger,
66
} from '@nestjs/common';
77
import { IFindRedisClientInstanceByOptions } from 'src/modules/redis/redis.service';
8+
import { unknownCommand } from 'src/constants';
89
import { CommandsService } from 'src/modules/commands/commands.service';
910
import {
1011
ClusterNodeRole,
@@ -143,7 +144,7 @@ export class CliBusinessService {
143144
): Promise<SendCommandResponse> {
144145
this.logger.log('Executing redis CLI command.');
145146
const { command: commandLine } = dto;
146-
let command: string;
147+
let command: string = unknownCommand;
147148
let args: string[] = [];
148149

149150
const outputFormat = dto.outputFormat || CliOutputFormatterTypes.Raw;
@@ -229,7 +230,7 @@ export class CliBusinessService {
229230
outputFormat: CliOutputFormatterTypes = CliOutputFormatterTypes.Raw,
230231
): Promise<SendClusterCommandResponse[]> {
231232
this.logger.log(`Executing redis.cluster CLI command for [${role}] nodes.`);
232-
let command: string;
233+
let command: string = unknownCommand;
233234
let args: string[] = [];
234235

235236
try {
@@ -298,7 +299,7 @@ export class CliBusinessService {
298299
outputFormat: CliOutputFormatterTypes = CliOutputFormatterTypes.Raw,
299300
): Promise<SendClusterCommandResponse> {
300301
this.logger.log(`Executing redis.cluster CLI command for single node ${JSON.stringify(nodeOptions)}`);
301-
let command: string;
302+
let command: string = unknownCommand;
302303
let args: string[] = [];
303304

304305
try {

redisinsight/api/src/modules/workbench/providers/workbench-commands.executor.spec.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
mockDatabase,
66
mockWorkbenchAnalyticsService,
77
} from 'src/__mocks__';
8+
import ERROR_MESSAGES from 'src/constants/error-messages';
9+
import { unknownCommand } from 'src/constants';
810
import { IFindRedisClientInstanceByOptions } from 'src/modules/redis/redis.service';
911
import { WorkbenchCommandsExecutor } from 'src/modules/workbench/providers/workbench-commands.executor';
1012
import {
@@ -17,6 +19,7 @@ import { CommandExecutionStatus } from 'src/modules/cli/dto/cli.dto';
1719
import { BadRequestException, InternalServerErrorException, ServiceUnavailableException } from '@nestjs/common';
1820
import {
1921
CommandNotSupportedError,
22+
CommandParsingError,
2023
ClusterNodeNotFoundError,
2124
WrongDatabaseTypeError,
2225
} from 'src/modules/cli/constants/errors';
@@ -49,6 +52,7 @@ const mockCliNodeResponse: ICliExecResultFromNode = {
4952
};
5053

5154
const mockSetCommand = 'set';
55+
const mockGetEscapedKeyCommand = 'get "\\\\key';
5256
const mockCreateCommandExecutionDto: CreateCommandExecutionDto = {
5357
command: `${mockSetCommand} foo bar`,
5458
nodeOptions: {
@@ -564,5 +568,35 @@ describe('WorkbenchCommandsExecutor', () => {
564568
}
565569
});
566570
});
571+
describe('CommandParsingError', () => {
572+
it('should return response with [CLI_UNTERMINATED_QUOTES] error for sendCommandForNodes', async () => {
573+
const mockResult = [
574+
{
575+
response: ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES(),
576+
status: CommandExecutionStatus.Fail,
577+
},
578+
];
579+
580+
const result = await service.sendCommand(mockClientOptions, {
581+
command: mockGetEscapedKeyCommand,
582+
role: mockCreateCommandExecutionDto.role,
583+
mode: RunQueryMode.ASCII,
584+
});
585+
586+
expect(result).toEqual(mockResult);
587+
expect(mockAnalyticsService.sendCommandExecutedEvent).toHaveBeenCalledWith(
588+
mockClientOptions.instanceId,
589+
{
590+
response: ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES(),
591+
error: new CommandParsingError(ERROR_MESSAGES.CLI_UNTERMINATED_QUOTES()),
592+
status: CommandExecutionStatus.Fail,
593+
},
594+
{
595+
command: unknownCommand,
596+
rawMode: false,
597+
},
598+
);
599+
});
600+
});
567601
});
568602
});

redisinsight/api/src/modules/workbench/providers/workbench-commands.executor.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
ClusterNodeNotFoundError,
1919
WrongDatabaseTypeError,
2020
} from 'src/modules/cli/constants/errors';
21+
import { unknownCommand } from 'src/constants';
2122
import { CommandExecutionResult } from 'src/modules/workbench/models/command-execution-result';
2223
import { CreateCommandExecutionDto, RunQueryMode } from 'src/modules/workbench/dto/create-command-execution.dto';
2324
import { RedisToolService } from 'src/modules/redis/redis-tool.service';
@@ -62,17 +63,18 @@ export class WorkbenchCommandsExecutor {
6263
dto: CreateCommandExecutionDto,
6364
): Promise<CommandExecutionResult[]> {
6465
let result;
66+
let command = unknownCommand;
67+
let commandArgs: string[] = [];
6568

6669
const {
6770
command: commandLine,
6871
role,
6972
nodeOptions,
7073
mode,
7174
} = dto;
72-
73-
const [command, ...commandArgs] = splitCliCommandLine(commandLine);
74-
7575
try {
76+
[command, ...commandArgs] = splitCliCommandLine(commandLine);
77+
7678
if (nodeOptions) {
7779
result = [await this.sendCommandForSingleNode(
7880
clientOptions,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const QueryCard = (props: Props) => {
179179
/>
180180
{isOpen && (
181181
<>
182-
{React.isValidElement(commonError)
182+
{React.isValidElement(commonError) && !isGroupMode(resultsMode)
183183
? <QueryCardCommonResult loading={loading} result={commonError} />
184184
: (
185185
<>

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { flatten } from 'lodash'
22
import React from 'react'
33

44
import { CommandExecutionResult } from 'uiSrc/slices/interfaces'
5-
import { cliParseCommandsGroupResult, Maybe } from 'uiSrc/utils'
5+
import { cliParseCommandsGroupResult, wbSummaryCommand, Maybe } from 'uiSrc/utils'
66
import QueryCardCliDefaultResult from '../QueryCardCliDefaultResult'
7+
import { CommonErrorResponse } from '../QueryCardCommonResult'
78

89
export interface Props {
910
result?: Maybe<CommandExecutionResult[]>
@@ -12,12 +13,18 @@ export interface Props {
1213

1314
const QueryCardCliGroupResult = (props: Props) => {
1415
const { result = [], isFullScreen } = props
16+
1517
return (
1618
<div data-testid="query-cli-default-result" className="query-card-output-response-success">
1719
<QueryCardCliDefaultResult
1820
isFullScreen={isFullScreen}
19-
items={flatten(result?.[0]?.response.map((item: any) =>
20-
flatten(cliParseCommandsGroupResult(item))))}
21+
items={flatten(result?.[0]?.response.map((item: any) => {
22+
const commonError = CommonErrorResponse(item.command, item.response)
23+
if (React.isValidElement(commonError)) {
24+
return ([wbSummaryCommand(item.command), commonError])
25+
}
26+
return flatten(cliParseCommandsGroupResult(item))
27+
}))}
2128
/>
2229
</div>
2330
)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ const QueryCardHeader = (props: Props) => {
292292
<EuiFlexItem grow={false} className={styles.executionTime} data-testid="command-execution-time">
293293
{isNumber(executionTime) && (
294294
<EuiToolTip
295-
title="Execution Time"
295+
title="Processing Time"
296296
content={getExecutionTimeString(executionTime)}
297297
position="left"
298298
anchorClassName={cx(styles.tooltipIcon, styles.alignCenter)}

redisinsight/ui/src/components/query-card/QueryCardHeader/styles.module.scss

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,27 @@ $marginIcon: 12px;
4141

4242
.titleWrapper {
4343
width: calc(100% - 490px);
44+
min-width: calc(100% - 490px);
4445

45-
@media (min-width: $breakpoint-s) {
46-
width: calc(100% - 529px);
46+
@media (min-width: $breakpoint-m) {
47+
width: calc(100% - 582px);
48+
min-width: calc(100% - 582px);
4749
}
4850

49-
@media (min-width: $breakpoint-m) {
50-
width: calc(100% - 651px);
51+
@media (min-width: $breakpoint-l) {
52+
width: calc(100% - 633px);
53+
min-width: calc(100% - 633px);
5154
}
5255
}
5356

5457
:global(.fullscreen) .titleWrapper {
5558
width: calc(100% - 402px);
5659

57-
@media (min-width: $breakpoint-s) {
58-
width: calc(100% - 447px);
60+
@media (min-width: $breakpoint-m) {
61+
width: calc(100% - 474px);
5962
}
6063

61-
@media (min-width: $breakpoint-m) {
64+
@media (min-width: $breakpoint-l) {
6265
width: calc(100% - 519px);
6366
}
6467
}
@@ -146,21 +149,16 @@ $marginIcon: 12px;
146149
min-width: 13px;
147150
width: 13px;
148151

149-
@media (min-width: $breakpoint-s) {
152+
@media (min-width: $breakpoint-l) {
150153
min-width: 58px;
151154
width: 58px;
152155
}
153-
154-
@media (min-width: $breakpoint-m) {
155-
min-width: 70px;
156-
width: 70px;
157-
}
158156
}
159157

160158
.executionTimeValue {
161159
display: none;
162160

163-
@media (min-width: $breakpoint-s) {
161+
@media (min-width: $breakpoint-l) {
164162
display: initial;
165163
overflow: hidden;
166164
text-overflow: ellipsis;

redisinsight/ui/src/components/query-card/styles.module.scss

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,17 @@
22
@import "@elastic/eui/src/components/table/mixins";
33
@import "@elastic/eui/src/global_styling/index";
44

5+
$breakpoint-l: 1300px;
6+
$breakpoint-m: 1050px;
7+
58
.containerWrapper {
6-
min-width: 590px;
9+
min-width: 560px;
10+
@media (min-width: $breakpoint-m) {
11+
min-width: 650px;
12+
}
13+
@media (min-width: $breakpoint-l) {
14+
min-width: 720px;
15+
}
716
&:nth-of-type(even) {
817
background-color: var(--euiColorEmptyShade) !important;
918
}

0 commit comments

Comments
 (0)