Skip to content

Commit dbaaea2

Browse files
#RI-3822,3742,3788_fixed
1 parent ea0a70b commit dbaaea2

File tree

5 files changed

+59
-7
lines changed

5 files changed

+59
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const QueryCard = (props: Props) => {
179179
/>
180180
{isOpen && (
181181
<>
182-
{React.isValidElement(commonError)
182+
{React.isValidElement(commonError) && !isGroupMode(resultsMode)
183183
? <QueryCardCommonResult loading={loading} result={commonError} />
184184
: (
185185
<>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ const QueryCardHeader = (props: Props) => {
291291
<EuiFlexItem grow={false} className={styles.executionTime} data-testid="command-execution-time">
292292
{isNumber(executionTime) && (
293293
<EuiToolTip
294-
title="Execution Time"
294+
title="Processing Time"
295295
content={getExecutionTimeString(executionTime)}
296296
position="left"
297297
anchorClassName={cx(styles.tooltipIcon, styles.alignCenter)}

redisinsight/ui/src/pages/databaseAnalysis/components/top-namespace/TopNamespace.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EuiButton, EuiLink, EuiSwitch, EuiTitle } from '@elastic/eui'
22
import cx from 'classnames'
3+
import { isNull } from 'lodash'
34
import React, { useEffect, useState } from 'react'
45
import { useDispatch } from 'react-redux'
56
import { useHistory, useParams } from 'react-router-dom'
@@ -46,6 +47,10 @@ const TopNamespace = (props: Props) => {
4647
history.push(Pages.browser(instanceId))
4748
}
4849

50+
if (isNull(data)) {
51+
return null
52+
}
53+
4954
if (!data?.topMemoryNsp?.length && !data?.topKeysNsp?.length) {
5055
return (
5156
<div className={cx('section', styles.wrapper)} data-testid="top-namespaces-empty">

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

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import reducer, {
1717
sendWBCommand,
1818
sendWBCommandSuccess,
1919
processWBCommandFailure,
20+
processWBCommandsFailure,
2021
workbenchResultsSelector,
2122
sendWBCommandAction,
2223
sendWBCommandClusterAction,
@@ -207,6 +208,32 @@ describe('workbench results slice', () => {
207208
})
208209
})
209210

211+
describe('processWBCommandsFailure', () => {
212+
it('should properly remove from items', () => {
213+
// Arrange
214+
const data = 'error'
215+
const mockCommandExecution = {
216+
commandsId: [mockItemId + 0],
217+
error: data,
218+
}
219+
const state = {
220+
...initialStateWithItems,
221+
items: []
222+
}
223+
224+
// Act
225+
const nextState = reducer(initialStateWithItems, processWBCommandsFailure(mockCommandExecution))
226+
227+
// Assert
228+
const rootState = Object.assign(initialStateDefault, {
229+
workbench: {
230+
results: nextState,
231+
},
232+
})
233+
expect(workbenchResultsSelector(rootState)).toEqual(state)
234+
})
235+
})
236+
210237
describe('loadWBHistorySuccess', () => {
211238
it('should properly set history items', () => {
212239
// Arrange
@@ -323,7 +350,7 @@ describe('workbench results slice', () => {
323350
expect(clearStoreActions(store.getActions())).toEqual(clearStoreActions(expectedActions))
324351
})
325352

326-
it('call both sendWBCommandAction and processWBCommandFailure when fetch is fail', async () => {
353+
it('call both sendWBCommandAction and processWBCommandsFailure when fetch is fail', async () => {
327354
// Arrange
328355
const commands = ['keys *']
329356
const commandId = `${Date.now()}`
@@ -344,7 +371,10 @@ describe('workbench results slice', () => {
344371
const expectedActions = [
345372
sendWBCommand({ commands, commandId }),
346373
addErrorNotification(responsePayload as AxiosError),
347-
processWBCommandFailure({ id: commandId, error: responsePayload.response.data.message }),
374+
processWBCommandsFailure({
375+
commandsId: commands.map((_, i) => commandId + i),
376+
error: responsePayload.response.data.message
377+
}),
348378
]
349379
expect(clearStoreActions(store.getActions())).toEqual(clearStoreActions(expectedActions))
350380
})
@@ -438,7 +468,10 @@ describe('workbench results slice', () => {
438468
const expectedActions = [
439469
sendWBCommand({ commands, commandId }),
440470
addErrorNotification(responsePayload as AxiosError),
441-
processWBCommandFailure({ id: commandId, error: responsePayload.response.data.message }),
471+
processWBCommandsFailure({
472+
commandsId: commands.map((_, i) => commandId + i),
473+
error: responsePayload.response.data.message
474+
}),
442475
]
443476
expect(clearStoreActions(store.getActions())).toEqual(clearStoreActions(expectedActions))
444477
})

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ const workbenchResultsSlice = createSlice({
6363
})
6464
},
6565

66+
// temporary solution, need improve on BE how we handle errors
67+
processWBCommandsFailure: (state, { payload }: { payload: { commandsId: string[], error: string } }) => {
68+
state.items = [...state.items].filter((item) => payload.commandsId.indexOf(item?.id as string) === -1)
69+
state.loading = false
70+
state.processing = false
71+
},
72+
6673
processWBCommandFailure: (state, { payload }: { payload: { id: string, error: string } }) => {
6774
state.items = [...state.items].map((item) => {
6875
if (item.id === payload.id) {
@@ -155,6 +162,7 @@ export const {
155162
processWBCommand,
156163
fetchWBCommandSuccess,
157164
processWBCommandFailure,
165+
processWBCommandsFailure,
158166
sendWBCommand,
159167
sendWBCommandSuccess,
160168
toggleOpenWBResult,
@@ -242,7 +250,10 @@ export function sendWBCommandAction({
242250
const error = _err as AxiosError
243251
const errorMessage = getApiErrorMessage(error)
244252
dispatch(addErrorNotification(error))
245-
dispatch(processWBCommandFailure({ id: commandId, error: errorMessage }))
253+
dispatch(processWBCommandsFailure({
254+
commandsId: commands.map((_, i) => commandId + i),
255+
error: errorMessage
256+
}))
246257
onFailAction?.()
247258
}
248259
}
@@ -300,7 +311,10 @@ export function sendWBCommandClusterAction({
300311
const error = _err as AxiosError
301312
const errorMessage = getApiErrorMessage(error)
302313
dispatch(addErrorNotification(error))
303-
dispatch(processWBCommandFailure({ id: commandId, error: errorMessage }))
314+
dispatch(processWBCommandsFailure({
315+
commandsId: commands.map((_, i) => commandId + i),
316+
error: errorMessage
317+
}))
304318
onFailAction?.()
305319
}
306320
}

0 commit comments

Comments
 (0)