1- import { ButtonDomRef , FlexBox , Icon , ResponsivePopover , Text } from '@ui5/webcomponents-react' ;
1+ import { Button , ButtonDomRef , FlexBox , Icon , ResponsivePopover , Text } from '@ui5/webcomponents-react' ;
22import { formatDateAsTimeAgo } from '../../utils/i18n/timeAgo' ;
33import { useRef , useState } from 'react' ;
44import { AnimatedHoverTextButton } from '../Helper/AnimatedHoverTextButton.tsx' ;
@@ -10,16 +10,19 @@ export interface ResourceStatusCellProps {
1010 message ?: string ;
1111 positiveText : string ;
1212 negativeText : string ;
13+ hideOnHoverEffect ?: boolean ;
1314}
1415export const ResourceStatusCell = ( {
1516 isOk,
1617 transitionTime,
1718 message,
1819 positiveText,
1920 negativeText,
21+ hideOnHoverEffect,
2022} : ResourceStatusCellProps ) => {
2123 const btnRef = useRef < ButtonDomRef > ( null ) ;
2224 const [ popoverIsOpen , setPopoverIsOpen ] = useState ( false ) ;
25+ const timeAgo = transitionTime ? formatDateAsTimeAgo ( transitionTime ) : '-' ;
2326
2427 const handleClose = ( ) => {
2528 setPopoverIsOpen ( false ) ;
@@ -29,19 +32,31 @@ export const ResourceStatusCell = ({
2932 } ;
3033 return (
3134 < span >
32- < AnimatedHoverTextButton
33- ref = { btnRef }
34- icon = {
35+ { hideOnHoverEffect ? (
36+ < Button ref = { btnRef } design = "Transparent" title = { timeAgo } aria-label = { timeAgo } onClick = { handleOpen } >
3537 < Icon
3638 design = { isOk ? 'Positive' : 'Negative' }
3739 name = { isOk ? 'sys-enter-2' : 'sys-cancel-2' }
3840 showTooltip = { true }
39- accessibleName = { transitionTime ? formatDateAsTimeAgo ( transitionTime ) : '-' }
41+ accessibleName = { timeAgo }
4042 />
41- }
42- text = { isOk ? positiveText : negativeText }
43- onClick = { handleOpen }
44- />
43+ </ Button >
44+ ) : (
45+ < AnimatedHoverTextButton
46+ ref = { btnRef }
47+ icon = {
48+ < Icon
49+ design = { isOk ? 'Positive' : 'Negative' }
50+ name = { isOk ? 'sys-enter-2' : 'sys-cancel-2' }
51+ showTooltip = { true }
52+ accessibleName = { timeAgo }
53+ />
54+ }
55+ text = { isOk ? positiveText : negativeText }
56+ onClick = { handleOpen }
57+ />
58+ ) }
59+
4560 < ResponsivePopover
4661 opener = { btnRef . current ?? undefined }
4762 open = { popoverIsOpen }
@@ -64,7 +79,7 @@ export const ResourceStatusCell = ({
6479 color : isOk ? 'var(--sapPositiveTextColor)' : 'var(--sapNegativeTextColor)' ,
6580 } }
6681 >
67- { formatDateAsTimeAgo ( transitionTime ) }
82+ { timeAgo }
6883 </ Text >
6984 </ FlexBox >
7085 </ ResponsivePopover >
0 commit comments