1
1
import {
2
2
Criteria ,
3
+ EuiButtonEmpty ,
3
4
EuiButtonIcon ,
4
5
EuiIcon ,
5
6
EuiLink ,
7
+ EuiPopover ,
6
8
EuiResizeObserver ,
7
9
EuiTableFieldDataColumnType ,
8
10
EuiText ,
@@ -23,16 +25,16 @@ import RediStackLightMin from 'uiSrc/assets/img/modules/redistack/RediStackLight
23
25
import RediStackDarkLogo from 'uiSrc/assets/img/modules/redistack/RedisStackLogoDark.svg'
24
26
import RediStackLightLogo from 'uiSrc/assets/img/modules/redistack/RedisStackLogoLight.svg'
25
27
import CloudLinkIcon from 'uiSrc/assets/img/oauth/cloud_link.svg?react'
28
+ import ThreeDots from 'uiSrc/assets/img/icons/three_dots.svg?react'
26
29
import DatabaseListModules from 'uiSrc/components/database-list-modules/DatabaseListModules'
27
30
import ItemList from 'uiSrc/components/item-list'
28
31
import { BrowserStorageItem , DEFAULT_SORT , FeatureFlags , Pages , Theme } from 'uiSrc/constants'
29
32
import { EXTERNAL_LINKS } from 'uiSrc/constants/links'
30
33
import { ThemeContext } from 'uiSrc/contexts/themeContext'
31
34
import PopoverDelete from 'uiSrc/pages/browser/components/popover-delete/PopoverDelete'
32
35
import { 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
+
36
38
import {
37
39
checkConnectToInstanceAction ,
38
40
deleteInstancesAction ,
@@ -100,6 +102,12 @@ const DatabasesListWrapper = (props: Props) => {
100
102
)
101
103
102
104
const deletingIdRef = useRef ( '' )
105
+ const controlsOpenIdRef = useRef ( '' )
106
+
107
+ const toggleControlsPopover = ( instanceId : string ) => {
108
+ controlsOpenIdRef . current = controlsOpenIdRef . current === instanceId ? '' : instanceId
109
+ forceRerender ( { } )
110
+ }
103
111
104
112
const closePopover = ( ) => {
105
113
if ( deletingIdRef . current ) {
@@ -270,6 +278,15 @@ const DatabasesListWrapper = (props: Props) => {
270
278
'data-testid' : `db-row_${ instance ?. id } `
271
279
} )
272
280
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
+
273
290
const columns : EuiTableFieldDataColumnType < Instance > [ ] = [
274
291
{
275
292
field : 'name' ,
@@ -450,26 +467,46 @@ const DatabasesListWrapper = (props: Props) => {
450
467
</ EuiToolTip >
451
468
) }
452
469
< 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 >
473
510
</ FeatureFlagComponent >
474
511
</ >
475
512
)
0 commit comments