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 . size } px;
21+ }
22+ .ant-tooltip-content {
23+ left: ${ token . size } px;
24+ bottom: ${ token . size } 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,51 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
118134 justifyItems : 'center' ,
119135 } }
120136 >
121- < BAIPanelItem title = { t ( 'data.InvitedFolders' ) } value = { invitedCount } />
137+ < BAIPanelItem
138+ title = {
139+ count > 0 ? (
140+ // Add a tag to the Tooltip to make it clickable
141+ // eslint-disable-next-line
142+ < a >
143+ < Tooltip
144+ title = {
145+ count > 0
146+ ? t ( 'data.InvitedFoldersTooltip' , {
147+ count : count ,
148+ } )
149+ : null
150+ }
151+ rootClassName = { styles . invitationTooltip }
152+ placement = "topRight"
153+ >
154+ < Badge
155+ count = { count > 0 ? `+${ count } ` : null }
156+ offset = { [ 0 , - `${ token . sizeXS } ` ] }
157+ >
158+ < Typography . Title level = { 5 } style = { { margin : 0 } } >
159+ { t ( 'data.InvitedFolders' ) }
160+ </ Typography . Title >
161+ </ Badge >
162+ </ Tooltip >
163+ </ a >
164+ ) : (
165+ < Typography . Title level = { 5 } style = { { margin : 0 } } >
166+ { t ( 'data.InvitedFolders' ) }
167+ </ Typography . Title >
168+ )
169+ }
170+ value = {
171+ < Typography . Text
172+ strong
173+ style = { {
174+ fontSize : token . fontSizeHeading1 ,
175+ color : token . Layout ?. headerBg ,
176+ } }
177+ >
178+ { invitedCount }
179+ </ Typography . Text >
180+ }
181+ />
122182 </ Col >
123183 </ Row >
124184 </ BAICard >
0 commit comments