Skip to content

Commit 3e3f19a

Browse files
minor fixes on access check
1 parent 3b90fe6 commit 3e3f19a

File tree

1 file changed

+9
-6
lines changed
  • src/components/ChallengeEditor/ChallengeViewTabs

1 file changed

+9
-6
lines changed

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import LegacyLinks from '../../LegacyLinks'
1313
import ForumLink from '../../ForumLink'
1414
import Registrants from '../Registrants'
1515
import Submissions from '../Submissions'
16-
import { getResourceRoleByName } from '../../../util/tc'
16+
import { checkAdmin, getResourceRoleByName } from '../../../util/tc'
1717
import { CHALLENGE_STATUS, MESSAGE } from '../../../config/constants'
1818
import Tooltip from '../../Tooltip'
1919
import CancelDropDown from '../Cancel-Dropdown'
@@ -86,13 +86,16 @@ const ChallengeViewTabs = ({
8686

8787
const isSelfService = challenge.legacy.selfService
8888
const isDraft = challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT
89-
const isCopilot = challenge.legacy.selfServiceCopilot === loggedInUser.handle
90-
const canApprove = isCopilot && isDraft && isSelfService
89+
const isSelfServiceCopilot = challenge.legacy.selfServiceCopilot === loggedInUser.handle
90+
const isAdmin = checkAdmin(token)
91+
const canApprove = isSelfServiceCopilot && isDraft && isSelfService
9192
// only the copilot can launch AND
9293
// if this isn't self-service, permit launching if the challenge is draft
9394
// OR if this is self-service, permit launching if the challenge is approved
94-
const canLaunch = isCopilot && ((!isSelfService && isDraft) || challenge.status.toUpperCase() === CHALLENGE_STATUS.APPROVED)
95-
95+
const hasBA = _.get(projectDetail, 'billingAccountId') !== null
96+
const canLaunch = hasBA && ((!isSelfService && isDraft) || ((isSelfServiceCopilot || isAdmin) && challenge.status.toUpperCase() === CHALLENGE_STATUS.APPROVED))
97+
console.log(`can launch ${_.isEmpty(_.get(projectDetail, 'billingAccountId'))}`)
98+
console.log(_.get(projectDetail, 'billingAccountId'))
9699
return (
97100
<div className={styles.list}>
98101
<Helmet title='View Details' />
@@ -164,7 +167,7 @@ const ChallengeViewTabs = ({
164167
{enableEdit && !isSelfService && (
165168
<PrimaryButton text={'Edit'} type={'info'} submit link={`./edit`} />
166169
)}
167-
{isSelfService && isDraft && isCopilot && (
170+
{isSelfService && isDraft && (isAdmin || isSelfServiceCopilot) && (
168171
<div className={styles.button}>
169172
<PrimaryButton
170173
text='Reject challenge'

0 commit comments

Comments
 (0)