1
- import { ClipboardButton , Link as UIKitLink } from '@gravity-ui/uikit' ;
1
+ import React from 'react' ;
2
+
3
+ import { CircleInfo } from '@gravity-ui/icons' ;
4
+ import { Button , ClipboardButton , Icon , Popover , Link as UIKitLink } from '@gravity-ui/uikit' ;
2
5
3
6
import { EFlag } from '../../types/api/enums' ;
4
7
import { cn } from '../../utils/cn' ;
@@ -25,6 +28,7 @@ interface EntityStatusProps {
25
28
withLeftTrim ?: boolean ;
26
29
27
30
hasClipboardButton ?: boolean ;
31
+ infoPopoverContent ?: React . ReactNode ;
28
32
clipboardButtonAlwaysVisible ?: boolean ;
29
33
30
34
className ?: string ;
@@ -45,10 +49,13 @@ export function EntityStatus({
45
49
withLeftTrim = false ,
46
50
47
51
hasClipboardButton,
52
+ infoPopoverContent,
48
53
clipboardButtonAlwaysVisible = false ,
49
54
50
55
className,
51
56
} : EntityStatusProps ) {
57
+ const [ infoIconHovered , setInfoIconHovered ] = React . useState ( false ) ;
58
+
52
59
const renderIcon = ( ) => {
53
60
if ( ! showStatus ) {
54
61
return null ;
@@ -90,24 +97,51 @@ export function EntityStatus({
90
97
</ span >
91
98
) }
92
99
{ ( path || name ) && (
93
- < div className = { b ( 'wrapper' , { 'with-button' : hasClipboardButton } ) } >
100
+ < div
101
+ className = { b ( 'wrapper' , {
102
+ 'with-clipboard-button' : hasClipboardButton ,
103
+ 'with-info-button' : Boolean ( infoPopoverContent ) ,
104
+ } ) }
105
+ >
94
106
< span className = { b ( 'link' , { 'with-left-trim' : withLeftTrim } ) } title = { name } >
95
107
{ renderLink ( ) }
96
108
</ span >
97
- { hasClipboardButton && (
109
+ { ( hasClipboardButton || infoPopoverContent ) && (
98
110
< div
99
111
className = { b ( 'controls-wrapper' , {
100
- visible : clipboardButtonAlwaysVisible ,
112
+ visible : clipboardButtonAlwaysVisible || infoIconHovered ,
101
113
} ) }
102
114
>
103
- < ClipboardButton
104
- text = { name }
105
- size = "xs"
106
- view = "normal"
107
- className = { b ( 'clipboard-button' , {
108
- visible : clipboardButtonAlwaysVisible ,
109
- } ) }
110
- />
115
+ { infoPopoverContent && (
116
+ < Popover
117
+ className = { b ( 'info-popover' ) }
118
+ content = { infoPopoverContent }
119
+ tooltipOffset = { [ - 4 , 4 ] }
120
+ placement = { [ 'top-start' , 'bottom-start' ] }
121
+ onOpenChange = { ( visible ) => setInfoIconHovered ( visible ) }
122
+ >
123
+ < Button view = "normal" size = "xs" >
124
+ < Icon
125
+ data = { CircleInfo }
126
+ size = "12"
127
+ className = { b ( 'info-icon' , {
128
+ visible :
129
+ clipboardButtonAlwaysVisible || infoIconHovered ,
130
+ } ) }
131
+ />
132
+ </ Button >
133
+ </ Popover >
134
+ ) }
135
+ { hasClipboardButton && (
136
+ < ClipboardButton
137
+ text = { name }
138
+ size = "xs"
139
+ view = "normal"
140
+ className = { b ( 'clipboard-button' , {
141
+ visible : clipboardButtonAlwaysVisible || infoIconHovered ,
142
+ } ) }
143
+ />
144
+ ) }
111
145
</ div >
112
146
) }
113
147
</ div >
0 commit comments