Skip to content

Commit b830c6c

Browse files
#RI-4608 - remove deprecated command groups
1 parent 8aa08a4 commit b830c6c

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

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/utils/cliHelper.tsx

Lines changed: 11 additions & 3 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 {
@@ -218,12 +218,19 @@ const getCommandNameFromQuery = (
218218
}
219219
}
220220

221-
const DEPRECATED_MODULES_PREFIXES = [
221+
const DEPRECATED_MODULE_PREFIXES = [
222222
ModuleCommandPrefix.Graph
223223
]
224224

225+
const DEPRECATED_MODULE_GROUPS = [
226+
CommandGroup.Graph
227+
]
228+
225229
const checkDeprecatedModuleCommand = (command: string) =>
226-
DEPRECATED_MODULES_PREFIXES.some((prefix) => command.startsWith(prefix))
230+
DEPRECATED_MODULE_PREFIXES.some((prefix) => command.startsWith(prefix))
231+
232+
const checkDeprecatedCommandGroup = (item: string) =>
233+
DEPRECATED_MODULE_GROUPS.some((group) => group === item)
227234

228235
const removeDeprecatedModuleCommands = (commands: string[]) => commands
229236
.filter((command) => !checkDeprecatedModuleCommand(command))
@@ -248,4 +255,5 @@ export {
248255
replaceEmptyValue,
249256
removeDeprecatedModuleCommands,
250257
checkDeprecatedModuleCommand,
258+
checkDeprecatedCommandGroup,
251259
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
replaceEmptyValue,
1212
removeDeprecatedModuleCommands,
1313
checkDeprecatedModuleCommand,
14+
checkDeprecatedCommandGroup,
1415
} from 'uiSrc/utils'
1516
import { MOCK_COMMANDS_SPEC } from 'uiSrc/constants'
1617
import { render, screen } from 'uiSrc/utils/test-utils'
@@ -124,6 +125,35 @@ const removeDeprecatedModuleCommandsTests = [
124125
{ input: ['FOO', 'GRAPH.FOO', 'CF.FOO', 'GRAPH.BAR'], expected: ['FOO', 'CF.FOO'] },
125126
]
126127

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+
127157
describe('getCommandNameFromQuery', () => {
128158
test.each(getCommandNameFromQueryTests)('%j', ({ input, expected }) => {
129159
// @ts-ignore
@@ -211,3 +241,9 @@ describe('removeDeprecatedModuleCommands', () => {
211241
expect(removeDeprecatedModuleCommands(input)).toEqual(expected)
212242
})
213243
})
244+
245+
describe('checkDeprecatedCommandGroup', () => {
246+
test.each(checkDeprecatedCommandGroupTests)('%j', ({ input, expected }) => {
247+
expect(checkDeprecatedCommandGroup(input)).toEqual(expected)
248+
})
249+
})

0 commit comments

Comments
 (0)