File tree Expand file tree Collapse file tree 4 files changed +31
-4
lines changed
redisinsight/ui/src/pages/browser/components Expand file tree Collapse file tree 4 files changed +31
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import KeyDetailsWrapper from 'uiSrc/pages/browser/components/key-details/KeyDet
10
10
11
11
import { updateBrowserTreeSelectedLeaf } from 'uiSrc/slices/app/context'
12
12
import {
13
+ keysDataSelector ,
13
14
keysSelector ,
14
15
selectedKeyDataSelector ,
15
16
toggleBrowserFullScreen
@@ -45,6 +46,7 @@ const BrowserRightPanel = (props: Props) => {
45
46
} = props
46
47
47
48
const { isBrowserFullScreen, viewType } = useSelector ( keysSelector )
49
+ const { total } = useSelector ( keysDataSelector )
48
50
const { type, length } = useSelector ( selectedKeyDataSelector ) ?? { type : '' , length : 0 }
49
51
50
52
const { instanceId } = useParams < { instanceId : string } > ( )
@@ -116,6 +118,7 @@ const BrowserRightPanel = (props: Props) => {
116
118
onCloseKey = { closePanel }
117
119
onEditKey = { onEditKey }
118
120
onRemoveKey = { onSelectKey }
121
+ totalKeys = { total }
119
122
/>
120
123
) }
121
124
{ isAddKeyPanelOpen && every ( [ ! isBulkActionsPanelOpen , ! isCreateIndexPanelOpen ] , Boolean ) && (
Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
import { instance , mock } from 'ts-mockito'
3
- import { render } from 'uiSrc/utils/test-utils'
3
+ import { render , screen } from 'uiSrc/utils/test-utils'
4
4
import KeyDetails , { Props } from './KeyDetails'
5
5
6
6
const mockedProps = mock < Props > ( )
@@ -9,4 +9,16 @@ describe('KeyDetails', () => {
9
9
it ( 'should render' , ( ) => {
10
10
expect ( render ( < KeyDetails { ...instance ( mockedProps ) } /> ) ) . toBeTruthy ( )
11
11
} )
12
+
13
+ it ( 'should render explore-guides when there are no keys' , ( ) => {
14
+ render ( < KeyDetails { ...instance ( mockedProps ) } totalKeys = { 0 } /> )
15
+
16
+ expect ( screen . getByTestId ( 'explore-guides' ) ) . toBeInTheDocument ( )
17
+ } )
18
+
19
+ it ( 'should render proper message when there are keys' , ( ) => {
20
+ render ( < KeyDetails { ...instance ( mockedProps ) } totalKeys = { 10 } /> )
21
+
22
+ expect ( screen . getByTestId ( 'select-key-message' ) ) . toBeInTheDocument ( )
23
+ } )
12
24
} )
Original file line number Diff line number Diff line change @@ -55,10 +55,11 @@ export interface Props {
55
55
onRemoveKey : ( ) => void
56
56
onEditTTL : ( key : RedisResponseBuffer , ttl : number ) => void
57
57
onEditKey : ( key : RedisResponseBuffer , newKey : RedisResponseBuffer , onFailure ?: ( ) => void ) => void
58
+ totalKeys : number
58
59
}
59
60
60
61
const KeyDetails = ( { ...props } : Props ) => {
61
- const { onClosePanel, onRemoveKey } = props
62
+ const { onClosePanel, onRemoveKey, totalKeys } = props
62
63
const { loading, error = '' , data } = useSelector ( selectedKeySelector )
63
64
const { type : selectedKeyType , name : selectedKey } = useSelector ( selectedKeyDataSelector ) ?? {
64
65
type : KeyTypes . String ,
@@ -168,7 +169,15 @@ const KeyDetails = ({ ...props }: Props) => {
168
169
< p data-testid = "no-keys-selected-text" >
169
170
{ error }
170
171
</ p >
171
- ) : ( < ExploreGuides /> ) }
172
+ ) : (
173
+ < >
174
+ { totalKeys > 0 ? (
175
+ < span data-testid = "select-key-message" >
176
+ Select the key from the list on the left to see the details of the key.
177
+ </ span >
178
+ ) : ( < ExploreGuides /> ) }
179
+ </ >
180
+ ) }
172
181
</ EuiText >
173
182
</ div >
174
183
</ >
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export interface Props {
33
33
onEditKey : ( key : RedisResponseBuffer , newKey : RedisResponseBuffer ) => void
34
34
onRemoveKey : ( ) => void
35
35
keyProp : RedisResponseBuffer | null
36
+ totalKeys : number
36
37
}
37
38
38
39
const KeyDetailsWrapper = ( props : Props ) => {
@@ -43,7 +44,8 @@ const KeyDetailsWrapper = (props: Props) => {
43
44
onCloseKey,
44
45
onEditKey,
45
46
onRemoveKey,
46
- keyProp
47
+ keyProp,
48
+ totalKeys
47
49
} = props
48
50
49
51
const { instanceId } = useParams < { instanceId : string } > ( )
@@ -155,6 +157,7 @@ const KeyDetailsWrapper = (props: Props) => {
155
157
onRemoveKey = { onRemoveKey }
156
158
onEditTTL = { handleEditTTL }
157
159
onEditKey = { handleEditKey }
160
+ totalKeys = { totalKeys }
158
161
/>
159
162
)
160
163
}
You can’t perform that action at this time.
0 commit comments