-
Notifications
You must be signed in to change notification settings - Fork 21
fix(PM-2662): prevent download for submitters if challenge is configured that way #1385
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
base: dev
Are you sure you want to change the base?
Changes from 1 commit
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,6 +44,7 @@ import type { SubmissionHistoryPartition } from '../../utils' | |||||
| import { TABLE_DATE_FORMAT } from '../../../config/index.config' | ||||||
| import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow' | ||||||
| import { useRolePermissions, UseRolePermissionsResult } from '../../hooks' | ||||||
| import { SUBMISSION_DOWNLOAD_RESTRICTION_MESSAGE } from '../../constants' | ||||||
|
|
||||||
| import styles from './TabContentSubmissions.module.scss' | ||||||
|
|
||||||
|
|
@@ -234,24 +235,13 @@ export const TabContentSubmissions: FC<Props> = props => { | |||||
|
|
||||||
| const filteredSubmissions = useMemo<BackendSubmission[]>( | ||||||
| () => { | ||||||
|
|
||||||
| const filterFunc = (submissions: BackendSubmission[]): BackendSubmission[] => submissions | ||||||
| .filter(submission => { | ||||||
| if (!canViewSubmissions) { | ||||||
| return String(submission.memberId) === String(loginUserInfo?.userId) | ||||||
| } | ||||||
|
|
||||||
| return true | ||||||
| }) | ||||||
| const filteredByUserId = filterFunc(latestBackendSubmissions) | ||||||
| const filteredByUserIdSubmissions = filterFunc(props.submissions) | ||||||
| if (restrictToLatest && hasLatestFlag) { | ||||||
| return latestBackendSubmissions.length | ||||||
| ? filteredByUserId | ||||||
| : filteredByUserIdSubmissions | ||||||
| ? latestBackendSubmissions | ||||||
| : props.submissions | ||||||
| } | ||||||
|
|
||||||
| return filteredByUserIdSubmissions | ||||||
| return props.submissions | ||||||
| }, | ||||||
| [ | ||||||
| latestBackendSubmissions, | ||||||
|
|
@@ -280,13 +270,21 @@ export const TabContentSubmissions: FC<Props> = props => { | |||||
| ? undefined | ||||||
| : submission.virusScan | ||||||
| const failedScan = normalizedVirusScan === false | ||||||
| const isRestricted = isRestrictedBase || failedScan | ||||||
| const tooltipMessage = failedScan | ||||||
| const canDownloadSubmission = ( | ||||||
| !canViewSubmissions && String(submission.memberId) === String(loginUserInfo?.userId) | ||||||
|
||||||
| !canViewSubmissions && String(submission.memberId) === String(loginUserInfo?.userId) | |
| canViewSubmissions || String(submission.memberId) === String(loginUserInfo?.userId) |
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.
@hentrymartin can update? Both AIs are in agreement about the inverted logic.
Outdated
Copilot
AI
Dec 18, 2025
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.
The variable name canDownloadSubmission is misleading. It actually represents whether the user CAN download (they own it and can't view all), but it's used with a negation in the restriction check. Consider renaming to cannotDownloadSubmission or isDownloadDisabled to match the naming pattern used in other files like TableIterativeReview.tsx and TableCheckpointSubmissions.tsx.
hentrymartin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
kkartunov marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ import { useWindowSize, WindowSize } from '~/libs/shared' | |
| import { Table, TableColumn } from '~/libs/ui' | ||
|
|
||
| import { WITHOUT_APPEAL } from '../../../config/index.config' | ||
| import { ChallengeDetailContext } from '../../contexts' | ||
| import { ChallengeDetailContext, ReviewAppContext } from '../../contexts' | ||
| import { useSubmissionDownloadAccess } from '../../hooks/useSubmissionDownloadAccess' | ||
| import type { UseSubmissionDownloadAccessResult } from '../../hooks/useSubmissionDownloadAccess' | ||
| import { useRolePermissions } from '../../hooks/useRolePermissions' | ||
|
|
@@ -22,6 +22,7 @@ import { | |
| ChallengeDetailContextModel, | ||
| ChallengeInfo, | ||
| MappingReviewAppeal, | ||
| ReviewAppContextModel, | ||
| SubmissionInfo, | ||
| } from '../../models' | ||
| import { TableWrapper } from '../TableWrapper' | ||
|
|
@@ -70,7 +71,7 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) => | |
| reviewers, | ||
| }: ChallengeDetailContextModel = useContext(ChallengeDetailContext) | ||
| const { width: screenWidth }: WindowSize = useWindowSize() | ||
|
|
||
| const { loginUserInfo }: ReviewAppContextModel = useContext(ReviewAppContext) | ||
| const downloadAccess: UseSubmissionDownloadAccessResult = useSubmissionDownloadAccess() | ||
| const { | ||
| getRestrictionMessageForMember, | ||
|
|
@@ -219,13 +220,45 @@ export const TableAppeals: FC<TableAppealsProps> = (props: TableAppealsProps) => | |
| [aggregatedResults], | ||
| ) | ||
|
|
||
| const { canViewAllSubmissions }: UseRolePermissionsResult = useRolePermissions() | ||
|
|
||
| const isCompletedDesignChallenge = useMemo(() => { | ||
| if (!challengeInfo) return false | ||
| const type = challengeInfo.track.name ? String(challengeInfo.track.name) | ||
| .toLowerCase() : '' | ||
| const status = challengeInfo.status ? String(challengeInfo.status) | ||
| .toLowerCase() : '' | ||
| return type === 'design' && ( | ||
| status === 'completed' | ||
| ) | ||
| }, [challengeInfo]) | ||
|
|
||
| const isSubmissionsViewable = useMemo(() => { | ||
| if (!challengeInfo?.metadata?.length) return false | ||
| return challengeInfo.metadata.some(m => m.name === 'submissionsViewable' && String(m.value) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .toLowerCase() === 'true') | ||
| }, [challengeInfo]) | ||
|
|
||
| const canViewSubmissions = useMemo(() => { | ||
| if (isCompletedDesignChallenge) { | ||
| return canViewAllSubmissions || isSubmissionsViewable | ||
| } | ||
|
|
||
| return true | ||
| }, [isCompletedDesignChallenge, isSubmissionsViewable, canViewAllSubmissions]) | ||
|
|
||
| const isSubmissionNotViewable = (submission: SubmissionRow): boolean => ( | ||
| !canViewSubmissions && String(submission.memberId) !== String(loginUserInfo?.userId) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| const downloadButtonConfig = useMemo<DownloadButtonConfig>( | ||
| () => ({ | ||
| downloadSubmission, | ||
| getRestrictionMessageForMember, | ||
| isDownloading, | ||
| isSubmissionDownloadRestricted, | ||
| isSubmissionDownloadRestrictedForMember, | ||
| isSubmissionNotViewable, | ||
| ownedMemberIds, | ||
| restrictionMessage, | ||
| shouldRestrictSubmitterToOwnSubmission: false, | ||
|
Comment on lines
254
to
264
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ import { resolveSubmissionReviewResult } from '../common/reviewResult' | |
| import { ProgressBar } from '../ProgressBar' | ||
| import { TableWrapper } from '../TableWrapper' | ||
| import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow' | ||
| import { SUBMISSION_DOWNLOAD_RESTRICTION_MESSAGE } from '../../constants' | ||
|
|
||
| import styles from './TableIterativeReview.module.scss' | ||
|
|
||
|
|
@@ -505,7 +506,7 @@ export const TableIterativeReview: FC<Props> = (props: Props) => { | |
| const isTablet = useMemo(() => screenWidth <= 744, [screenWidth]) | ||
| const { loginUserInfo }: ReviewAppContextModel = useContext(ReviewAppContext) | ||
| const { actionChallengeRole, myChallengeResources }: useRoleProps = useRole() | ||
| const { isCopilotWithReviewerAssignments }: UseRolePermissionsResult = useRolePermissions() | ||
| const { isCopilotWithReviewerAssignments, canViewAllSubmissions }: UseRolePermissionsResult = useRolePermissions() | ||
| const isSubmitterView = actionChallengeRole === SUBMITTER | ||
| const ownedMemberIds: Set<string> = useMemo( | ||
| (): Set<string> => new Set( | ||
|
|
@@ -658,6 +659,31 @@ export const TableIterativeReview: FC<Props> = (props: Props) => { | |
| const isPostMortemColumn = columnLabelKey === 'postmortem' | ||
| const isApprovalColumn = columnLabelKey === 'approval' | ||
|
|
||
| const isCompletedDesignChallenge = useMemo(() => { | ||
| if (!challengeInfo) return false | ||
| const type = challengeInfo.track.name ? String(challengeInfo.track.name) | ||
| .toLowerCase() : '' | ||
| const status = challengeInfo.status ? String(challengeInfo.status) | ||
| .toLowerCase() : '' | ||
| return type === 'design' && ( | ||
| status === 'completed' | ||
| ) | ||
| }, [challengeInfo]) | ||
|
|
||
| const isSubmissionsViewable = useMemo(() => { | ||
| if (!challengeInfo?.metadata?.length) return false | ||
| return challengeInfo.metadata.some(m => m.name === 'submissionsViewable' && String(m.value) | ||
| .toLowerCase() === 'true') | ||
| }, [challengeInfo]) | ||
|
|
||
| const canViewSubmissions = useMemo(() => { | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (isCompletedDesignChallenge) { | ||
| return canViewAllSubmissions || isSubmissionsViewable | ||
| } | ||
|
|
||
| return true | ||
| }, [isCompletedDesignChallenge, isSubmissionsViewable, canViewAllSubmissions]) | ||
|
Comment on lines
+679
to
+685
|
||
|
|
||
| const submissionColumn: TableColumn<SubmissionInfo> = useMemo( | ||
| () => ({ | ||
| className: styles.submissionColumn, | ||
|
|
@@ -682,10 +708,14 @@ export const TableIterativeReview: FC<Props> = (props: Props) => { | |
| ? undefined | ||
| : data.virusScan | ||
| const failedScan = normalizedVirusScan === false | ||
| const isDownloadDisabled = ( | ||
| !canViewSubmissions && String(data.memberId) !== String(loginUserInfo?.userId) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
| const isButtonDisabled = Boolean( | ||
| isDownloading[data.id] | ||
| || isRestrictedForMember | ||
| || failedScan, | ||
| || failedScan | ||
| || isDownloadDisabled, | ||
| ) | ||
|
|
||
| const downloadButton = ( | ||
|
|
@@ -712,14 +742,18 @@ export const TableIterativeReview: FC<Props> = (props: Props) => { | |
| }) | ||
| } | ||
|
|
||
| const tooltipContent = failedScan | ||
| let tooltipContent = failedScan | ||
| ? 'Submission failed virus scan' | ||
| : isRestrictedForMember | ||
| ? memberRestrictionMessage ?? restrictionMessage | ||
| : isOwnershipRestricted | ||
| ? DOWNLOAD_OWN_SUBMISSION_TOOLTIP | ||
| : (isSubmissionDownloadRestricted && restrictionMessage) || undefined | ||
|
|
||
| if (isDownloadDisabled) { | ||
| tooltipContent = SUBMISSION_DOWNLOAD_RESTRICTION_MESSAGE | ||
| } | ||
|
|
||
| const downloadControl = isOwnershipRestricted ? ( | ||
| <span className={styles.textBlue}> | ||
| {data.id} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ import { MobileTableColumn } from '~/apps/admin/src/lib/models/MobileTableColumn | |
| import { handleError, useWindowSize, WindowSize } from '~/libs/shared' | ||
| import { IconOutline, Table, TableColumn } from '~/libs/ui' | ||
|
|
||
| import { ChallengeDetailContext } from '../../contexts' | ||
| import { ChallengeDetailContext, ReviewAppContext } from '../../contexts' | ||
| import { useRole, useScorecardPassingScores, useSubmissionDownloadAccess } from '../../hooks' | ||
| import type { useRoleProps } from '../../hooks/useRole' | ||
| import { useSubmissionHistory } from '../../hooks/useSubmissionHistory' | ||
|
|
@@ -28,6 +28,7 @@ import type { UseSubmissionDownloadAccessResult } from '../../hooks/useSubmissio | |
| import { | ||
| ChallengeDetailContextModel, | ||
| MappingReviewAppeal, | ||
| ReviewAppContextModel, | ||
| SubmissionInfo, | ||
| } from '../../models' | ||
| import { | ||
|
|
@@ -120,6 +121,7 @@ export const TableReview: FC<TableReviewProps> = (props: TableReviewProps) => { | |
| isSubmissionDownloadRestrictedForMember, | ||
| restrictionMessage, | ||
| }: UseSubmissionDownloadAccessResult = useSubmissionDownloadAccess() | ||
| const { loginUserInfo }: ReviewAppContextModel = useContext(ReviewAppContext) | ||
|
|
||
| const isTablet = useMemo<boolean>(() => screenWidth <= 744, [screenWidth]) | ||
| const reviewPhaseDatas = useMemo<SubmissionInfo[]>( | ||
|
|
@@ -379,13 +381,45 @@ export const TableReview: FC<TableReviewProps> = (props: TableReviewProps) => { | |
| [], | ||
| ) | ||
|
|
||
| const { canViewAllSubmissions }: UseRolePermissionsResult = useRolePermissions() | ||
|
|
||
| const isCompletedDesignChallenge = useMemo(() => { | ||
| if (!challengeInfo) return false | ||
| const type = challengeInfo.track.name ? String(challengeInfo.track.name) | ||
| .toLowerCase() : '' | ||
| const status = challengeInfo.status ? String(challengeInfo.status) | ||
| .toLowerCase() : '' | ||
| return type === 'design' && ( | ||
| status === 'completed' | ||
| ) | ||
| }, [challengeInfo]) | ||
|
|
||
| const isSubmissionsViewable = useMemo(() => { | ||
| if (!challengeInfo?.metadata?.length) return false | ||
| return challengeInfo.metadata.some(m => m.name === 'submissionsViewable' && String(m.value) | ||
| .toLowerCase() === 'true') | ||
| }, [challengeInfo]) | ||
|
|
||
| const canViewSubmissions = useMemo(() => { | ||
| if (isCompletedDesignChallenge) { | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return canViewAllSubmissions || isSubmissionsViewable | ||
| } | ||
|
|
||
| return true | ||
| }, [isCompletedDesignChallenge, isSubmissionsViewable, canViewAllSubmissions]) | ||
|
|
||
| const isSubmissionNotViewable = (submission: SubmissionRow): boolean => ( | ||
| !canViewSubmissions && String(submission.memberId) !== String(loginUserInfo?.userId) | ||
hentrymartin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ) | ||
|
|
||
| const downloadButtonConfig = useMemo<DownloadButtonConfig>( | ||
| () => ({ | ||
| downloadSubmission, | ||
| getRestrictionMessageForMember, | ||
| isDownloading, | ||
| isSubmissionDownloadRestricted, | ||
| isSubmissionDownloadRestrictedForMember, | ||
| isSubmissionNotViewable, | ||
| ownedMemberIds, | ||
| restrictionMessage, | ||
| shouldRestrictSubmitterToOwnSubmission: false, | ||
|
Comment on lines
415
to
425
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.