diff --git a/config/constants/dev.js b/config/constants/dev.js index 95fee417c..ec1f0325c 100644 --- a/config/constants/dev.js +++ b/config/constants/dev.js @@ -60,7 +60,6 @@ module.exports = { CONTENTFUL_DELIVERY_KEY : process.env.CONTENTFUL_DELIVERY_KEY, CONTENTFUL_SPACE_ID : process.env.CONTENTFUL_SPACE_ID, - TAAS_APP_URL: 'https://platform.topcoder-dev.com/taas', DEFAULT_NDA_UUID: 'e5811a7b-43d1-407a-a064-69e5015b4900', UNIVERSAL_NAV_URL: '//uni-nav.topcoder-dev.com/v1/tc-universal-nav.js', HEADER_AUTH_URLS_HREF: `https://accounts-auth0.${DOMAIN}?utm_source=community-app-main`, diff --git a/config/constants/master.js b/config/constants/master.js index c6de2d6b0..7af89019a 100644 --- a/config/constants/master.js +++ b/config/constants/master.js @@ -60,7 +60,6 @@ module.exports = { CONTENTFUL_DELIVERY_KEY : process.env.CONTENTFUL_DELIVERY_KEY, CONTENTFUL_SPACE_ID : process.env.CONTENTFUL_SPACE_ID, - TAAS_APP_URL: 'https://platform.topcoder.com/taas', DEFAULT_NDA_UUID: 'c41e90e5-4d0e-4811-bd09-38ff72674490', UNIVERSAL_NAV_URL: '//uni-nav.topcoder.com/v1/tc-universal-nav.js', HEADER_AUTH_URLS_HREF: `https://accounts-auth0.${DOMAIN}?utm_source=community-app-main`, diff --git a/config/constants/qa.js b/config/constants/qa.js index 63dea5c31..d9a2ffe3e 100644 --- a/config/constants/qa.js +++ b/config/constants/qa.js @@ -55,7 +55,6 @@ module.exports = { TC_CDN_URL: process.env.TC_CDN_URL, - TAAS_APP_URL: 'https://platform.topcoder-dev.com/taas', DEFAULT_NDA_UUID: 'e5811a7b-43d1-407a-a064-69e5015b4900', UNIVERSAL_NAV_URL: '//uni-nav.topcoder-dev.com/v1/tc-universal-nav.js', HEADER_AUTH_URLS_HREF: `https://accounts-auth0.${DOMAIN}?utm_source=community-app-main`, diff --git a/connect-automation/config/config.json b/connect-automation/config/config.json index 16655dc1b..0353ad4dd 100644 --- a/connect-automation/config/config.json +++ b/connect-automation/config/config.json @@ -23,6 +23,5 @@ "accountAndSecurityUrl": "https://connect.topcoder-dev.com/settings/account", "notificationsUrl": "https://connect.topcoder-dev.com/notifications", "allProjectsUrl": "https://connect.topcoder-dev.com/projects", - "expiredProjectUrl": "https://connect.topcoder-dev.com/projects/17236", - "platformUrl": "https://platform.topcoder-dev.com/taas/myteams" + "expiredProjectUrl": "https://connect.topcoder-dev.com/projects/17236" } \ No newline at end of file diff --git a/connect-automation/page-objects/project-creation-flow/create-project/create-project.helper.ts b/connect-automation/page-objects/project-creation-flow/create-project/create-project.helper.ts index 410e3dd97..297939b26 100644 --- a/connect-automation/page-objects/project-creation-flow/create-project/create-project.helper.ts +++ b/connect-automation/page-objects/project-creation-flow/create-project/create-project.helper.ts @@ -58,9 +58,6 @@ export class CreateProjectPageHelper { await this.createProjectPageObject.submitJobRequest.click(); const message = await CommonHelper.getAlertMessageAndClosePopup(); expect(message).toContain(`PROJECT '${taasData.title.toUpperCase()}' CREATED`); - - await this.createProjectPageObject.viewTalentRequestButton.click(); - await CommonHelper.verifyPageUrl(ConfigHelper.getPlatformUrl()); } private static createProjectPageObject: CreateProjectPageObject; @@ -240,7 +237,7 @@ export class CreateProjectPageHelper { await this.createProjectPageObject.skillsInput.click(); await CommonHelper.waitForListToGetLoaded('xpath', this.createProjectPageObject.multiSelectOptionClassName, 2); - + const elements = await this.createProjectPageObject.multiSelectOption; await elements[1].click(); diff --git a/connect-automation/page-objects/project-creation-flow/create-project/create-project.po.ts b/connect-automation/page-objects/project-creation-flow/create-project/create-project.po.ts index f55ea2289..3243d3be5 100644 --- a/connect-automation/page-objects/project-creation-flow/create-project/create-project.po.ts +++ b/connect-automation/page-objects/project-creation-flow/create-project/create-project.po.ts @@ -71,13 +71,6 @@ export class CreateProjectPageObject { return ElementHelper.getElementByButtonText('Submit job request'); } - /** - * Get view Talent Request button - */ - public get viewTalentRequestButton() { - return ElementHelper.getElementByCss('.go-to-project-dashboard-btn'); - } - /** * Get Current Form Page's title element */ diff --git a/connect-automation/utils/config-helper.ts b/connect-automation/utils/config-helper.ts index 7778926bf..5330d4357 100644 --- a/connect-automation/utils/config-helper.ts +++ b/connect-automation/utils/config-helper.ts @@ -112,11 +112,4 @@ export const ConfigHelper = { getExpiredProjectUrl(): string { return this.getConfig().expiredProjectUrl; }, - - /** - * Get platform URL - */ - getPlatformUrl(): string { - return this.getConfig().platformUrl; - }, }; diff --git a/src/api/projectMembers.js b/src/api/projectMembers.js index 90501f311..83e8e7f4f 100644 --- a/src/api/projectMembers.js +++ b/src/api/projectMembers.js @@ -1,42 +1,32 @@ -import _ from 'lodash' import { axiosInstance as axios } from './requestInterceptor' import { TC_API_URL, PROJECTS_API_URL } from '../config/constants' export function getMembersById (userIds) { - const _userIdArr = _.map(userIds, _id => `userId:${_id}`) // only requesting certain member attributes - const fields = 'userId,handle,photoURL,details' - const query = _userIdArr.join(' OR ') - const url = `${TC_API_URL}/v3/members/_search/?fields=` - + encodeURIComponent(fields) - + `&query=${encodeURIComponent(query)}` - + '&limit=' + userIds.length + const fields = 'userId,handle,photoURL,firstName,lastName' + const url = `${TC_API_URL}/v5/members?userIds=[${userIds.join(',')}]&fields=${encodeURIComponent(fields)}` return axios.get(url) .then(resp => { - return resp.data.result.content + return resp.data }) } export function getMembersByHandle (handles) { - const _handlesArr = _.map(handles, _handle => `handleLower:${_handle.toLowerCase()}`) // only requesting certain member attributes - const fields = 'userId,handle,photoURL,details' - const query = _handlesArr.join(' OR ') - const url = `${TC_API_URL}/v3/members/_search/?fields=` - + encodeURIComponent(fields) - + `&query=${encodeURIComponent(query)}` - + '&limit=' + handles.length + const fields = 'userId,handle,photoURL,firstName,lastName' + const quotedHandles = handles.map(handle => JSON.stringify(handle)).join(',') + const url = `${TC_API_URL}/v5/members?handles=[${quotedHandles}]&fields=${encodeURIComponent(fields)}` return axios.get(url) .then(resp => { - return resp.data.result.content + return resp.data }) } export function loadMemberSuggestions(value) { - const url = `${TC_API_URL}/v3/members/_suggest/${value}` + const url = `${TC_API_URL}/v5/members/autocomplete?term=${value}` return axios.get(url) .then(resp => { - return resp.data.result.content + return resp.data }) } diff --git a/src/api/skills.js b/src/api/skills.js deleted file mode 100644 index cdb90e2ef..000000000 --- a/src/api/skills.js +++ /dev/null @@ -1,49 +0,0 @@ -import { TC_API_URL } from '../config/constants' -import { axiosInstance as axios } from './requestInterceptor' - -const skillPageSize = 100 -let cachedSkillsAsPromise - -/** - * Loads and caches all the skills the first time. Returns the skills list from the cache from the second time. - */ -export function getSkills() { - cachedSkillsAsPromise = cachedSkillsAsPromise || getAllSkills().catch(ex => { - console.error('Error loading skills', ex) - cachedSkillsAsPromise = null - return [] - }) - - return cachedSkillsAsPromise -} - -/** - * Recursively loads all the pages from skills api. - */ -function getAllSkills() { - let skills = [] - - return new Promise((resolve, reject) => { - const loop = (page) => getSkillsPage(page) - .then((skillResponse) => { - skills = skills.concat(skillResponse.data) - if (skillResponse.data.length === skillPageSize) { - page++ - loop(page) - } else { - resolve(skills) - } - }) - .catch(ex => reject(ex)) - - loop(1) - }) -} - -/** - * Loads the skills in the given page. - * @param {number} page The page number to load - */ -function getSkillsPage(page) { - return axios.get(`${TC_API_URL}/v5/taas-teams/skills?perPage=${skillPageSize}&orderBy=name&page=${page}`) -} diff --git a/src/api/skills.ts b/src/api/skills.ts new file mode 100644 index 000000000..0597b39a8 --- /dev/null +++ b/src/api/skills.ts @@ -0,0 +1,19 @@ +import _ from 'lodash' +import { TC_API_URL } from '../config/constants' +import { axiosInstance as axios } from './requestInterceptor' +import qs from 'query-string' + + +/** + * Api request for fetching skills + * + * @param {String} term search key + * + * @returns {Promise<*>} + */ +export const searchSkills = async (term) => { + const skills = await axios.get(`${TC_API_URL}/v5/standardized-skills/skills/autocomplete?${qs.stringify({ + term + })}`) + return _.get(skills, 'data', []) +} diff --git a/src/api/users.js b/src/api/users.js index 88b025020..1a20c3d9b 100644 --- a/src/api/users.js +++ b/src/api/users.js @@ -63,8 +63,8 @@ export function updateUserProfile(handle, updatedProfile, queryParams = {}) { * @returns {Promise} member traits */ export const getMemberTraits = (handle) => { - return axios.get(`${TC_API_URL}/v3/members/${handle}/traits`) - .then(resp => _.get(resp.data, 'result.content', {})) + return axios.get(`${TC_API_URL}/v5/members/${handle}/traits`) + .then(resp => resp.data) } /** @@ -76,10 +76,10 @@ export const getMemberTraits = (handle) => { * @returns {Promise} member traits */ export const updateMemberTraits = (handle, updatedTraits) => { - return axios.put(`${TC_API_URL}/v3/members/${handle}/traits`, { - param: updatedTraits - }) - .then(resp => _.get(resp.data, 'result.content', {})) + return axios.put(`${TC_API_URL}/v5/members/${handle}/traits`, (updatedTraits || []).map(traitInfo => { + return _.pick(traitInfo, ['categoryName', 'traitId', 'traits', ]) + })) + .then(resp => resp.data) } /** @@ -91,10 +91,10 @@ export const updateMemberTraits = (handle, updatedTraits) => { * @returns {Promise} member traits */ export const createMemberTraits = (handle, traits) => { - return axios.post(`${TC_API_URL}/v3/members/${handle}/traits`, { - param: traits - }) - .then(resp => _.get(resp.data, 'result.content', {})) + return axios.post(`${TC_API_URL}/v5/members/${handle}/traits`, (traits || []).map(traitInfo => { + return _.pick(traitInfo, ['categoryName', 'traitId', 'traits', ]) + })) + .then(resp => resp.data) } /** diff --git a/src/components/Select/Select.jsx b/src/components/Select/Select.jsx index 3c2e470ae..68ebeeffe 100644 --- a/src/components/Select/Select.jsx +++ b/src/components/Select/Select.jsx @@ -9,6 +9,7 @@ import React from 'react' import ReactSelect from 'react-select' import CreatableSelect from 'react-select/lib/Creatable' +import Async from 'react-select/lib/Async' import './Select.scss' const Select = (props) => { @@ -30,6 +31,16 @@ const Select = (props) => { classNamePrefix="react-select" /> ) + } else if (props.asyncOption) { + return ( + + ) } else { return ( { + searchSkills(inputValue).then( + (skills) => { + const suggestedOptions = skills.map((skillItem) => ({ + name: skillItem.name, + skillId: skillItem.id + })) + return callback(suggestedOptions) + }) + .catch(() => { + return callback(null) + }) +}, 150) /** * If `categoriesMapping` is defined - filter options using selected categories. @@ -48,13 +62,6 @@ class SkillsQuestion extends React.PureComponent { } componentWillMount() { - getSkills().then(skills => { - const options = skills.map(skill => ({ - skillId: skill.id, - name: skill.name - })) - this.updateOptions(options) - }) } componentWillReceiveProps(nextProps) { @@ -177,9 +184,7 @@ class SkillsQuestion extends React.PureComponent { const selectedCategories = _.get(currentProjectData, categoriesField, []) - let currentValues = getValue() || [] - // remove from currentValues not available options but still keep created custom options without skillId - currentValues = currentValues.filter(skill => _.some(availableOptions, skill) || !skill.skillId) + const currentValues = getValue() || [] const questionDisabled = isFormDisabled() || disabled || (selectedCategories.length === 0 && _.isUndefined(skillsCategories)) const hasError = !isPristine() && !isValid() @@ -205,7 +210,7 @@ class SkillsQuestion extends React.PureComponent { />) : null}