@@ -33,7 +33,8 @@ import {
3333 MenuItem ,
3434 Modal ,
3535 TextField ,
36- Typography
36+ Typography ,
37+ Link ,
3738} from '@mui/material' ;
3839import ToggleButton from '@mui/material/ToggleButton' ;
3940import ToggleButtonGroup from '@mui/material/ToggleButtonGroup' ;
@@ -79,6 +80,8 @@ const ScoreOptionLabel = {
7980 'Combined' : 'Both' ,
8081} ;
8182
83+ const pulsesPerPage = 15 ;
84+
8285/*
8386// Returns a random, integer score between 1 and 5.
8487// We may want to uncomment this later for testing.
@@ -117,6 +120,7 @@ const PulseReportPage = () => {
117120 const [ expanded , setExpanded ] = useState ( false ) ;
118121 const [ scoreChartData , setScoreChartData ] = useState ( [ ] ) ;
119122 const [ pulses , setPulses ] = useState ( [ ] ) ;
123+ const [ pulsesUpperBounds , setPulsesUpperBounds ] = useState ( pulsesPerPage ) ;
120124 const [ scope , setScope ] = useState ( 'Individual' ) ;
121125 const [ scoreType , setScoreType ] = useState ( ScoreOption . COMBINED ) ;
122126 const [ selectedPulse , setSelectedPulse ] = useState ( null ) ;
@@ -329,6 +333,7 @@ const PulseReportPage = () => {
329333 return compare ;
330334 } ) ;
331335 setPulses ( pulses ) ;
336+ setPulsesUpperBounds ( pulsesPerPage ) ;
332337 } ;
333338
334339 useEffect ( ( ) => {
@@ -389,63 +394,6 @@ const PulseReportPage = () => {
389394 </ Card >
390395 ) ;
391396
392- const scoreDistributionChart = ( ) => (
393- < Card >
394- < CardHeader
395- title = "Distribution of pulse scores for selected team members"
396- titleTypographyProps = { { variant : 'h5' , component : 'h2' } }
397- />
398- < CardContent >
399- < BarChart
400- width = { 500 }
401- height = { 300 }
402- data = { barChartData }
403- margin = { {
404- top : 5 ,
405- right : 30 ,
406- left : 20 ,
407- bottom : 5
408- } }
409- >
410- < CartesianGrid strokeDasharray = "3 3" />
411- < XAxis dataKey = "score" />
412- < YAxis />
413- < Tooltip />
414- < Legend />
415- { ( scoreType == ScoreOption . COMBINED || scoreType == ScoreOption . INTERNAL ) &&
416- < Bar
417- dataKey = "internal"
418- fill = { ociDarkBlue }
419- name = { ScoreOptionLabel [ ScoreOption . INTERNAL ] }
420- />
421- }
422- { ( scoreType == ScoreOption . COMBINED || scoreType == ScoreOption . EXTERNAL ) &&
423- < Bar
424- dataKey = "external"
425- fill = { ociOrange }
426- name = { ScoreOptionLabel [ ScoreOption . EXTERNAL ] }
427- />
428- }
429- </ BarChart >
430- < ExpandMore
431- expand = { expanded }
432- onClick = { ( ) => setExpanded ( ! expanded ) }
433- aria-expanded = { expanded }
434- aria-label = { expanded ? 'show less' : 'show more' }
435- size = "large"
436- />
437- < Collapse
438- className = "bottom-row"
439- in = { expanded }
440- timeout = "auto"
441- unmountOnExit
442- >
443- { responseSummary ( ) }
444- </ Collapse >
445- </ CardContent >
446- </ Card >
447- ) ;
448-
449397 const handleCommentClick = pulse => {
450398 setSelectedPulse ( pulse ) ;
451399 setShowComments ( true ) ;
@@ -725,16 +673,33 @@ const PulseReportPage = () => {
725673 </ div >
726674 }
727675 </ div >
676+ < ExpandMore
677+ expand = { expanded }
678+ onClick = { ( ) => setExpanded ( ! expanded ) }
679+ aria-expanded = { expanded }
680+ aria-label = { expanded ? 'show less' : 'show more' }
681+ size = "large"
682+ />
683+ < Collapse
684+ className = "bottom-row"
685+ in = { expanded }
686+ timeout = "auto"
687+ unmountOnExit
688+ >
689+ { responseSummary ( ) }
690+ </ Collapse >
728691 </ CardContent >
729692 </ Card >
730693 </ >
731694 ) ;
732695
733696 const responseSummary = ( ) => {
734- let filteredPulses = pulses ;
697+ const pulsesSlice = pulses . slice ( 0 , pulsesUpperBounds ) ;
698+
699+ let filteredPulses = pulsesSlice ;
735700 const teamMemberIds = teamMembers . map ( member => member . id ) ;
736701 if ( teamMemberIds . length ) {
737- filteredPulses = pulses . filter ( pulse =>
702+ filteredPulses = pulsesSlice . filter ( pulse =>
738703 teamMemberIds . includes ( pulse . teamMemberId )
739704 ) ;
740705 }
@@ -773,6 +738,14 @@ const PulseReportPage = () => {
773738 </ div >
774739 ) ;
775740 } ) }
741+ { pulsesUpperBounds < pulses . length &&
742+ < Link to = "#" style = { { cursor : 'pointer' } } onClick = { ( event ) => {
743+ event . preventDefault ( ) ;
744+ setPulsesUpperBounds ( pulsesUpperBounds + pulsesPerPage ) ;
745+ } } >
746+ Load more...
747+ </ Link >
748+ }
776749 </ >
777750 ) ;
778751 } ;
@@ -840,7 +813,6 @@ const PulseReportPage = () => {
840813 />
841814 { pulseScoresChart ( ) }
842815 { averageScores ( ) }
843- { scoreDistributionChart ( ) }
844816 < Modal open = { showComments } onClose = { ( ) => setShowComments ( false ) } >
845817 < Card className = "feedback-request-enable-edits-modal" >
846818 < CardHeader
0 commit comments