Skip to content

Commit 2ff0192

Browse files
Merge pull request #1179 from RedisInsight/fe/feature/RI-3493_Change_wording_no_keys
#RI-3493 - Change wording when there are no keys
2 parents 1c302d4 + f9b29e0 commit 2ff0192

File tree

4 files changed

+46
-6
lines changed

4 files changed

+46
-6
lines changed

redisinsight/ui/src/constants/texts.tsx

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
import React from 'react'
2-
import { EuiText, EuiSpacer } from '@elastic/eui'
2+
import { EuiText, EuiSpacer, EuiLink } from '@elastic/eui'
3+
4+
import { getRouterLinkProps } from 'uiSrc/services'
35

46
export const NoResultsFoundText = (<EuiText size="m">No results found.</EuiText>)
5-
export const NoKeysToDisplayText = (<EuiText size="m">No keys to display.</EuiText>)
7+
export const NoKeysToDisplayText = (path: string, onClick: ()=> void) => (
8+
<EuiText size="m">
9+
No keys to display.
10+
<br />
11+
<EuiLink
12+
{...getRouterLinkProps(path, onClick)}
13+
color="text"
14+
data-test-subj="pubsub-page-btn"
15+
>
16+
Use Workbench Guides and Tutorials
17+
</EuiLink>
18+
{' to quickly load the data.'}
19+
</EuiText>
20+
)
21+
622
export const FullScanNoResultsFoundText = (
723
<>
824
<EuiText size="m" data-test-subj="no-result-found">No results found.</EuiText>

redisinsight/ui/src/pages/browser/components/key-list/KeyList.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react'
1+
import React, { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import cx from 'classnames'
4+
import { useParams } from 'react-router-dom'
45

56
import {
67
EuiText,
@@ -39,8 +40,9 @@ import { SCAN_COUNT_DEFAULT } from 'uiSrc/constants/api'
3940
import { KeysStoreData, KeyViewType } from 'uiSrc/slices/interfaces/keys'
4041
import VirtualTable from 'uiSrc/components/virtual-table/VirtualTable'
4142
import { ITableColumn } from 'uiSrc/components/virtual-table/interfaces'
42-
import { OVER_RENDER_BUFFER_COUNT, TableCellAlignment, TableCellTextAlignment } from 'uiSrc/constants'
43+
import { OVER_RENDER_BUFFER_COUNT, Pages, TableCellAlignment, TableCellTextAlignment } from 'uiSrc/constants'
4344
import { IKeyPropTypes } from 'uiSrc/constants/prop-types/keys'
45+
import { getBasedOnViewTypeEvent, sendEventTelemetry, TelemetryEvent } from 'uiSrc/telemetry'
4446

4547
import { GetKeyInfoResponse } from 'apiSrc/modules/browser/dto'
4648
import styles from './styles.module.scss'
@@ -61,6 +63,8 @@ const KeyList = forwardRef((props: Props, ref) => {
6163
let wheelTimer = 0
6264
const { selectKey, loadMoreItems, loading, keysState, hideFooter } = props
6365

66+
const { instanceId = '' } = useParams<{ instanceId: string }>()
67+
6468
const { data: selectedKey } = useSelector(selectedKeySelector)
6569
const { total, nextCursor, previousResultCount } = useSelector(keysDataSelector)
6670
const { isSearched, isFiltered, viewType } = useSelector(keysSelector)
@@ -99,14 +103,30 @@ const KeyList = forwardRef((props: Props, ref) => {
99103
setItems(newKeys)
100104
}, [keysState.keys])
101105

106+
const onNoKeysLinkClick = () => {
107+
sendEventTelemetry({
108+
event: getBasedOnViewTypeEvent(
109+
viewType,
110+
TelemetryEvent.BROWSER_WORKBENCH_LINK_CLICKED,
111+
TelemetryEvent.TREE_VIEW_WORKBENCH_LINK_CLICKED
112+
),
113+
eventData: {
114+
databaseId: instanceId,
115+
}
116+
})
117+
}
118+
102119
const getNoItemsMessage = () => {
120+
if (total === 0) {
121+
return NoKeysToDisplayText(Pages.workbench(instanceId), onNoKeysLinkClick)
122+
}
103123
if (isSearched) {
104124
return keysState.scanned < total ? ScanNoResultsFoundText : FullScanNoResultsFoundText
105125
}
106126
if (isFiltered && keysState.scanned < total) {
107127
return ScanNoResultsFoundText
108128
}
109-
return total ? NoResultsFoundText : NoKeysToDisplayText
129+
return NoResultsFoundText
110130
}
111131

112132
const onLoadMoreItems = (props: { startIndex: number, stopIndex: number }) => {

redisinsight/ui/src/services/routing.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ export const registerRouter = (reactRouter: any): any => {
1010
router = reactRouter
1111
}
1212

13-
export const getRouterLinkProps = (to: any) => {
13+
export const getRouterLinkProps = (to: any, customOnClick?: () => void) => {
1414
const location = typeof to === 'string'
1515
? createLocation(to, null, '', router?.history?.location)
1616
: to
1717

1818
const href = router?.history?.createHref(location)
1919

2020
const onClick = (event: any) => {
21+
customOnClick?.()
22+
2123
if (event.defaultPrevented) {
2224
return
2325
}

redisinsight/ui/src/telemetry/events.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export enum TelemetryEvent {
6767
BROWSER_KEY_FIELD_VALUE_EXPANDED = 'BROWSER_KEY_FIELD_VALUE_EXPANDED',
6868
BROWSER_KEY_FIELD_VALUE_COLLAPSED = 'BROWSER_KEY_FIELD_VALUE_COLLAPSED',
6969
BROWSER_KEY_DETAILS_FORMATTER_CHANGED = 'BROWSER_KEY_DETAILS_FORMATTER_CHANGED',
70+
BROWSER_WORKBENCH_LINK_CLICKED = 'BROWSER_WORKBENCH_LINK_CLICKED',
7071

7172
CLI_OPENED = 'CLI_OPENED',
7273
CLI_CLOSED = 'CLI_CLOSED',
@@ -148,6 +149,7 @@ export enum TelemetryEvent {
148149
TREE_VIEW_KEY_FIELD_VALUE_EXPANDED = 'TREE_VIEW_KEY_FIELD_VALUE_EXPANDED',
149150
TREE_VIEW_KEY_FIELD_VALUE_COLLAPSED = 'TREE_VIEW_KEY_FIELD_VALUE_COLLAPSED',
150151
TREE_VIEW_KEY_DETAILS_FORMATTER_CHANGED = 'TREE_VIEW_KEY_DETAILS_FORMATTER_CHANGED',
152+
TREE_VIEW_WORKBENCH_LINK_CLICKED = 'TREE_VIEW_WORKBENCH_LINK_CLICKED',
151153

152154
SLOWLOG_LOADED = 'SLOWLOG_LOADED',
153155
SLOWLOG_CLEARED = 'SLOWLOG_CLEARED',

0 commit comments

Comments
 (0)