@@ -21,10 +21,11 @@ import {
2121 useContextMenuGroups ,
2222 usePersistedState ,
2323 AtlasSkillsBanner ,
24+ Tooltip ,
2425} from '@mongodb-js/compass-components' ;
2526import type { MenuAction , Signal } from '@mongodb-js/compass-components' ;
2627import { ViewSwitcher } from './view-switcher' ;
27- import type { DocumentView } from '../stores/crud-store' ;
28+ import { COUNT_MAX_TIME_MS_CAP , type DocumentView } from '../stores/crud-store' ;
2829import { AddDataMenu } from './add-data-menu' ;
2930import { usePreference } from 'compass-preferences-model/provider' ;
3031import UpdateMenu from './update-data-menu' ;
@@ -87,6 +88,12 @@ const loaderContainerStyles = css({
8788 paddingRight : spacing [ 200 ] ,
8889} ) ;
8990
91+ const countUnavailableTextStyles = css ( {
92+ textDecoration : 'underline' ,
93+ textDecorationStyle : 'dotted' ,
94+ textUnderlineOffset : '3px' ,
95+ } ) ;
96+
9097type ExportDataOption = 'export-query' | 'export-full-collection' ;
9198const exportDataActions : MenuAction < ExportDataOption > [ ] = [
9299 { action : 'export-query' , label : 'Export query results' } ,
@@ -109,6 +116,8 @@ const ERROR_CODE_OPERATION_TIMED_OUT = 50;
109116const INCREASE_MAX_TIME_MS_HINT =
110117 'Operation exceeded time limit. Please try increasing the maxTimeMS for the query in the expanded filter options.' ;
111118
119+ const COUNT_UNAVAILABLE_TOOLTIP = `The count is not available for this query. This can happen when the count operation fails or exceeds the maxTimeMS of ${ COUNT_MAX_TIME_MS_CAP } .` ;
120+
112121type ErrorWithPossibleCode = Error & {
113122 code ?: {
114123 value : number ;
@@ -198,11 +207,6 @@ const CrudToolbar: React.FunctionComponent<CrudToolbarProps> = ({
198207 SkillsBannerContextEnum . Documents
199208 ) ;
200209
201- const displayedDocumentCount = useMemo (
202- ( ) => ( loadingCount ? '' : `${ count ?? 'N/A' } ` ) ,
203- [ loadingCount , count ]
204- ) ;
205-
206210 const onClickRefreshDocuments = useCallback ( ( ) => {
207211 track ( 'Query Results Refreshed' , { } , connectionInfoRef . current ) ;
208212 refreshDocuments ( ) ;
@@ -416,7 +420,20 @@ const CrudToolbar: React.FunctionComponent<CrudToolbarProps> = ({
416420 </ Select >
417421 < Body data-testid = "crud-document-count-display" >
418422 { start } – { end } { ' ' }
419- { displayedDocumentCount && `of ${ displayedDocumentCount } ` }
423+ { ! loadingCount && (
424+ < span >
425+ { 'of ' }
426+ { count ?? (
427+ < Tooltip
428+ trigger = {
429+ < span className = { countUnavailableTextStyles } > N/A</ span >
430+ }
431+ >
432+ < Body > { COUNT_UNAVAILABLE_TOOLTIP } </ Body >
433+ </ Tooltip >
434+ ) }
435+ </ span >
436+ ) }
420437 </ Body >
421438 { loadingCount && (
422439 < div className = { loaderContainerStyles } >
0 commit comments