diff --git a/src/components/ChallengeEditor/ChallengeViewTabs/index.js b/src/components/ChallengeEditor/ChallengeViewTabs/index.js index 3e02af94..d09a24e1 100644 --- a/src/components/ChallengeEditor/ChallengeViewTabs/index.js +++ b/src/components/ChallengeEditor/ChallengeViewTabs/index.js @@ -46,7 +46,8 @@ const ChallengeViewTabs = ({ projectPhases, assignYourselfCopilot, showRejectChallengeModal, - loggedInUser + loggedInUser, + onApproveChallenge }) => { const [selectedTab, setSelectedTab] = useState(0) @@ -85,8 +86,12 @@ const ChallengeViewTabs = ({ const isSelfService = challenge.legacy.selfService const isDraft = challenge.status.toUpperCase() === CHALLENGE_STATUS.DRAFT - const launchText = `${isSelfService && isDraft ? 'Approve and ' : ''}Launch` const isCopilot = challenge.legacy.selfServiceCopilot === loggedInUser.handle + const canApprove = isCopilot && isDraft && isSelfService + // only the copilot can launch AND + // if this isn't self-service, permit launching if the challenge is draft + // OR if this is self-service, permit launching if the challenge is approved + const canLaunch = isCopilot && ((!isSelfService && isDraft) || challenge.status.toUpperCase() === CHALLENGE_STATUS.APPROVED) return (
@@ -117,12 +122,12 @@ const ChallengeViewTabs = ({ > {(isDraft || challenge.status === 'New') && !isSelfService && (
)} - {isDraft && (!isSelfService || isCopilot) && ( + {canLaunch && (
{challenge.legacyId || isTask ? ( ) : ( @@ -133,6 +138,15 @@ const ChallengeViewTabs = ({ )}
)} + {canApprove && ( +
+ +
+ )} {isTask && challenge.status === 'Active' && (
{assignedMemberDetails ? ( @@ -153,8 +167,8 @@ const ChallengeViewTabs = ({ {isSelfService && isDraft && isCopilot && (
@@ -228,6 +242,7 @@ const ChallengeViewTabs = ({ projectPhases={projectPhases} assignYourselfCopilot={assignYourselfCopilot} showRejectChallengeModal={showRejectChallengeModal} + onApproveChallenge={onApproveChallenge} /> )} {selectedTab === 1 && ( @@ -267,7 +282,8 @@ ChallengeViewTabs.propTypes = { projectPhases: PropTypes.arrayOf(PropTypes.object), assignYourselfCopilot: PropTypes.func.isRequired, showRejectChallengeModal: PropTypes.func.isRequired, - loggedInUser: PropTypes.object.isRequired + loggedInUser: PropTypes.object.isRequired, + onApproveChallenge: PropTypes.func } export default ChallengeViewTabs diff --git a/src/components/ChallengesComponent/ChallengeList/index.js b/src/components/ChallengesComponent/ChallengeList/index.js index 70a497b6..9a50bbab 100644 --- a/src/components/ChallengesComponent/ChallengeList/index.js +++ b/src/components/ChallengesComponent/ChallengeList/index.js @@ -224,7 +224,7 @@ class ChallengeList extends Component { { challenges.length > 0 && (
-
Challenges Name
+
Challenge Name
Last Updated
Status
{(selectedTab === 0) && (
Current phase
)} diff --git a/src/config/constants.js b/src/config/constants.js index 58bcff97..b05d9e10 100644 --- a/src/config/constants.js +++ b/src/config/constants.js @@ -167,6 +167,7 @@ export const CHALLENGE_STATUS = { ACTIVE: 'ACTIVE', NEW: 'NEW', DRAFT: 'DRAFT', + APPROVED: 'APPROVED', COMPLETED: 'COMPLETED', CANCELLED: 'CANCELLED' } diff --git a/src/containers/ChallengeEditor/index.js b/src/containers/ChallengeEditor/index.js index 16fc303c..4881025b 100644 --- a/src/containers/ChallengeEditor/index.js +++ b/src/containers/ChallengeEditor/index.js @@ -77,6 +77,7 @@ class ChallengeEditor extends Component { this.closeRejectModal = this.closeRejectModal.bind(this) this.rejectChallenge = this.rejectChallenge.bind(this) this.onChangeCancelReason = this.onChangeCancelReason.bind(this) + this.onApproveChallenge = this.onApproveChallenge.bind(this) } componentDidMount () { @@ -203,6 +204,20 @@ class ChallengeEditor extends Component { } } + async onApproveChallenge () { + const { partiallyUpdateChallengeDetails, challengeDetails } = this.props + const newStatus = 'Approved' + await partiallyUpdateChallengeDetails(challengeDetails.id, { + status: newStatus + }) + this.setState({ + challengeDetails: { + ...challengeDetails, + status: newStatus + } + }) + } + async cancelChallenge (challenge, cancelReason) { const { partiallyUpdateChallengeDetails, history } = this.props @@ -580,6 +595,7 @@ class ChallengeEditor extends Component { assignYourselfCopilot={this.assignYourselfCopilot} showRejectChallengeModal={this.showRejectChallengeModal} loggedInUser={loggedInUser} + onApproveChallenge={this.onApproveChallenge} /> )} />