@@ -28,10 +28,12 @@ const useStyles = createStyles(({ css, token }) => ({
2828
2929interface StorageStatusPanelProps extends BAICardProps {
3030 fetchKey ?: string ;
31+ onRequestBadgeClick ?: ( ) => void ;
3132}
3233
3334const StorageStatusPanelCard : React . FC < StorageStatusPanelProps > = ( {
3435 fetchKey,
36+ onRequestBadgeClick,
3537 ...cardProps
3638} ) => {
3739 const { t } = useTranslation ( ) ;
@@ -40,7 +42,7 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
4042 const baiClient = useSuspendedBackendaiClient ( ) ;
4143 const currentProject = useCurrentProjectValue ( ) ;
4244 const deferredFetchKey = useDeferredValue ( fetchKey ) ;
43- const [ { count } ] = useVFolderInvitations ( ) ;
45+ const [ { count } ] = useVFolderInvitations ( deferredFetchKey ) ;
4446
4547 const isExcludedCount = ( status : string ) => {
4648 return _ . includes (
@@ -50,7 +52,7 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
5052 } ;
5153
5254 const { data : vfolders } = useSuspenseTanQuery ( {
53- queryKey : [ 'vfolders' , { deferredFetchKey } ] ,
55+ queryKey : [ 'vfolders' , { deferredFetchKey, id : currentProject ?. id } ] ,
5456 queryFn : ( ) => {
5557 return baiClient . vfolder . list ( currentProject ?. id ) ;
5658 } ,
@@ -92,96 +94,102 @@ const StorageStatusPanelCard: React.FC<StorageStatusPanelProps> = ({
9294 ) ;
9395
9496 return (
95- < BAICard { ...cardProps } title = { t ( 'data.StorageStatus' ) } >
96- < Row gutter = { [ 24 , 16 ] } >
97- < Col
98- span = { 8 }
99- style = { {
100- borderRight : `1px solid ${ token . colorBorderSecondary } ` ,
101- justifyItems : 'center' ,
102- } }
103- >
104- < BAIPanelItem
105- title = { t ( 'data.MyFolders' ) }
106- value = { createdCount }
107- unit = {
108- user_resource_policy ?. max_vfolder_count
109- ? `/ ${ user_resource_policy ?. max_vfolder_count } `
110- : undefined
111- }
112- />
113- </ Col >
114- < Col
115- span = { 8 }
116- style = { {
117- borderRight : `1px solid ${ token . colorBorderSecondary } ` ,
118- justifyItems : 'center' ,
119- } }
120- >
121- < BAIPanelItem
122- title = { t ( 'data.ProjectFolders' ) }
123- value = { projectCount }
124- unit = {
125- project_resource_policy ?. max_vfolder_count
126- ? `/ ${ project_resource_policy ?. max_vfolder_count } `
127- : undefined
128- }
129- />
130- </ Col >
131- < Col
132- span = { 8 }
133- style = { {
134- justifyItems : 'center' ,
135- } }
136- >
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"
97+ < >
98+ < BAICard { ...cardProps } title = { t ( 'data.StorageStatus' ) } >
99+ < Row gutter = { [ 24 , 16 ] } >
100+ < Col
101+ span = { 8 }
102+ style = { {
103+ borderRight : `1px solid ${ token . colorBorderSecondary } ` ,
104+ justifyItems : 'center' ,
105+ } }
106+ >
107+ < BAIPanelItem
108+ title = { t ( 'data.MyFolders' ) }
109+ value = { createdCount }
110+ unit = {
111+ user_resource_policy ?. max_vfolder_count
112+ ? `/ ${ user_resource_policy ?. max_vfolder_count } `
113+ : undefined
114+ }
115+ />
116+ </ Col >
117+ < Col
118+ span = { 8 }
119+ style = { {
120+ borderRight : `1px solid ${ token . colorBorderSecondary } ` ,
121+ justifyItems : 'center' ,
122+ } }
123+ >
124+ < BAIPanelItem
125+ title = { t ( 'data.ProjectFolders' ) }
126+ value = { projectCount }
127+ unit = {
128+ project_resource_policy ?. max_vfolder_count
129+ ? `/ ${ project_resource_policy ?. max_vfolder_count } `
130+ : undefined
131+ }
132+ />
133+ </ Col >
134+ < Col
135+ span = { 8 }
136+ style = { {
137+ justifyItems : 'center' ,
138+ } }
139+ >
140+ < BAIPanelItem
141+ title = {
142+ count > 0 ? (
143+ // Add a tag to the Tooltip to make it clickable
144+ // eslint-disable-next-line
145+ < a
146+ onClick = { ( ) => {
147+ onRequestBadgeClick ?.( ) ;
148+ } }
153149 >
154- < Badge
155- count = { count > 0 ? `+${ count } ` : null }
156- offset = { [ 0 , - `${ token . sizeXS } ` ] }
150+ < Tooltip
151+ title = {
152+ count > 0
153+ ? t ( 'data.InvitedFoldersTooltip' , {
154+ count : count ,
155+ } )
156+ : null
157+ }
158+ rootClassName = { styles . invitationTooltip }
159+ placement = "topRight"
157160 >
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- />
182- </ Col >
183- </ Row >
184- </ BAICard >
161+ < Badge
162+ count = { count > 0 ? `+${ count } ` : null }
163+ offset = { [ 0 , - `${ token . sizeXS } ` ] }
164+ >
165+ < Typography . Title level = { 5 } style = { { margin : 0 } } >
166+ { t ( 'data.InvitedFolders' ) }
167+ </ Typography . Title >
168+ </ Badge >
169+ </ Tooltip >
170+ </ a >
171+ ) : (
172+ < Typography . Title level = { 5 } style = { { margin : 0 } } >
173+ { t ( 'data.InvitedFolders' ) }
174+ </ Typography . Title >
175+ )
176+ }
177+ value = {
178+ < Typography . Text
179+ strong
180+ style = { {
181+ fontSize : token . fontSizeHeading1 ,
182+ color : token . Layout ?. headerBg ,
183+ } }
184+ >
185+ { invitedCount }
186+ </ Typography . Text >
187+ }
188+ />
189+ </ Col >
190+ </ Row >
191+ </ BAICard >
192+ </ >
185193 ) ;
186194} ;
187195
0 commit comments