88 TextFilter ,
99 MultiSelectDropdownFilter ,
1010} from '@openedx/paragon' ;
11- import { injectIntl , intlShape } from '@edx/frontend-platform/i18n' ;
11+ import { useIntl } from '@edx/frontend-platform/i18n' ;
1212
1313import { gradingStatuses , submissionFields } from 'data/services/lms/constants' ;
1414import lmsMessages from 'data/services/lms/messages' ;
@@ -25,113 +25,108 @@ import messages from './messages';
2525/**
2626 * <SubmissionsTable />
2727 */
28- export class SubmissionsTable extends React . Component {
29- get gradeStatusOptions ( ) {
30- return Object . keys ( gradingStatuses ) . map ( statusKey => ( {
31- name : this . translate ( lmsMessages [ gradingStatuses [ statusKey ] ] ) ,
32- value : gradingStatuses [ statusKey ] ,
33- } ) ) ;
34- }
28+ export const SubmissionsTable = ( {
29+ isIndividual,
30+ listData,
31+ loadSelectionForReview,
32+ } ) => {
33+ const intl = useIntl ( ) ;
3534
36- get userLabel ( ) {
37- return this . translate ( this . props . isIndividual ? messages . username : messages . teamName ) ;
38- }
35+ const translate = ( ...args ) => intl . formatMessage ( ...args ) ;
3936
40- get userAccessor ( ) {
41- return this . props . isIndividual
42- ? submissionFields . username
43- : submissionFields . teamName ;
44- }
37+ const gradeStatusOptions = Object . keys ( gradingStatuses ) . map ( statusKey => ( {
38+ name : translate ( lmsMessages [ gradingStatuses [ statusKey ] ] ) ,
39+ value : gradingStatuses [ statusKey ] ,
40+ } ) ) ;
4541
46- get dateSubmittedLabel ( ) {
47- return this . translate ( this . props . isIndividual
48- ? messages . learnerSubmissionDate
49- : messages . teamSubmissionDate ) ;
50- }
42+ const userLabel = translate ( isIndividual ? messages . username : messages . teamName ) ;
43+
44+ const userAccessor = isIndividual
45+ ? submissionFields . username
46+ : submissionFields . teamName ;
5147
52- formatDate = ( { value } ) => {
48+ const dateSubmittedLabel = translate ( isIndividual
49+ ? messages . learnerSubmissionDate
50+ : messages . teamSubmissionDate ) ;
51+
52+ const formatDate = ( { value } ) => {
5353 const date = new Date ( moment ( value ) ) ;
5454 return date . toLocaleString ( ) ;
5555 } ;
5656
57- formatGrade = ( { value : score } ) => (
57+ const formatGrade = ( { value : score } ) => (
5858 score === null ? '-' : `${ score . pointsEarned } /${ score . pointsPossible } `
5959 ) ;
6060
61- formatStatus = ( { value } ) => ( < StatusBadge status = { value } /> ) ;
62-
63- translate = ( ...args ) => this . props . intl . formatMessage ( ...args ) ;
61+ const formatStatus = ( { value } ) => ( < StatusBadge status = { value } /> ) ;
6462
65- handleViewAllResponsesClick = ( data ) => ( ) => {
63+ const handleViewAllResponsesClick = ( data ) => ( ) => {
6664 const getSubmissionUUID = ( row ) => row . original . submissionUUID ;
67- this . props . loadSelectionForReview ( data . map ( getSubmissionUUID ) ) ;
65+ loadSelectionForReview ( data . map ( getSubmissionUUID ) ) ;
6866 } ;
6967
70- render ( ) {
71- if ( ! this . props . listData . length ) {
72- return null ;
73- }
74- return (
75- < div className = "submissions-table" >
76- < DataTable
77- data-testid = "data-table"
78- isFilterable
79- FilterStatusComponent = { FilterStatusComponent }
80- numBreakoutFilters = { 2 }
81- defaultColumnValues = { { Filter : TextFilter } }
82- isSelectable
83- isSortable
84- isPaginated
85- itemCount = { this . props . listData . length }
86- initialState = { { pageSize : 10 , pageIndex : 0 } }
87- data = { this . props . listData }
88- tableActions = { [
89- < TableAction handleClick = { this . handleViewAllResponsesClick } /> ,
90- ] }
91- bulkActions = { [
92- < SelectedBulkAction handleClick = { this . handleViewAllResponsesClick } /> ,
93- ] }
94- columns = { [
95- {
96- Header : this . userLabel ,
97- accessor : this . userAccessor ,
98- } ,
99- {
100- Header : this . dateSubmittedLabel ,
101- accessor : submissionFields . dateSubmitted ,
102- Cell : this . formatDate ,
103- disableFilters : true ,
104- } ,
105- {
106- Header : this . translate ( messages . grade ) ,
107- accessor : submissionFields . score ,
108- Cell : this . formatGrade ,
109- disableFilters : true ,
110- } ,
111- {
112- Header : this . translate ( messages . gradingStatus ) ,
113- accessor : submissionFields . gradingStatus ,
114- Cell : this . formatStatus ,
115- Filter : MultiSelectDropdownFilter ,
116- filter : 'includesValue' ,
117- filterChoices : this . gradeStatusOptions ,
118- } ,
119- ] }
120- >
121- < DataTable . TableControlBar />
122- < DataTable . Table />
123- < DataTable . TableFooter />
124- </ DataTable >
125- </ div >
126- ) ;
68+ if ( ! listData . length ) {
69+ return null ;
12770 }
128- }
71+
72+ return (
73+ < div className = "submissions-table" >
74+ < DataTable
75+ data-testid = "data-table"
76+ isFilterable
77+ FilterStatusComponent = { FilterStatusComponent }
78+ numBreakoutFilters = { 2 }
79+ defaultColumnValues = { { Filter : TextFilter } }
80+ isSelectable
81+ isSortable
82+ isPaginated
83+ itemCount = { listData . length }
84+ initialState = { { pageSize : 10 , pageIndex : 0 } }
85+ data = { listData }
86+ tableActions = { [
87+ < TableAction handleClick = { handleViewAllResponsesClick } /> ,
88+ ] }
89+ bulkActions = { [
90+ < SelectedBulkAction handleClick = { handleViewAllResponsesClick } /> ,
91+ ] }
92+ columns = { [
93+ {
94+ Header : userLabel ,
95+ accessor : userAccessor ,
96+ } ,
97+ {
98+ Header : dateSubmittedLabel ,
99+ accessor : submissionFields . dateSubmitted ,
100+ Cell : formatDate ,
101+ disableFilters : true ,
102+ } ,
103+ {
104+ Header : translate ( messages . grade ) ,
105+ accessor : submissionFields . score ,
106+ Cell : formatGrade ,
107+ disableFilters : true ,
108+ } ,
109+ {
110+ Header : translate ( messages . gradingStatus ) ,
111+ accessor : submissionFields . gradingStatus ,
112+ Cell : formatStatus ,
113+ Filter : MultiSelectDropdownFilter ,
114+ filter : 'includesValue' ,
115+ filterChoices : gradeStatusOptions ,
116+ } ,
117+ ] }
118+ >
119+ < DataTable . TableControlBar />
120+ < DataTable . Table />
121+ < DataTable . TableFooter />
122+ </ DataTable >
123+ </ div >
124+ ) ;
125+ } ;
129126SubmissionsTable . defaultProps = {
130127 listData : [ ] ,
131128} ;
132129SubmissionsTable . propTypes = {
133- // injected
134- intl : intlShape . isRequired ,
135130 // redux
136131 isIndividual : PropTypes . bool . isRequired ,
137132 listData : PropTypes . arrayOf ( PropTypes . shape ( {
@@ -155,4 +150,4 @@ export const mapDispatchToProps = {
155150 loadSelectionForReview : thunkActions . grading . loadSelectionForReview ,
156151} ;
157152
158- export default injectIntl ( connect ( mapStateToProps , mapDispatchToProps ) ( SubmissionsTable ) ) ;
153+ export default connect ( mapStateToProps , mapDispatchToProps ) ( SubmissionsTable ) ;
0 commit comments