Skip to content

Commit 1155f84

Browse files
authored
Merge pull request #2503 from RedisInsight/fe/bugfix/RI-4879
#RI-4879 - fix explore guides message showing
2 parents 5e7b734 + 5665d16 commit 1155f84

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

redisinsight/ui/src/pages/browser/components/browser-right-panel/BrowserRightPanel.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import KeyDetailsWrapper from 'uiSrc/pages/browser/components/key-details/KeyDet
1010

1111
import { updateBrowserTreeSelectedLeaf } from 'uiSrc/slices/app/context'
1212
import {
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) && (
Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { instance, mock } from 'ts-mockito'
3-
import { render } from 'uiSrc/utils/test-utils'
3+
import { render, screen } from 'uiSrc/utils/test-utils'
44
import KeyDetails, { Props } from './KeyDetails'
55

66
const 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
})

redisinsight/ui/src/pages/browser/components/key-details/KeyDetails/KeyDetails.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff 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

6061
const 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
</>

redisinsight/ui/src/pages/browser/components/key-details/KeyDetailsWrapper.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff 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

3839
const 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
}

0 commit comments

Comments
 (0)