Skip to content

Sync Master into develop #1645

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

Merged
merged 12 commits into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/components/ChallengesComponent/ChallengeList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Loader from '../../Loader'
import UpdateBillingAccount from '../../UpdateBillingAccount'

import { CHALLENGE_STATUS, PAGE_SIZE, PAGINATION_PER_PAGE_OPTIONS, PROJECT_ROLES } from '../../../config/constants'
import { checkAdmin, checkReadOnlyRoles } from '../../../util/tc'
import { checkAdmin, checkManager, checkReadOnlyRoles } from '../../../util/tc'

require('bootstrap/scss/bootstrap.scss')

Expand Down Expand Up @@ -406,6 +406,9 @@ class ChallengeList extends Component {
} = this.props
const isReadOnly = checkReadOnlyRoles(this.props.auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ
const isAdmin = checkAdmin(this.props.auth.token)
const isManager = checkManager(this.props.auth.token)
const loginUserId = this.props.auth.user.userId
const isMemberOfActiveProject = activeProject && activeProject.members && activeProject.members.some(member => member.userId === loginUserId)

if (warnMessage) {
return <Message warnMessage={warnMessage} />
Expand Down Expand Up @@ -496,6 +499,8 @@ class ChallengeList extends Component {
currentBillingAccount={currentBillingAccount}
updateProject={updateProject}
projectId={activeProject.id}
isMemberOfActiveProject={isMemberOfActiveProject}
isManager={isManager}
/>
</div>
) : (
Expand Down
12 changes: 8 additions & 4 deletions src/components/UpdateBillingAccount/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const UpdateBillingAccount = ({
isAdmin,
currentBillingAccount,
projectId,
updateProject
updateProject,
isMemberOfActiveProject,
isManager
}) => {
const [isEditing, setIsEditing] = useState(false)
const [selectedBillingAccount, setSelectedBillingAccount] = useState(null)
Expand Down Expand Up @@ -129,7 +131,7 @@ const UpdateBillingAccount = ({
!currentBillingAccount && (
<Fragment>
<span className={styles.error}>No Billing Account set</span>
{isAdmin && (
{(isAdmin || (isManager && isMemberOfActiveProject)) && (

Choose a reason for hiding this comment

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

The condition (isAdmin || (isManager && isMemberOfActiveProject)) has been added. Ensure that this logic is correct and that it reflects the intended access control. Consider whether this change could inadvertently restrict or broaden access compared to the previous condition isAdmin.

<span>
{' '}
({' '}
Expand All @@ -153,7 +155,7 @@ const UpdateBillingAccount = ({
>
{isBillingAccountExpired ? 'INACTIVE' : 'ACTIVE'}
</span>{' '}
{isAdmin && (
{(isAdmin || (isManager && isMemberOfActiveProject)) && (

Choose a reason for hiding this comment

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

Consider extracting the condition (isAdmin || (isManager && isMemberOfActiveProject)) into a well-named variable to improve readability and maintainability of the code.

<span>
{' '}
({' '}
Expand Down Expand Up @@ -187,7 +189,9 @@ UpdateBillingAccount.propTypes = {
isBillingAccountExpired: PropTypes.bool,
isAdmin: PropTypes.bool,
projectId: PropTypes.number,
updateProject: PropTypes.func.isRequired
updateProject: PropTypes.func.isRequired,
isMemberOfActiveProject: PropTypes.bool.isRequired,

Choose a reason for hiding this comment

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

The isMemberOfActiveProject prop type should be PropTypes.bool instead of PropTypes.bool.isRequired. The .isRequired should be applied to PropTypes.bool, like this: PropTypes.bool.isRequired.

isManager: PropTypes.bool.isRequired

Choose a reason for hiding this comment

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

The isManager prop type should be PropTypes.bool instead of PropTypes.bool.isRequired. The .isRequired should be applied to PropTypes.bool, like this: PropTypes.bool.isRequired.

}

export default UpdateBillingAccount