-
Notifications
You must be signed in to change notification settings - Fork 21
[PROD] - Security, clean up & bug fixes #1368
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 15 commits
5ce15aa
3b1193a
0361d8c
985e16a
1468bd4
57b48d3
6528746
d37b511
195226c
d088964
951de7d
c3baec0
65eec2d
d6462df
da81018
5a25ed2
d216fde
b111246
548b0c4
7fd1d25
b6ed3ed
995d81e
75664d7
2e1fc7d
0563cf0
b8d39fa
48816c5
3db7d1a
61ad75b
e564eed
5b01f5f
72028ad
1b0df87
21226f2
12c4c64
d0a5e6d
86b03c8
4eb2201
8fac84b
5163510
1ced8a1
e9d4976
6ae3ec0
d1cf5c6
23a62d1
9ed7544
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 |
|---|---|---|
|
|
@@ -25,14 +25,15 @@ import { | |
| BackendSubmission, | ||
| ChallengeDetailContextModel, | ||
| convertBackendSubmissionToSubmissionInfo, | ||
| ReviewAppContextModel, | ||
| SubmissionInfo, | ||
| } from '../../models' | ||
| import { TableNoRecord } from '../TableNoRecord' | ||
| import { TableWrapper } from '../TableWrapper' | ||
| import { SubmissionHistoryModal } from '../SubmissionHistoryModal' | ||
| import { useSubmissionDownloadAccess } from '../../hooks/useSubmissionDownloadAccess' | ||
| import type { UseSubmissionDownloadAccessResult } from '../../hooks/useSubmissionDownloadAccess' | ||
| import { ChallengeDetailContext } from '../../contexts' | ||
| import { ChallengeDetailContext, ReviewAppContext } from '../../contexts' | ||
| import { | ||
| challengeHasSubmissionLimit, | ||
| getSubmissionHistoryKey, | ||
|
|
@@ -42,6 +43,7 @@ import { | |
| import type { SubmissionHistoryPartition } from '../../utils' | ||
| import { TABLE_DATE_FORMAT } from '../../../config/index.config' | ||
| import { CollapsibleAiReviewsRow } from '../CollapsibleAiReviewsRow' | ||
| import { useRolePermissions, UseRolePermissionsResult } from '../../hooks' | ||
|
|
||
| import styles from './TabContentSubmissions.module.scss' | ||
|
|
||
|
|
@@ -67,9 +69,36 @@ export const TabContentSubmissions: FC<Props> = props => { | |
| isSubmissionDownloadRestrictedForMember, | ||
| getRestrictionMessageForMember, | ||
| }: UseSubmissionDownloadAccessResult = useSubmissionDownloadAccess() | ||
| const { loginUserInfo }: ReviewAppContextModel = useContext(ReviewAppContext) | ||
| const { canViewAllSubmissions }: UseRolePermissionsResult = useRolePermissions() | ||
|
|
||
| const { challengeInfo }: ChallengeDetailContextModel = useContext(ChallengeDetailContext) | ||
|
|
||
| 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(() => { | ||
|
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. [❗❗ |
||
| 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) { | ||
| return canViewAllSubmissions || isSubmissionsViewable | ||
| } | ||
|
|
||
| return true | ||
| }, [isCompletedDesignChallenge, isSubmissionsViewable, canViewAllSubmissions]) | ||
|
|
||
| const submissionMetaById = useMemo( | ||
| () => { | ||
| const map = new Map<string, BackendSubmission>() | ||
|
|
@@ -205,19 +234,32 @@ export const TabContentSubmissions: FC<Props> = props => { | |
|
|
||
| const filteredSubmissions = useMemo<BackendSubmission[]>( | ||
| () => { | ||
|
|
||
| const filterFunc = (submissions: BackendSubmission[]): BackendSubmission[] => submissions | ||
|
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. [💡 |
||
| .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 | ||
| ? latestBackendSubmissions | ||
| : props.submissions | ||
| ? filteredByUserId | ||
| : filteredByUserIdSubmissions | ||
| } | ||
|
|
||
| return props.submissions | ||
| return filteredByUserIdSubmissions | ||
| }, | ||
| [ | ||
| latestBackendSubmissions, | ||
| props.submissions, | ||
| restrictToLatest, | ||
| hasLatestFlag, | ||
| canViewSubmissions, | ||
| loginUserInfo?.userId, | ||
| ], | ||
| ) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ import { get, includes } from 'lodash' | |
| import { yupResolver } from '@hookform/resolvers/yup' | ||
| import { IconAppeal, IconEdit } from '~/apps/review/src/lib/assets/icons' | ||
| import { ADMIN, COPILOT, REVIEWER } from '~/apps/review/src/config/index.config' | ||
| import { useRolePermissions, UseRolePermissionsResult } from '~/apps/review/src/lib/hooks' | ||
|
|
||
| import { | ||
| AppealInfo, | ||
|
|
@@ -44,6 +45,7 @@ const ReviewComment: FC<ReviewCommentProps> = props => { | |
| addAppeal, | ||
| isSavingAppeal, | ||
| }: ScorecardViewerContextValue = useScorecardViewerContext() | ||
| const { isAdmin, hasReviewerRole }: UseRolePermissionsResult = useRolePermissions() | ||
|
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. [❗❗ |
||
|
|
||
| const { challengeInfo }: ChallengeDetailContextModel = useContext( | ||
| ChallengeDetailContext, | ||
|
|
@@ -175,7 +177,7 @@ const ReviewComment: FC<ReviewCommentProps> = props => { | |
| appeal={props.appeal} | ||
| reviewItem={props.reviewItem} | ||
| scorecardQuestion={props.question} | ||
| canRespondToAppeal={isReviewerRole} | ||
| canRespondToAppeal={isAdmin || hasReviewerRole} | ||
|
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. [❗❗
Collaborator
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. What is this change for? Are we now allowing admins to respond to appeals? I'm not sure that's something we've done in the past? |
||
| > | ||
| {isSubmitter && canAddAppeal && ( | ||
| <div className={styles.blockBtns}> | ||
|
|
||
This file was deleted.
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.
Do we need to check the challenge type here as well? This will match F2Fs in addition to challenges.