@@ -18,7 +18,6 @@ import EnrolledLearnersForInactiveCoursesTable from '../EnrolledLearnersForInact
18
18
import CompletedLearnersTable from '../CompletedLearnersTable' ;
19
19
import PastWeekPassedLearnersTable from '../PastWeekPassedLearnersTable' ;
20
20
import LearnerActivityTable from '../LearnerActivityTable' ;
21
- import DownloadCsvButton from '../../containers/DownloadCsvButton' ;
22
21
import AdminCards from '../../containers/AdminCards' ;
23
22
import AdminSearchForm from './AdminSearchForm' ;
24
23
import EnterpriseAppSkeleton from '../EnterpriseApp/EnterpriseAppSkeleton' ;
@@ -34,6 +33,8 @@ import AIAnalyticsSummary from './AIAnalyticsSummary';
34
33
import AIAnalyticsSummarySkeleton from './AIAnalyticsSummarySkeleton' ;
35
34
import BudgetExpiryAlertAndModal from '../BudgetExpiryAlertAndModal' ;
36
35
import ModuleActivityReport from './tabs/ModuleActivityReport' ;
36
+ import { TableDataProvider } from './TableDataContext' ;
37
+ import DownloadButtonWrapper from './DownloadButtonWrapper' ;
37
38
38
39
class Admin extends React . Component {
39
40
constructor ( props ) {
@@ -264,18 +265,18 @@ class Admin extends React.Component {
264
265
return tableData && tableData . data ;
265
266
}
266
267
267
- displaySearchBar ( ) {
268
- return ! this . props . actionSlug ;
269
- }
270
-
271
- isTableDataMissing ( id ) {
268
+ isTableDataMissing = ( id ) => {
272
269
const tableData = this . getTableData ( id ) ;
273
270
if ( ! tableData ) {
274
271
return true ;
275
272
}
276
273
const isTableLoading = tableData . loading ;
277
274
const isTableEmpty = tableData . results && ! tableData . results . length ;
278
275
return isTableLoading || isTableEmpty ;
276
+ } ;
277
+
278
+ displaySearchBar ( ) {
279
+ return ! this . props . actionSlug ;
279
280
}
280
281
281
282
hasAnalyticsData ( ) {
@@ -313,11 +314,11 @@ class Admin extends React.Component {
313
314
}
314
315
315
316
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 }
321
322
/>
322
323
) ;
323
324
}
@@ -528,24 +529,25 @@ class Admin extends React.Component {
528
529
/>
529
530
) }
530
531
</ 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
+ } }
545
539
>
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 ( ) && (
549
551
< >
550
552
< div className = "row pb-3 mt-2" >
551
553
< div className = "col-12 col-md-12 col-xl-12" >
@@ -563,27 +565,28 @@ class Admin extends React.Component {
563
565
/>
564
566
) }
565
567
</ >
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 >
570
573
</ div >
571
574
</ 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 >
587
590
</ div >
588
591
</ div >
589
592
</ >
0 commit comments