11import { useSuspendedBackendaiClient } from '../hooks' ;
2+ import { useVFolderInvitations } from '../hooks/backendai' ;
23import { useSuspenseTanQuery } from '../hooks/reactQueryAlias' ;
34import { useCurrentProjectValue } from '../hooks/useCurrentProject' ;
45import BAICard , { BAICardProps } from './BAICard' ;
56import BAIPanelItem from './BAIPanelItem' ;
67import { StorageStatusPanelCardQuery } from './__generated__/StorageStatusPanelCardQuery.graphql' ;
7- import { Col , Row , theme } from 'antd' ;
8+ import { Badge , Col , Row , theme , Tooltip , Typography } from 'antd' ;
9+ import { createStyles } from 'antd-style' ;
810import graphql from 'babel-plugin-relay/macro' ;
911import _ from 'lodash' ;
1012import React , { useDeferredValue } from 'react' ;
1113import { useTranslation } from 'react-i18next' ;
1214import { useLazyLoadQuery } from 'react-relay' ;
1315
16+ const useStyles = createStyles ( ( { css, token } ) => ( {
17+ invitationTooltip : css `
18+ .ant-tooltip-arrow {
19+ right: -${ token . sizeXS } px;
20+ bottom: ${ token . sizeXS } px;
21+ }
22+ .ant-tooltip-content {
23+ left: ${ token . size } px;
24+ bottom: ${ token . sizeXS } px;
25+ }
26+ ` ,
27+ } ) ) ;
28+
1429interface StorageStatusPanelProps extends BAICardProps {
1530 fetchKey ?: string ;
1631}
@@ -21,9 +36,11 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
2136} ) => {
2237 const { t } = useTranslation ( ) ;
2338 const { token } = theme . useToken ( ) ;
39+ const { styles } = useStyles ( ) ;
2440 const baiClient = useSuspendedBackendaiClient ( ) ;
2541 const currentProject = useCurrentProjectValue ( ) ;
2642 const deferredFetchKey = useDeferredValue ( fetchKey ) ;
43+ const [ { count } ] = useVFolderInvitations ( ) ;
2744
2845 const isExcludedCount = ( status : string ) => {
2946 return _ . includes (
@@ -38,7 +55,6 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
3855 return baiClient . vfolder . list ( currentProject ?. id ) ;
3956 } ,
4057 } ) ;
41-
4258 // FIXME: vfolder_node query does not provide a information about the vfolder's owner.
4359 // So, even if we use fragment, we still need to filter the vfolders by each conditions in client side.
4460 const createdCount = vfolders ?. filter (
@@ -118,7 +134,42 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
118134 justifyItems : 'center' ,
119135 } }
120136 >
121- < BAIPanelItem title = { t ( 'data.InvitedFolders' ) } value = { invitedCount } />
137+ < BAIPanelItem
138+ title = {
139+ // Add a tag to the Tooltip to make it clickable
140+ // eslint-disable-next-line
141+ < a >
142+ < Tooltip
143+ title = {
144+ count > 0
145+ ? t ( 'data.InvitedFoldersTooltip' , {
146+ count : count ,
147+ } )
148+ : null
149+ }
150+ rootClassName = { styles . invitationTooltip }
151+ placement = "topRight"
152+ >
153+ < Badge count = { count > 0 ? `+${ count } ` : null } >
154+ < Typography . Title level = { 5 } style = { { margin : 0 } } >
155+ { t ( 'data.InvitedFolders' ) }
156+ </ Typography . Title >
157+ </ Badge >
158+ </ Tooltip >
159+ </ a >
160+ }
161+ value = {
162+ < Typography . Text
163+ strong
164+ style = { {
165+ fontSize : token . fontSizeHeading1 ,
166+ color : token . Layout ?. headerBg ,
167+ } }
168+ >
169+ { invitedCount }
170+ </ Typography . Text >
171+ }
172+ />
122173 </ Col >
123174 </ Row >
124175 </ BAICard >
0 commit comments