Skip to content

Commit 51c2948

Browse files
author
Vikas Agarwal
committed
git#1154-Prevent activation of challenge when BA associated to the project is not active
- preventing activation instead of just showing the expired symbol
1 parent d6be45b commit 51c2948

File tree

6 files changed

+38
-12
lines changed

6 files changed

+38
-12
lines changed

src/components/ChallengeEditor/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,11 @@ class ChallengeEditor extends Component {
655655
toggleLaunch (e) {
656656
e.preventDefault()
657657
if (this.validateChallenge()) {
658-
this.setState({ isLaunch: true })
658+
if (!this.props.isBillingAccountExpired) {
659+
this.setState({ isLaunch: true })
660+
} else {
661+
this.setState({ isLaunch: true, error: 'Unable to activate challenge as Billing Account is not active.' })
662+
}
659663
}
660664
}
661665

@@ -1279,6 +1283,7 @@ class ChallengeEditor extends Component {
12791283
errorMessage={this.state.error}
12801284
onCancel={this.resetModal}
12811285
onConfirm={this.onActiveChallenge}
1286+
disableConfirmButton={isBillingAccountExpired}
12821287
/>
12831288
)
12841289
}

src/components/ChallengesComponent/ChallengeCard/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,11 @@ class ChallengeCard extends React.Component {
209209

210210
onUpdateLaunch () {
211211
if (!this.state.isLaunch) {
212-
this.setState({ isLaunch: true })
212+
if (!this.props.isBillingAccountExpired) {
213+
this.setState({ isLaunch: true })
214+
} else {
215+
this.setState({ isLaunch: true, error: 'Unable to activate challenge as Billing Account is not active.' })
216+
}
213217
}
214218
}
215219

@@ -272,7 +276,7 @@ class ChallengeCard extends React.Component {
272276

273277
render () {
274278
const { isLaunch, isConfirm, isSaving, isDeleteLaunch, isCheckChalengePermission, hasEditChallengePermission } = this.state
275-
const { challenge, shouldShowCurrentPhase, reloadChallengeList } = this.props
279+
const { challenge, shouldShowCurrentPhase, reloadChallengeList, isBillingAccountExpired } = this.props
276280
const { phaseMessage, endTime } = getPhaseInfo(challenge)
277281
const deleteMessage = isCheckChalengePermission
278282
? 'Checking permissions...'
@@ -305,6 +309,7 @@ class ChallengeCard extends React.Component {
305309
errorMessage={this.state.error}
306310
onCancel={this.resetModal}
307311
onConfirm={this.onLaunchChallenge}
312+
disableConfirmButton={isBillingAccountExpired}
308313
/>
309314
)
310315
}
@@ -364,7 +369,8 @@ ChallengeCard.propTypes = {
364369
shouldShowCurrentPhase: PropTypes.bool,
365370
reloadChallengeList: PropTypes.func,
366371
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
367-
deleteChallenge: PropTypes.func.isRequired
372+
deleteChallenge: PropTypes.func.isRequired,
373+
isBillingAccountExpired: PropTypes.bool
368374
}
369375

370376
export default withRouter(ChallengeCard)

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ class ChallengeList extends Component {
103103
perPage,
104104
totalChallenges,
105105
partiallyUpdateChallengeDetails,
106-
deleteChallenge
106+
deleteChallenge,
107+
isBillingAccountExpired
107108
} = this.props
108109
if (warnMessage) {
109110
return <Message warnMessage={warnMessage} />
@@ -215,6 +216,7 @@ class ChallengeList extends Component {
215216
reloadChallengeList={this.reloadChallengeList}
216217
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
217218
deleteChallenge={deleteChallenge}
219+
isBillingAccountExpired={isBillingAccountExpired}
218220
/>
219221
</li>
220222
)
@@ -258,7 +260,8 @@ ChallengeList.propTypes = {
258260
perPage: PropTypes.number.isRequired,
259261
totalChallenges: PropTypes.number.isRequired,
260262
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
261-
deleteChallenge: PropTypes.func.isRequired
263+
deleteChallenge: PropTypes.func.isRequired,
264+
isBillingAccountExpired: PropTypes.bool
262265
}
263266

264267
export default ChallengeList

src/components/ChallengesComponent/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ const ChallengesComponent = ({
2727
perPage,
2828
totalChallenges,
2929
partiallyUpdateChallengeDetails,
30-
deleteChallenge
30+
deleteChallenge,
31+
isBillingAccountExpired
3132
}) => {
3233
return (
3334
<Sticky top={10}>
@@ -88,6 +89,7 @@ const ChallengesComponent = ({
8889
totalChallenges={totalChallenges}
8990
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
9091
deleteChallenge={deleteChallenge}
92+
isBillingAccountExpired={isBillingAccountExpired}
9193
/>
9294
)}
9395
</div>
@@ -112,7 +114,8 @@ ChallengesComponent.propTypes = {
112114
perPage: PropTypes.number.isRequired,
113115
totalChallenges: PropTypes.number.isRequired,
114116
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
115-
deleteChallenge: PropTypes.func.isRequired
117+
deleteChallenge: PropTypes.func.isRequired,
118+
isBillingAccountExpired: PropTypes.bool
116119
}
117120

118121
ChallengesComponent.defaultProps = {

src/containers/ChallengeEditor/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ class ChallengeEditor extends Component {
148148
}
149149

150150
onLaunchChallenge () {
151-
this.setState({ showLaunchModal: true })
151+
if (!this.props.isBillingAccountExpired) {
152+
this.setState({ showLaunchModal: true })
153+
} else {
154+
this.setState({ showLaunchModal: true, launchError: 'Unable to activate challenge as Billing Account is not active.' })
155+
}
152156
}
153157

154158
onCloseTask () {
@@ -289,6 +293,7 @@ class ChallengeEditor extends Component {
289293
errorMessage={this.state.launchError}
290294
onCancel={this.closeLaunchModal}
291295
onConfirm={this.activateChallenge}
296+
disableConfirmButton={isBillingAccountExpired}
292297
/>
293298
const closeTaskModal = <ConfirmationModal
294299
title='Confirm Close Task'

src/containers/Challenges/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class Challenges extends Component {
8787
totalChallenges,
8888
setActiveProject,
8989
partiallyUpdateChallengeDetails,
90-
deleteChallenge
90+
deleteChallenge,
91+
isBillingAccountExpired
9192
} = this.props
9293
const { searchProjectName, onlyMyProjects } = this.state
9394
const projectInfo = _.find(projects, { id: activeProjectId }) || {}
@@ -149,6 +150,7 @@ class Challenges extends Component {
149150
totalChallenges={totalChallenges}
150151
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
151152
deleteChallenge={deleteChallenge}
153+
isBillingAccountExpired={isBillingAccountExpired}
152154
/>
153155
}
154156
</Fragment>
@@ -176,15 +178,17 @@ Challenges.propTypes = {
176178
loadProjects: PropTypes.func.isRequired,
177179
setActiveProject: PropTypes.func.isRequired,
178180
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
179-
deleteChallenge: PropTypes.func.isRequired
181+
deleteChallenge: PropTypes.func.isRequired,
182+
isBillingAccountExpired: PropTypes.bool
180183
}
181184

182185
const mapStateToProps = ({ challenges, sidebar, projects }) => ({
183186
..._.omit(challenges, ['projectId']),
184187
challengeProjectId: challenges.projectId,
185188
activeProjectId: sidebar.activeProjectId,
186189
projects: sidebar.projects,
187-
projectDetail: projects.projectDetail
190+
projectDetail: projects.projectDetail,
191+
isBillingAccountExpired: projects.isBillingAccountExpired
188192
})
189193

190194
const mapDispatchToProps = {

0 commit comments

Comments
 (0)