Skip to content

Commit 4841c7a

Browse files
#RI-4608 - remove GRAPH commands from command helper
1 parent 9c37388 commit 4841c7a

File tree

7 files changed

+68
-18
lines changed

7 files changed

+68
-18
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 not since 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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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 = removeDeprecatedModuleCommands(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/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: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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,16 @@ const getCommandNameFromQuery = (
221218
}
222219
}
223220

221+
const DEPRECATED_MODULES_PREFIXES = [
222+
ModuleCommandPrefix.Graph
223+
]
224+
225+
const checkDeprecatedModuleCommand = (command: string) =>
226+
DEPRECATED_MODULES_PREFIXES.some((prefix) => command.startsWith(prefix))
227+
228+
const removeDeprecatedModuleCommands = (commands: string[]) => commands
229+
.filter((command) => !checkDeprecatedModuleCommand(command))
230+
224231
export {
225232
cliParseTextResponse,
226233
cliParseTextResponseWithOffset,
@@ -239,4 +246,6 @@ export {
239246
getCommandNameFromQuery,
240247
wbSummaryCommand,
241248
replaceEmptyValue,
249+
removeDeprecatedModuleCommands,
250+
checkDeprecatedModuleCommand,
242251
}

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import {
99
checkUnsupportedCommand,
1010
checkBlockingCommand,
1111
replaceEmptyValue,
12+
removeDeprecatedModuleCommands,
13+
checkDeprecatedModuleCommand,
1214
} from 'uiSrc/utils'
1315
import { MOCK_COMMANDS_SPEC } from 'uiSrc/constants'
1416
import { render, screen } from 'uiSrc/utils/test-utils'
@@ -89,7 +91,6 @@ const checkCommandModuleTests = [
8991
{ input: 'FT.foo bar', expected: RedisDefaultModules.Search },
9092
{ input: 'JSON.foo bar', expected: RedisDefaultModules.ReJSON },
9193
{ input: 'TS.foo bar', expected: RedisDefaultModules.TimeSeries },
92-
{ input: 'GRAPH.foo bar', expected: RedisDefaultModules.Graph },
9394
{ input: 'BF.foo bar', expected: RedisDefaultModules.Bloom },
9495
{ input: 'CF.foo bar', expected: RedisDefaultModules.Bloom },
9596
{ input: 'CMS.foo bar', expected: RedisDefaultModules.Bloom },
@@ -110,6 +111,19 @@ const checkBlockingCommandTests = [
110111
{ input: [['foo', 'bar'], 'FT.foo bar'], expected: undefined },
111112
]
112113

114+
const checkDeprecatedModuleCommandTests = [
115+
{ input: 'FT.foo bar', expected: false },
116+
{ input: 'GRAPH foo bar', expected: false },
117+
{ input: 'GRAPH.foo bar', expected: true },
118+
{ input: 'FOO bar', expected: false },
119+
]
120+
121+
const removeDeprecatedModuleCommandsTests = [
122+
{ input: ['FT.foo'], expected: ['FT.foo'] },
123+
{ input: ['GRAPH.foo', 'FT.foo'], expected: ['FT.foo'] },
124+
{ input: ['FOO', 'GRAPH.FOO', 'CF.FOO', 'GRAPH.BAR'], expected: ['FOO', 'CF.FOO'] },
125+
]
126+
113127
describe('getCommandNameFromQuery', () => {
114128
test.each(getCommandNameFromQueryTests)('%j', ({ input, expected }) => {
115129
// @ts-ignore
@@ -185,3 +199,15 @@ describe('checkBlockingCommand', () => {
185199
expect(checkBlockingCommand(...input)).toEqual(expected)
186200
})
187201
})
202+
203+
describe('checkDeprecatedModuleCommand', () => {
204+
test.each(checkDeprecatedModuleCommandTests)('%j', ({ input, expected }) => {
205+
expect(checkDeprecatedModuleCommand(input)).toEqual(expected)
206+
})
207+
})
208+
209+
describe('removeDeprecatedModuleCommands', () => {
210+
test.each(removeDeprecatedModuleCommandsTests)('%j', ({ input, expected }) => {
211+
expect(removeDeprecatedModuleCommands(input)).toEqual(expected)
212+
})
213+
})

0 commit comments

Comments
 (0)