-
Notifications
You must be signed in to change notification settings - Fork 18
Topcoder Admin App - Add Non-MM Submission Management #1191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
/** | ||
* Manage Submission Page. | ||
*/ | ||
import { FC } from 'react' | ||
import { FC, useMemo } from 'react' | ||
import { useParams } from 'react-router-dom' | ||
import classNames from 'classnames' | ||
|
||
import { LinkButton } from '~/libs/ui' | ||
|
||
import { | ||
useDownloadSubmission, | ||
useDownloadSubmissionProps, | ||
useFetchChallenge, | ||
useFetchChallengeProps, | ||
useManageAVScan, | ||
useManageAVScanProps, | ||
useManageBusEvent, | ||
useManageBusEventProps, | ||
useManageChallengeSubmissions, | ||
|
@@ -20,6 +26,7 @@ import { | |
TableLoading, | ||
TableNoRecord, | ||
} from '../../lib' | ||
import { checkIsMM } from '../../lib/utils' | ||
|
||
import styles from './ManageSubmissionPage.module.scss' | ||
|
||
|
@@ -35,7 +42,13 @@ export const ManageSubmissionPage: FC<Props> = (props: Props) => { | |
= useManageBusEvent() | ||
|
||
const { | ||
isLoading, | ||
isLoading: isLoadingChallenge, | ||
challengeInfo, | ||
}: useFetchChallengeProps = useFetchChallenge(challengeId) | ||
const isMM = useMemo(() => checkIsMM(challengeInfo), [challengeInfo]) | ||
|
||
const { | ||
isLoading: isLoadingSubmission, | ||
submissions, | ||
isRemovingSubmission, | ||
isRemovingSubmissionBool, | ||
|
@@ -48,6 +61,19 @@ export const ManageSubmissionPage: FC<Props> = (props: Props) => { | |
}: useManageChallengeSubmissionsProps | ||
= useManageChallengeSubmissions(challengeId) | ||
|
||
const { | ||
isLoading: isDownloadingSubmission, | ||
isLoadingBool: isDownloadingSubmissionBool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable |
||
downloadSubmission, | ||
}: useDownloadSubmissionProps = useDownloadSubmission() | ||
const { | ||
isLoading: isDoingAvScan, | ||
isLoadingBool: isDoingAvScanBool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comment, |
||
doPostBusEvent: doPostBusEventAvScan, | ||
}: useManageAVScanProps = useManageAVScan() | ||
|
||
const isLoading = isLoadingSubmission || isLoadingChallenge | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
return ( | ||
<PageWrapper | ||
pageTitle='Submission Management' | ||
|
@@ -67,6 +93,10 @@ export const ManageSubmissionPage: FC<Props> = (props: Props) => { | |
) : ( | ||
<div className={styles.blockTableContainer}> | ||
<SubmissionTable | ||
isDoingAvScan={isDoingAvScan} | ||
doPostBusEventAvScan={doPostBusEventAvScan} | ||
isDownloading={isDownloadingSubmission} | ||
downloadSubmission={downloadSubmission} | ||
data={submissions} | ||
isRemovingSubmission={isRemovingSubmission} | ||
doRemoveSubmission={doRemoveSubmission} | ||
|
@@ -80,9 +110,12 @@ export const ManageSubmissionPage: FC<Props> = (props: Props) => { | |
doPostBusEvent={doPostBusEvent} | ||
showSubmissionHistory={showSubmissionHistory} | ||
setShowSubmissionHistory={setShowSubmissionHistory} | ||
isMM={isMM} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
/> | ||
|
||
{(isRemovingSubmissionBool | ||
{(isDoingAvScanBool | ||
|| isDownloadingSubmissionBool | ||
|| isRemovingSubmissionBool | ||
|| isRunningTestBool | ||
|| isRemovingReviewSummationsBool) && ( | ||
<ActionLoading /> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,14 @@ | |
*/ | ||
import { v4 as uuidv4 } from 'uuid' | ||
|
||
import { RequestBusAPI } from '../lib/models' | ||
import { | ||
RequestBusAPI, | ||
RequestBusAPIAVScan, | ||
RequestBusAPIAVScanPayload, | ||
} from '../lib/models' | ||
|
||
/** | ||
* Create data for bus event | ||
* Create data for data submission marathon match bus event | ||
* @param submissionId submission id | ||
* @param testType test type | ||
* @returns data for bus event | ||
|
@@ -27,3 +31,19 @@ export const CREATE_BUS_EVENT_DATA_SUBMISSION_MARATHON_MATCH = ( | |
.toISOString(), | ||
topic: 'submission.notification.score', | ||
}) | ||
|
||
/** | ||
* Create data for av rescan bus event | ||
* @param payload av rescan payload | ||
* @returns data for bus event | ||
*/ | ||
export const CREATE_BUS_EVENT_AV_RESCAN = ( | ||
payload: RequestBusAPIAVScanPayload, | ||
): RequestBusAPIAVScan => ({ | ||
'mime-type': 'application/json', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using consistent casing for keys. The key 'mime-type' uses kebab-case, while other keys use camelCase. It might be beneficial to standardize the casing for consistency. |
||
originator: 'submission-processor', | ||
payload, | ||
timestamp: new Date() | ||
.toISOString(), | ||
topic: 'avscan.action.scan', | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Submission Table Actions For Non MM Challenge. | ||
*/ | ||
import { Dispatch, FC, SetStateAction } from 'react' | ||
|
||
import { Button } from '~/libs/ui' | ||
|
||
import { IsRemovingType, Submission } from '../../models' | ||
|
||
interface Props { | ||
data: Submission | ||
showSubmissionHistory: IsRemovingType | ||
setShowSubmissionHistory: Dispatch<SetStateAction<IsRemovingType>> | ||
} | ||
|
||
export const ShowHistoryButton: FC<Props> = (props: Props) => ( | ||
<Button | ||
onClick={function onClick() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider using an arrow function for the |
||
props.setShowSubmissionHistory(prev => ({ | ||
...prev, | ||
[props.data.id]: !prev[props.data.id], | ||
})) | ||
}} | ||
> | ||
{props.showSubmissionHistory[props.data.id] ? 'Hide' : 'Show'} | ||
{' '} | ||
History | ||
</Button> | ||
) | ||
|
||
export default ShowHistoryButton |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ | |
.rowActions { | ||
display: flex; | ||
align-items: center; | ||
|
||
@include ltelg { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The mixin |
||
flex-wrap: wrap; | ||
} | ||
} | ||
|
||
.desktopTable { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useMemo
is used here to memoize the result ofcheckIsMM(challengeInfo)
. Ensure thatcheckIsMM
is a pure function, as impure functions can lead to unexpected behavior when used withuseMemo
.