Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@stripe/stripe-js": "1.41.0",
"@tinymce/tinymce-react": "^6.2.1",
"@types/codemirror": "5.60.15",
"amazon-s3-uri": "^0.1.1",
"apexcharts": "^3.36.0",
"axios": "^1.7.9",
"browser-cookies": "^1.2.0",
Expand Down
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,
Expand All @@ -20,6 +26,7 @@ import {
TableLoading,
TableNoRecord,
} from '../../lib'
import { checkIsMM } from '../../lib/utils'

import styles from './ManageSubmissionPage.module.scss'

Expand All @@ -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])

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 of checkIsMM(challengeInfo). Ensure that checkIsMM is a pure function, as impure functions can lead to unexpected behavior when used with useMemo.


const {
isLoading: isLoadingSubmission,
submissions,
isRemovingSubmission,
isRemovingSubmissionBool,
Expand All @@ -48,6 +61,19 @@ export const ManageSubmissionPage: FC<Props> = (props: Props) => {
}: useManageChallengeSubmissionsProps
= useManageChallengeSubmissions(challengeId)

const {
isLoading: isDownloadingSubmission,
isLoadingBool: isDownloadingSubmissionBool,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable isLoadingBool seems redundant if isLoading already represents the loading state. Consider removing isLoadingBool unless it serves a distinct purpose.

downloadSubmission,
}: useDownloadSubmissionProps = useDownloadSubmission()
const {
isLoading: isDoingAvScan,
isLoadingBool: isDoingAvScanBool,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous comment, isLoadingBool appears redundant if isLoading is sufficient to represent the loading state. Evaluate if both are necessary.

doPostBusEvent: doPostBusEventAvScan,
}: useManageAVScanProps = useManageAVScan()

const isLoading = isLoadingSubmission || isLoadingChallenge

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isLoading variable combines isLoadingSubmission and isLoadingChallenge. Ensure this logic correctly represents the intended loading state for the page, especially if additional loading states are introduced.


return (
<PageWrapper
pageTitle='Submission Management'
Expand All @@ -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}
Expand All @@ -80,9 +110,12 @@ export const ManageSubmissionPage: FC<Props> = (props: Props) => {
doPostBusEvent={doPostBusEvent}
showSubmissionHistory={showSubmissionHistory}
setShowSubmissionHistory={setShowSubmissionHistory}
isMM={isMM}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The isMM prop is added to the component, but it's not clear from the diff if this prop is being used within the component. Ensure that isMM is utilized appropriately within the component to avoid unnecessary prop passing.

/>

{(isRemovingSubmissionBool
{(isDoingAvScanBool
|| isDownloadingSubmissionBool
|| isRemovingSubmissionBool
|| isRunningTestBool
|| isRemovingReviewSummationsBool) && (
<ActionLoading />
Expand Down
24 changes: 22 additions & 2 deletions src/apps/admin/src/config/busEvent.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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',

Choose a reason for hiding this comment

The 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',
})
20 changes: 8 additions & 12 deletions src/apps/admin/src/lib/components/ChallengeList/ChallengeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
import { useEventCallback } from '../../hooks'
import { Challenge, ChallengeFilterCriteria, ChallengeType } from '../../models'
import { Paging } from '../../models/challenge-management/Pagination'
import { checkIsMM } from '../../utils'

import { MobileListView } from './MobileListView'
import styles from './ChallengeList.module.scss'
Expand Down Expand Up @@ -135,7 +134,6 @@ const Actions: FC<{
challenge: Challenge
currentFilters: ChallengeFilterCriteria
}> = props => {
const isMM = useMemo(() => checkIsMM(props.challenge), [props.challenge])
const [openDropdown, setOpenDropdown] = useState(false)
const navigate = useNavigate()
const goToManageUser = useEventCallback(() => {
Expand Down Expand Up @@ -202,16 +200,14 @@ const Actions: FC<{
>
Users
</li>
{isMM && (
<li
onClick={function onClick() {
navigate(`${props.challenge.id}/manage-submission`)
setOpenDropdown(false)
}}
>
Submissions
</li>
)}
<li
onClick={function onClick() {
navigate(`${props.challenge.id}/manage-submission`)
setOpenDropdown(false)
}}
>
Submissions
</li>
</ul>
</DropdownMenu>

Expand Down
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() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using an arrow function for the onClick handler to maintain consistency with modern React practices and improve readability.

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
Expand Up @@ -13,6 +13,10 @@
.rowActions {
display: flex;
align-items: center;

@include ltelg {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mixin ltelg is used here, but it is not clear from the diff whether it is defined or imported correctly in the file. Ensure that the mixin is properly defined or imported to avoid potential errors.

flex-wrap: wrap;
}
}

.desktopTable {
Expand Down
Loading