Skip to content

Commit

Permalink
Merge pull request #1526 from topcoder-platform/develop
Browse files Browse the repository at this point in the history
Release 0.20.6
  • Loading branch information
jmgasper authored May 10, 2023
2 parents dc42874 + 53271dc commit 274e4c1
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 55 deletions.
1 change: 0 additions & 1 deletion config/constants/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
ACCOUNTS_APP_LOGIN_URL: `https://accounts-auth0.${DOMAIN}`,
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
MEMBER_API_URL: `${DEV_API_HOSTNAME}/v5/members`,
MEMBER_API_V3_URL: `${DEV_API_HOSTNAME}/v3/members`,
CHALLENGE_API_URL: `${DEV_API_HOSTNAME}/v5/challenges`,
CHALLENGE_TIMELINE_TEMPLATES_URL: `${DEV_API_HOSTNAME}/v5/timeline-templates`,
CHALLENGE_TYPES_URL: `${DEV_API_HOSTNAME}/v5/challenge-types`,
Expand Down
1 change: 0 additions & 1 deletion config/constants/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
ACCOUNTS_APP_LOGIN_URL: `https://accounts-auth0.${DOMAIN}`,
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
MEMBER_API_URL: `${PROD_API_HOSTNAME}/v5/members`,
MEMBER_API_V3_URL: `${PROD_API_HOSTNAME}/v3/members`,
CHALLENGE_API_URL: `${PROD_API_HOSTNAME}/v5/challenges`,
CHALLENGE_TIMELINE_TEMPLATES_URL: `${PROD_API_HOSTNAME}/v5/timeline-templates`,
CHALLENGE_TYPES_URL: `${PROD_API_HOSTNAME}/v5/challenge-types`,
Expand Down
19 changes: 13 additions & 6 deletions src/actions/challenges.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { removeChallengeFromPhaseProduct, saveChallengeAsPhaseProduct } from '..
* @param {number} page
* @param {string} projectId
* @param {string} status
* @param {boolean} dashboard is in dashboard or not
* @param {string} filterChallengeName
* @param {bool} selfService
* @param {string} userHandle this will be null for admin user(we will return all datas for admin user)
Expand All @@ -77,6 +78,7 @@ export function loadChallengesByPage (
page,
projectId,
status,
dashboard,
filterChallengeName = null,
selfService = false,
userHandle = null,
Expand Down Expand Up @@ -156,16 +158,21 @@ export function loadChallengesByPage (
filters['memberId'] = userId
}

if (status === 'all') {
delete filters['status']
} else if (!_.isEmpty(status)) {
filters['status'] = status === '' ? undefined : _.startCase(status.toLowerCase())
} else if (!(_.isInteger(projectId) && projectId > 0)) {
if (status !== 'all') {
filters['status'] = !status ? undefined : _.startCase(status.toLowerCase())
}

if (!dashboard && !filters['status'] && !(_.isInteger(projectId) && projectId > 0)) {
filters['status'] = 'Active'
}
if (selfService) {
filters.selfService = true
if (userHandle && filters.status.toUpperCase() !== CHALLENGE_STATUS.DRAFT && filters.status.toUpperCase() !== CHALLENGE_STATUS.NEW) {
const filtersStatus = filters.status ? filters.status.toUpperCase() : filters.status
if (
userHandle &&
filtersStatus !== CHALLENGE_STATUS.DRAFT &&
filtersStatus !== CHALLENGE_STATUS.NEW
) {
filters.selfServiceCopilot = userHandle
}
}
Expand Down
25 changes: 16 additions & 9 deletions src/components/ChallengesComponent/ChallengeList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require('bootstrap/scss/bootstrap.scss')
const defaultSearchParam = {
searchText: '',
challengeProjectOption: null,
challengeStatus: '',
challengeStatus: 'all',
challengeType: null,
sortBy: 'startDate',
sortOrder: 'desc',
Expand Down Expand Up @@ -112,7 +112,8 @@ class ChallengeList extends Component {
loadChallengesByPage(
1,
projectId,
!projectStatus ? 'all' : projectStatus,
projectStatus,
dashboard,
searchText,
selfService,
this.getHandle(),
Expand Down Expand Up @@ -150,6 +151,7 @@ class ChallengeList extends Component {
pageNumber,
projectId,
status,
dashboard,
searchText,
selfService,
this.getHandle(),
Expand Down Expand Up @@ -188,6 +190,7 @@ class ChallengeList extends Component {
1,
projectId,
status,
dashboard,
searchText,
selfService,
this.getHandle(),
Expand All @@ -211,12 +214,14 @@ class ChallengeList extends Component {
loadChallengesByPage,
activeProjectId,
status,
selfService
selfService,
dashboard
} = this.props
loadChallengesByPage(
page,
activeProjectId,
status,
dashboard,
searchText,
selfService,
this.getHandle(),
Expand Down Expand Up @@ -301,6 +306,7 @@ class ChallengeList extends Component {
page,
projectId,
status,
dashboard,
searchText,
selfService,
this.getHandle(),
Expand Down Expand Up @@ -346,15 +352,16 @@ class ChallengeList extends Component {
loadChallengesByPage(
1,
projectId,
'all',
'',
defaultSearchParam.challengeStatus,
dashboard,
defaultSearchParam.searchText,
selfService,
this.getHandle(),
this.getLoginUserId(),
null,
{},
null,
null,
defaultSearchParam.challengeType,
defaultSearchParam.challengeDate,
defaultSearchParam.sortBy,
defaultSearchParam.sortOrder,
PAGE_SIZE
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/SelectUserAutocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useState, useCallback } from 'react'
import PropTypes from 'prop-types'
import Select from '../Select'
import { suggestProfilesV5, fetchProfileV5 } from '../../services/user'
import { suggestProfiles, fetchProfile } from '../../services/user'
import _ from 'lodash'
import { AUTOCOMPLETE_MIN_LENGTH, AUTOCOMPLETE_DEBOUNCE_TIME_MS } from '../../config/constants'

Expand All @@ -27,7 +27,7 @@ export default function SelectUserAutocomplete (props) {
return
}

Promise.all([suggestProfilesV5(inputValue), fetchProfileV5(inputValue)]).then(
Promise.all([suggestProfiles(inputValue), fetchProfile(inputValue)]).then(
([suggestions, user]) => {
const suggestedOptions = suggestions.map((u) => ({
label: u.handle,
Expand Down
21 changes: 21 additions & 0 deletions src/components/Tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const Tab = ({
selectTab(3)
}

const onSelfServiceClick = () => {
if (currentTab === 4) {
return
}
selectTab(4)
}

const tabComponent = (
<ul className={styles.challengeTab}>
<li
Expand Down Expand Up @@ -72,6 +79,20 @@ const Tab = ({
>
Users
</li>
<li
key='tab-item-self-service'
className={cn(styles.item, { [styles.active]: currentTab === 4 })}
onClick={onSelfServiceClick}
onKeyDown={e => {
if (e.key !== 'Enter') {
return
}
onSelfServiceClick()
}}
role='presentation'
>
Self-Service
</li>
</ul>
)

Expand Down
3 changes: 2 additions & 1 deletion src/containers/Challenges/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ class Challenges extends Component {
this.props.loadChallengesByPage(
1,
projectId ? parseInt(projectId) : -1,
dashboard ? 'all' : '',
'all',
dashboard,
'',
selfService,
isAdmin ? null : this.props.auth.user.handle,
Expand Down
5 changes: 5 additions & 0 deletions src/containers/Tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class TabContainer extends Component {
this.setState({ currentTab: 2 })
} else if (nextProps.history.location.pathname === '/users') {
this.setState({ currentTab: 3 })
} else if (nextProps.history.location.pathname === '/self-service') {
this.setState({ currentTab: 4 })
} else {
this.setState({ currentTab: 0 })
}
Expand Down Expand Up @@ -85,6 +87,9 @@ class TabContainer extends Component {
} else if (tab === 3) {
history.push('/users')
this.setState({ currentTab: 3 })
} else if (tab === 4) {
history.push('/self-service')
this.setState({ currentTab: 4 })
}

resetSidebarActiveParams()
Expand Down
51 changes: 16 additions & 35 deletions src/services/user.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
import _ from 'lodash'
import { axiosInstance } from './axiosWithAuth'
const { MEMBER_API_URL, MEMBER_API_V3_URL } = process.env
const { MEMBER_API_URL } = process.env

/**
* Api request for fetching user profile
* @returns {Promise<*>}
*/
export async function fetchProfile (handle) {
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/${handle}`)
return _.get(response, 'data.result.content')
}

/**
* Api request for fetching user profile v5
* @returns {Promise<*>}
*/
export async function fetchProfileV5 (handle) {
const response = await axiosInstance.get(`${MEMBER_API_URL}?handle=${handle}`)
const data = _.get(response, 'data')
return data.length ? data[0] : undefined
const response = await axiosInstance.get(`${MEMBER_API_URL}/${handle}`)
return _.get(response, 'data')
}

/**
* Api request for fetching user profile
* Api request for searching profiles
* @returns {Promise<*>}
*/
export async function searchProfiles (fields, query, limit) {
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/_search`, {
export async function searchProfiles (fields, queryObject = {}, limit) {
const response = await axiosInstance.get(`${MEMBER_API_URL}`, {
params: {
fields,
query,
limit
...queryObject,
perPage: limit,
page: 1
}
})
return _.get(response, 'data.result.content')
Expand All @@ -41,30 +32,20 @@ export async function searchProfiles (fields, query, limit) {
* @returns {Promise<*>}
*/
export async function searchProfilesByUserIds (userIds, fields = 'userId,handle,firstName,lastName,email', limit) {
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/_search`, {
params: {
query: `${_.map(userIds, id => `userId:${id}`).join(encodeURIComponent(' OR '))}`,
fields,
limit
}
})
return _.get(response, 'data.result.content')
return searchProfiles(
fields,
{
userIds
},
limit
)
}

/**
* Api request for finding (suggesting) users by the part of the handle
* @returns {Promise<*>}
*/
export async function suggestProfiles (partialHandle) {
const response = await axiosInstance.get(`${MEMBER_API_V3_URL}/_suggest/${encodeURIComponent(partialHandle)}`)
return _.get(response, 'data.result.content')
}

/**
* Api request for finding (suggesting) users by the part of the handle
* @returns {Promise<*>}
*/
export async function suggestProfilesV5 (partialHandle) {
const response = await axiosInstance.get(`${MEMBER_API_URL}/autocomplete?term=${encodeURIComponent(partialHandle)}`)
return _.get(response, 'data')
}

0 comments on commit 274e4c1

Please sign in to comment.