Skip to content

Commit 328cc19

Browse files
committed
Show challenge BA on challenge page, not project BA
#1533 #1532
1 parent c9cfcca commit 328cc19

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
lines changed

src/components/ChallengeEditor/ChallengeView/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const ChallengeView = ({
4949
showRejectChallengeModal,
5050
loggedInUser
5151
}) => {
52+
const challengeBillingAccount = _.get(challenge, 'billing.billingAccountId')
5253
const selectedType = _.find(metadata.challengeTypes, { id: challenge.typeId })
5354
const challengeTrack = _.find(metadata.challengeTracks, { id: challenge.trackId })
5455
const selectedMilestone = challenge.milestoneId
@@ -196,7 +197,7 @@ const ChallengeView = ({
196197
<div className={styles.col}>
197198
<span>
198199
<span className={styles.fieldTitle}>Billing Account Id:</span>
199-
{projectDetail.billingAccountId}
200+
{challengeBillingAccount}
200201
</span>
201202
{isBillingAccountExpired && <span className={styles.expiredMessage}>Expired</span>}
202203
</div>

src/components/ChallengeEditor/Submissions/index.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
getRatingLevel,
1616
sortList,
1717
getProvisionalScore,
18-
getFinalScore
18+
getFinalScore,
19+
checkManageRoles
1920
} from '../../../util/tc'
2021
import {
2122
getTopcoderReactLib
@@ -207,12 +208,12 @@ class SubmissionsComponent extends React.Component {
207208
render () {
208209
const { challenge, token } = this.props
209210
const { checkpoints, track, type, tags } = challenge
211+
const haveManagePermission = checkManageRoles(token)
210212

211213
const { field, sort } = this.getSubmissionsSortParam()
212214
const revertSort = sort === 'desc' ? 'asc' : 'desc'
213215

214216
const { sortedSubmissions, downloadingAll } = this.state
215-
console.log('totest sortedSubmissions', sortedSubmissions)
216217

217218
const renderSubmission = s => (
218219
<div className={styles.submission} key={s.id}>
@@ -308,7 +309,7 @@ class SubmissionsComponent extends React.Component {
308309

309310
return (
310311
<div className={cn(styles.container, styles.dev, styles['non-mm'])}>
311-
<div className={styles['empty-left']} />
312+
{haveManagePermission ? (<div className={styles['empty-left']} />) : null}
312313
<div className={styles.submissionsContainer}>
313314
<div className={styles.head}>
314315
{!isF2F && !isBugHunt && (
@@ -405,11 +406,11 @@ class SubmissionsComponent extends React.Component {
405406
>
406407
<span>Legacy submission ID</span>
407408
</div>
408-
<div
409+
{haveManagePermission ? (<div
409410
className={cn(styles['col-8'])}
410411
>
411412
<span>Actions</span>
412-
</div>
413+
</div>) : null}
413414
</div>
414415
{sortedSubmissions.map(s => (
415416
<div
@@ -464,11 +465,10 @@ class SubmissionsComponent extends React.Component {
464465
<div className={styles['col-7']}>
465466
{s.legacySubmissionId}
466467
</div>
467-
<div className={styles['col-8']}>
468+
{haveManagePermission ? (<div className={styles['col-8']}>
468469
<button
469470
onClick={() => {
470471
// download submission
471-
console.log('totest download submission')
472472
const reactLib = getTopcoderReactLib()
473473
const { getService } = reactLib.services.submissions
474474
const submissionsService = getService(token)
@@ -487,12 +487,12 @@ class SubmissionsComponent extends React.Component {
487487
>
488488
<ReactSVG path={assets(`${Download}`)} />
489489
</button>
490-
</div>
490+
</div>) : null}
491491
</div>
492492
))}
493493
</div>
494494

495-
<div className={styles['top-title']} >
495+
{haveManagePermission ? (<div className={styles['top-title']} >
496496
<div className={styles.btnManageSubmissions} >
497497
<PrimaryButton
498498
text='Download All'
@@ -540,7 +540,7 @@ class SubmissionsComponent extends React.Component {
540540
}}
541541
/>
542542
</div>
543-
</div>
543+
</div>) : null}
544544
</div>
545545
)
546546
}

src/config/constants.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,14 @@ export const ALLOWED_USER_ROLES = [
233233
'topcoder user'
234234
]
235235

236+
export const ALLOWED_MANAGE_ROLES = [
237+
'copilot',
238+
'administrator',
239+
'connect admin',
240+
'connect manager',
241+
'connect copilot'
242+
]
243+
236244
export const READ_ONLY_ROLES = [
237245
'topcoder user'
238246
]

src/util/tc.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
ALLOWED_USER_ROLES,
88
ADMIN_ROLES,
99
SUBMITTER_ROLE_UUID,
10-
READ_ONLY_ROLES
10+
READ_ONLY_ROLES,
11+
ALLOWED_MANAGE_ROLES
1112
} from '../config/constants'
1213
import _ from 'lodash'
1314
import { decodeToken } from 'tc-auth-lib'
@@ -171,6 +172,15 @@ export const checkOnlyReadOnlyRoles = token => {
171172
return roles.some(val => READ_ONLY_ROLES.indexOf(val.toLowerCase()) > -1)
172173
}
173174

175+
/**
176+
* Checks if this role can have manage permission
177+
* @param token
178+
*/
179+
export const checkManageRoles = token => {
180+
const roles = _.get(decodeToken(token), 'roles')
181+
return roles.some(val => ALLOWED_MANAGE_ROLES.indexOf(val.toLowerCase()) > -1)
182+
}
183+
174184
/**
175185
* Checks if token has any of the admin roles
176186
* @param token

0 commit comments

Comments
 (0)