Skip to content

Commit 274e4c1

Browse files
authored
Merge pull request #1526 from topcoder-platform/develop
Release 0.20.6
2 parents dc42874 + 53271dc commit 274e4c1

File tree

9 files changed

+75
-55
lines changed

9 files changed

+75
-55
lines changed

config/constants/development.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
ACCOUNTS_APP_LOGIN_URL: `https://accounts-auth0.${DOMAIN}`,
1111
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
1212
MEMBER_API_URL: `${DEV_API_HOSTNAME}/v5/members`,
13-
MEMBER_API_V3_URL: `${DEV_API_HOSTNAME}/v3/members`,
1413
CHALLENGE_API_URL: `${DEV_API_HOSTNAME}/v5/challenges`,
1514
CHALLENGE_TIMELINE_TEMPLATES_URL: `${DEV_API_HOSTNAME}/v5/timeline-templates`,
1615
CHALLENGE_TYPES_URL: `${DEV_API_HOSTNAME}/v5/challenge-types`,

config/constants/production.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ module.exports = {
1010
ACCOUNTS_APP_LOGIN_URL: `https://accounts-auth0.${DOMAIN}`,
1111
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
1212
MEMBER_API_URL: `${PROD_API_HOSTNAME}/v5/members`,
13-
MEMBER_API_V3_URL: `${PROD_API_HOSTNAME}/v3/members`,
1413
CHALLENGE_API_URL: `${PROD_API_HOSTNAME}/v5/challenges`,
1514
CHALLENGE_TIMELINE_TEMPLATES_URL: `${PROD_API_HOSTNAME}/v5/timeline-templates`,
1615
CHALLENGE_TYPES_URL: `${PROD_API_HOSTNAME}/v5/challenge-types`,

src/actions/challenges.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
6262
* @param {number} page
6363
* @param {string} projectId
6464
* @param {string} status
65+
* @param {boolean} dashboard is in dashboard or not
6566
* @param {string} filterChallengeName
6667
* @param {bool} selfService
6768
* @param {string} userHandle this will be null for admin user(we will return all datas for admin user)
@@ -77,6 +78,7 @@ export function loadChallengesByPage (
7778
page,
7879
projectId,
7980
status,
81+
dashboard,
8082
filterChallengeName = null,
8183
selfService = false,
8284
userHandle = null,
@@ -156,16 +158,21 @@ export function loadChallengesByPage (
156158
filters['memberId'] = userId
157159
}
158160

159-
if (status === 'all') {
160-
delete filters['status']
161-
} else if (!_.isEmpty(status)) {
162-
filters['status'] = status === '' ? undefined : _.startCase(status.toLowerCase())
163-
} else if (!(_.isInteger(projectId) && projectId > 0)) {
161+
if (status !== 'all') {
162+
filters['status'] = !status ? undefined : _.startCase(status.toLowerCase())
163+
}
164+
165+
if (!dashboard && !filters['status'] && !(_.isInteger(projectId) && projectId > 0)) {
164166
filters['status'] = 'Active'
165167
}
166168
if (selfService) {
167169
filters.selfService = true
168-
if (userHandle && filters.status.toUpperCase() !== CHALLENGE_STATUS.DRAFT && filters.status.toUpperCase() !== CHALLENGE_STATUS.NEW) {
170+
const filtersStatus = filters.status ? filters.status.toUpperCase() : filters.status
171+
if (
172+
userHandle &&
173+
filtersStatus !== CHALLENGE_STATUS.DRAFT &&
174+
filtersStatus !== CHALLENGE_STATUS.NEW
175+
) {
169176
filters.selfServiceCopilot = userHandle
170177
}
171178
}

src/components/ChallengesComponent/ChallengeList/index.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ require('bootstrap/scss/bootstrap.scss')
3131
const defaultSearchParam = {
3232
searchText: '',
3333
challengeProjectOption: null,
34-
challengeStatus: '',
34+
challengeStatus: 'all',
3535
challengeType: null,
3636
sortBy: 'startDate',
3737
sortOrder: 'desc',
@@ -112,7 +112,8 @@ class ChallengeList extends Component {
112112
loadChallengesByPage(
113113
1,
114114
projectId,
115-
!projectStatus ? 'all' : projectStatus,
115+
projectStatus,
116+
dashboard,
116117
searchText,
117118
selfService,
118119
this.getHandle(),
@@ -150,6 +151,7 @@ class ChallengeList extends Component {
150151
pageNumber,
151152
projectId,
152153
status,
154+
dashboard,
153155
searchText,
154156
selfService,
155157
this.getHandle(),
@@ -188,6 +190,7 @@ class ChallengeList extends Component {
188190
1,
189191
projectId,
190192
status,
193+
dashboard,
191194
searchText,
192195
selfService,
193196
this.getHandle(),
@@ -211,12 +214,14 @@ class ChallengeList extends Component {
211214
loadChallengesByPage,
212215
activeProjectId,
213216
status,
214-
selfService
217+
selfService,
218+
dashboard
215219
} = this.props
216220
loadChallengesByPage(
217221
page,
218222
activeProjectId,
219223
status,
224+
dashboard,
220225
searchText,
221226
selfService,
222227
this.getHandle(),
@@ -301,6 +306,7 @@ class ChallengeList extends Component {
301306
page,
302307
projectId,
303308
status,
309+
dashboard,
304310
searchText,
305311
selfService,
306312
this.getHandle(),
@@ -346,15 +352,16 @@ class ChallengeList extends Component {
346352
loadChallengesByPage(
347353
1,
348354
projectId,
349-
'all',
350-
'',
355+
defaultSearchParam.challengeStatus,
356+
dashboard,
357+
defaultSearchParam.searchText,
351358
selfService,
352359
this.getHandle(),
353360
this.getLoginUserId(),
354-
null,
355-
{},
356-
null,
357-
null,
361+
defaultSearchParam.challengeType,
362+
defaultSearchParam.challengeDate,
363+
defaultSearchParam.sortBy,
364+
defaultSearchParam.sortOrder,
358365
PAGE_SIZE
359366
)
360367
}

src/components/SelectUserAutocomplete/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import React, { useState, useCallback } from 'react'
88
import PropTypes from 'prop-types'
99
import Select from '../Select'
10-
import { suggestProfilesV5, fetchProfileV5 } from '../../services/user'
10+
import { suggestProfiles, fetchProfile } from '../../services/user'
1111
import _ from 'lodash'
1212
import { AUTOCOMPLETE_MIN_LENGTH, AUTOCOMPLETE_DEBOUNCE_TIME_MS } from '../../config/constants'
1313

@@ -27,7 +27,7 @@ export default function SelectUserAutocomplete (props) {
2727
return
2828
}
2929

30-
Promise.all([suggestProfilesV5(inputValue), fetchProfileV5(inputValue)]).then(
30+
Promise.all([suggestProfiles(inputValue), fetchProfile(inputValue)]).then(
3131
([suggestions, user]) => {
3232
const suggestedOptions = suggestions.map((u) => ({
3333
label: u.handle,

src/components/Tab/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ const Tab = ({
2828
selectTab(3)
2929
}
3030

31+
const onSelfServiceClick = () => {
32+
if (currentTab === 4) {
33+
return
34+
}
35+
selectTab(4)
36+
}
37+
3138
const tabComponent = (
3239
<ul className={styles.challengeTab}>
3340
<li
@@ -72,6 +79,20 @@ const Tab = ({
7279
>
7380
Users
7481
</li>
82+
<li
83+
key='tab-item-self-service'
84+
className={cn(styles.item, { [styles.active]: currentTab === 4 })}
85+
onClick={onSelfServiceClick}
86+
onKeyDown={e => {
87+
if (e.key !== 'Enter') {
88+
return
89+
}
90+
onSelfServiceClick()
91+
}}
92+
role='presentation'
93+
>
94+
Self-Service
95+
</li>
7596
</ul>
7697
)
7798

src/containers/Challenges/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class Challenges extends Component {
8181
this.props.loadChallengesByPage(
8282
1,
8383
projectId ? parseInt(projectId) : -1,
84-
dashboard ? 'all' : '',
84+
'all',
85+
dashboard,
8586
'',
8687
selfService,
8788
isAdmin ? null : this.props.auth.user.handle,

src/containers/Tab/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ class TabContainer extends Component {
4141
this.setState({ currentTab: 2 })
4242
} else if (nextProps.history.location.pathname === '/users') {
4343
this.setState({ currentTab: 3 })
44+
} else if (nextProps.history.location.pathname === '/self-service') {
45+
this.setState({ currentTab: 4 })
4446
} else {
4547
this.setState({ currentTab: 0 })
4648
}
@@ -85,6 +87,9 @@ class TabContainer extends Component {
8587
} else if (tab === 3) {
8688
history.push('/users')
8789
this.setState({ currentTab: 3 })
90+
} else if (tab === 4) {
91+
history.push('/self-service')
92+
this.setState({ currentTab: 4 })
8893
}
8994

9095
resetSidebarActiveParams()

src/services/user.js

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,27 @@
11
import _ from 'lodash'
22
import { axiosInstance } from './axiosWithAuth'
3-
const { MEMBER_API_URL, MEMBER_API_V3_URL } = process.env
3+
const { MEMBER_API_URL } = process.env
44

55
/**
66
* Api request for fetching user profile
77
* @returns {Promise<*>}
88
*/
99
export async function fetchProfile (handle) {
10-
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/${handle}`)
11-
return _.get(response, 'data.result.content')
12-
}
13-
14-
/**
15-
* Api request for fetching user profile v5
16-
* @returns {Promise<*>}
17-
*/
18-
export async function fetchProfileV5 (handle) {
19-
const response = await axiosInstance.get(`${MEMBER_API_URL}?handle=${handle}`)
20-
const data = _.get(response, 'data')
21-
return data.length ? data[0] : undefined
10+
const response = await axiosInstance.get(`${MEMBER_API_URL}/${handle}`)
11+
return _.get(response, 'data')
2212
}
2313

2414
/**
25-
* Api request for fetching user profile
15+
* Api request for searching profiles
2616
* @returns {Promise<*>}
2717
*/
28-
export async function searchProfiles (fields, query, limit) {
29-
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/_search`, {
18+
export async function searchProfiles (fields, queryObject = {}, limit) {
19+
const response = await axiosInstance.get(`${MEMBER_API_URL}`, {
3020
params: {
3121
fields,
32-
query,
33-
limit
22+
...queryObject,
23+
perPage: limit,
24+
page: 1
3425
}
3526
})
3627
return _.get(response, 'data.result.content')
@@ -41,30 +32,20 @@ export async function searchProfiles (fields, query, limit) {
4132
* @returns {Promise<*>}
4233
*/
4334
export async function searchProfilesByUserIds (userIds, fields = 'userId,handle,firstName,lastName,email', limit) {
44-
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/_search`, {
45-
params: {
46-
query: `${_.map(userIds, id => `userId:${id}`).join(encodeURIComponent(' OR '))}`,
47-
fields,
48-
limit
49-
}
50-
})
51-
return _.get(response, 'data.result.content')
35+
return searchProfiles(
36+
fields,
37+
{
38+
userIds
39+
},
40+
limit
41+
)
5242
}
5343

5444
/**
5545
* Api request for finding (suggesting) users by the part of the handle
5646
* @returns {Promise<*>}
5747
*/
5848
export async function suggestProfiles (partialHandle) {
59-
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/_suggest/${encodeURIComponent(partialHandle)}`)
60-
return _.get(response, 'data.result.content')
61-
}
62-
63-
/**
64-
* Api request for finding (suggesting) users by the part of the handle
65-
* @returns {Promise<*>}
66-
*/
67-
export async function suggestProfilesV5 (partialHandle) {
6849
const response = await axiosInstance.get(`${MEMBER_API_URL}/autocomplete?term=${encodeURIComponent(partialHandle)}`)
6950
return _.get(response, 'data')
7051
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy