Skip to content

PM-1270 Exclude cancelled and completed projects from copilot request creation #1660

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/ChallengesComponent/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import PropTypes from 'prop-types'
import { Helmet } from 'react-helmet'
import { Link } from 'react-router-dom'
import ProjectStatus from './ProjectStatus'
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL } from '../../config/constants'
import { PROJECT_ROLES, PROJECT_STATUS, COPILOTS_URL, CHALLENGE_STATUS } from '../../config/constants'
import { PrimaryButton, OutlineButton } from '../Buttons'
import ChallengeList from './ChallengeList'
import styles from './ChallengesComponent.module.scss'
Expand Down Expand Up @@ -53,6 +53,12 @@ const ChallengesComponent = ({
const isReadOnly = checkReadOnlyRoles(auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ
const isAdminOrCopilot = checkAdminOrCopilot(auth.token, activeProject)

const projectStatus = activeProject && activeProject.status
? activeProject.status.toUpperCase()
: ''
const isCompletedOrCancelled =
projectStatus === CHALLENGE_STATUS.CANCELLED || projectStatus === CHALLENGE_STATUS.COMPLETED
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a more descriptive variable name for isCompletedOrCancelled to clarify its purpose, such as isProjectInactive.


useEffect(() => {
const loggedInUser = auth.user
const projectMembers = activeProject.members
Expand Down Expand Up @@ -94,7 +100,7 @@ const ChallengesComponent = ({
className={styles.btnOutline}
/>
)}
{(checkAdmin(auth.token) || checkManager(auth.token)) && (
{(checkAdmin(auth.token) || checkManager(auth.token)) && !isCompletedOrCancelled && (
<OutlineButton
text='Request Copilot'
type={'info'}
Expand Down