Skip to content

Commit

Permalink
git#1154-Prevent activation of challenge when BA associated to the pr…
Browse files Browse the repository at this point in the history
…oject is not active

- preventing activation instead of just showing the expired symbol
  • Loading branch information
Vikas Agarwal committed Jun 1, 2021
1 parent d6be45b commit 51c2948
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 12 deletions.
7 changes: 6 additions & 1 deletion src/components/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,11 @@ class ChallengeEditor extends Component {
toggleLaunch (e) {
e.preventDefault()
if (this.validateChallenge()) {
this.setState({ isLaunch: true })
if (!this.props.isBillingAccountExpired) {
this.setState({ isLaunch: true })
} else {
this.setState({ isLaunch: true, error: 'Unable to activate challenge as Billing Account is not active.' })
}
}
}

Expand Down Expand Up @@ -1279,6 +1283,7 @@ class ChallengeEditor extends Component {
errorMessage={this.state.error}
onCancel={this.resetModal}
onConfirm={this.onActiveChallenge}
disableConfirmButton={isBillingAccountExpired}
/>
)
}
Expand Down
12 changes: 9 additions & 3 deletions src/components/ChallengesComponent/ChallengeCard/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ class ChallengeCard extends React.Component {

onUpdateLaunch () {
if (!this.state.isLaunch) {
this.setState({ isLaunch: true })
if (!this.props.isBillingAccountExpired) {
this.setState({ isLaunch: true })
} else {
this.setState({ isLaunch: true, error: 'Unable to activate challenge as Billing Account is not active.' })
}
}
}

Expand Down Expand Up @@ -272,7 +276,7 @@ class ChallengeCard extends React.Component {

render () {
const { isLaunch, isConfirm, isSaving, isDeleteLaunch, isCheckChalengePermission, hasEditChallengePermission } = this.state
const { challenge, shouldShowCurrentPhase, reloadChallengeList } = this.props
const { challenge, shouldShowCurrentPhase, reloadChallengeList, isBillingAccountExpired } = this.props
const { phaseMessage, endTime } = getPhaseInfo(challenge)
const deleteMessage = isCheckChalengePermission
? 'Checking permissions...'
Expand Down Expand Up @@ -305,6 +309,7 @@ class ChallengeCard extends React.Component {
errorMessage={this.state.error}
onCancel={this.resetModal}
onConfirm={this.onLaunchChallenge}
disableConfirmButton={isBillingAccountExpired}
/>
)
}
Expand Down Expand Up @@ -364,7 +369,8 @@ ChallengeCard.propTypes = {
shouldShowCurrentPhase: PropTypes.bool,
reloadChallengeList: PropTypes.func,
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
deleteChallenge: PropTypes.func.isRequired
deleteChallenge: PropTypes.func.isRequired,
isBillingAccountExpired: PropTypes.bool
}

export default withRouter(ChallengeCard)
7 changes: 5 additions & 2 deletions src/components/ChallengesComponent/ChallengeList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ class ChallengeList extends Component {
perPage,
totalChallenges,
partiallyUpdateChallengeDetails,
deleteChallenge
deleteChallenge,
isBillingAccountExpired
} = this.props
if (warnMessage) {
return <Message warnMessage={warnMessage} />
Expand Down Expand Up @@ -215,6 +216,7 @@ class ChallengeList extends Component {
reloadChallengeList={this.reloadChallengeList}
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
deleteChallenge={deleteChallenge}
isBillingAccountExpired={isBillingAccountExpired}
/>
</li>
)
Expand Down Expand Up @@ -258,7 +260,8 @@ ChallengeList.propTypes = {
perPage: PropTypes.number.isRequired,
totalChallenges: PropTypes.number.isRequired,
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
deleteChallenge: PropTypes.func.isRequired
deleteChallenge: PropTypes.func.isRequired,
isBillingAccountExpired: PropTypes.bool
}

export default ChallengeList
7 changes: 5 additions & 2 deletions src/components/ChallengesComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const ChallengesComponent = ({
perPage,
totalChallenges,
partiallyUpdateChallengeDetails,
deleteChallenge
deleteChallenge,
isBillingAccountExpired
}) => {
return (
<Sticky top={10}>
Expand Down Expand Up @@ -88,6 +89,7 @@ const ChallengesComponent = ({
totalChallenges={totalChallenges}
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
deleteChallenge={deleteChallenge}
isBillingAccountExpired={isBillingAccountExpired}
/>
)}
</div>
Expand All @@ -112,7 +114,8 @@ ChallengesComponent.propTypes = {
perPage: PropTypes.number.isRequired,
totalChallenges: PropTypes.number.isRequired,
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
deleteChallenge: PropTypes.func.isRequired
deleteChallenge: PropTypes.func.isRequired,
isBillingAccountExpired: PropTypes.bool
}

ChallengesComponent.defaultProps = {
Expand Down
7 changes: 6 additions & 1 deletion src/containers/ChallengeEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ class ChallengeEditor extends Component {
}

onLaunchChallenge () {
this.setState({ showLaunchModal: true })
if (!this.props.isBillingAccountExpired) {
this.setState({ showLaunchModal: true })
} else {
this.setState({ showLaunchModal: true, launchError: 'Unable to activate challenge as Billing Account is not active.' })
}
}

onCloseTask () {
Expand Down Expand Up @@ -289,6 +293,7 @@ class ChallengeEditor extends Component {
errorMessage={this.state.launchError}
onCancel={this.closeLaunchModal}
onConfirm={this.activateChallenge}
disableConfirmButton={isBillingAccountExpired}
/>
const closeTaskModal = <ConfirmationModal
title='Confirm Close Task'
Expand Down
10 changes: 7 additions & 3 deletions src/containers/Challenges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class Challenges extends Component {
totalChallenges,
setActiveProject,
partiallyUpdateChallengeDetails,
deleteChallenge
deleteChallenge,
isBillingAccountExpired
} = this.props
const { searchProjectName, onlyMyProjects } = this.state
const projectInfo = _.find(projects, { id: activeProjectId }) || {}
Expand Down Expand Up @@ -149,6 +150,7 @@ class Challenges extends Component {
totalChallenges={totalChallenges}
partiallyUpdateChallengeDetails={partiallyUpdateChallengeDetails}
deleteChallenge={deleteChallenge}
isBillingAccountExpired={isBillingAccountExpired}
/>
}
</Fragment>
Expand Down Expand Up @@ -176,15 +178,17 @@ Challenges.propTypes = {
loadProjects: PropTypes.func.isRequired,
setActiveProject: PropTypes.func.isRequired,
partiallyUpdateChallengeDetails: PropTypes.func.isRequired,
deleteChallenge: PropTypes.func.isRequired
deleteChallenge: PropTypes.func.isRequired,
isBillingAccountExpired: PropTypes.bool
}

const mapStateToProps = ({ challenges, sidebar, projects }) => ({
..._.omit(challenges, ['projectId']),
challengeProjectId: challenges.projectId,
activeProjectId: sidebar.activeProjectId,
projects: sidebar.projects,
projectDetail: projects.projectDetail
projectDetail: projects.projectDetail,
isBillingAccountExpired: projects.isBillingAccountExpired
})

const mapDispatchToProps = {
Expand Down

0 comments on commit 51c2948

Please sign in to comment.