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
1010
1111import { updateBrowserTreeSelectedLeaf } from 'uiSrc/slices/app/context'
1212import {
13+ keysDataSelector ,
1314 keysSelector ,
1415 selectedKeyDataSelector ,
1516 toggleBrowserFullScreen
@@ -45,6 +46,7 @@ const BrowserRightPanel = (props: Props) => {
4546 } = props
4647
4748 const { isBrowserFullScreen, viewType } = useSelector ( keysSelector )
49+ const { total } = useSelector ( keysDataSelector )
4850 const { type, length } = useSelector ( selectedKeyDataSelector ) ?? { type : '' , length : 0 }
4951
5052 const { instanceId } = useParams < { instanceId : string } > ( )
@@ -116,6 +118,7 @@ const BrowserRightPanel = (props: Props) => {
116118 onCloseKey = { closePanel }
117119 onEditKey = { onEditKey }
118120 onRemoveKey = { onSelectKey }
121+ totalKeys = { total }
119122 />
120123 ) }
121124 { isAddKeyPanelOpen && every ( [ ! isBulkActionsPanelOpen , ! isCreateIndexPanelOpen ] , Boolean ) && (
Original file line number Diff line number Diff line change 11import React from 'react'
22import { instance , mock } from 'ts-mockito'
3- import { render } from 'uiSrc/utils/test-utils'
3+ import { render , screen } from 'uiSrc/utils/test-utils'
44import KeyDetails , { Props } from './KeyDetails'
55
66const mockedProps = mock < Props > ( )
@@ -9,4 +9,16 @@ describe('KeyDetails', () => {
99 it ( 'should render' , ( ) => {
1010 expect ( render ( < KeyDetails { ...instance ( mockedProps ) } /> ) ) . toBeTruthy ( )
1111 } )
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+ } )
1224} )
Original file line number Diff line number Diff line change @@ -55,10 +55,11 @@ export interface Props {
5555 onRemoveKey : ( ) => void
5656 onEditTTL : ( key : RedisResponseBuffer , ttl : number ) => void
5757 onEditKey : ( key : RedisResponseBuffer , newKey : RedisResponseBuffer , onFailure ?: ( ) => void ) => void
58+ totalKeys : number
5859}
5960
6061const KeyDetails = ( { ...props } : Props ) => {
61- const { onClosePanel, onRemoveKey } = props
62+ const { onClosePanel, onRemoveKey, totalKeys } = props
6263 const { loading, error = '' , data } = useSelector ( selectedKeySelector )
6364 const { type : selectedKeyType , name : selectedKey } = useSelector ( selectedKeyDataSelector ) ?? {
6465 type : KeyTypes . String ,
@@ -168,7 +169,15 @@ const KeyDetails = ({ ...props }: Props) => {
168169 < p data-testid = "no-keys-selected-text" >
169170 { error }
170171 </ 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+ ) }
172181 </ EuiText >
173182 </ div >
174183 </ >
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export interface Props {
3333 onEditKey : ( key : RedisResponseBuffer , newKey : RedisResponseBuffer ) => void
3434 onRemoveKey : ( ) => void
3535 keyProp : RedisResponseBuffer | null
36+ totalKeys : number
3637}
3738
3839const KeyDetailsWrapper = ( props : Props ) => {
@@ -43,7 +44,8 @@ const KeyDetailsWrapper = (props: Props) => {
4344 onCloseKey,
4445 onEditKey,
4546 onRemoveKey,
46- keyProp
47+ keyProp,
48+ totalKeys
4749 } = props
4850
4951 const { instanceId } = useParams < { instanceId : string } > ( )
@@ -155,6 +157,7 @@ const KeyDetailsWrapper = (props: Props) => {
155157 onRemoveKey = { onRemoveKey }
156158 onEditTTL = { handleEditTTL }
157159 onEditKey = { handleEditKey }
160+ totalKeys = { totalKeys }
158161 />
159162 )
160163}
You can’t perform that action at this time.
0 commit comments