Skip to content

Commit 9124501

Browse files
authored
Merge pull request #1515 from topcoder-platform/develop
Allow admins to see all challenges
2 parents 50fa557 + 9f049d6 commit 9124501

File tree

12 files changed

+47
-29
lines changed

12 files changed

+47
-29
lines changed

config/constants/development.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = {
4141
CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e',
4242
MARATHON_TYPE_ID: '929bc408-9cf2-4b3e-ba71-adfbf693046c',
4343
SEGMENT_API_KEY: 'QBtLgV8vCiuRX1lDikbMjcoe9aCHkF6n',
44-
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31'],
44+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31', '78b37a69-92d5-4ad7-bf85-c79b65420c79', '929bc408-9cf2-4b3e-ba71-adfbf693046c'],
4545
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY,
4646
FILE_PICKER_CONTAINER_NAME: 'tc-challenge-v5-dev',
4747
FILE_PICKER_REGION: 'us-east-1',

config/constants/production.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = {
4141
CHALLENGE_TYPE_ID: '927abff4-7af9-4145-8ba1-577c16e64e2e',
4242
MARATHON_TYPE_ID: '929bc408-9cf2-4b3e-ba71-adfbf693046c',
4343
SEGMENT_API_KEY: 'QSQAW5BWmZfLoKFNRgNKaqHvLDLJoGqF',
44-
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31'],
44+
CREATE_FORUM_TYPE_IDS: ['927abff4-7af9-4145-8ba1-577c16e64e2e', 'dc876fa4-ef2d-4eee-b701-b555fcc6544c', 'ecd58c69-238f-43a4-a4bb-d172719b9f31', '78b37a69-92d5-4ad7-bf85-c79b65420c79', '929bc408-9cf2-4b3e-ba71-adfbf693046c'],
4545
FILE_PICKER_API_KEY: process.env.FILE_PICKER_API_KEY,
4646
FILE_PICKER_CONTAINER_NAME: 'tc-challenge-v5-prod',
4747
FILE_PICKER_REGION: 'us-east-1',

src/actions/challenges.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
5858

5959
/**
6060
* Loads active challenges of project by page
61+
*
62+
* @param {number} page
63+
* @param {string} projectId
64+
* @param {string} status
65+
* @param {string} filterChallengeName
66+
* @param {bool} selfService
67+
* @param {string} userHandle this will be null for admin user(we will return all datas for admin user)
68+
* @param {string} filterChallengeType
69+
* @param {object} filterDate
70+
* @param {string} filterSortBy
71+
* @param {string} filterSortOrder
72+
* @param {number} perPage
73+
* @returns redux action
6174
*/
6275
export function loadChallengesByPage (
6376
page,
@@ -66,7 +79,6 @@ export function loadChallengesByPage (
6679
filterChallengeName = null,
6780
selfService = false,
6881
userHandle = null,
69-
filterCreatedBy = null,
7082
filterChallengeType = {},
7183
filterDate = {},
7284
filterSortBy = null,
@@ -126,8 +138,8 @@ export function loadChallengesByPage (
126138
if (filterSortBy) {
127139
filters['sortBy'] = filterSortBy
128140
}
129-
if (filterCreatedBy) {
130-
filters['createdBy'] = filterCreatedBy
141+
if (userHandle) {
142+
filters['createdBy'] = userHandle
131143
}
132144
if (filterSortOrder) {
133145
filters['sortOrder'] = filterSortOrder

src/actions/sidebar.js

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22
* Sidebar related redux actions
33
*/
44
import { fetchMemberProjects } from '../services/projects'
5-
import { SET_ACTIVE_PROJECT, LOAD_PROJECTS_FAILURE, LOAD_PROJECTS_PENDING, LOAD_PROJECTS_SUCCESS, RESET_SIDEBAR_ACTIVE_PARAMS } from '../config/constants'
5+
import {
6+
SET_ACTIVE_PROJECT,
7+
LOAD_PROJECTS_FAILURE,
8+
LOAD_PROJECTS_PENDING,
9+
LOAD_PROJECTS_SUCCESS,
10+
RESET_SIDEBAR_ACTIVE_PARAMS,
11+
UNLOAD_PROJECTS_SUCCESS
12+
} from '../config/constants'
613
import _ from 'lodash'
714

815
/**
@@ -58,8 +65,7 @@ export function loadProjects (filterProjectName = '', myProjects = true) {
5865
export function unloadProjects () {
5966
return (dispatch) => {
6067
dispatch({
61-
type: LOAD_PROJECTS_SUCCESS,
62-
projects: []
68+
type: UNLOAD_PROJECTS_SUCCESS
6369
})
6470
}
6571
}

src/components/ChallengeEditor/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
MULTI_ROUND_CHALLENGE_TEMPLATE_ID, DS_TRACK_ID,
3131
CHALLENGE_STATUS
3232
} from '../../config/constants'
33-
import { getDomainTypes, getResourceRoleByName } from '../../util/tc'
33+
import { getDomainTypes, getResourceRoleByName, is2RoundsChallenge } from '../../util/tc'
3434
import { PrimaryButton, OutlineButton } from '../Buttons'
3535
import TrackField from './Track-Field'
3636
import TypeField from './Type-Field'
@@ -838,8 +838,7 @@ class ChallengeEditor extends Component {
838838
const { phases } = this.state.challenge
839839
let newChallenge = _.cloneDeep(this.state.challenge)
840840
const isDesignChallenge = newChallenge.trackId === DES_TRACK_ID
841-
const is2RoundChallenge =
842-
newChallenge.timelineTemplateId === MULTI_ROUND_CHALLENGE_TEMPLATE_ID
841+
const is2RoundChallenge = is2RoundsChallenge(newChallenge)
843842
const is2RoundDesignChallenge = isDesignChallenge && is2RoundChallenge
844843

845844
for (let index = 0; index < phases.length; ++index) {

src/components/ChallengesComponent/ChallengeCard/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ class ChallengeCard extends React.Component {
323323
<a className={styles.link} href={communityAppUrl} target='_blank'>CA</a>
324324
</div>
325325
<div className={styles.col6}>
326-
{forumLink ? (<a className={styles.link} href={forumLink} target='_blank'>CA</a>)
326+
{forumLink ? (<a className={styles.link} href={forumLink} target='_blank'>Forum</a>)
327327
: (<a className={styles.link} href='javascript:void(0)'>Forum</a>)}
328328
</div>
329329
</div>

src/components/ChallengesComponent/ChallengeList/index.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,6 @@ class ChallengeList extends Component {
116116
searchText,
117117
selfService,
118118
this.getHandle(),
119-
this.getLoginHandle(),
120119
challengeType,
121120
challengeDate
122121
)
@@ -153,7 +152,6 @@ class ChallengeList extends Component {
153152
searchText,
154153
selfService,
155154
this.getHandle(),
156-
this.getLoginHandle(),
157155
filterChallengeType,
158156
filterDate,
159157
sortBy,
@@ -191,7 +189,6 @@ class ChallengeList extends Component {
191189
searchText,
192190
selfService,
193191
this.getHandle(),
194-
this.getLoginHandle(),
195192
filterChallengeType,
196193
filterDate,
197194
sortBy,
@@ -219,8 +216,7 @@ class ChallengeList extends Component {
219216
status,
220217
searchText,
221218
selfService,
222-
this.getHandle(),
223-
this.getLoginHandle()
219+
this.getHandle()
224220
)
225221
}
226222

@@ -298,7 +294,6 @@ class ChallengeList extends Component {
298294
searchText,
299295
selfService,
300296
this.getHandle(),
301-
this.getLoginHandle(),
302297
challengeType,
303298
challengeDate,
304299
name,
@@ -344,7 +339,6 @@ class ChallengeList extends Component {
344339
'',
345340
selfService,
346341
this.getHandle(),
347-
this.getLoginHandle(),
348342
null,
349343
{},
350344
null,

src/config/constants.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const getAWSContainerFileURL = (key) => `https://${FILE_PICKER_CONTAINER_
5555
export const LOAD_PROJECTS_SUCCESS = 'LOAD_PROJECTS_SUCCESS'
5656
export const LOAD_PROJECTS_PENDING = 'LOAD_PROJECTS_PENDING'
5757
export const LOAD_PROJECTS_FAILURE = 'LOAD_PROJECTS_FAILURE'
58+
export const UNLOAD_PROJECTS_SUCCESS = 'UNLOAD_PROJECTS_SUCCESS'
5859

5960
// project billingAccount
6061
export const LOAD_PROJECT_BILLING_ACCOUNT = 'LOAD_PROJECT_BILLING_ACCOUNT'

src/containers/Challenges/index.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ class Challenges extends Component {
6262
(nextProps.dashboard && this.props.dashboard !== nextProps.dashboard) ||
6363
this.props.activeProjectId !== nextProps.activeProjectId
6464
) {
65-
this.reloadChallenges(nextProps, false, true)
65+
this.reloadChallenges(nextProps, false)
6666
}
6767
}
6868

69-
reloadChallenges (props, forceLoad, loadMyChallenge) {
69+
reloadChallenges (props, forceLoad) {
7070
const {
7171
activeProjectId,
7272
projectDetail: reduxProjectInfo,
@@ -84,8 +84,7 @@ class Challenges extends Component {
8484
dashboard ? 'all' : '',
8585
'',
8686
selfService,
87-
isAdmin ? null : this.props.auth.user.handle,
88-
loadMyChallenge ? this.props.auth.user.handle : ''
87+
isAdmin ? null : this.props.auth.user.handle
8988
)
9089
const projectLoading =
9190
window.localStorage.getItem('projectLoading') !== null

src/containers/Users/index.js

-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { connect } from 'react-redux'
33
import _ from 'lodash'
44
import PT from 'prop-types'
55
import UsersComponent from '../../components/Users'
6-
import { loadProjects } from '../../actions/sidebar'
76
import { loadProject, reloadProjectMembers } from '../../actions/projects'
87
import { PROJECT_ROLES } from '../../config/constants'
98

@@ -17,7 +16,6 @@ class Users extends Component {
1716
}
1817

1918
componentDidMount () {
20-
this.props.loadProjects()
2119
}
2220

2321
isEditable () {
@@ -76,13 +74,11 @@ const mapStateToProps = ({ sidebar, challenges, auth, projects }) => {
7674

7775
const mapDispatchToProps = {
7876
loadProject,
79-
loadProjects,
8077
reloadProjectMembers
8178
}
8279

8380
Users.propTypes = {
8481
loadProject: PT.func.isRequired,
85-
loadProjects: PT.func.isRequired,
8682
reloadProjectMembers: PT.func.isRequired,
8783
projects: PT.arrayOf(PT.object),
8884
projectMembers: PT.arrayOf(PT.object),

src/reducers/sidebar.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import {
66
LOAD_PROJECTS_SUCCESS,
77
LOAD_PROJECTS_PENDING,
88
LOAD_PROJECTS_FAILURE,
9-
RESET_SIDEBAR_ACTIVE_PARAMS
9+
RESET_SIDEBAR_ACTIVE_PARAMS,
10+
UNLOAD_PROJECTS_SUCCESS
1011
} from '../config/constants'
1112

1213
const initialState = {
@@ -19,9 +20,11 @@ const initialState = {
1920
export default function (state = initialState, action) {
2021
switch (action.type) {
2122
case SET_ACTIVE_PROJECT:
22-
return { ...state, activeProjectId: action.projectId, projects: [], isLoading: false }
23+
return { ...state, activeProjectId: action.projectId, projects: [], isLoading: false, isLoadProjectsSuccess: false }
2324
case LOAD_PROJECTS_SUCCESS:
2425
return { ...state, projects: action.projects, isLoading: false, isLoggedIn: true, isLoadProjectsSuccess: true }
26+
case UNLOAD_PROJECTS_SUCCESS:
27+
return { ...state, projects: [], isLoading: false, isLoggedIn: true, isLoadProjectsSuccess: false }
2528
case LOAD_PROJECTS_PENDING:
2629
return { ...state, isLoading: true }
2730
case LOAD_PROJECTS_FAILURE:

src/util/tc.js

+8
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,11 @@ export function getChallengeTypeAbbr (track, challengeTypes) {
269269
}
270270
return null
271271
}
272+
273+
/**
274+
* Check if challenge is 2 rounds challenge or not
275+
* @param {Object} challenge challenge info
276+
*/
277+
export function is2RoundsChallenge (challenge) {
278+
return !!_.find(challenge.phases, { name: 'Checkpoint Submission' })
279+
}

0 commit comments

Comments
 (0)