@@ -8,7 +8,7 @@ import PT from 'prop-types'
8
8
import moment from 'moment'
9
9
import _ from 'lodash'
10
10
import { STUDIO_URL , SUBMISSION_REVIEW_APP_URL , getTCMemberURL } from '../../../config/constants'
11
- import { PrimaryButton } from '../../Buttons'
11
+ import { OutlineButton , PrimaryButton } from '../../Buttons'
12
12
import AlertModal from '../../Modal/AlertModal'
13
13
import cn from 'classnames'
14
14
import ReactSVG from 'react-svg'
@@ -29,6 +29,7 @@ import {
29
29
} from '../../../util/files'
30
30
import styles from './Submissions.module.scss'
31
31
import modalStyles from '../../../styles/modal.module.scss'
32
+ import { ArtifactsListModal } from '../ArtifactsListModal'
32
33
const assets = require . context ( '../../../assets/images' , false , / s v g / )
33
34
const ArrowDown = './arrow-down.svg'
34
35
const Lock = './lock.svg'
@@ -50,7 +51,8 @@ class SubmissionsComponent extends React.Component {
50
51
memberOfModal : '' ,
51
52
sortedSubmissions : [ ] ,
52
53
downloadingAll : false ,
53
- alertMessage : ''
54
+ alertMessage : '' ,
55
+ selectedSubmissionId : ''
54
56
}
55
57
this . getSubmissionsSortParam = this . getSubmissionsSortParam . bind ( this )
56
58
this . updateSortedSubmissions = this . updateSortedSubmissions . bind ( this )
@@ -220,6 +222,12 @@ class SubmissionsComponent extends React.Component {
220
222
return isReviewPhaseComplete
221
223
}
222
224
225
+ closeArtifactsModal ( ) {
226
+ this . setState ( {
227
+ selectedSubmissionId : ''
228
+ } )
229
+ }
230
+
223
231
render ( ) {
224
232
const { challenge, token, loggedInUserResource } = this . props
225
233
const { checkpoints, track, type, tags } = challenge
@@ -544,40 +552,52 @@ class SubmissionsComponent extends React.Component {
544
552
</ span >
545
553
</ td >
546
554
{ canDownloadSubmission ? ( < td className = { cn ( styles [ 'col-8Table' ] , styles [ 'col-bodyTable' ] ) } >
547
- < button
548
- onClick = { ( ) => {
549
- // download submission
550
- const reactLib = getTopcoderReactLib ( )
551
- const { getService } = reactLib . services . submissions
552
- const submissionsService = getService ( token )
553
- submissionsService . downloadSubmission ( s . id )
554
- . then ( ( blob ) => {
555
- isValidDownloadFile ( blob ) . then ( ( isValidFile ) => {
556
- if ( isValidFile . success ) {
557
- // eslint-disable-next-line no-undef
558
- const url = window . URL . createObjectURL ( new Blob ( [ blob ] ) )
559
- const link = document . createElement ( 'a' )
560
- link . href = url
561
- let fileName = s . legacySubmissionId
562
- if ( ! fileName ) {
563
- fileName = s . id
555
+ < div className = { styles [ 'button-wrapper' ] } >
556
+ < button
557
+ className = { styles [ 'download-submission-button' ] }
558
+ onClick = { ( ) => {
559
+ // download submission
560
+ const reactLib = getTopcoderReactLib ( )
561
+ const { getService } = reactLib . services . submissions
562
+ const submissionsService = getService ( token )
563
+ submissionsService . downloadSubmission ( s . id )
564
+ . then ( ( blob ) => {
565
+ isValidDownloadFile ( blob ) . then ( ( isValidFile ) => {
566
+ if ( isValidFile . success ) {
567
+ // eslint-disable-next-line no-undef
568
+ const url = window . URL . createObjectURL ( new Blob ( [ blob ] ) )
569
+ const link = document . createElement ( 'a' )
570
+ link . href = url
571
+ let fileName = s . legacySubmissionId
572
+ if ( ! fileName ) {
573
+ fileName = s . id
574
+ }
575
+ fileName = fileName + '.zip'
576
+ link . setAttribute ( 'download' , `${ fileName } ` )
577
+ document . body . appendChild ( link )
578
+ link . click ( )
579
+ link . parentNode . removeChild ( link )
580
+ } else {
581
+ this . setState ( {
582
+ alertMessage : isValidFile . message || 'Can not download this submission.'
583
+ } )
564
584
}
565
- fileName = fileName + '.zip'
566
- link . setAttribute ( 'download' , `${ fileName } ` )
567
- document . body . appendChild ( link )
568
- link . click ( )
569
- link . parentNode . removeChild ( link )
570
- } else {
571
- this . setState ( {
572
- alertMessage : isValidFile . message || 'Can not download this submission.'
573
- } )
574
- }
585
+ } )
575
586
} )
576
- } )
577
- } }
578
- >
579
- < ReactSVG path = { assets ( `${ Download } ` ) } />
580
- </ button >
587
+ } }
588
+ >
589
+ < ReactSVG path = { assets ( `${ Download } ` ) } />
590
+ </ button >
591
+
592
+ < OutlineButton
593
+ text = 'Download Artifacts'
594
+ type = 'info'
595
+ className = { styles [ 'download-artifacts-button' ] }
596
+ onClick = { async ( ) => {
597
+ this . setState ( { selectedSubmissionId : s . id } )
598
+ } }
599
+ />
600
+ </ div >
581
601
</ td > ) : null }
582
602
</ tr >
583
603
)
@@ -586,6 +606,21 @@ class SubmissionsComponent extends React.Component {
586
606
</ table >
587
607
</ div >
588
608
609
+ {
610
+ this . state . selectedSubmissionId ? (
611
+ < ArtifactsListModal
612
+ submissionId = { this . state . selectedSubmissionId }
613
+ token = { this . props . token }
614
+ theme = { theme }
615
+ onClose = { ( ) => {
616
+ this . setState ( {
617
+ selectedSubmissionId : ''
618
+ } )
619
+ } }
620
+ />
621
+ ) : null
622
+ }
623
+
589
624
{ canDownloadSubmission ? ( < div className = { styles [ 'top-title' ] } >
590
625
591
626
< div className = { styles . btnManageSubmissions } >
0 commit comments