Skip to content

Commit fd75f61

Browse files
authored
Merge pull request #2294 from RedisInsight/feature/RI-4608_redisgraph_commands
#RI-4608 - remove GRAPH commands from command helper
2 parents a334c31 + 43d60d9 commit fd75f61

File tree

9 files changed

+118
-22
lines changed

9 files changed

+118
-22
lines changed

redisinsight/ui/src/components/command-helper/CommandHelperWrapper.spec.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,21 @@ describe('CliBodyWrapper', () => {
193193
unmount()
194194
})
195195
})
196+
197+
it('should render default message when matched command is deprecated', () => {
198+
const sinceId = 'cli-helper-since'
199+
const cliHelperDefaultId = 'cli-helper-default'
200+
201+
cliSettingsSelector.mockImplementation(() => ({
202+
matchedCommand: 'GRAPH.CONFIG SET',
203+
isEnteringCommand: true,
204+
}))
205+
206+
const { unmount, queryByTestId } = render(<CommandHelperWrapper />)
207+
208+
expect(queryByTestId(cliHelperDefaultId)).toBeInTheDocument()
209+
expect(queryByTestId(sinceId)).not.toBeInTheDocument()
210+
211+
unmount()
212+
})
196213
})

redisinsight/ui/src/components/command-helper/CommandHelperWrapper.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { EuiBadge, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'
2-
import React, { ReactElement, useEffect } from 'react'
2+
import React, { ReactElement, useEffect, useMemo } from 'react'
33
import { useSelector } from 'react-redux'
44
import { useParams } from 'react-router-dom'
55

@@ -11,7 +11,13 @@ import {
1111
import { sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
1212
import { cliSettingsSelector } from 'uiSrc/slices/cli/cli-settings'
1313
import { appRedisCommandsSelector } from 'uiSrc/slices/app/redis-commands'
14-
import { generateArgs, generateArgsNames, getComplexityShortNotation } from 'uiSrc/utils'
14+
import {
15+
generateArgs,
16+
generateArgsNames,
17+
getComplexityShortNotation,
18+
removeDeprecatedModuleCommands,
19+
checkDeprecatedModuleCommand,
20+
} from 'uiSrc/utils'
1521
import CommandHelper from './CommandHelper'
1622
import CommandHelperHeader from './CommandHelperHeader'
1723

@@ -26,9 +32,12 @@ const CommandHelperWrapper = () => {
2632
searchingCommand,
2733
searchingCommandFilter
2834
} = useSelector(cliSettingsSelector)
29-
const { spec: ALL_REDIS_COMMANDS, commandsArray: KEYS_OF_COMMANDS } = useSelector(appRedisCommandsSelector)
35+
const { spec: ALL_REDIS_COMMANDS, commandsArray } = useSelector(appRedisCommandsSelector)
3036
const { instanceId = '' } = useParams<{ instanceId: string }>()
31-
const lastMatchedCommand = (isEnteringCommand && matchedCommand) ? matchedCommand : searchedCommand
37+
const lastMatchedCommand = (isEnteringCommand && matchedCommand && !checkDeprecatedModuleCommand(matchedCommand))
38+
? matchedCommand
39+
: searchedCommand
40+
const KEYS_OF_COMMANDS = useMemo(() => removeDeprecatedModuleCommands(commandsArray), [commandsArray])
3241
let searchedCommands: string[] = []
3342

3443
useEffect(() => {

redisinsight/ui/src/constants/keys.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const GROUP_TYPES_DISPLAY = Object.freeze({
2727
[KeyTypes.ReJSON]: 'JSON',
2828
[KeyTypes.JSON]: 'JSON',
2929
[KeyTypes.Stream]: 'Stream',
30-
[ModulesKeyTypes.Graph]: 'Graph',
3130
[ModulesKeyTypes.TimeSeries]: 'TS',
3231
[CommandGroup.Bitmap]: 'Bitmap',
3332
[CommandGroup.Cluster]: 'Cluster',

redisinsight/ui/src/constants/workbenchResults.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@ export const MODULE_NOT_LOADED_CONTENT: { [key in RedisDefaultModules]?: any } =
2424
additionalText: ['These features enable multi-field queries, aggregation, exact phrase matching, numeric filtering, ', 'geo filtering and vector similarity semantic search on top of text queries.'],
2525
link: 'https://redis.io/docs/stack/search/'
2626
},
27-
[RedisDefaultModules.Graph]: {
28-
text: ['RedisGraph adds a Property Graph data structure to Redis. ', 'With this capability you can:'],
29-
improvements: [
30-
'Create graphs',
31-
'Query property graphs using the Cypher query language with proprietary extensions'
32-
],
33-
link: 'https://redis.io/docs/stack/graph/'
34-
},
3527
[RedisDefaultModules.ReJSON]: {
3628
text: ['RedisJSON adds the capability to:'],
3729
improvements: [
@@ -58,7 +50,6 @@ export const MODULE_NOT_LOADED_CONTENT: { [key in RedisDefaultModules]?: any } =
5850

5951
export const MODULE_TEXT_VIEW: { [key in RedisDefaultModules]?: string } = {
6052
[RedisDefaultModules.Bloom]: 'RedisBloom',
61-
[RedisDefaultModules.Graph]: 'RedisGraph',
6253
[RedisDefaultModules.ReJSON]: 'RedisJSON',
6354
[RedisDefaultModules.Search]: 'RediSearch',
6455
[RedisDefaultModules.TimeSeries]: 'RedisTimeSeries',

redisinsight/ui/src/slices/app/redis-commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { createSlice } from '@reduxjs/toolkit'
22
import { isString, uniqBy } from 'lodash'
33
import { apiService } from 'uiSrc/services'
44
import { ApiEndpoints, ICommand, ICommands } from 'uiSrc/constants'
5-
import { getApiErrorMessage, isStatusSuccessful } from 'uiSrc/utils'
5+
import { getApiErrorMessage, isStatusSuccessful, checkDeprecatedCommandGroup } from 'uiSrc/utils'
66
import { GetServerInfoResponse } from 'apiSrc/modules/server/dto/server.dto'
77

88
import { AppDispatch, RootState } from '../store'
@@ -31,6 +31,7 @@ const appRedisCommandsSlice = createSlice({
3131
state.commandGroups = uniqBy(Object.values(payload), 'group')
3232
.map((item: ICommand) => item.group)
3333
.filter((group: string) => isString(group))
34+
.filter((group: string) => !checkDeprecatedCommandGroup(group))
3435
},
3536
getRedisCommandsFailure: (state, { payload }) => {
3637
state.loading = false

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ export const COMMAND_MODULES = {
183183
[RedisDefaultModules.Search]: REDISEARCH_MODULES,
184184
[RedisDefaultModules.ReJSON]: [RedisDefaultModules.ReJSON],
185185
[RedisDefaultModules.TimeSeries]: [RedisDefaultModules.TimeSeries],
186-
[RedisDefaultModules.Graph]: [RedisDefaultModules.Graph],
187186
[RedisDefaultModules.Bloom]: [RedisDefaultModules.Bloom],
188187
}
189188

redisinsight/ui/src/utils/cliHelper.tsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { isUndefined } from 'lodash'
66
import { localStorageService } from 'uiSrc/services'
77
import { CommandExecutionStatus } from 'uiSrc/slices/interfaces/cli'
88
import { resetOutput, updateCliCommandHistory } from 'uiSrc/slices/cli/cli-output'
9-
import { BrowserStorageItem, ICommands } from 'uiSrc/constants'
9+
import { BrowserStorageItem, ICommands, CommandGroup } from 'uiSrc/constants'
1010
import { ModuleCommandPrefix } from 'uiSrc/pages/workbench/constants'
1111
import { SelectCommand } from 'uiSrc/constants/cliOutput'
1212
import {
@@ -162,9 +162,6 @@ const checkCommandModule = (command: string) => {
162162
case command.startsWith(ModuleCommandPrefix.TimeSeries): {
163163
return RedisDefaultModules.TimeSeries
164164
}
165-
case command.startsWith(ModuleCommandPrefix.Graph): {
166-
return RedisDefaultModules.Graph
167-
}
168165
case command.startsWith(ModuleCommandPrefix.BF):
169166
case command.startsWith(ModuleCommandPrefix.CF):
170167
case command.startsWith(ModuleCommandPrefix.CMS):
@@ -221,6 +218,23 @@ const getCommandNameFromQuery = (
221218
}
222219
}
223220

221+
const DEPRECATED_MODULE_PREFIXES = [
222+
ModuleCommandPrefix.Graph
223+
]
224+
225+
const DEPRECATED_MODULE_GROUPS = [
226+
CommandGroup.Graph
227+
]
228+
229+
const checkDeprecatedModuleCommand = (command: string) =>
230+
DEPRECATED_MODULE_PREFIXES.some((prefix) => command.startsWith(prefix))
231+
232+
const checkDeprecatedCommandGroup = (item: string) =>
233+
DEPRECATED_MODULE_GROUPS.some((group) => group === item)
234+
235+
const removeDeprecatedModuleCommands = (commands: string[]) => commands
236+
.filter((command) => !checkDeprecatedModuleCommand(command))
237+
224238
export {
225239
cliParseTextResponse,
226240
cliParseTextResponseWithOffset,
@@ -239,4 +253,7 @@ export {
239253
getCommandNameFromQuery,
240254
wbSummaryCommand,
241255
replaceEmptyValue,
256+
removeDeprecatedModuleCommands,
257+
checkDeprecatedModuleCommand,
258+
checkDeprecatedCommandGroup,
242259
}

redisinsight/ui/src/utils/tests/cliHelper.spec.ts

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import {
99
checkUnsupportedCommand,
1010
checkBlockingCommand,
1111
replaceEmptyValue,
12+
removeDeprecatedModuleCommands,
13+
checkDeprecatedModuleCommand,
14+
checkDeprecatedCommandGroup,
1215
} from 'uiSrc/utils'
1316
import { MOCK_COMMANDS_SPEC } from 'uiSrc/constants'
1417
import { render, screen } from 'uiSrc/utils/test-utils'
@@ -89,7 +92,6 @@ const checkCommandModuleTests = [
8992
{ input: 'FT.foo bar', expected: RedisDefaultModules.Search },
9093
{ input: 'JSON.foo bar', expected: RedisDefaultModules.ReJSON },
9194
{ input: 'TS.foo bar', expected: RedisDefaultModules.TimeSeries },
92-
{ input: 'GRAPH.foo bar', expected: RedisDefaultModules.Graph },
9395
{ input: 'BF.foo bar', expected: RedisDefaultModules.Bloom },
9496
{ input: 'CF.foo bar', expected: RedisDefaultModules.Bloom },
9597
{ input: 'CMS.foo bar', expected: RedisDefaultModules.Bloom },
@@ -110,6 +112,48 @@ const checkBlockingCommandTests = [
110112
{ input: [['foo', 'bar'], 'FT.foo bar'], expected: undefined },
111113
]
112114

115+
const checkDeprecatedModuleCommandTests = [
116+
{ input: 'FT.foo bar', expected: false },
117+
{ input: 'GRAPH foo bar', expected: false },
118+
{ input: 'GRAPH.foo bar', expected: true },
119+
{ input: 'FOO bar', expected: false },
120+
]
121+
122+
const removeDeprecatedModuleCommandsTests = [
123+
{ input: ['FT.foo'], expected: ['FT.foo'] },
124+
{ input: ['GRAPH.foo', 'FT.foo'], expected: ['FT.foo'] },
125+
{ input: ['FOO', 'GRAPH.FOO', 'CF.FOO', 'GRAPH.BAR'], expected: ['FOO', 'CF.FOO'] },
126+
]
127+
128+
const checkDeprecatedCommandGroupTests = [
129+
{ input: 'cluster', expected: false },
130+
{ input: 'connection', expected: false },
131+
{ input: 'geo', expected: false },
132+
{ input: 'bitmap', expected: false },
133+
{ input: 'generic', expected: false },
134+
{ input: 'pubsub', expected: false },
135+
{ input: 'scripting', expected: false },
136+
{ input: 'transactions', expected: false },
137+
{ input: 'server', expected: false },
138+
{ input: 'sorted-set', expected: false },
139+
{ input: 'hyperloglog', expected: false },
140+
{ input: 'hash', expected: false },
141+
{ input: 'set', expected: false },
142+
{ input: 'stream', expected: false },
143+
{ input: 'list', expected: false },
144+
{ input: 'string', expected: false },
145+
{ input: 'search', expected: false },
146+
{ input: 'json', expected: false },
147+
{ input: 'timeseries', expected: false },
148+
{ input: 'graph', expected: true },
149+
{ input: 'ai', expected: false },
150+
{ input: 'tdigest', expected: false },
151+
{ input: 'cms', expected: false },
152+
{ input: 'topk', expected: false },
153+
{ input: 'bf', expected: false },
154+
{ input: 'cf', expected: false },
155+
]
156+
113157
describe('getCommandNameFromQuery', () => {
114158
test.each(getCommandNameFromQueryTests)('%j', ({ input, expected }) => {
115159
// @ts-ignore
@@ -185,3 +229,21 @@ describe('checkBlockingCommand', () => {
185229
expect(checkBlockingCommand(...input)).toEqual(expected)
186230
})
187231
})
232+
233+
describe('checkDeprecatedModuleCommand', () => {
234+
test.each(checkDeprecatedModuleCommandTests)('%j', ({ input, expected }) => {
235+
expect(checkDeprecatedModuleCommand(input)).toEqual(expected)
236+
})
237+
})
238+
239+
describe('removeDeprecatedModuleCommands', () => {
240+
test.each(removeDeprecatedModuleCommandsTests)('%j', ({ input, expected }) => {
241+
expect(removeDeprecatedModuleCommands(input)).toEqual(expected)
242+
})
243+
})
244+
245+
describe('checkDeprecatedCommandGroup', () => {
246+
test.each(checkDeprecatedCommandGroupTests)('%j', ({ input, expected }) => {
247+
expect(checkDeprecatedCommandGroup(input)).toEqual(expected)
248+
})
249+
})

tests/e2e/tests/critical-path/cli/cli-command-helper.e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ test
9696
// await browserPage.CommandHelper.checkURLCommand(timeSeriesCommands[0], `https://redis.io/commands/${timeSeriesCommands[0].toLowerCase()}/`);
9797
// await t.switchToParentWindow();
9898
});
99-
test
99+
// outdated after https://redislabs.atlassian.net/browse/RI-4608
100+
test.skip
100101
.meta({ env: env.web })('Verify that user can type GRAPH. in Command helper and see auto-suggestions from RedisGraph commands.json', async t => {
101102
const commandForSearch = 'GRAPH.';
102103
// const externalPageLink = 'https://redis.io/commands/graph.config-get/';

0 commit comments

Comments
 (0)