Skip to content

Commit a5220d8

Browse files
committed
Fixes for readonly access
1 parent 36c35f9 commit a5220d8

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ class ChallengeList extends Component {
4343
challengeProjectOption: this.props.filterProjectOption,
4444
challengeStatus: this.props.status,
4545
challengeType: this.props.filterChallengeType,
46-
challengeDate: this.props.filterDate,
47-
loginUserRoleInProject: ''
46+
challengeDate: this.props.filterDate
4847
}
4948
this.directUpdateSearchParam = this.updateSearchParam.bind(this) // update search param without debounce
5049
this.handlePageChange = this.handlePageChange.bind(this) // update search param without debounce
@@ -58,20 +57,6 @@ class ChallengeList extends Component {
5857
this.resetFilter = this.resetFilter.bind(this)
5958
}
6059

61-
componentWillReceiveProps (nextProps) {
62-
const { activeProject, auth } = nextProps
63-
if (activeProject && auth && auth.user) {
64-
const loggedInUser = auth.user
65-
const projectMembers = activeProject.members
66-
const loginUserProjectInfo = _.find(projectMembers, { userId: loggedInUser.userId })
67-
if (loginUserProjectInfo && this.state.loginUserRoleInProject !== loginUserProjectInfo.role) {
68-
this.setState({
69-
loginUserRoleInProject: loginUserProjectInfo.role
70-
})
71-
}
72-
}
73-
}
74-
7560
/**
7661
* Update filter for getting project
7762
* @param {String} searchText search text
@@ -361,8 +346,7 @@ class ChallengeList extends Component {
361346
challengeProjectOption,
362347
challengeStatus,
363348
challengeType,
364-
challengeDate,
365-
loginUserRoleInProject
349+
challengeDate
366350
} = this.state
367351

368352
const {
@@ -385,7 +369,8 @@ class ChallengeList extends Component {
385369
isBillingAccountLoadingFailed,
386370
isBillingAccountLoading,
387371
selfService,
388-
challengeTypes
372+
challengeTypes,
373+
loginUserRoleInProject
389374
} = this.props
390375
if (warnMessage) {
391376
return <Message warnMessage={warnMessage} />
@@ -837,7 +822,8 @@ class ChallengeList extends Component {
837822
}
838823

839824
ChallengeList.defaultProps = {
840-
isLoading: false
825+
isLoading: false,
826+
loginUserRoleInProject: ''
841827
}
842828

843829
ChallengeList.propTypes = {
@@ -872,7 +858,8 @@ ChallengeList.propTypes = {
872858
dashboard: PropTypes.bool,
873859
selfService: PropTypes.bool,
874860
auth: PropTypes.object.isRequired,
875-
challengeTypes: PropTypes.arrayOf(PropTypes.shape()).isRequired
861+
challengeTypes: PropTypes.arrayOf(PropTypes.shape()).isRequired,
862+
loginUserRoleInProject: PropTypes.string
876863
}
877864

878865
export default ChallengeList

src/components/ChallengesComponent/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
/**
22
* Component to render Challenges page
33
*/
4-
import React from 'react'
4+
import React, { useState, useEffect } from 'react'
5+
import _ from 'lodash'
56
import PropTypes from 'prop-types'
67
import { Helmet } from 'react-helmet'
78
import { Link } from 'react-router-dom'
8-
import { CONNECT_APP_URL } from '../../config/constants'
9+
import { CONNECT_APP_URL, PROJECT_ROLES } from '../../config/constants'
910
import { PrimaryButton } from '../Buttons'
1011
import ChallengeList from './ChallengeList'
1112
import styles from './ChallengesComponent.module.scss'
@@ -43,7 +44,17 @@ const ChallengesComponent = ({
4344
auth,
4445
challengeTypes
4546
}) => {
46-
const isReadOnly = checkReadOnlyRoles(auth.token)
47+
const [loginUserRoleInProject, setLoginUserRoleInProject] = useState('')
48+
const isReadOnly = checkReadOnlyRoles(auth.token) || loginUserRoleInProject === PROJECT_ROLES.READ
49+
50+
useEffect(() => {
51+
const loggedInUser = auth.user
52+
const projectMembers = activeProject.members
53+
const loginUserProjectInfo = _.find(projectMembers, { userId: loggedInUser.userId })
54+
if (loginUserProjectInfo && loginUserRoleInProject !== loginUserProjectInfo.role) {
55+
setLoginUserRoleInProject(loginUserProjectInfo.role)
56+
}
57+
}, [activeProject, auth])
4758

4859
return (
4960
<div>
@@ -112,6 +123,7 @@ const ChallengesComponent = ({
112123
selfService={selfService}
113124
auth={auth}
114125
challengeTypes={challengeTypes}
126+
loginUserRoleInProject={loginUserRoleInProject}
115127
/>
116128
</div>
117129
</div>

src/components/TopcoderFooter/index.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* global tcUniNav */
22
import React, { useEffect, useRef, useState } from 'react'
3+
import styles from './styles.module.scss'
34

45
let uniqueId = 0
56

@@ -25,5 +26,11 @@ export default function TopcoderFooter () {
2526
})
2627
}, [footerId])
2728

28-
return <div id={`footerNav-${footerId}`} ref={footerRef} />
29+
return (
30+
<div
31+
id={`footerNav-${footerId}`}
32+
className={styles.container}
33+
ref={footerRef}
34+
/>
35+
)
2936
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@import '../../styles/includes';
2+
3+
.container {
4+
margin-top: auto;
5+
}

src/components/TwoRowsLayout/TwoRowsLayout.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}
1414

1515
.content {
16-
max-height: 100vh;
16+
height: 100vh;
1717
display: flex;
1818
position: relative;
1919
flex-direction: column;

0 commit comments

Comments
 (0)