Skip to content

Commit f4af1cc

Browse files
author
ALENA NABOKA
committed
Merge branch 'main' into feature/RI-3413-telemetry-command-module
2 parents 82a553d + ac6f4ad commit f4af1cc

File tree

12 files changed

+148
-31
lines changed

12 files changed

+148
-31
lines changed

README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,10 @@ Check out the [release notes](https://docs.redis.com/latest/ri/release-notes/).
3939

4040
## Get started with RedisInsight
4141

42-
This repository includes the code for RedisInsight 2.0, Currently available in public preview. Check out the [blogpost](https://redis.com/blog/introducing-redisinsight-2/) announcing it.
43-
44-
The current GA version of RedisInsight is 1.11. You can install RedisInsight 2.0 along with the GA version.
42+
This repository includes the code for the GA version of RedisInsight 2.0. Check out the [blogpost](https://redis.com/blog/introducing-redisinsight-2/) announcing it.
4543

4644
### Installable
47-
Available to download for free from [here](https://redis.com/redis-enterprise/redis-insight/#insight-form).
45+
Available to download for free from [here](https://redis.com/redis-enterprise/redis-insight/#insight-form).
4846

4947
### Build
5048
Alternatively you can also build from source. See our wiki for instructions.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface Props {
3030
result: Maybe<CommandExecutionResult[]>
3131
activeMode: RunQueryMode
3232
mode: RunQueryMode
33+
emptyCommand: boolean
3334
createdAt?: Date
3435
loading?: boolean
3536
onQueryDelete: () => void
@@ -52,7 +53,8 @@ const QueryCard = (props: Props) => {
5253
onQueryOpen,
5354
onQueryDelete,
5455
onQueryReRun,
55-
loading
56+
loading,
57+
emptyCommand,
5658
} = props
5759

5860
const { visualizations = [] } = useSelector(appPluginsSelector)
@@ -146,6 +148,7 @@ const QueryCard = (props: Props) => {
146148
selectedValue={selectedViewValue}
147149
activeMode={activeMode}
148150
mode={mode}
151+
emptyCommand={emptyCommand}
149152
toggleOpen={toggleOpen}
150153
toggleFullScreen={toggleFullScreen}
151154
setSelectedValue={changeViewTypeSelected}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface Props {
4343
queryType: WBQueryType
4444
selectedValue: string
4545
loading?: boolean
46+
emptyCommand: boolean
4647
toggleOpen: () => void
4748
toggleFullScreen: () => void
4849
setSelectedValue: (type: WBQueryType, value: string) => void
@@ -63,6 +64,7 @@ const QueryCardHeader = (props: Props) => {
6364
mode,
6465
activeMode,
6566
selectedValue,
67+
emptyCommand,
6668
setSelectedValue,
6769
onQueryDelete,
6870
onQueryReRun,
@@ -302,7 +304,13 @@ const QueryCardHeader = (props: Props) => {
302304
content="Run again"
303305
position="left"
304306
>
305-
<EuiButtonIcon iconType="play" aria-label="Re-run command" data-testid="re-run-command" onClick={handleQueryReRun} />
307+
<EuiButtonIcon
308+
disabled={emptyCommand}
309+
iconType="play"
310+
aria-label="Re-run command"
311+
data-testid="re-run-command"
312+
onClick={handleQueryReRun}
313+
/>
306314
</EuiToolTip>
307315
</EuiFlexItem>
308316
)}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
export const bulkReplyCommands = ['LOLWUT', 'INFO', 'CLIENT', 'CLUSTER', 'MEMORY', 'MONITOR', 'PSUBSCRIBE']
2+
3+
export const EMPTY_COMMAND = 'Encrypted data'

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,18 @@ const WBResults = (props: Props) => {
4848
return (
4949
<div className={cx(styles.container)}>
5050
<div ref={scrollDivRef} />
51-
{items.map(({ command = '', isOpen = false, result = undefined, id = '', loading, createdAt, mode }) => (
51+
{items.map((
52+
{
53+
command = '',
54+
isOpen = false,
55+
result = undefined,
56+
id = '',
57+
loading,
58+
createdAt,
59+
mode,
60+
emptyCommand,
61+
}
62+
) => (
5263
<QueryCard
5364
id={id}
5465
key={id}
@@ -58,6 +69,7 @@ const WBResults = (props: Props) => {
5869
command={command}
5970
createdAt={createdAt}
6071
activeMode={activeMode}
72+
emptyCommand={emptyCommand}
6173
mode={mode}
6274
onQueryOpen={() => onQueryOpen(id)}
6375
onQueryReRun={() => onQueryReRun(command, null, false)}

redisinsight/ui/src/slices/interfaces/workbench.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export interface CommandExecutionUI extends Partial<CommandExecution> {
3939
loading?: boolean
4040
isOpen?: boolean
4141
error?: string
42+
emptyCommand: boolean
4243
}
4344

4445
export enum RunQueryMode {

redisinsight/ui/src/slices/tests/workbench/wb-results.spec.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { apiService } from 'uiSrc/services'
1111
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
1212
import { ClusterNodeRole, CommandExecutionStatus } from 'uiSrc/slices/interfaces/cli'
1313
import { SendClusterCommandDto } from 'apiSrc/modules/cli/dto/cli.dto'
14+
import { EMPTY_COMMAND } from 'uiSrc/constants'
1415
import reducer, {
1516
initialState,
1617
sendWBCommand,
@@ -205,6 +206,49 @@ describe('workbench results slice', () => {
205206
})
206207
})
207208

209+
describe('loadWBHistorySuccess', () => {
210+
it('should properly set history items', () => {
211+
// Arrange
212+
const mockCommandExecution = [{ mode: null, id: 'e3553f5a-0fdf-4282-8406-8b377c2060d2', databaseId: '3f795233-e26a-463b-a116-58cf620b18f2', command: 'get test', role: null, nodeOptions: null, createdAt: '2022-06-10T15:47:13.000Z', emptyCommand: false }]
213+
const state = {
214+
...initialStateWithItems,
215+
items: mockCommandExecution
216+
}
217+
218+
// Act
219+
const nextState = reducer(initialStateWithItems, loadWBHistorySuccess(mockCommandExecution))
220+
221+
// Assert
222+
const rootState = Object.assign(initialStateDefault, {
223+
workbench: {
224+
results: nextState,
225+
},
226+
})
227+
expect(workbenchResultsSelector(rootState)).toEqual(state)
228+
})
229+
230+
it(`if command=null should properly set history items with command=${EMPTY_COMMAND}`, () => {
231+
// Arrange
232+
const mockCommandExecution = [{ mode: null, id: 'e3553f5a-0fdf-4282-8406-8b377c2060d2', databaseId: '3f795233-e26a-463b-a116-58cf620b18f2', command: null, role: null, nodeOptions: null, createdAt: '2022-06-10T15:47:13.000Z' }]
233+
234+
const state = {
235+
...initialStateWithItems,
236+
items: [{ mode: null, id: 'e3553f5a-0fdf-4282-8406-8b377c2060d2', databaseId: '3f795233-e26a-463b-a116-58cf620b18f2', command: EMPTY_COMMAND, role: null, nodeOptions: null, createdAt: '2022-06-10T15:47:13.000Z', emptyCommand: true }]
237+
}
238+
239+
// Act
240+
const nextState = reducer(initialStateWithItems, loadWBHistorySuccess(mockCommandExecution))
241+
242+
// Assert
243+
const rootState = Object.assign(initialStateDefault, {
244+
workbench: {
245+
results: nextState,
246+
},
247+
})
248+
expect(workbenchResultsSelector(rootState)).toEqual(state)
249+
})
250+
})
251+
208252
describe('thunks', () => {
209253
describe('Standalone Cli command', () => {
210254
it('call both sendWBCommandAction and sendWBCommandSuccess when response status is successed', async () => {

redisinsight/ui/src/slices/workbench/wb-results.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createSlice } from '@reduxjs/toolkit'
22
import { AxiosError } from 'axios'
33
import { apiService } from 'uiSrc/services'
4-
import { ApiEndpoints } from 'uiSrc/constants'
4+
import { ApiEndpoints, EMPTY_COMMAND } from 'uiSrc/constants'
55
import { addErrorNotification } from 'uiSrc/slices/app/notifications'
66
import { CliOutputFormatterType } from 'uiSrc/constants/cliOutput'
77
import { RunQueryMode } from 'uiSrc/slices/interfaces/workbench'
@@ -40,7 +40,8 @@ const workbenchResultsSlice = createSlice({
4040
},
4141

4242
loadWBHistorySuccess: (state, { payload }:{ payload: CommandExecution[] }) => {
43-
state.items = payload
43+
state.items = payload.map((item) =>
44+
({ ...item, command: item.command || EMPTY_COMMAND, emptyCommand: !item.command }))
4445
state.loading = false
4546
},
4647

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { t } from 'testcafe';
2+
import { CliPage } from '../pageObjects';
3+
4+
const cliPage = new CliPage();
5+
6+
export class CliActions {
7+
8+
/**
9+
* Check list of commands searched
10+
* @param searchedCommand Searched command in Command Helper
11+
* @param listToCompare The list with commands to compare with opened in Command Helper
12+
*/
13+
async checkSearchedCommandInCommandHelper(searchedCommand: string, listToCompare: string[]): Promise<void> {
14+
await t.typeText(cliPage.cliHelperSearch, searchedCommand, { speed: 0.5 });
15+
//Verify results in the output
16+
const commandsCount = await cliPage.cliHelperOutputTitles.count;
17+
for (let i = 0; i < commandsCount; i++) {
18+
await t.expect(cliPage.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output contains searched value');
19+
}
20+
}
21+
22+
/**
23+
* Check commands list
24+
* @param listToCompare The list with commands to compare with opened in Command Helper
25+
*/
26+
async checkCommandsInCommandHelper(listToCompare: string[]): Promise<void> {
27+
//Verify results in the output
28+
const commandsCount = await cliPage.cliHelperOutputTitles.count;
29+
for (let i = 0; i < commandsCount; i++) {
30+
await t.expect(cliPage.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output not contain searched value');
31+
}
32+
}
33+
}

tests/e2e/pageObjects/cli-page.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class CliPage {
2727
commandHelperBadge = Selector('[data-testid=expand-command-helper] span');
2828
cliResizeButton = Selector('[data-test-subj=resize-btn-browser-cli]');
2929
workbenchLink = Selector('[data-test-subj=cli-workbench-page-btn]');
30+
returnToList = Selector('[data-testid=cli-helper-back-to-list-btn]');
3031
//TEXT INPUTS (also referred to as 'Text fields')
3132
cliCommandInput = Selector('[data-testid=cli-command]');
3233
cliArea = Selector('[data-testid=cli');
@@ -58,7 +59,7 @@ export class CliPage {
5859
* Select filter group type
5960
* @param groupName The group name
6061
*/
61-
async selectFilterGroupType(groupName: string): Promise<void>{
62+
async selectFilterGroupType(groupName: string): Promise<void> {
6263
await t.click(this.filterGroupTypeButton);
6364
await t.click(this.filterOptionGroupType.withExactText(groupName));
6465
}
@@ -69,7 +70,7 @@ export class CliPage {
6970
* @param amount The amount of the keys
7071
* @param keyName The name of the keys. The default value is keyName
7172
*/
72-
async addKeysFromCli(keyCommand: string, amount: number, keyName = 'keyName'): Promise<void>{
73+
async addKeysFromCli(keyCommand: string, amount: number, keyName = 'keyName'): Promise<void> {
7374
//Open CLI
7475
await t.click(this.cliExpandButton);
7576
//Add keys
@@ -83,7 +84,7 @@ export class CliPage {
8384
* Send command in Cli
8485
* @param command The command to send
8586
*/
86-
async sendCommandInCli(command: string): Promise<void>{
87+
async sendCommandInCli(command: string): Promise<void> {
8788
//Open CLI
8889
await t.click(this.cliExpandButton);
8990
await t.typeText(this.cliCommandInput, command, { paste: true });
@@ -95,7 +96,7 @@ export class CliPage {
9596
* Get command result execution
9697
* @param command The command for send in CLI
9798
*/
98-
async getSuccessCommandResultFromCli(command: string): Promise<string>{
99+
async getSuccessCommandResultFromCli(command: string): Promise<string> {
99100
//Open CLI
100101
await t.click(this.cliExpandButton);
101102
//Add keys
@@ -127,18 +128,4 @@ export class CliPage {
127128
await t.click(this.readMoreButton);
128129
await t.expect(getPageUrl()).eql(url, 'The opened page');
129130
}
130-
131-
/**
132-
* Check URL of command opened from command helper
133-
* @param searchedCommand Searched command in Command Helper
134-
* @param listToCompare The list with commands to compare with opened in Command Helper
135-
*/
136-
async checkSearchedCommandInCommandHelper(searchedCommand: string, listToCompare: string[]): Promise<void> {
137-
await t.typeText(this.cliHelperSearch, searchedCommand, { speed: 0.5 });
138-
//Verify results in the output
139-
const commandsCount = await this.cliHelperOutputTitles.count;
140-
for (let i = 0; i < commandsCount; i++) {
141-
await t.expect(this.cliHelperOutputTitles.nth(i).textContent).eql(listToCompare[i], 'Results in the output contains searched value');
142-
}
143-
}
144131
}

0 commit comments

Comments
 (0)