@@ -18,7 +18,6 @@ import EnrolledLearnersForInactiveCoursesTable from '../EnrolledLearnersForInact
1818import CompletedLearnersTable from '../CompletedLearnersTable' ;
1919import PastWeekPassedLearnersTable from '../PastWeekPassedLearnersTable' ;
2020import LearnerActivityTable from '../LearnerActivityTable' ;
21- import DownloadCsvButton from '../../containers/DownloadCsvButton' ;
2221import AdminCards from '../../containers/AdminCards' ;
2322import AdminSearchForm from './AdminSearchForm' ;
2423import EnterpriseAppSkeleton from '../EnterpriseApp/EnterpriseAppSkeleton' ;
@@ -34,6 +33,8 @@ import AIAnalyticsSummary from './AIAnalyticsSummary';
3433import AIAnalyticsSummarySkeleton from './AIAnalyticsSummarySkeleton' ;
3534import BudgetExpiryAlertAndModal from '../BudgetExpiryAlertAndModal' ;
3635import ModuleActivityReport from './tabs/ModuleActivityReport' ;
36+ import { TableDataProvider } from './TableDataContext' ;
37+ import DownloadButtonWrapper from './DownloadButtonWrapper' ;
3738
3839class Admin extends React . Component {
3940 constructor ( props ) {
@@ -264,18 +265,18 @@ class Admin extends React.Component {
264265 return tableData && tableData . data ;
265266 }
266267
267- displaySearchBar ( ) {
268- return ! this . props . actionSlug ;
269- }
270-
271- isTableDataMissing ( id ) {
268+ isTableDataMissing = ( id ) => {
272269 const tableData = this . getTableData ( id ) ;
273270 if ( ! tableData ) {
274271 return true ;
275272 }
276273 const isTableLoading = tableData . loading ;
277274 const isTableEmpty = tableData . results && ! tableData . results . length ;
278275 return isTableLoading || isTableEmpty ;
276+ } ;
277+
278+ displaySearchBar ( ) {
279+ return ! this . props . actionSlug ;
279280 }
280281
281282 hasAnalyticsData ( ) {
@@ -313,11 +314,11 @@ class Admin extends React.Component {
313314 }
314315
315316 return (
316- < DownloadCsvButton
317- id = { tableMetadata . csvButtonId }
318- fetchMethod = { tableMetadata . csvFetchMethod }
319- disabled = { this . isTableDataMissing ( actionSlug ) }
320- buttonLabel = { downloadButtonLabel }
317+ < DownloadButtonWrapper
318+ tableMetadata = { tableMetadata }
319+ actionSlug = { actionSlug }
320+ downloadButtonLabel = { downloadButtonLabel }
321+ isTableDataMissing = { this . isTableDataMissing }
321322 />
322323 ) ;
323324 }
@@ -528,24 +529,25 @@ class Admin extends React.Component {
528529 />
529530 ) }
530531 </ div >
531- < Tabs
532- variant = "tabs"
533- activeKey = { activeTab }
534- onSelect = { ( tab ) => {
535- this . setState ( { activeTab : tab } ) ;
536- } }
537- >
538- < Tab
539- eventKey = "learner-progress-report"
540- title = { intl . formatMessage ( {
541- id : 'adminPortal.lpr.tab.learnerProgressReport.title' ,
542- defaultMessage : 'Learner Progress Report' ,
543- description : 'Title for the learner progress report tab in admin portal.' ,
544- } ) }
532+ < TableDataProvider >
533+ < Tabs
534+ variant = "tabs"
535+ activeKey = { activeTab }
536+ onSelect = { ( tab ) => {
537+ this . setState ( { activeTab : tab } ) ;
538+ } }
545539 >
546- < div className = "row" >
547- < div className = "col" >
548- { ! error && ! loading && ! this . hasEmptyData ( ) && (
540+ < Tab
541+ eventKey = "learner-progress-report"
542+ title = { intl . formatMessage ( {
543+ id : 'adminPortal.lpr.tab.learnerProgressReport.title' ,
544+ defaultMessage : 'Learner Progress Report' ,
545+ description : 'Title for the learner progress report tab in admin portal.' ,
546+ } ) }
547+ >
548+ < div className = "row" >
549+ < div className = "col" >
550+ { ! error && ! loading && ! this . hasEmptyData ( ) && (
549551 < >
550552 < div className = "row pb-3 mt-2" >
551553 < div className = "col-12 col-md-12 col-xl-12" >
@@ -563,27 +565,28 @@ class Admin extends React.Component {
563565 />
564566 ) }
565567 </ >
566- ) }
567- { csvErrorMessage && this . renderCsvErrorMessage ( csvErrorMessage ) }
568- < div className = "mt-3 mb-5" >
569- { enterpriseId && tableMetadata . component }
568+ ) }
569+ { csvErrorMessage && this . renderCsvErrorMessage ( csvErrorMessage ) }
570+ < div className = "mt-3 mb-5" >
571+ { enterpriseId && tableMetadata . component }
572+ </ div >
570573 </ div >
571574 </ div >
572- </ div >
573- </ Tab >
574- < Tab
575- eventKey = "module-activity"
576- title = { intl . formatMessage ( {
577- id : 'adminPortal.lpr.tab.moduleActivity.title ' ,
578- defaultMessage : 'Module Activity (Executive Education) ' ,
579- description : 'Title for the module activity tab in admin portal.' ,
580- } ) }
581- >
582- < div className = "mt-3" >
583- < ModuleActivityReport enterpriseId = { enterpriseId } / >
584- </ div >
585- </ Tab >
586- </ Tabs >
575+ </ Tab >
576+ < Tab
577+ eventKey = "module-activity"
578+ title = { intl . formatMessage ( {
579+ id : 'adminPortal.lpr.tab.moduleActivity.title' ,
580+ defaultMessage : 'Module Activity (Executive Education) ' ,
581+ description : 'Title for the module activity tab in admin portal. ' ,
582+ } ) }
583+ >
584+ < div className = "mt-3" >
585+ < ModuleActivityReport enterpriseId = { enterpriseId } / >
586+ </ div >
587+ </ Tab >
588+ </ Tabs >
589+ </ TableDataProvider >
587590 </ div >
588591 </ div >
589592 </ >
0 commit comments