Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion redisinsight/ui/src/components/query/QueryWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const QueryWrapper = (props: Props) => {
const command = [commandLine, multiCommands].join('') ? [commandLine, multiCommands].join(';') : null

return {
command,
command: command?.toUpperCase(),
databaseId: instanceId,
multiple: multiCommands ? 'Multiple' : 'Single',
pipeline: batchSize > 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,14 @@ const BrowserLeftPanel = (props: Props) => {
const { loading: patternLoading, viewType, searchMode, isSearched: patternIsSearched } = useSelector(keysSelector)
const { contextInstanceId } = useSelector(appContextSelector)
const {
keyList: { isDataLoaded, scrollPatternTopPosition, scrollRedisearchTopPosition }
keyList: { isDataPatternLoaded, isDataRedisearchLoaded, scrollPatternTopPosition, scrollRedisearchTopPosition }
} = useSelector(appContextBrowser)

const keyListRef = useRef<any>()

const dispatch = useDispatch()

const isDataLoaded = searchMode === SearchMode.Pattern ? isDataPatternLoaded : isDataRedisearchLoaded
const keysState = searchMode === SearchMode.Pattern ? patternKeysState : redisearchKeysState
const loading = searchMode === SearchMode.Pattern ? patternLoading : redisearchLoading || redisearchListLoading
const isSearched = searchMode === SearchMode.Pattern ? patternIsSearched : redisearchIsSearched
Expand All @@ -79,8 +80,8 @@ const BrowserLeftPanel = (props: Props) => {
searchMode,
'0',
keyViewType === KeyViewType.Browser ? SCAN_COUNT_DEFAULT : SCAN_TREE_COUNT_DEFAULT,
() => dispatch(setBrowserKeyListDataLoaded(true)),
() => dispatch(setBrowserKeyListDataLoaded(false))
() => dispatch(setBrowserKeyListDataLoaded(searchMode, true)),
() => dispatch(setBrowserKeyListDataLoaded(searchMode, false))
))
}, [searchMode])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
fetchKeysMetadata,
keysDataSelector,
keysSelector,
resetKeysData,
selectedKeySelector,
setLastBatchKeys,
sourceKeysFetch,
Expand Down Expand Up @@ -117,6 +118,7 @@ const KeyList = forwardRef((props: Props, ref) => {
if (itemsRef.current.length === 0) {
cancelAllMetadataRequests()
setFirstDataLoaded(true)
dispatch(resetKeysData(searchMode))
rerender({})
return
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ const KeysHeader = (props: Props) => {
searchMode,
'0',
viewType === KeyViewType.Browser ? SCAN_COUNT_DEFAULT : SCAN_TREE_COUNT_DEFAULT,
() => dispatch(setBrowserKeyListDataLoaded(true)),
() => dispatch(setBrowserKeyListDataLoaded(false)),
() => dispatch(setBrowserKeyListDataLoaded(searchMode, true)),
() => dispatch(setBrowserKeyListDataLoaded(searchMode, false)),
))
}

Expand Down Expand Up @@ -229,11 +229,14 @@ const KeysHeader = (props: Props) => {
}
})
}
dispatch(resetKeysData(searchMode))
dispatch(changeKeyViewType(type))
dispatch(resetBrowserTree())
dispatch(resetKeysData(searchMode))
localStorageService.set(BrowserStorageItem.browserViewType, type)
loadKeys(type)

setTimeout(() => {
dispatch(changeKeyViewType(type))
}, 0)
}

const handleSwitchSearchMode = (mode: SearchMode) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const Table = (props: Props) => {
SearchMode.Pattern,
'0',
viewType === KeyViewType.Browser ? SCAN_COUNT_DEFAULT : SCAN_TREE_COUNT_DEFAULT,
() => dispatch(setBrowserKeyListDataLoaded(true)),
() => dispatch(setBrowserKeyListDataLoaded(false)),
() => dispatch(setBrowserKeyListDataLoaded(SearchMode.Pattern, true)),
() => dispatch(setBrowserKeyListDataLoaded(SearchMode.Pattern, false)),
))
dispatch(resetBrowserTree())
dispatch(setBrowserSelectedKey(stringToBuffer(name)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ const NameSpacesTable = (props: Props) => {
SearchMode.Pattern,
'0',
viewType === KeyViewType.Browser ? SCAN_COUNT_DEFAULT : SCAN_TREE_COUNT_DEFAULT,
() => dispatch(setBrowserKeyListDataLoaded(true)),
() => dispatch(setBrowserKeyListDataLoaded(false)),
() => dispatch(setBrowserKeyListDataLoaded(SearchMode.Pattern, true)),
() => dispatch(setBrowserKeyListDataLoaded(SearchMode.Pattern, false)),
))
dispatch(resetBrowserTree())
history.push(Pages.browser(instanceId))
Expand Down
4 changes: 2 additions & 2 deletions redisinsight/ui/src/pages/workbench/WorkbenchPage.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe('Telemetry', () => {
expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.WORKBENCH_COMMAND_SUBMITTED,
eventData: {
command: 'info;',
command: 'info;'.toUpperCase(),
databaseId: INSTANCE_ID_MOCK,
group: false,
multiple: 'Single',
Expand Down Expand Up @@ -205,7 +205,7 @@ describe('Telemetry', () => {
expect(sendEventTelemetry).toBeCalledWith({
event: TelemetryEvent.WORKBENCH_COMMAND_SUBMITTED,
eventData: {
command: 'info;',
command: 'info;'.toUpperCase(),
databaseId: INSTANCE_ID_MOCK,
group: false,
multiple: 'Single',
Expand Down
24 changes: 20 additions & 4 deletions redisinsight/ui/src/slices/app/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { BrowserStorageItem, DEFAULT_DELIMITER, KeyTypes } from 'uiSrc/constants
import { localStorageService } from 'uiSrc/services'
import { RootState } from '../store'
import { RedisResponseBuffer, StateAppContext } from '../interfaces'
import { SearchMode } from '../interfaces/keys'

export const initialState: StateAppContext = {
contextInstanceId: '',
lastPage: '',
browser: {
keyList: {
isDataLoaded: false,
isDataPatternLoaded: false,
isDataRedisearchLoaded: false,
scrollPatternTopPosition: 0,
scrollRedisearchTopPosition: 0,
isNotRendered: true,
Expand Down Expand Up @@ -73,8 +75,11 @@ const appContextSlice = createSlice({
setBrowserSelectedKey: (state, { payload }: { payload: Nullable<RedisResponseBuffer> }) => {
state.browser.keyList.selectedKey = payload
},
setBrowserKeyListDataLoaded: (state, { payload }: { payload: boolean }) => {
state.browser.keyList.isDataLoaded = payload
setBrowserPatternKeyListDataLoaded: (state, { payload }: { payload: boolean }) => {
state.browser.keyList.isDataPatternLoaded = payload
},
setBrowserRedisearchKeyListDataLoaded: (state, { payload }: { payload: boolean }) => {
state.browser.keyList.isDataRedisearchLoaded = payload
},
setBrowserPatternScrollPosition: (state, { payload }: { payload: number }) => {
state.browser.keyList.scrollPatternTopPosition = payload
Expand Down Expand Up @@ -176,7 +181,8 @@ const appContextSlice = createSlice({
export const {
setAppContextInitialState,
setAppContextConnectedInstanceId,
setBrowserKeyListDataLoaded,
setBrowserPatternKeyListDataLoaded,
setBrowserRedisearchKeyListDataLoaded,
setBrowserSelectedKey,
setBrowserPatternScrollPosition,
setBrowserRedisearchScrollPosition,
Expand Down Expand Up @@ -222,3 +228,13 @@ export const appContextAnalytics = (state: RootState) =>

// The reducer
export default appContextSlice.reducer

// Asynchronous thunk action
export function setBrowserKeyListDataLoaded(
searchMode: SearchMode,
value: boolean,
) {
return searchMode === SearchMode.Pattern
? setBrowserPatternKeyListDataLoaded(value)
: setBrowserRedisearchKeyListDataLoaded(value)
}
2 changes: 2 additions & 0 deletions redisinsight/ui/src/slices/browser/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ const keysSlice = createSlice({

resetPatternKeysData: (state) => {
// state.data.keys = []
state.data.total = 0
state.data.scanned = 0
state.data.keys.length = 0
},

Expand Down
2 changes: 2 additions & 0 deletions redisinsight/ui/src/slices/browser/redisearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ const redisearchSlice = createSlice({
},

resetRedisearchKeysData: (state) => {
state.data.total = 0
state.data.scanned = 0
state.data.keys.length = 0
},

Expand Down
3 changes: 2 additions & 1 deletion redisinsight/ui/src/slices/interfaces/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export interface StateAppContext {
lastPage: string
browser: {
keyList: {
isDataLoaded: boolean
isDataPatternLoaded: boolean
isDataRedisearchLoaded: boolean
scrollPatternTopPosition: number
scrollRedisearchTopPosition: number
isNotRendered: boolean
Expand Down
35 changes: 30 additions & 5 deletions redisinsight/ui/src/slices/tests/app/context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import reducer, {
initialState,
setAppContextInitialState,
setAppContextConnectedInstanceId,
setBrowserKeyListDataLoaded,
setBrowserPatternKeyListDataLoaded,
setBrowserRedisearchKeyListDataLoaded,
setBrowserSelectedKey,
setBrowserPatternScrollPosition,
setBrowserPanelSizes,
Expand Down Expand Up @@ -126,20 +127,44 @@ describe('slices', () => {
})
})

describe('setBrowserKeyListDataLoaded', () => {
describe('setBrowserPatternKeyListDataLoaded', () => {
it('should properly set context is data loaded', () => {
// Arrange
const isDataLoaded = true
const isDataPatternLoaded = true
const state = {
...initialState.browser,
keyList: {
...initialState.browser.keyList,
isDataLoaded
isDataPatternLoaded
}
}

// Act
const nextState = reducer(initialState, setBrowserKeyListDataLoaded(isDataLoaded))
const nextState = reducer(initialState, setBrowserPatternKeyListDataLoaded(isDataPatternLoaded))

// Assert
const rootState = Object.assign(initialStateDefault, {
app: { context: nextState },
})

expect(appContextBrowser(rootState)).toEqual(state)
})
})

describe('setBrowserRedisearchKeyListDataLoaded', () => {
it('should properly set context is data loaded', () => {
// Arrange
const isDataRedisearchLoaded = true
const state = {
...initialState.browser,
keyList: {
...initialState.browser.keyList,
isDataRedisearchLoaded
}
}

// Act
const nextState = reducer(initialState, setBrowserRedisearchKeyListDataLoaded(isDataRedisearchLoaded))

// Assert
const rootState = Object.assign(initialStateDefault, {
Expand Down