11import {
22 Criteria ,
3+ EuiButtonEmpty ,
34 EuiButtonIcon ,
45 EuiIcon ,
56 EuiLink ,
7+ EuiPopover ,
68 EuiResizeObserver ,
79 EuiTableFieldDataColumnType ,
810 EuiText ,
@@ -23,16 +25,16 @@ import RediStackLightMin from 'uiSrc/assets/img/modules/redistack/RediStackLight
2325import RediStackDarkLogo from 'uiSrc/assets/img/modules/redistack/RedisStackLogoDark.svg'
2426import RediStackLightLogo from 'uiSrc/assets/img/modules/redistack/RedisStackLogoLight.svg'
2527import CloudLinkIcon from 'uiSrc/assets/img/oauth/cloud_link.svg?react'
28+ import ThreeDots from 'uiSrc/assets/img/icons/three_dots.svg?react'
2629import DatabaseListModules from 'uiSrc/components/database-list-modules/DatabaseListModules'
2730import ItemList from 'uiSrc/components/item-list'
2831import { BrowserStorageItem , DEFAULT_SORT , FeatureFlags , Pages , Theme } from 'uiSrc/constants'
2932import { EXTERNAL_LINKS } from 'uiSrc/constants/links'
3033import { ThemeContext } from 'uiSrc/contexts/themeContext'
3134import PopoverDelete from 'uiSrc/pages/browser/components/popover-delete/PopoverDelete'
3235import { localStorageService } from 'uiSrc/services'
33- import { appContextSelector , resetRdiContext , setAppContextInitialState } from 'uiSrc/slices/app/context'
34- import { resetKeys } from 'uiSrc/slices/browser/keys'
35- import { resetRedisearchKeysData } from 'uiSrc/slices/browser/redisearch'
36+ import { appContextSelector , resetRdiContext } from 'uiSrc/slices/app/context'
37+
3638import {
3739 checkConnectToInstanceAction ,
3840 deleteInstancesAction ,
@@ -100,6 +102,12 @@ const DatabasesListWrapper = (props: Props) => {
100102 )
101103
102104 const deletingIdRef = useRef ( '' )
105+ const controlsOpenIdRef = useRef ( '' )
106+
107+ const toggleControlsPopover = ( instanceId : string ) => {
108+ controlsOpenIdRef . current = controlsOpenIdRef . current === instanceId ? '' : instanceId
109+ forceRerender ( { } )
110+ }
103111
104112 const closePopover = ( ) => {
105113 if ( deletingIdRef . current ) {
@@ -270,6 +278,15 @@ const DatabasesListWrapper = (props: Props) => {
270278 'data-testid' : `db-row_${ instance ?. id } `
271279 } )
272280
281+ const controlsButton = ( instanceId : string ) => (
282+ < EuiButtonIcon
283+ iconType = { ThreeDots }
284+ aria-label = "Controls icon"
285+ data-testid = { `controls-button-${ instanceId } ` }
286+ onClick = { ( ) => toggleControlsPopover ( instanceId ) }
287+ />
288+ )
289+
273290 const columns : EuiTableFieldDataColumnType < Instance > [ ] = [
274291 {
275292 field : 'name' ,
@@ -450,26 +467,46 @@ const DatabasesListWrapper = (props: Props) => {
450467 </ EuiToolTip >
451468 ) }
452469 < FeatureFlagComponent name = { FeatureFlags . databaseManagement } >
453- < EuiButtonIcon
454- iconType = "pencil"
455- className = "editInstanceBtn"
456- aria-label = "Edit instance"
457- data-testid = { `edit-instance-${ instance . id } ` }
458- onClick = { ( ) => handleClickEditInstance ( instance ) }
459- />
460- < PopoverDelete
461- header = { formatLongName ( instance . name , 50 , 10 , '...' ) }
462- text = "will be removed from Redis Insight."
463- item = { instance . id }
464- suffix = { suffix }
465- deleting = { deletingIdRef . current }
466- closePopover = { closePopover }
467- updateLoading = { false }
468- showPopover = { showPopover }
469- handleDeleteItem = { ( ) => handleDeleteInstance ( instance ) }
470- handleButtonClick = { ( ) => handleClickDeleteInstance ( instance ) }
471- testid = { `delete-instance-${ instance . id } ` }
472- />
470+ < EuiPopover
471+ ownFocus
472+ initialFocus = { false }
473+ anchorPosition = 'leftUp'
474+ isOpen = { controlsOpenIdRef . current === instance . id }
475+ closePopover = { ( ) => toggleControlsPopover ( '' ) }
476+ panelPaddingSize = "s"
477+ button = { controlsButton ( instance . id ) }
478+ data-testid = { `controls-popover-${ instance . id } ` }
479+ >
480+ < div className = "controlsPopoverContent" >
481+ < div >
482+ < EuiButtonEmpty
483+ iconType = "pencil"
484+ className = "editInstanceBtn"
485+ aria-label = "Edit instance"
486+ data-testid = { `edit-instance-${ instance . id } ` }
487+ onClick = { ( ) => handleClickEditInstance ( instance ) }
488+ >
489+ Edit database
490+ </ EuiButtonEmpty >
491+ </ div >
492+ < div >
493+ < PopoverDelete
494+ header = { formatLongName ( instance . name , 50 , 10 , '...' ) }
495+ text = "will be removed from Redis Insight."
496+ item = { instance . id }
497+ suffix = { suffix }
498+ deleting = { deletingIdRef . current }
499+ closePopover = { closePopover }
500+ updateLoading = { false }
501+ showPopover = { showPopover }
502+ handleDeleteItem = { ( ) => handleDeleteInstance ( instance ) }
503+ handleButtonClick = { ( ) => handleClickDeleteInstance ( instance ) }
504+ testid = { `delete-instance-${ instance . id } ` }
505+ buttonLabel = "Remove database"
506+ />
507+ </ div >
508+ </ div >
509+ </ EuiPopover >
473510 </ FeatureFlagComponent >
474511 </ >
475512 )
0 commit comments