Skip to content

Commit b117c10

Browse files
committed
Merge branch 'develop' of github.com:topcoder-platform/community-app into develop
2 parents 8acb26b + 3cddd60 commit b117c10

File tree

3 files changed

+55
-15
lines changed

3 files changed

+55
-15
lines changed

__tests__/shared/components/SubmissionManagement/__snapshots__/SubmissionsTable.jsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ exports[`Matches shallow shapshot 1`] = `
3030
"id": "test-challenge",
3131
}
3232
}
33+
isWorkflowRunComplete={true}
3334
onDelete={[Function]}
3435
onDownload={[Function]}
3536
onOpenDownloadArtifactsModal={[Function]}

src/shared/components/SubmissionManagement/Submission/index.jsx

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default function Submission(props) {
4242
onOpenRatingsListModal,
4343
status,
4444
allowDelete,
45+
isWorkflowRunComplete,
4546
} = props;
4647
const formatDate = date => moment(+new Date(date)).format('MMM DD, YYYY hh:mm A');
4748
const onDownloadSubmission = onDownload.bind(1, submissionObject.id);
@@ -66,6 +67,10 @@ export default function Submission(props) {
6667
}
6768
}
6869

70+
const showDeleteButton = status !== CHALLENGE_STATUS.COMPLETED
71+
&& track === COMPETITION_TRACKS.DES
72+
&& safeForDownloadCheck === true;
73+
6974
return (
7075
<tr styleName="submission-row">
7176
<td styleName="id-col">
@@ -146,17 +151,33 @@ export default function Submission(props) {
146151
onClick={() => onDownload(submissionObject.id)}
147152
><DownloadIcon /></button>
148153
*/ }
149-
{status !== CHALLENGE_STATUS.COMPLETED
150-
&& track === COMPETITION_TRACKS.DES
151-
&& safeForDownloadCheck === true && (
152-
<button
153-
styleName="delete-icon"
154-
onClick={() => onDelete(submissionObject.id)}
155-
disabled={!allowDelete}
156-
type="button"
157-
>
158-
<DeleteIcon />
159-
</button>
154+
{showDeleteButton && (
155+
isWorkflowRunComplete ? (
156+
<button
157+
styleName="delete-icon"
158+
onClick={() => onDelete(submissionObject.id)}
159+
type="button"
160+
disabled={!allowDelete}
161+
>
162+
<DeleteIcon />
163+
</button>
164+
) : (
165+
// Disabled delete button with tooltip when workflow run is pending
166+
<Tooltip content={() => (
167+
<div styleName="tooltip-content">
168+
You can delete this submission only after the review is complete.
169+
</div>
170+
)}
171+
>
172+
<button
173+
styleName="delete-icon"
174+
disabled
175+
type="button"
176+
>
177+
<DeleteIcon />
178+
</button>
179+
</Tooltip>
180+
)
160181
)
161182
}
162183
{ !isTopCrowdChallenge
@@ -217,4 +238,5 @@ Submission.propTypes = {
217238
allowDelete: PT.bool.isRequired,
218239
onOpenDownloadArtifactsModal: PT.func,
219240
onOpenRatingsListModal: PT.func,
241+
isWorkflowRunComplete: PT.bool.isRequired,
220242
};

src/shared/components/SubmissionManagement/SubmissionsTable/index.jsx

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,29 @@ export default function SubmissionsTable(props) {
7474
submissionObjects.forEach((subObject) => {
7575
// submissionPhaseStartDate will be the start date of
7676
// the current submission/checkpoint or empty string if any other phase
77+
78+
const TERMINAL_STATUSES = [
79+
'COMPLETED',
80+
'FAILURE',
81+
'CANCELLED',
82+
'SUCCESS',
83+
];
84+
85+
const workflowRunsForSubmission = submissionWorkflowRuns
86+
&& submissionWorkflowRuns[subObject.id]
87+
? submissionWorkflowRuns[subObject.id]
88+
: null;
89+
90+
const hasRuns = workflowRunsForSubmission && workflowRunsForSubmission.length > 0;
91+
92+
const isWorkflowRunComplete = !hasRuns
93+
? true
94+
: workflowRunsForSubmission.every(run => TERMINAL_STATUSES.includes(run.status));
95+
7796
const allowDelete = submissionPhaseStartDate
7897
&& moment(subObject.submissionDate).isAfter(submissionPhaseStartDate);
7998

99+
80100
const submission = (
81101
<Submission
82102
challenge={challenge}
@@ -91,13 +111,10 @@ export default function SubmissionsTable(props) {
91111
allowDelete={allowDelete}
92112
onOpenDownloadArtifactsModal={onOpenDownloadArtifactsModal}
93113
onOpenRatingsListModal={onOpenRatingsListModal}
114+
isWorkflowRunComplete={isWorkflowRunComplete}
94115
/>
95116
);
96117
submissionsWithDetails.push(submission);
97-
const workflowRunsForSubmission = submissionWorkflowRuns
98-
&& submissionWorkflowRuns[subObject.id]
99-
? submissionWorkflowRuns[subObject.id]
100-
: null;
101118

102119
const submissionDetail = (
103120
<tr key={subObject.id} styleName="submission-row">

0 commit comments

Comments
 (0)