1
- import React , { forwardRef , useCallback , useEffect , useImperativeHandle , useLayoutEffect , useRef , useState } from 'react'
1
+ import React , { forwardRef , useCallback , useEffect , useImperativeHandle , useRef , useState } from 'react'
2
2
import { useDispatch , useSelector } from 'react-redux'
3
3
import cx from 'classnames'
4
+ import { useParams } from 'react-router-dom'
4
5
5
6
import {
6
7
EuiText ,
@@ -39,8 +40,9 @@ import { SCAN_COUNT_DEFAULT } from 'uiSrc/constants/api'
39
40
import { KeysStoreData , KeyViewType } from 'uiSrc/slices/interfaces/keys'
40
41
import VirtualTable from 'uiSrc/components/virtual-table/VirtualTable'
41
42
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'
43
44
import { IKeyPropTypes } from 'uiSrc/constants/prop-types/keys'
45
+ import { getBasedOnViewTypeEvent , sendEventTelemetry , TelemetryEvent } from 'uiSrc/telemetry'
44
46
45
47
import { GetKeyInfoResponse } from 'apiSrc/modules/browser/dto'
46
48
import styles from './styles.module.scss'
@@ -61,6 +63,8 @@ const KeyList = forwardRef((props: Props, ref) => {
61
63
let wheelTimer = 0
62
64
const { selectKey, loadMoreItems, loading, keysState, hideFooter } = props
63
65
66
+ const { instanceId = '' } = useParams < { instanceId : string } > ( )
67
+
64
68
const { data : selectedKey } = useSelector ( selectedKeySelector )
65
69
const { total, nextCursor, previousResultCount } = useSelector ( keysDataSelector )
66
70
const { isSearched, isFiltered, viewType } = useSelector ( keysSelector )
@@ -99,14 +103,30 @@ const KeyList = forwardRef((props: Props, ref) => {
99
103
setItems ( newKeys )
100
104
} , [ keysState . keys ] )
101
105
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
+
102
119
const getNoItemsMessage = ( ) => {
120
+ if ( total === 0 ) {
121
+ return NoKeysToDisplayText ( Pages . workbench ( instanceId ) , onNoKeysLinkClick )
122
+ }
103
123
if ( isSearched ) {
104
124
return keysState . scanned < total ? ScanNoResultsFoundText : FullScanNoResultsFoundText
105
125
}
106
126
if ( isFiltered && keysState . scanned < total ) {
107
127
return ScanNoResultsFoundText
108
128
}
109
- return total ? NoResultsFoundText : NoKeysToDisplayText
129
+ return NoResultsFoundText
110
130
}
111
131
112
132
const onLoadMoreItems = ( props : { startIndex : number , stopIndex : number } ) => {
0 commit comments