@@ -11,6 +11,7 @@ import LoadingIndicator from 'components/LoadingIndicator';
1111import SubmissionManagement from 'components/SubmissionManagement/SubmissionManagement' ;
1212import React from 'react' ;
1313import PT from 'prop-types' ;
14+ import { safeForDownload } from 'utils/tc' ;
1415import { connect } from 'react-redux' ;
1516import { Modal , PrimaryButton } from 'topcoder-react-ui-kit' ;
1617import { config } from 'topcoder-react-utils' ;
@@ -21,8 +22,22 @@ import smpActions from '../../actions/page/submission_management';
2122
2223const { getService } = services . submissions ;
2324
25+ const theme = {
26+ container : style . modalContainer ,
27+ } ;
28+
2429// The container component
2530class SubmissionManagementPageContainer extends React . Component {
31+ constructor ( props ) {
32+ super ( props ) ;
33+
34+ this . state = {
35+ needReload : false ,
36+ initialState : true ,
37+ submissions : [ ] ,
38+ } ;
39+ }
40+
2641 componentDidMount ( ) {
2742 const {
2843 authTokens,
@@ -43,6 +58,52 @@ class SubmissionManagementPageContainer extends React.Component {
4358 }
4459 }
4560
61+ componentWillReceiveProps ( nextProps ) {
62+ const {
63+ loadMySubmissions, authTokens, challengeId, mySubmissions,
64+ } = nextProps ;
65+ const { needReload } = this . state ;
66+
67+ if ( needReload === false && mySubmissions ) {
68+ if ( mySubmissions . find ( item => safeForDownload ( item . url ) !== true ) ) {
69+ this . setState ( { needReload : true } ) ;
70+ setTimeout ( ( ) => {
71+ loadMySubmissions ( authTokens , challengeId ) ;
72+ this . setState ( { needReload : false } ) ;
73+ } , 2000 ) ;
74+ }
75+ }
76+ }
77+
78+ componentDidUpdate ( prevProps ) {
79+ const {
80+ deletionSucceed,
81+ toBeDeletedId,
82+ mySubmissions,
83+ } = this . props ;
84+ const { initialState } = this . state ;
85+
86+ if ( initialState && mySubmissions ) {
87+ // eslint-disable-next-line react/no-did-update-set-state
88+ this . setState ( {
89+ submissions : [ ...mySubmissions ] ,
90+ initialState : false ,
91+ } ) ;
92+ return ;
93+ }
94+ const { submissions } = this . state ;
95+
96+ if ( deletionSucceed !== prevProps . deletionSucceed ) {
97+ _ . remove ( submissions , submission => (
98+ submission . id === toBeDeletedId
99+ ) ) ;
100+ // eslint-disable-next-line react/no-did-update-set-state
101+ this . setState ( {
102+ submissions,
103+ } ) ;
104+ }
105+ }
106+
46107 render ( ) {
47108 const {
48109 authTokens,
@@ -53,7 +114,6 @@ class SubmissionManagementPageContainer extends React.Component {
53114 loadingSubmissionsForChallengeId,
54115 submissionPhaseStartDate,
55116 isLoadingChallenge,
56- mySubmissions,
57117 onCancelSubmissionDelete,
58118 onShowDetails,
59119 onSubmissionDelete,
@@ -62,6 +122,9 @@ class SubmissionManagementPageContainer extends React.Component {
62122 showModal,
63123 toBeDeletedId,
64124 } = this . props ;
125+
126+ const { submissions } = this . state ;
127+
65128 if ( ! challenge . isRegistered ) return < AccessDenied redirectLink = { `${ challengesUrl } /${ challenge . id } ` } cause = { ACCESS_DENIED_REASON . HAVE_NOT_SUBMITTED_TO_THE_CHALLENGE } /> ;
66129
67130 const isEmpty = _ . isEmpty ( challenge ) ;
@@ -96,7 +159,7 @@ class SubmissionManagementPageContainer extends React.Component {
96159 challenge = { challenge }
97160 challengesUrl = { challengesUrl }
98161 loadingSubmissions = { Boolean ( loadingSubmissionsForChallengeId ) }
99- submissions = { mySubmissions }
162+ submissions = { submissions }
100163 showDetails = { showDetails }
101164 submissionPhaseStartDate = { submissionPhaseStartDate }
102165 { ...smConfig }
@@ -108,6 +171,7 @@ class SubmissionManagementPageContainer extends React.Component {
108171 { showModal && (
109172 < Modal
110173 onCancel = { deleting ? _ . noop : onCancelSubmissionDelete }
174+ theme = { theme }
111175 >
112176 < div styleName = "modal-content" >
113177 < p styleName = "are-you-sure" >
@@ -123,6 +187,8 @@ class SubmissionManagementPageContainer extends React.Component {
123187 This will permanently remove all
124188 files from our servers and can’t be undone.
125189 You’ll have to upload all the files again in order to restore it.
190+ Note that deleting the file may take a few minutes to propagate
191+ through the Topcoder platform.
126192 </ p >
127193 < div
128194 /* NOTE: Current implementation of the loading indicator is
@@ -179,6 +245,7 @@ SubmissionManagementPageContainer.defaultProps = {
179245 showModal : false ,
180246 toBeDeletedId : '' ,
181247 challenge : null ,
248+ deletionSucceed : false ,
182249} ;
183250
184251SubmissionManagementPageContainer . propTypes = {
@@ -199,6 +266,7 @@ SubmissionManagementPageContainer.propTypes = {
199266 showModal : PT . bool ,
200267 onCancelSubmissionDelete : PT . func . isRequired ,
201268 toBeDeletedId : PT . string ,
269+ deletionSucceed : PT . bool ,
202270 onSubmissionDeleteConfirmed : PT . func . isRequired ,
203271 submissionPhaseStartDate : PT . string . isRequired ,
204272} ;
@@ -232,6 +300,7 @@ function mapStateToProps(state, props) {
232300
233301 showModal : state . page . submissionManagement . showModal ,
234302 toBeDeletedId : state . page . submissionManagement . toBeDeletedId ,
303+ deletionSucceed : state . page . submissionManagement . deletionSucceed ,
235304
236305 authTokens : state . auth ,
237306 registrants : state . challenge . details . registrants ,
0 commit comments