Skip to content

Commit aa6280a

Browse files
Merge pull request #1285 from doctorhilarius/self-service-opps
Self Service App -- approved challenges tab
2 parents 3e3f19a + 9dc43bf commit aa6280a

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@ const ChallengeViewTabs = ({
8989
const isSelfServiceCopilot = challenge.legacy.selfServiceCopilot === loggedInUser.handle
9090
const isAdmin = checkAdmin(token)
9191
const canApprove = isSelfServiceCopilot && isDraft && isSelfService
92-
// only the copilot can launch AND
92+
const hasBillingAccount = _.get(projectDetail, 'billingAccountId') !== null
93+
// only challenges that have a billing account can be launched AND
9394
// if this isn't self-service, permit launching if the challenge is draft
94-
// OR if this is self-service, permit launching if the challenge is approved
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'))
95+
// OR if this isn't a non-self-service draft, permit launching if:
96+
// a) the current user is either the self-service copilot or is an admin AND
97+
// b) the challenge is approved
98+
const canLaunch = hasBillingAccount &&
99+
((!isSelfService && isDraft) ||
100+
((isSelfServiceCopilot || isAdmin) &&
101+
challenge.status.toUpperCase() === CHALLENGE_STATUS.APPROVED))
102+
99103
return (
100104
<div className={styles.list}>
101105
<Helmet title='View Details' />

src/components/ChallengesComponent/ChallengeCard/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ const hoverComponents = (challenge, onUpdateLaunch, deleteModalLaunch) => {
166166
const renderStatus = (status, getStatusText) => {
167167
switch (status) {
168168
case CHALLENGE_STATUS.ACTIVE:
169+
case CHALLENGE_STATUS.APPROVED:
169170
case CHALLENGE_STATUS.NEW:
170171
case CHALLENGE_STATUS.DRAFT:
171172
case CHALLENGE_STATUS.COMPLETED:

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,12 @@ class ChallengeList extends Component {
129129

130130
let selectedTab = 0
131131
switch (status) {
132+
case CHALLENGE_STATUS.APPROVED:
132133
case CHALLENGE_STATUS.NEW:
133134
selectedTab = 1
134135
break
135136
case CHALLENGE_STATUS.DRAFT:
136-
selectedTab = selfService ? 1 : 2
137+
selectedTab = 2
137138
break
138139
case CHALLENGE_STATUS.COMPLETED:
139140
selectedTab = 3
@@ -184,7 +185,7 @@ class ChallengeList extends Component {
184185
break
185186
}
186187
case 1: {
187-
const status = selfService ? CHALLENGE_STATUS.DRAFT : CHALLENGE_STATUS.NEW
188+
const status = selfService ? CHALLENGE_STATUS.APPROVED : CHALLENGE_STATUS.NEW
188189
this.directUpdateSearchParam(searchText, status)
189190
break
190191
}
@@ -204,14 +205,14 @@ class ChallengeList extends Component {
204205
}}>
205206
<TabList>
206207
<Tab>{(selfService ? 'Assigned challenges' : 'Active')}</Tab>
207-
{(!selfService && <Tab>New</Tab>)}
208+
<Tab>{(selfService ? 'Approved' : 'New')}</Tab>
208209
<Tab>{this.getStatusTextFunc(selfService)(CHALLENGE_STATUS.DRAFT)}</Tab>
209210
{(!selfService && <Tab>Completed</Tab>)}
210211
{(!selfService && <Tab>Cancelled</Tab>)}
211212
</TabList>
212213
<TabPanel />
213214
<TabPanel />
214-
{(!selfService && <TabPanel />)}
215+
<TabPanel />
215216
</Tabs>)}
216217
{
217218
challenges.length === 0 && (

src/components/ChallengesComponent/ChallengeStatus/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import styles from './ChallengeStatus.module.scss'
1212

1313
const statuses = {
1414
[CHALLENGE_STATUS.ACTIVE]: styles.green,
15+
[CHALLENGE_STATUS.APPROVED]: styles.yellow,
1516
[CHALLENGE_STATUS.NEW]: styles.yellow,
1617
[CHALLENGE_STATUS.DRAFT]: styles.gray,
1718
[CHALLENGE_STATUS.COMPLETED]: styles.blue

0 commit comments

Comments
 (0)