Compare commits
8 Commits
frontend-b
...
open-relea
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a4174d2f2 | ||
|
|
9461973574 | ||
|
|
06e827bdb4 | ||
|
|
5e3508051c | ||
|
|
8c779590a1 | ||
|
|
b533bf7046 | ||
|
|
2af0383847 | ||
|
|
57e3bd0125 |
5
.env
5
.env
@@ -25,9 +25,4 @@ FAVICON_URL=''
|
||||
COLLECT_YEAR_OF_BIRTH=true
|
||||
APP_ID=''
|
||||
MFE_CONFIG_API_URL=''
|
||||
ENABLE_SKILLS_BUILDER=''
|
||||
ENABLE_SKILLS_BUILDER_PROFILE=''
|
||||
ALGOLIA_APP_ID=''
|
||||
ALGOLIA_JOBS_INDEX_NAME=''
|
||||
ALGOLIA_PRODUCT_INDEX_NAME=''
|
||||
ALGOLIA_SEARCH_API_KEY=''
|
||||
|
||||
@@ -26,9 +26,4 @@ FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
|
||||
COLLECT_YEAR_OF_BIRTH=true
|
||||
APP_ID=''
|
||||
MFE_CONFIG_API_URL=''
|
||||
ENABLE_SKILLS_BUILDER='true'
|
||||
ENABLE_SKILLS_BUILDER_PROFILE=''
|
||||
ALGOLIA_APP_ID=''
|
||||
ALGOLIA_JOBS_INDEX_NAME=''
|
||||
ALGOLIA_PRODUCT_INDEX_NAME=''
|
||||
ALGOLIA_SEARCH_API_KEY=''
|
||||
|
||||
@@ -18,13 +18,8 @@ LOGO_TRADEMARK_URL=https://edx-cdn.org/v3/default/logo-trademark.svg
|
||||
LOGO_WHITE_URL=https://edx-cdn.org/v3/default/logo-white.svg
|
||||
FAVICON_URL=https://edx-cdn.org/v3/default/favicon.ico
|
||||
ENABLE_LEARNER_RECORD_MFE=''
|
||||
ENABLE_SKILLS_BUILDER='true'
|
||||
ENABLE_SKILLS_BUILDER_PROFILE=''
|
||||
LEARNER_RECORD_MFE_BASE_URL='http://localhost:1990'
|
||||
COLLECT_YEAR_OF_BIRTH=true
|
||||
APP_ID=''
|
||||
MFE_CONFIG_API_URL=''
|
||||
ALGOLIA_APP_ID=''
|
||||
ALGOLIA_JOBS_INDEX_NAME=''
|
||||
ALGOLIA_PRODUCT_INDEX_NAME=''
|
||||
ALGOLIA_SEARCH_API_KEY=''
|
||||
|
||||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@@ -13,13 +13,13 @@ jobs:
|
||||
- i18n_extract
|
||||
- lint
|
||||
- test
|
||||
node: [16]
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Nodejs Env
|
||||
run: echo "NODE_VER=`cat .nvmrc`" >> $GITHUB_ENV
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: npm install -g npm@8.x.x
|
||||
node-version: ${{ env.NODE_VER }}
|
||||
- run: make requirements
|
||||
- run: make test NPM_TESTS=build
|
||||
- run: make test NPM_TESTS=${{ matrix.npm-test }}
|
||||
|
||||
2
.github/workflows/lockfileversion-check.yml
vendored
2
.github/workflows/lockfileversion-check.yml
vendored
@@ -10,4 +10,4 @@ on:
|
||||
|
||||
jobs:
|
||||
version-check:
|
||||
uses: openedx/.github/.github/workflows/lockfileversion-check.yml@master
|
||||
uses: openedx/.github/.github/workflows/lockfileversion-check-v3.yml@master
|
||||
|
||||
18426
package-lock.json
generated
18426
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -28,16 +28,15 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"@edx/brand": "npm:@edx/brand-openedx@1.2.0",
|
||||
"@edx/frontend-component-footer": "11.7.1",
|
||||
"@edx/frontend-component-header": "3.6.5",
|
||||
"@edx/frontend-platform": "3.3.1",
|
||||
"@edx/frontend-component-footer": "12.0.0",
|
||||
"@edx/frontend-component-header": "4.0.0",
|
||||
"@edx/frontend-platform": "4.2.0",
|
||||
"@edx/paragon": "^20.20.0",
|
||||
"@fortawesome/fontawesome-svg-core": "1.2.36",
|
||||
"@fortawesome/free-brands-svg-icons": "5.15.4",
|
||||
"@fortawesome/free-regular-svg-icons": "5.15.4",
|
||||
"@fortawesome/free-solid-svg-icons": "5.15.4",
|
||||
"@fortawesome/react-fontawesome": "0.2.0",
|
||||
"algoliasearch": "4.6.0",
|
||||
"classnames": "2.3.2",
|
||||
"core-js": "3.27.2",
|
||||
"history": "4.10.1",
|
||||
@@ -49,7 +48,6 @@
|
||||
"react": "16.14.0",
|
||||
"react-dom": "16.14.0",
|
||||
"react-helmet": "6.1.0",
|
||||
"react-instantsearch-hooks-web": "^6.40.1",
|
||||
"react-redux": "7.2.9",
|
||||
"react-router": "5.3.4",
|
||||
"react-router-dom": "5.3.4",
|
||||
|
||||
@@ -56,12 +56,7 @@ initialize({
|
||||
config: () => {
|
||||
mergeConfig({
|
||||
COLLECT_YEAR_OF_BIRTH: process.env.COLLECT_YEAR_OF_BIRTH,
|
||||
ENABLE_SKILLS_BUILDER: process.env.ENABLE_SKILLS_BUILDER,
|
||||
ENABLE_SKILLS_BUILDER_PROFILE: process.env.ENABLE_SKILLS_BUILDER_PROFILE,
|
||||
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID || null,
|
||||
ALGOLIA_JOBS_INDEX_NAME: process.env.ALGOLIA_JOBS_INDEX_NAME || null,
|
||||
ALGOLIA_PRODUCT_INDEX_NAME: process.env.ALGOLIA_PRODUCT_INDEX_NAME || null,
|
||||
ALGOLIA_SEARCH_API_KEY: process.env.ALGOLIA_SEARCH_API_KEY || null,
|
||||
}, 'App loadConfig override handler');
|
||||
},
|
||||
},
|
||||
|
||||
@@ -6,6 +6,3 @@
|
||||
@import "~@edx/frontend-component-footer/dist/footer";
|
||||
|
||||
@import './profile/index';
|
||||
|
||||
@import './skills-builder/skills-builder-modal/skillsBuilderModal.scss';
|
||||
@import './skills-builder/skills-builder-header/skillsBuilderHeader.scss';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
const Banner = () => <div className="profile-page-bg-banner bg-primary d-none d-md-block p-relative" />;
|
||||
const Banner = () => <div className="profile-page-bg-banner bg-primary d-md-block p-relative" />;
|
||||
|
||||
export default Banner;
|
||||
|
||||
@@ -124,7 +124,7 @@ class ProfilePage extends React.Component {
|
||||
|
||||
return (
|
||||
<span data-hj-suppress>
|
||||
<h1 className="h2 mb-0 font-weight-bold">{this.props.match.params.username}</h1>
|
||||
<h1 className="h2 mb-0 font-weight-bold text-truncate">{this.props.match.params.username}</h1>
|
||||
<DateJoined date={dateJoined} />
|
||||
{this.isYOBDisabled() && <UsernameDescription />}
|
||||
<hr className="d-none d-md-block" />
|
||||
@@ -176,6 +176,7 @@ class ProfilePage extends React.Component {
|
||||
visibilityLearningGoal,
|
||||
languageProficiencies,
|
||||
visibilityLanguageProficiencies,
|
||||
courseCertificates,
|
||||
visibilityCourseCertificates,
|
||||
bio,
|
||||
visibilityBio,
|
||||
@@ -194,6 +195,17 @@ class ProfilePage extends React.Component {
|
||||
changeHandler: this.handleChange,
|
||||
};
|
||||
|
||||
const isBlockVisible = (blockInfo) => this.isAuthenticatedUserProfile()
|
||||
|| (!this.isAuthenticatedUserProfile() && Boolean(blockInfo));
|
||||
|
||||
const isLanguageBlockVisible = isBlockVisible(languageProficiencies.length);
|
||||
const isEducationBlockVisible = isBlockVisible(levelOfEducation);
|
||||
const isSocialLinksBLockVisible = isBlockVisible(socialLinks.some((link) => link.socialLink !== null));
|
||||
const isBioBlockVisible = isBlockVisible(bio);
|
||||
const isCertificatesBlockVisible = isBlockVisible(courseCertificates.length);
|
||||
const isNameBlockVisible = isBlockVisible(name);
|
||||
const isLocationBlockVisible = isBlockVisible(country);
|
||||
|
||||
return (
|
||||
<div className="container-fluid">
|
||||
<div className="row align-items-center pt-4 mb-4 pt-md-0 mb-md-0">
|
||||
@@ -210,7 +222,7 @@ class ProfilePage extends React.Component {
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col pl-0">
|
||||
<div className="col">
|
||||
<div className="d-md-none">
|
||||
{this.renderHeadingLockup()}
|
||||
</div>
|
||||
@@ -228,46 +240,58 @@ class ProfilePage extends React.Component {
|
||||
<div className="d-md-none mb-4">
|
||||
{this.renderViewMyRecordsButton()}
|
||||
</div>
|
||||
<Name
|
||||
name={name}
|
||||
visibilityName={visibilityName}
|
||||
formId="name"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
<Country
|
||||
country={country}
|
||||
visibilityCountry={visibilityCountry}
|
||||
formId="country"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
<PreferredLanguage
|
||||
languageProficiencies={languageProficiencies}
|
||||
visibilityLanguageProficiencies={visibilityLanguageProficiencies}
|
||||
formId="languageProficiencies"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
<Education
|
||||
levelOfEducation={levelOfEducation}
|
||||
visibilityLevelOfEducation={visibilityLevelOfEducation}
|
||||
formId="levelOfEducation"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
<SocialLinks
|
||||
socialLinks={socialLinks}
|
||||
draftSocialLinksByPlatform={draftSocialLinksByPlatform}
|
||||
visibilitySocialLinks={visibilitySocialLinks}
|
||||
formId="socialLinks"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
{isNameBlockVisible && (
|
||||
<Name
|
||||
name={name}
|
||||
visibilityName={visibilityName}
|
||||
formId="name"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
{isLocationBlockVisible && (
|
||||
<Country
|
||||
country={country}
|
||||
visibilityCountry={visibilityCountry}
|
||||
formId="country"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
{isLanguageBlockVisible && (
|
||||
<PreferredLanguage
|
||||
languageProficiencies={languageProficiencies}
|
||||
visibilityLanguageProficiencies={visibilityLanguageProficiencies}
|
||||
formId="languageProficiencies"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
{isEducationBlockVisible && (
|
||||
<Education
|
||||
levelOfEducation={levelOfEducation}
|
||||
visibilityLevelOfEducation={visibilityLevelOfEducation}
|
||||
formId="levelOfEducation"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
{isSocialLinksBLockVisible && (
|
||||
<SocialLinks
|
||||
socialLinks={socialLinks}
|
||||
draftSocialLinksByPlatform={draftSocialLinksByPlatform}
|
||||
visibilitySocialLinks={visibilitySocialLinks}
|
||||
formId="socialLinks"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className="pt-md-3 col-md-8 col-lg-7 offset-lg-1">
|
||||
{!this.isYOBDisabled() && this.renderAgeMessage()}
|
||||
<Bio
|
||||
bio={bio}
|
||||
visibilityBio={visibilityBio}
|
||||
formId="bio"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
{isBioBlockVisible && (
|
||||
<Bio
|
||||
bio={bio}
|
||||
visibilityBio={visibilityBio}
|
||||
formId="bio"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
{getConfig().ENABLE_SKILLS_BUILDER_PROFILE && (
|
||||
<LearningGoal
|
||||
learningGoal={learningGoal}
|
||||
@@ -276,11 +300,13 @@ class ProfilePage extends React.Component {
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
<Certificates
|
||||
visibilityCourseCertificates={visibilityCourseCertificates}
|
||||
formId="certificates"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
{isCertificatesBlockVisible && (
|
||||
<Certificates
|
||||
visibilityCourseCertificates={visibilityCourseCertificates}
|
||||
formId="certificates"
|
||||
{...commonFormProps}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -346,7 +372,7 @@ ProfilePage.propTypes = {
|
||||
|
||||
// Learning Goal form data
|
||||
learningGoal: PropTypes.string,
|
||||
visibilityLearningGoal: PropTypes.string.isRequired,
|
||||
visibilityLearningGoal: PropTypes.string,
|
||||
|
||||
// Other data we need
|
||||
profileImage: PropTypes.shape({
|
||||
@@ -397,6 +423,7 @@ ProfilePage.defaultProps = {
|
||||
courseCertificates: null,
|
||||
requiresParentalConsent: null,
|
||||
dateJoined: null,
|
||||
visibilityLearningGoal: null,
|
||||
};
|
||||
|
||||
export default connect(
|
||||
|
||||
@@ -115,15 +115,33 @@ describe('<ProfilePage />', () => {
|
||||
expect(tree).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('viewing other profile', () => {
|
||||
it('viewing other profile with all fields', () => {
|
||||
const contextValue = {
|
||||
authenticatedUser: { userId: 123, username: 'staff', administrator: true },
|
||||
config: getConfig(),
|
||||
};
|
||||
|
||||
const component = (
|
||||
<ProfilePageWrapper
|
||||
contextValue={contextValue}
|
||||
store={mockStore(storeMocks.viewOtherProfile)}
|
||||
store={mockStore({
|
||||
...storeMocks.viewOtherProfile,
|
||||
profilePage: {
|
||||
...storeMocks.viewOtherProfile.profilePage,
|
||||
account: {
|
||||
...storeMocks.viewOtherProfile.profilePage.account,
|
||||
name: 'user',
|
||||
country: 'EN',
|
||||
bio: 'bio',
|
||||
courseCertificates: ['course certificates'],
|
||||
levelOfEducation: 'some level',
|
||||
languageProficiencies: ['some lang'],
|
||||
socialLinks: ['twitter'],
|
||||
timeZone: 'time zone',
|
||||
accountPrivacy: 'all_users',
|
||||
},
|
||||
},
|
||||
})}
|
||||
match={{ params: { username: 'verified' } }} // Override default match
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ exports[`<ProfilePage /> Renders correctly in various states app loading 1`] = `
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div>
|
||||
<div
|
||||
@@ -36,7 +36,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -104,7 +104,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -113,7 +113,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -191,7 +191,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -1694,7 +1694,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
|
||||
</svg>
|
||||
</span>
|
||||
<select
|
||||
className="d-inline-block w-auto form-control"
|
||||
className="d-inline-block form-control"
|
||||
id="visibilityCountry"
|
||||
name="visibilityCountry"
|
||||
onChange={[Function]}
|
||||
@@ -2305,7 +2305,7 @@ exports[`<ProfilePage /> Renders correctly in various states test country edit w
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
@@ -2417,7 +2417,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -2485,7 +2485,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -2494,7 +2494,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -2572,7 +2572,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -2995,7 +2995,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
No formal education
|
||||
</option>
|
||||
<option
|
||||
value="o"
|
||||
value="other"
|
||||
>
|
||||
Other education
|
||||
</option>
|
||||
@@ -3049,7 +3049,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
</svg>
|
||||
</span>
|
||||
<select
|
||||
className="d-inline-block w-auto form-control"
|
||||
className="d-inline-block form-control"
|
||||
id="visibilityLevelOfEducation"
|
||||
name="visibilityLevelOfEducation"
|
||||
onChange={[Function]}
|
||||
@@ -3480,7 +3480,7 @@ exports[`<ProfilePage /> Renders correctly in various states test education edit
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
@@ -3592,7 +3592,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -3660,7 +3660,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -3669,7 +3669,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -3747,7 +3747,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -5009,7 +5009,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
</svg>
|
||||
</span>
|
||||
<select
|
||||
className="d-inline-block w-auto form-control"
|
||||
className="d-inline-block form-control"
|
||||
id="visibilityLanguageProficiencies"
|
||||
name="visibilityLanguageProficiencies"
|
||||
onChange={[Function]}
|
||||
@@ -5530,7 +5530,7 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
@@ -5637,12 +5637,12 @@ exports[`<ProfilePage /> Renders correctly in various states test preferreded la
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`<ProfilePage /> Renders correctly in various states viewing other profile 1`] = `
|
||||
exports[`<ProfilePage /> Renders correctly in various states viewing other profile with all fields 1`] = `
|
||||
<div
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -5687,7 +5687,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -5696,7 +5696,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
verified
|
||||
</h1>
|
||||
@@ -5757,7 +5757,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
verified
|
||||
</h1>
|
||||
@@ -5810,7 +5810,32 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
"height": null,
|
||||
}
|
||||
}
|
||||
/>
|
||||
>
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": ".1px 0",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
className="editable-item-header mb-2"
|
||||
>
|
||||
<h2
|
||||
className="edit-section-header"
|
||||
id={null}
|
||||
>
|
||||
Full Name
|
||||
</h2>
|
||||
</div>
|
||||
<p
|
||||
className="h5"
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
user
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pgn-transition-replace-group position-relative mb-5"
|
||||
style={
|
||||
@@ -5818,7 +5843,30 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
"height": null,
|
||||
}
|
||||
}
|
||||
/>
|
||||
>
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": ".1px 0",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
className="editable-item-header mb-2"
|
||||
>
|
||||
<h2
|
||||
className="edit-section-header"
|
||||
id={null}
|
||||
>
|
||||
Location
|
||||
</h2>
|
||||
</div>
|
||||
<p
|
||||
className="h5"
|
||||
data-hj-suppress={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pgn-transition-replace-group position-relative mb-5"
|
||||
style={
|
||||
@@ -5826,7 +5874,30 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
"height": null,
|
||||
}
|
||||
}
|
||||
/>
|
||||
>
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": ".1px 0",
|
||||
}
|
||||
}
|
||||
>
|
||||
<div
|
||||
className="editable-item-header mb-2"
|
||||
>
|
||||
<h2
|
||||
className="edit-section-header"
|
||||
id={null}
|
||||
>
|
||||
Primary Language Spoken
|
||||
</h2>
|
||||
</div>
|
||||
<p
|
||||
className="h5"
|
||||
data-hj-suppress={true}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pgn-transition-replace-group position-relative mb-5"
|
||||
style={
|
||||
@@ -5834,15 +5905,32 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
"height": null,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<div
|
||||
className="pgn-transition-replace-group position-relative mb-5"
|
||||
style={
|
||||
Object {
|
||||
"height": null,
|
||||
>
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": ".1px 0",
|
||||
}
|
||||
}
|
||||
}
|
||||
/>
|
||||
>
|
||||
<div
|
||||
className="editable-item-header mb-2"
|
||||
>
|
||||
<h2
|
||||
className="edit-section-header"
|
||||
id={null}
|
||||
>
|
||||
Education
|
||||
</h2>
|
||||
</div>
|
||||
<p
|
||||
className="h5"
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
Other education
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="pt-md-3 col-md-8 col-lg-7 offset-lg-1"
|
||||
@@ -5854,15 +5942,32 @@ exports[`<ProfilePage /> Renders correctly in various states viewing other profi
|
||||
"height": null,
|
||||
}
|
||||
}
|
||||
/>
|
||||
<div
|
||||
className="pgn-transition-replace-group position-relative mb-4"
|
||||
style={
|
||||
Object {
|
||||
"height": null,
|
||||
>
|
||||
<div
|
||||
style={
|
||||
Object {
|
||||
"padding": ".1px 0",
|
||||
}
|
||||
}
|
||||
}
|
||||
/>
|
||||
>
|
||||
<div
|
||||
className="editable-item-header mb-2"
|
||||
>
|
||||
<h2
|
||||
className="edit-section-header"
|
||||
id={null}
|
||||
>
|
||||
About Me
|
||||
</h2>
|
||||
</div>
|
||||
<p
|
||||
className="lead"
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
bio
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5874,7 +5979,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing own profile
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -5942,7 +6047,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing own profile
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -5951,7 +6056,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing own profile
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -6029,7 +6134,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing own profile
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -6812,7 +6917,7 @@ exports[`<ProfilePage /> Renders correctly in various states viewing own profile
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
@@ -6924,7 +7029,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -6992,7 +7097,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -7001,7 +7106,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -7079,7 +7184,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -7767,7 +7872,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
</svg>
|
||||
</span>
|
||||
<select
|
||||
className="d-inline-block w-auto form-control"
|
||||
className="d-inline-block form-control"
|
||||
id="visibilityBio"
|
||||
name="visibilityBio"
|
||||
onChange={[Function]}
|
||||
@@ -7929,7 +8034,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
@@ -8041,7 +8146,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -8109,7 +8214,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -8118,7 +8223,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -8196,7 +8301,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -8890,7 +8995,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
</svg>
|
||||
</span>
|
||||
<select
|
||||
className="d-inline-block w-auto form-control"
|
||||
className="d-inline-block form-control"
|
||||
id="visibilityBio"
|
||||
name="visibilityBio"
|
||||
onChange={[Function]}
|
||||
@@ -9052,7 +9157,7 @@ exports[`<ProfilePage /> Renders correctly in various states while saving an edi
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
@@ -9164,7 +9269,7 @@ exports[`<ProfilePage /> Renders correctly in various states without credentials
|
||||
className="profile-page"
|
||||
>
|
||||
<div
|
||||
className="profile-page-bg-banner bg-primary d-none d-md-block p-relative"
|
||||
className="profile-page-bg-banner bg-primary d-md-block p-relative"
|
||||
/>
|
||||
<div
|
||||
className="container-fluid"
|
||||
@@ -9232,7 +9337,7 @@ exports[`<ProfilePage /> Renders correctly in various states without credentials
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="col pl-0"
|
||||
className="col"
|
||||
>
|
||||
<div
|
||||
className="d-md-none"
|
||||
@@ -9241,7 +9346,7 @@ exports[`<ProfilePage /> Renders correctly in various states without credentials
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -9274,7 +9379,7 @@ exports[`<ProfilePage /> Renders correctly in various states without credentials
|
||||
data-hj-suppress={true}
|
||||
>
|
||||
<h1
|
||||
className="h2 mb-0 font-weight-bold"
|
||||
className="h2 mb-0 font-weight-bold text-truncate"
|
||||
>
|
||||
staff
|
||||
</h1>
|
||||
@@ -10012,7 +10117,7 @@ exports[`<ProfilePage /> Renders correctly in various states without credentials
|
||||
className="row align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="col col-sm-6 d-flex align-items-stretch"
|
||||
className="col-12 col-sm-6 d-flex align-items-stretch"
|
||||
>
|
||||
<div
|
||||
className="card mb-4 certificate flex-grow-1"
|
||||
|
||||
@@ -7,7 +7,7 @@ const EDUCATION_LEVELS = [
|
||||
'jhs',
|
||||
'el',
|
||||
'none',
|
||||
'o',
|
||||
'other',
|
||||
];
|
||||
|
||||
const SOCIAL = {
|
||||
|
||||
@@ -66,6 +66,25 @@ export function* handleFetchProfile(action) {
|
||||
} else {
|
||||
[account, courseCertificates] = result;
|
||||
}
|
||||
|
||||
// Set initial visibility values for account
|
||||
// Set account_privacy as custom is necessary so that when viewing another user's profile,
|
||||
// their full name is displayed and change visibility forms are worked correctly
|
||||
if (isAuthenticatedUserProfile && result[0].accountPrivacy === 'all_users') {
|
||||
yield call(ProfileApiService.patchPreferences, action.payload.username, {
|
||||
account_privacy: 'custom',
|
||||
'visibility.name': 'all_users',
|
||||
'visibility.bio': 'all_users',
|
||||
'visibility.course_certificates': 'all_users',
|
||||
'visibility.country': 'all_users',
|
||||
'visibility.date_joined': 'all_users',
|
||||
'visibility.level_of_education': 'all_users',
|
||||
'visibility.language_proficiencies': 'all_users',
|
||||
'visibility.social_links': 'all_users',
|
||||
'visibility.time_zone': 'all_users',
|
||||
});
|
||||
}
|
||||
|
||||
yield put(fetchProfileSuccess(
|
||||
account,
|
||||
preferences,
|
||||
|
||||
@@ -35,9 +35,12 @@ export const editableFormModeSelector = createSelector(
|
||||
// or is being hidden from us (for other users' profiles)
|
||||
let propExists = account[formId] != null && account[formId].length > 0;
|
||||
propExists = formId === 'certificates' ? certificates.length > 0 : propExists; // overwrite for certificates
|
||||
// If this isn't the current user's profile or if
|
||||
// If this isn't the current user's profile
|
||||
if (!isAuthenticatedUserProfile) {
|
||||
return 'static';
|
||||
}
|
||||
// the current user has no age set / under 13 ...
|
||||
if (!isAuthenticatedUserProfile || account.requiresParentalConsent) {
|
||||
if (account.requiresParentalConsent) {
|
||||
// then there are only two options: static or nothing.
|
||||
// We use 'null' as a return value because the consumers of
|
||||
// getMode render nothing at all on a mode of null.
|
||||
@@ -228,13 +231,13 @@ export const visibilitiesSelector = createSelector(
|
||||
switch (accountPrivacy) {
|
||||
case 'custom':
|
||||
return {
|
||||
visibilityBio: preferences.visibilityBio || 'private',
|
||||
visibilityCourseCertificates: preferences.visibilityCourseCertificates || 'private',
|
||||
visibilityCountry: preferences.visibilityCountry || 'private',
|
||||
visibilityLevelOfEducation: preferences.visibilityLevelOfEducation || 'private',
|
||||
visibilityLanguageProficiencies: preferences.visibilityLanguageProficiencies || 'private',
|
||||
visibilityName: preferences.visibilityName || 'private',
|
||||
visibilitySocialLinks: preferences.visibilitySocialLinks || 'private',
|
||||
visibilityBio: preferences.visibilityBio || 'all_users',
|
||||
visibilityCourseCertificates: preferences.visibilityCourseCertificates || 'all_users',
|
||||
visibilityCountry: preferences.visibilityCountry || 'all_users',
|
||||
visibilityLevelOfEducation: preferences.visibilityLevelOfEducation || 'all_users',
|
||||
visibilityLanguageProficiencies: preferences.visibilityLanguageProficiencies || 'all_users',
|
||||
visibilityName: preferences.visibilityName || 'all_users',
|
||||
visibilitySocialLinks: preferences.visibilitySocialLinks || 'all_users',
|
||||
};
|
||||
case 'private':
|
||||
return {
|
||||
|
||||
@@ -68,7 +68,7 @@ class Certificates extends React.Component {
|
||||
})();
|
||||
|
||||
return (
|
||||
<div key={`${modifiedDate}-${courseId}`} className="col col-sm-6 d-flex align-items-stretch">
|
||||
<div key={`${modifiedDate}-${courseId}`} className="col-12 col-sm-6 d-flex align-items-stretch">
|
||||
<div className="card mb-4 certificate flex-grow-1">
|
||||
<div
|
||||
className="certificate-type-illustration"
|
||||
|
||||
@@ -119,7 +119,7 @@ exports[`<SocialLinks /> calls social links with edit mode bio 1`] = `
|
||||
</svg>
|
||||
</span>
|
||||
<select
|
||||
className="d-inline-block w-auto form-control"
|
||||
className="d-inline-block form-control"
|
||||
id="visibilitySocialLinks"
|
||||
name="visibilitySocialLinks"
|
||||
onChange={[Function]}
|
||||
|
||||
@@ -39,7 +39,7 @@ const VisibilitySelect = ({ intl, className, ...props }) => {
|
||||
<span className="d-inline-block ml-1 mr-2" style={{ width: '1.5rem' }}>
|
||||
<FontAwesomeIcon icon={icon} />
|
||||
</span>
|
||||
<select className="d-inline-block w-auto form-control" {...props}>
|
||||
<select className="d-inline-block form-control" {...props}>
|
||||
<option key="private" value="private">
|
||||
{intl.formatMessage(messages['profile.visibility.who.just.me'])}
|
||||
</option>
|
||||
|
||||
@@ -1,18 +1,13 @@
|
||||
import React from 'react';
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import {
|
||||
AuthenticatedPageRoute,
|
||||
PageRoute,
|
||||
} from '@edx/frontend-platform/react';
|
||||
import { Switch } from 'react-router-dom';
|
||||
import { ProfilePage, NotFoundPage } from '../profile';
|
||||
import { SkillsBuilder } from '../skills-builder';
|
||||
|
||||
const AppRoutes = () => (
|
||||
<Switch>
|
||||
{getConfig().ENABLE_SKILLS_BUILDER && (
|
||||
<PageRoute path="/skills" component={SkillsBuilder} />
|
||||
)}
|
||||
<AuthenticatedPageRoute path="/u/:username" component={ProfilePage} />
|
||||
<PageRoute path="/notfound" component={NotFoundPage} />
|
||||
<PageRoute path="*" component={NotFoundPage} />
|
||||
|
||||
@@ -13,21 +13,11 @@ jest.mock('@edx/frontend-platform/auth', () => ({
|
||||
getLoginRedirectUrl: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('@edx/frontend-platform', () => ({
|
||||
getConfig: jest.fn(() => ({
|
||||
ENABLE_SKILLS_BUILDER: true,
|
||||
})),
|
||||
}));
|
||||
|
||||
jest.mock('../profile', () => ({
|
||||
ProfilePage: () => (<div>Profile page</div>),
|
||||
NotFoundPage: () => (<div>Not found page</div>),
|
||||
}));
|
||||
|
||||
jest.mock('../skills-builder', () => ({
|
||||
SkillsBuilder: () => (<div>Skills Builder</div>),
|
||||
}));
|
||||
|
||||
const RoutesWithProvider = (context, history) => (
|
||||
<AppContext.Provider value={context}>
|
||||
<Router history={history}>
|
||||
@@ -73,14 +63,6 @@ describe('routes', () => {
|
||||
expect(screen.getByText('Profile page')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('Skills Builder page should be accessible to unauthenticated users', () => {
|
||||
history.push('/skills');
|
||||
render(
|
||||
RoutesWithProvider(unauthenticatedUser, history),
|
||||
);
|
||||
expect(screen.getByText('Skills Builder')).toBeTruthy();
|
||||
});
|
||||
|
||||
test('should show NotFound page for a bad route', () => {
|
||||
history.push('/nonMatchingRoute');
|
||||
render(
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
import React from 'react';
|
||||
import { SkillsBuilderModal } from './skills-builder-modal';
|
||||
import { SkillsBuilderProvider } from './skills-builder-context';
|
||||
|
||||
const SkillsBuilder = () => (
|
||||
<SkillsBuilderProvider>
|
||||
<SkillsBuilderModal />
|
||||
</SkillsBuilderProvider>
|
||||
);
|
||||
|
||||
export default SkillsBuilder;
|
||||
@@ -1,26 +0,0 @@
|
||||
import {
|
||||
SET_GOAL,
|
||||
SET_CURRENT_JOB_TITLE,
|
||||
ADD_CAREER_INTEREST,
|
||||
REMOVE_CAREER_INTEREST,
|
||||
} from './constants';
|
||||
|
||||
export const setGoal = (payload) => ({
|
||||
type: SET_GOAL,
|
||||
payload,
|
||||
});
|
||||
|
||||
export const setCurrentJobTitle = (payload) => ({
|
||||
type: SET_CURRENT_JOB_TITLE,
|
||||
payload,
|
||||
});
|
||||
|
||||
export const addCareerInterest = (payload) => ({
|
||||
type: ADD_CAREER_INTEREST,
|
||||
payload,
|
||||
});
|
||||
|
||||
export const removeCareerInterest = (payload) => ({
|
||||
type: REMOVE_CAREER_INTEREST,
|
||||
payload,
|
||||
});
|
||||
@@ -1,9 +0,0 @@
|
||||
// Actions for Skills Context
|
||||
export const SET_GOAL = 'SET_GOAL';
|
||||
export const SET_CURRENT_JOB_TITLE = 'SET_CURRENT_JOB_TITLE';
|
||||
export const ADD_CAREER_INTEREST = 'ADD_CAREER_INTEREST';
|
||||
export const REMOVE_CAREER_INTEREST = 'REMOVE_CAREER_INTEREST';
|
||||
|
||||
// Stepper keys
|
||||
export const STEP1 = 'select-your-preferences';
|
||||
export const STEP2 = 'review-your-results';
|
||||
@@ -1,41 +0,0 @@
|
||||
import {
|
||||
SET_GOAL,
|
||||
SET_CURRENT_JOB_TITLE,
|
||||
ADD_CAREER_INTEREST,
|
||||
REMOVE_CAREER_INTEREST,
|
||||
} from './constants';
|
||||
|
||||
export function skillsReducer(state, action) {
|
||||
switch (action.type) {
|
||||
case SET_GOAL:
|
||||
return {
|
||||
...state,
|
||||
currentGoal: action.payload,
|
||||
};
|
||||
case SET_CURRENT_JOB_TITLE:
|
||||
return {
|
||||
...state,
|
||||
currentJobTitle: action.payload,
|
||||
};
|
||||
case ADD_CAREER_INTEREST:
|
||||
return {
|
||||
...state,
|
||||
careerInterests: [...state.careerInterests, action.payload],
|
||||
};
|
||||
case REMOVE_CAREER_INTEREST:
|
||||
return {
|
||||
...state,
|
||||
careerInterests: state.careerInterests.filter(interest => interest !== action.payload),
|
||||
};
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
}
|
||||
|
||||
export const skillsInitialState = {
|
||||
currentGoal: '',
|
||||
currentJobTitle: '',
|
||||
careerInterests: [],
|
||||
};
|
||||
|
||||
export default skillsReducer;
|
||||
@@ -1,60 +0,0 @@
|
||||
import { skillsReducer, skillsInitialState } from '../reducer';
|
||||
import {
|
||||
SET_GOAL,
|
||||
SET_CURRENT_JOB_TITLE,
|
||||
ADD_CAREER_INTEREST,
|
||||
REMOVE_CAREER_INTEREST,
|
||||
} from '../constants';
|
||||
|
||||
describe('skillsReducer', () => {
|
||||
const testState = skillsInitialState;
|
||||
beforeEach(() => jest.resetModules());
|
||||
|
||||
it('does not remove present data when SET_GOAL action is dispatched', () => {
|
||||
const newGoalPayload = 'test-goal';
|
||||
const returnedState = skillsReducer(testState, { type: SET_GOAL, payload: newGoalPayload });
|
||||
const finalState = {
|
||||
...testState,
|
||||
currentGoal: 'test-goal',
|
||||
};
|
||||
expect(returnedState).toEqual(finalState);
|
||||
});
|
||||
|
||||
it('does not remove present data when SET_JOB_TITLE action is dispatched', () => {
|
||||
const newJobTitlePayload = 'test-job-title';
|
||||
const returnedState = skillsReducer(testState, { type: SET_CURRENT_JOB_TITLE, payload: newJobTitlePayload });
|
||||
const finalState = {
|
||||
...testState,
|
||||
currentJobTitle: 'test-job-title',
|
||||
};
|
||||
expect(returnedState).toEqual(finalState);
|
||||
});
|
||||
|
||||
it('adds a careerInterest when ADD_CAREER_INTEREST action is dispatched', () => {
|
||||
const newCareerInterestPayload = 'test-career-interest';
|
||||
const returnedState = skillsReducer(testState, { type: ADD_CAREER_INTEREST, payload: newCareerInterestPayload });
|
||||
const finalState = {
|
||||
...testState,
|
||||
careerInterests: [...testState.careerInterests, 'test-career-interest'],
|
||||
};
|
||||
expect(returnedState).toEqual(finalState);
|
||||
});
|
||||
|
||||
it('removes a careerInterest when REMOVE_CAREER_INTEREST action is dispatched', () => {
|
||||
const newCareerInterestPayload = 'test-career-interest';
|
||||
const testStateWithInterest = {
|
||||
...testState,
|
||||
careerInterests: [newCareerInterestPayload],
|
||||
};
|
||||
const returnedState = skillsReducer(
|
||||
testStateWithInterest,
|
||||
{ type: REMOVE_CAREER_INTEREST, payload: newCareerInterestPayload },
|
||||
);
|
||||
const finalState = {
|
||||
...testStateWithInterest,
|
||||
// override the 'careerInterests` field and remove 'test-career-interest' from the array
|
||||
careerInterests: testStateWithInterest.careerInterests.filter(interest => interest !== newCareerInterestPayload),
|
||||
};
|
||||
expect(returnedState).toEqual(finalState);
|
||||
});
|
||||
});
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
@@ -1,3 +0,0 @@
|
||||
<svg width="148" height="83" viewBox="0 0 148 83" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M97.6992 0L94.8413 14.525H148L133.537 83H66.3135L70.1777 64.325H0L13.7661 0H97.6992ZM45.3759 37.6596C45.419 37.1851 45.4513 36.7212 45.4729 36.2654C45.4944 35.8123 45.5052 35.4154 45.5025 35.0776C45.5025 32.8602 45.1523 30.8949 44.452 29.1842C43.7517 27.4736 42.8063 26.0311 41.6184 24.8594C40.4306 23.685 39.0461 22.7948 37.465 22.1808C35.8812 21.5668 34.2112 21.2611 32.4496 21.2611C29.8396 21.2611 27.4343 21.7679 25.2391 22.7814C23.0412 23.7949 21.1584 25.2267 19.588 27.0741C18.0177 28.9241 16.7922 31.1415 15.9114 33.7289C15.0306 36.3163 14.5915 39.1853 14.5915 42.333C14.5915 44.6362 14.9579 46.674 15.6905 48.449C16.4231 50.2239 17.4198 51.7174 18.683 52.932C19.9463 54.1466 21.4277 55.0663 23.1246 55.6883C24.8216 56.313 26.6262 56.6241 28.5359 56.6241C30.5319 56.6241 32.3608 56.3854 34.0281 55.9109C35.6927 55.4363 37.1579 54.7794 38.4212 53.9455C39.6845 53.1116 40.7296 52.1223 41.5565 50.9827C42.3834 49.8432 42.9787 48.6179 43.3396 47.3067H37.5135C36.7916 48.6393 35.7411 49.6957 34.3621 50.476C32.983 51.2562 31.1568 51.6477 28.8861 51.6477C27.8464 51.6477 26.8175 51.4734 25.7993 51.1248C24.7812 50.7763 23.8627 50.2132 23.0465 49.4303C22.2277 48.6474 21.5651 47.6392 21.056 46.4032C20.5469 45.1671 20.2911 43.6737 20.2911 41.9201C20.2911 41.6252 20.2964 41.341 20.3072 41.0648C20.318 40.7913 20.3342 40.5071 20.3557 40.2095H45.0904C45.155 39.8931 45.2062 39.507 45.2493 39.0539C45.2762 38.7515 45.3044 38.4432 45.333 38.1306L45.3759 37.6596ZM37.8017 28.5488C37.1445 27.7873 36.3256 27.1867 35.3506 26.7416C34.3728 26.2992 33.2388 26.0767 31.9433 26.0767C30.6261 26.0767 29.3952 26.3099 28.2504 26.7738C27.103 27.2376 26.0633 27.8999 25.1313 28.7552C24.1967 29.6105 23.3913 30.6348 22.7125 31.8279C22.0338 33.0211 21.4924 34.3483 21.0883 35.8042H39.7114C39.7329 35.6997 39.7491 35.5039 39.7599 35.217C39.7706 34.9328 39.776 34.6513 39.776 34.3778C39.776 33.257 39.6117 32.1953 39.2831 31.1925C38.9518 30.1924 38.4589 29.3102 37.8017 28.5488ZM71.4707 56.0235L72.4565 51.3661H71.9475C70.695 52.9937 69.1246 54.2753 67.2365 55.2164C65.3483 56.1549 63.3093 56.6268 61.1249 56.6268C59.4064 56.6268 57.793 56.305 56.2846 55.6588C54.7762 55.0153 53.4564 54.0903 52.3224 52.8864C51.1857 51.6825 50.2888 50.2239 49.6316 48.5133C48.9743 46.8027 48.6457 44.8909 48.6457 42.7781C48.6457 40.7297 48.8531 38.7697 49.2652 36.9008C49.68 35.032 50.2672 33.2999 51.0322 31.7046C51.7972 30.1092 52.713 28.6667 53.785 27.3797C54.857 26.0901 56.0449 24.9934 57.3512 24.0845C58.6576 23.1755 60.0663 22.4784 61.5854 21.9931C63.1019 21.5078 64.6884 21.2638 66.3449 21.2638C67.5759 21.2638 68.7475 21.4327 69.8627 21.7706C70.9778 22.1084 71.9852 22.5776 72.8875 23.1809C73.7898 23.7842 74.5629 24.5108 75.212 25.3661C75.8585 26.2214 76.3325 27.1572 76.6288 28.1707H77.1379L81.3721 8.3H86.9423L76.7554 56.0261H71.4707V56.0235ZM70.3556 26.8381C71.4169 27.2805 72.3192 27.9106 73.0626 28.723C73.806 29.5381 74.3771 30.5248 74.7784 31.6831C75.1824 32.8468 75.3844 34.1552 75.3844 35.6138C75.3844 37.8741 75.0639 39.9816 74.4282 41.9362C73.7926 43.8908 72.9118 45.5907 71.7859 47.0386C70.6627 48.4838 69.3402 49.626 67.8237 50.4599C66.3046 51.2964 64.6561 51.712 62.873 51.712C61.6016 51.712 60.4434 51.4734 59.4037 50.9988C58.364 50.5216 57.4725 49.8566 56.7291 49.0013C55.9856 48.146 55.4092 47.1164 54.9944 45.9125C54.5796 44.7086 54.3722 43.3894 54.3722 41.9523C54.3722 39.6491 54.6927 37.5309 55.3284 35.5978C55.9641 33.6673 56.8341 32.0022 57.9384 30.608C59.0428 29.2137 60.3465 28.1278 61.8548 27.3449C63.3605 26.5646 64.9955 26.1732 66.7571 26.1732C68.0957 26.1732 69.2944 26.393 70.3556 26.8381ZM126.409 74.7H114.031L105.938 57.0191H104.927L89.9496 74.7H77.6479L100.989 47.1736L90.1767 22.825H102.789L109.982 39.5884H110.652L124.254 22.825H136.724L114.442 48.3925L126.409 74.7Z" fill="white"/>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB |
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { default as SkillsBuilder } from './SkillsBuilder';
|
||||
@@ -1,32 +0,0 @@
|
||||
import React, { createContext, useReducer, useMemo } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import reducer, { skillsInitialState } from '../data/reducer';
|
||||
import { useAlgoliaSearch } from '../utils/search';
|
||||
|
||||
export const SkillsBuilderContext = createContext();
|
||||
|
||||
export const SkillsBuilderProvider = ({ children }) => {
|
||||
const [state, dispatch] = useReducer(reducer, skillsInitialState);
|
||||
|
||||
const [searchClient, productSearchIndex, jobSearchIndex] = useAlgoliaSearch();
|
||||
|
||||
const value = useMemo(() => ({
|
||||
state,
|
||||
dispatch,
|
||||
algolia: {
|
||||
searchClient,
|
||||
productSearchIndex,
|
||||
jobSearchIndex,
|
||||
},
|
||||
}), [state, searchClient, productSearchIndex, jobSearchIndex]);
|
||||
|
||||
return (
|
||||
<SkillsBuilderContext.Provider value={value}>
|
||||
{children}
|
||||
</SkillsBuilderContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
SkillsBuilderProvider.propTypes = {
|
||||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
|
||||
};
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { SkillsBuilderProvider, SkillsBuilderContext } from './SkillsBuilderProvider';
|
||||
@@ -1,25 +0,0 @@
|
||||
import React from 'react';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import edXLogo from '../images/edX-logo.svg';
|
||||
import messages from './messages';
|
||||
|
||||
const SkillsBuilderHeader = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
|
||||
return (
|
||||
<div className="d-flex">
|
||||
<img src={edXLogo} alt="edx-logo" className="mt-2 h-50" />
|
||||
<div className="ml-5 vertical-line" />
|
||||
<div className="w-100 ml-5">
|
||||
<h1 className="h1 text-warning-300">
|
||||
{formatMessage(messages.skillsBuilderHeaderTitle)}
|
||||
</h1>
|
||||
<p className="h2 text-white">
|
||||
{formatMessage(messages.skillsBuilderHeaderSubheading)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SkillsBuilderHeader;
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { default as SkillsBuilderHeader } from './SkillsBuilderHeader';
|
||||
@@ -1,16 +0,0 @@
|
||||
import { defineMessages } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const messages = defineMessages({
|
||||
skillsBuilderHeaderTitle: {
|
||||
id: 'skills.builder.header.title',
|
||||
defaultMessage: 'Skills Builder',
|
||||
description: 'Title for the Skills Builder feature',
|
||||
},
|
||||
skillsBuilderHeaderSubheading: {
|
||||
id: 'skills.builder.header.subheading',
|
||||
defaultMessage: 'Let edX be your guide',
|
||||
description: 'Subheading to the Skills Builder title in the header component',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
@@ -1,4 +0,0 @@
|
||||
.vertical-line {
|
||||
border-left: 7px solid #D23228;
|
||||
transform: rotate(13deg);
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
import React, { useState, useContext } from 'react';
|
||||
import {
|
||||
Button, Container, Stepper, ModalDialog,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { useHistory } from 'react-router';
|
||||
import {
|
||||
STEP1, STEP2,
|
||||
} from '../data/constants';
|
||||
import messages from './messages';
|
||||
|
||||
import { SkillsBuilderContext } from '../skills-builder-context';
|
||||
import { SkillsBuilderHeader } from '../skills-builder-header';
|
||||
import { SelectPreferences } from './select-preferences';
|
||||
import ViewResults from './view-results/ViewResults';
|
||||
|
||||
import headerImage from '../images/headerImage.png';
|
||||
|
||||
const SkillsBuilderModal = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { state } = useContext(SkillsBuilderContext);
|
||||
const { careerInterests } = state;
|
||||
const [currentStep, setCurrentStep] = useState(STEP1);
|
||||
|
||||
const history = useHistory();
|
||||
|
||||
const onCloseHandle = () => {
|
||||
history.goBack();
|
||||
};
|
||||
|
||||
return (
|
||||
<Stepper activeKey={currentStep}>
|
||||
<ModalDialog
|
||||
title="Skills Builder"
|
||||
size="fullscreen"
|
||||
className="skills-builder-modal bg-light-200"
|
||||
isOpen
|
||||
onClose={onCloseHandle}
|
||||
>
|
||||
<ModalDialog.Hero>
|
||||
<ModalDialog.Hero.Background className="bg-primary-500">
|
||||
<img src={headerImage} alt="" className="h-100" />
|
||||
</ModalDialog.Hero.Background>
|
||||
<ModalDialog.Hero.Content>
|
||||
<SkillsBuilderHeader />
|
||||
</ModalDialog.Hero.Content>
|
||||
</ModalDialog.Hero>
|
||||
|
||||
<Stepper.Header />
|
||||
|
||||
<ModalDialog.Body>
|
||||
<Container size="md" className="p-4.5">
|
||||
<Stepper.Step eventKey={STEP1} title={formatMessage(messages.selectPreferences)}>
|
||||
<SelectPreferences />
|
||||
</Stepper.Step>
|
||||
|
||||
<Stepper.Step eventKey={STEP2} title={formatMessage(messages.reviewResults)}>
|
||||
<ViewResults />
|
||||
</Stepper.Step>
|
||||
</Container>
|
||||
</ModalDialog.Body>
|
||||
|
||||
<ModalDialog.Footer>
|
||||
<Stepper.ActionRow eventKey={STEP1}>
|
||||
<Button variant="outline-primary" onClick={onCloseHandle}>
|
||||
{formatMessage(messages.goBackButton)}
|
||||
</Button>
|
||||
<Stepper.ActionRow.Spacer />
|
||||
<Button
|
||||
onClick={() => setCurrentStep(STEP2)}
|
||||
disabled={careerInterests.length === 0}
|
||||
>
|
||||
{formatMessage(messages.nextStepButton)}
|
||||
</Button>
|
||||
</Stepper.ActionRow>
|
||||
<Stepper.ActionRow eventKey={STEP2}>
|
||||
<Button
|
||||
variant="outline-primary"
|
||||
onClick={() => setCurrentStep(STEP1)}
|
||||
>
|
||||
{formatMessage(messages.goBackButton)}
|
||||
</Button>
|
||||
<Stepper.ActionRow.Spacer />
|
||||
<Button onClick={onCloseHandle}>
|
||||
{formatMessage(messages.exitButton)}
|
||||
</Button>
|
||||
</Stepper.ActionRow>
|
||||
</ModalDialog.Footer>
|
||||
</ModalDialog>
|
||||
</Stepper>
|
||||
);
|
||||
};
|
||||
|
||||
export default SkillsBuilderModal;
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { default as SkillsBuilderModal } from './SkillsBuilderModal';
|
||||
@@ -1,32 +0,0 @@
|
||||
import { defineMessages } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const messages = defineMessages({
|
||||
/* Modal Action Row Buttons */
|
||||
goBackButton: {
|
||||
id: 'go.back.button',
|
||||
defaultMessage: 'Go Back',
|
||||
description: 'Button that sends the user to the previous step in the skills builder.',
|
||||
},
|
||||
nextStepButton: {
|
||||
id: 'next.step.button',
|
||||
defaultMessage: 'Next Step',
|
||||
description: 'Button that sends the user to the next step in the skills builder.',
|
||||
},
|
||||
exitButton: {
|
||||
id: 'exit.button',
|
||||
defaultMessage: 'Exit',
|
||||
description: 'Button that exits the Skills Builder.',
|
||||
},
|
||||
selectPreferences: {
|
||||
id: 'select.preferences',
|
||||
defaultMessage: 'Select preferences',
|
||||
description: 'The first step of the Skills Builder for selecting a goal, a current job/occupation, and career interests',
|
||||
},
|
||||
reviewResults: {
|
||||
id: 'review.results',
|
||||
defaultMessage: 'Review results',
|
||||
description: 'The second step of the Skills Builder for rendering results from learner input',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
@@ -1,35 +0,0 @@
|
||||
import React, { useContext } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
IconButton, Icon,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { Close } from '@edx/paragon/icons';
|
||||
import { SkillsBuilderContext } from '../../skills-builder-context';
|
||||
import { removeCareerInterest } from '../../data/actions';
|
||||
import messages from './messages';
|
||||
|
||||
const CareerInterestCard = ({ interest }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { dispatch } = useContext(SkillsBuilderContext);
|
||||
|
||||
return (
|
||||
<div className="d-flex justify-content-between align-items-center pb-2 pr-2 pl-4 rounded shadow-sm">
|
||||
<p className="pt-4">
|
||||
{interest}
|
||||
</p>
|
||||
<IconButton
|
||||
iconAs={Icon}
|
||||
src={Close}
|
||||
alt={`${formatMessage(messages.removeCareerInterestButtonAltText)} ${interest}`}
|
||||
onClick={() => dispatch(removeCareerInterest(interest))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
CareerInterestCard.propTypes = {
|
||||
interest: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default CareerInterestCard;
|
||||
@@ -1,51 +0,0 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import {
|
||||
Stack, Row, Col, Form,
|
||||
} from '@edx/paragon';
|
||||
import { InstantSearch } from 'react-instantsearch-hooks-web';
|
||||
import JobTitleInstantSearch from './JobTitleInstantSearch';
|
||||
import CareerInterestCard from './CareerInterestCard';
|
||||
import { addCareerInterest } from '../../data/actions';
|
||||
import { SkillsBuilderContext } from '../../skills-builder-context';
|
||||
import messages from './messages';
|
||||
|
||||
const CareerInterestSelect = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { state, dispatch, algolia } = useContext(SkillsBuilderContext);
|
||||
const { careerInterests } = state;
|
||||
const { searchClient } = algolia;
|
||||
|
||||
const handleCareerInterestSelect = (value) => {
|
||||
if (!careerInterests.includes(value) && careerInterests.length < 3) {
|
||||
dispatch(addCareerInterest(value));
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Stack gap={2}>
|
||||
<Form.Label>
|
||||
<h4 className="mb-3">
|
||||
{formatMessage(messages.careerInterestPrompt)}
|
||||
</h4>
|
||||
<InstantSearch searchClient={searchClient} indexName={getConfig().ALGOLIA_JOBS_INDEX_NAME}>
|
||||
<JobTitleInstantSearch
|
||||
onSelected={handleCareerInterestSelect}
|
||||
placeholder={formatMessage(messages.careerInterestInputPlaceholderText)}
|
||||
/>
|
||||
</InstantSearch>
|
||||
</Form.Label>
|
||||
<Row>
|
||||
{careerInterests.map((interest, index) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<Col key={index} xs={12} sm={4} className="mb-4">
|
||||
<CareerInterestCard interest={interest} />
|
||||
</Col>
|
||||
))}
|
||||
</Row>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default CareerInterestSelect;
|
||||
@@ -1,39 +0,0 @@
|
||||
import React, { useContext } from 'react';
|
||||
import {
|
||||
Form,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { setGoal } from '../../data/actions';
|
||||
import { SkillsBuilderContext } from '../../skills-builder-context';
|
||||
import messages from './messages';
|
||||
|
||||
const GoalDropdown = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { state, dispatch } = useContext(SkillsBuilderContext);
|
||||
const { currentGoal } = state;
|
||||
|
||||
return (
|
||||
<Form.Group>
|
||||
<Form.Label>
|
||||
<h4>
|
||||
{formatMessage(messages.learningGoalPrompt)}
|
||||
</h4>
|
||||
</Form.Label>
|
||||
<Form.Control
|
||||
as="select"
|
||||
value={currentGoal}
|
||||
onChange={(e) => dispatch(setGoal(e.target.value))}
|
||||
data-testid="goal-select-dropdown"
|
||||
>
|
||||
<option value="">{formatMessage(messages.selectLearningGoal)}</option>
|
||||
<option>{formatMessage(messages.learningGoalStartCareer)}</option>
|
||||
<option>{formatMessage(messages.learningGoalAdvanceCareer)}</option>
|
||||
<option>{formatMessage(messages.learningGoalChangeCareer)}</option>
|
||||
<option>{formatMessage(messages.learningGoalSomethingNew)}</option>
|
||||
<option>{formatMessage(messages.learningGoalSomethingElse)}</option>
|
||||
</Form.Control>
|
||||
</Form.Group>
|
||||
);
|
||||
};
|
||||
|
||||
export default GoalDropdown;
|
||||
@@ -1,43 +0,0 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
Form,
|
||||
} from '@edx/paragon';
|
||||
import { useHits, useSearchBox } from 'react-instantsearch-hooks-web';
|
||||
|
||||
const JobTitleInstantSearch = (props) => {
|
||||
const { refine } = useSearchBox(props);
|
||||
const { hits } = useHits(props);
|
||||
|
||||
const [jobInput, setJobInput] = useState('');
|
||||
|
||||
const handleAutosuggestChange = (value) => {
|
||||
setJobInput(value);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
refine(jobInput);
|
||||
}, [jobInput, refine]);
|
||||
|
||||
return (
|
||||
<Form.Autosuggest
|
||||
value={jobInput}
|
||||
onChange={handleAutosuggestChange}
|
||||
name="job-title-suggest"
|
||||
autoComplete="off"
|
||||
{...props}
|
||||
>
|
||||
{hits.map(job => (
|
||||
<Form.AutosuggestOption key={job.id} id={job.name.replaceAll(' ', '-').toLowerCase()}>
|
||||
{job.name}
|
||||
</Form.AutosuggestOption>
|
||||
))}
|
||||
</Form.Autosuggest>
|
||||
);
|
||||
};
|
||||
|
||||
JobTitleInstantSearch.propTypes = {
|
||||
onSelected: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default JobTitleInstantSearch;
|
||||
@@ -1,56 +0,0 @@
|
||||
import React, { useContext } from 'react';
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import {
|
||||
Form, Stack,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { InstantSearch } from 'react-instantsearch-hooks-web';
|
||||
import { setCurrentJobTitle } from '../../data/actions';
|
||||
import { SkillsBuilderContext } from '../../skills-builder-context';
|
||||
import JobTitleInstantSearch from './JobTitleInstantSearch';
|
||||
import messages from './messages';
|
||||
|
||||
const JobTitleSelect = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { dispatch, algolia } = useContext(SkillsBuilderContext);
|
||||
const { searchClient } = algolia;
|
||||
|
||||
const handleCurrentJobTitleSelect = (value) => {
|
||||
dispatch(setCurrentJobTitle(value));
|
||||
};
|
||||
|
||||
// Below implementation sets the job title to "Student" or "Looking for work" — this overwrites any previous selection
|
||||
// This will need to be revisited when we decide what to do with this data
|
||||
const handleCheckboxChange = (e) => dispatch(setCurrentJobTitle(e.target.value));
|
||||
|
||||
return (
|
||||
<Stack>
|
||||
<Form.Label>
|
||||
<h4 className="mb-3">
|
||||
{formatMessage(messages.jobTitlePrompt)}
|
||||
</h4>
|
||||
<InstantSearch searchClient={searchClient} indexName={getConfig().ALGOLIA_JOBS_INDEX_NAME}>
|
||||
<JobTitleInstantSearch
|
||||
onSelected={handleCurrentJobTitleSelect}
|
||||
placeholder={formatMessage(messages.jobTitleInputPlaceholderText)}
|
||||
/>
|
||||
</InstantSearch>
|
||||
</Form.Label>
|
||||
<Form.Group>
|
||||
<Form.CheckboxSet
|
||||
name="other-occupations"
|
||||
onChange={handleCheckboxChange}
|
||||
>
|
||||
<Form.Checkbox value="Student">
|
||||
{formatMessage(messages.studentCheckboxPrompt)}
|
||||
</Form.Checkbox>
|
||||
<Form.Checkbox value="Looking for work">
|
||||
{formatMessage(messages.currentlyLookingCheckboxPrompt)}
|
||||
</Form.Checkbox>
|
||||
</Form.CheckboxSet>
|
||||
</Form.Group>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default JobTitleSelect;
|
||||
@@ -1,38 +0,0 @@
|
||||
import React, { useContext } from 'react';
|
||||
import {
|
||||
Stack,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { SkillsBuilderContext } from '../../skills-builder-context';
|
||||
import GoalSelect from './GoalSelect';
|
||||
import JobTitleSelect from './JobTitleSelect';
|
||||
import CareerInterestSelect from './CareerInterestSelect';
|
||||
import messages from './messages';
|
||||
|
||||
const SelectPreferences = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { state } = useContext(SkillsBuilderContext);
|
||||
const { currentGoal, currentJobTitle } = state;
|
||||
|
||||
return (
|
||||
<Stack gap={4}>
|
||||
<p className="lead">
|
||||
{formatMessage(messages.skillsBuilderDescription)}
|
||||
</p>
|
||||
<Stack gap={4}>
|
||||
|
||||
<GoalSelect />
|
||||
|
||||
{currentGoal && (
|
||||
<JobTitleSelect />
|
||||
)}
|
||||
|
||||
{currentJobTitle && (
|
||||
<CareerInterestSelect />
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
);
|
||||
};
|
||||
|
||||
export default SelectPreferences;
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { default as SelectPreferences } from './SelectPreferences';
|
||||
@@ -1,80 +0,0 @@
|
||||
import { defineMessages } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const messages = defineMessages({
|
||||
skillsBuilderDescription: {
|
||||
id: 'skills.builder.description',
|
||||
defaultMessage: 'Find the right courses and programs that help you reach your goals.',
|
||||
description: 'Description of what the Skills Builder seeks to accomplish',
|
||||
},
|
||||
learningGoalPrompt: {
|
||||
id: 'learning.goal.prompt',
|
||||
defaultMessage: 'First, tell us what you want to achieve',
|
||||
description: 'Prompts the user to select their current goal.',
|
||||
},
|
||||
selectLearningGoal: {
|
||||
id: 'select.learning.goal',
|
||||
defaultMessage: 'Select a goal',
|
||||
description: 'Placeholder text for the goal selection component.',
|
||||
},
|
||||
learningGoalStartCareer: {
|
||||
id: 'learning.goal.start_career',
|
||||
defaultMessage: 'I want to start my career',
|
||||
description: 'Selected by user if their goal is to start their career.',
|
||||
},
|
||||
learningGoalAdvanceCareer: {
|
||||
id: 'learning.goal.advance_career',
|
||||
defaultMessage: 'I want to advance my career',
|
||||
description: 'Selected by user if their goal is to advance their career.',
|
||||
},
|
||||
learningGoalChangeCareer: {
|
||||
id: 'learning.goal.change_career',
|
||||
defaultMessage: 'I want to change careers',
|
||||
description: 'Selected by user if their goal is to change careers.',
|
||||
},
|
||||
learningGoalSomethingNew: {
|
||||
id: 'learning.goal.something.new',
|
||||
defaultMessage: 'I want to learn something new',
|
||||
description: 'Selected by user if their goal is to learn something new.',
|
||||
},
|
||||
learningGoalSomethingElse: {
|
||||
id: 'learning.goal.something.else',
|
||||
defaultMessage: 'Something else',
|
||||
description: 'Selected by user if their goal is not described by the other choices.',
|
||||
},
|
||||
jobTitlePrompt: {
|
||||
id: 'job.title.prompt',
|
||||
defaultMessage: 'Next, search and select your current job title',
|
||||
description: 'Prompts the user to select their current job title or occupation.',
|
||||
},
|
||||
jobTitleInputPlaceholderText: {
|
||||
id: 'job.title.input.placeholder.text',
|
||||
defaultMessage: 'Search and select a job title',
|
||||
description: 'Placeholder text for the job title input control.',
|
||||
},
|
||||
studentCheckboxPrompt: {
|
||||
id: 'student.checkbox.prompt',
|
||||
defaultMessage: 'I\'m a student',
|
||||
description: 'Label text for the corresponding checkbox',
|
||||
},
|
||||
currentlyLookingCheckboxPrompt: {
|
||||
id: 'currently.looking.checkbox.prompt',
|
||||
defaultMessage: 'I\'m currently looking for work',
|
||||
description: 'Label text for the corresponding checkbox',
|
||||
},
|
||||
careerInterestPrompt: {
|
||||
id: 'career.interest.prompt',
|
||||
defaultMessage: 'What careers are you interested in?',
|
||||
description: 'Prompts the user to select careers they are interested in pursuing.',
|
||||
},
|
||||
careerInterestInputPlaceholderText: {
|
||||
id: 'career.interest.input.placeholder.text',
|
||||
defaultMessage: 'Select up to 3 new job titles',
|
||||
description: 'Placeholder text for the career interest input control.',
|
||||
},
|
||||
removeCareerInterestButtonAltText: {
|
||||
id: 'career.interest.remove.button.alt.text',
|
||||
defaultMessage: 'Remove career interest: ',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
@@ -1,109 +0,0 @@
|
||||
import {
|
||||
screen, render, cleanup, fireEvent,
|
||||
} from '@testing-library/react';
|
||||
import { mergeConfig } from '@edx/frontend-platform';
|
||||
import { SkillsBuilderWrapperWithContext, dispatchMock, contextValue } from '../../../test/setupSkillsBuilder';
|
||||
|
||||
describe('select-preferences', () => {
|
||||
beforeAll(() => {
|
||||
mergeConfig({
|
||||
ALGOLIA_JOBS_INDEX_NAME: 'test-job-index-name',
|
||||
});
|
||||
});
|
||||
beforeEach(() => cleanup());
|
||||
|
||||
describe('render behavior', () => {
|
||||
it('should render the second prompt if a goal is selected', () => {
|
||||
render(
|
||||
SkillsBuilderWrapperWithContext(
|
||||
{
|
||||
...contextValue,
|
||||
state: {
|
||||
...contextValue.state,
|
||||
currentGoal: 'I want to start my career',
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
const expectedGoal = {
|
||||
payload: 'I want to advance my career',
|
||||
type: 'SET_GOAL',
|
||||
};
|
||||
const expectedJobTitle = {
|
||||
payload: 'Student',
|
||||
type: 'SET_CURRENT_JOB_TITLE',
|
||||
};
|
||||
|
||||
const goalSelect = screen.getByTestId('goal-select-dropdown');
|
||||
fireEvent.change(goalSelect, { target: { value: 'I want to advance my career' } });
|
||||
|
||||
const checkbox = screen.getByRole('checkbox', { name: 'I\'m a student' });
|
||||
fireEvent.click(checkbox);
|
||||
|
||||
expect(screen.getByText('Next, search and select your current job title')).toBeTruthy();
|
||||
expect(dispatchMock).toHaveBeenCalledWith(expectedGoal);
|
||||
expect(dispatchMock).toHaveBeenCalledWith(expectedJobTitle);
|
||||
});
|
||||
|
||||
it('should render the third prompt if a current job title is selected', () => {
|
||||
render(
|
||||
SkillsBuilderWrapperWithContext(
|
||||
{
|
||||
...contextValue,
|
||||
state: {
|
||||
...contextValue.state,
|
||||
currentGoal: 'I want to start my career',
|
||||
currentJobTitle: 'Goblin Guide',
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
expect(screen.getByText('What careers are you interested in?')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should render a <CareerInterestCard> for each career interest', () => {
|
||||
render(
|
||||
SkillsBuilderWrapperWithContext(
|
||||
{
|
||||
...contextValue,
|
||||
state: {
|
||||
...contextValue.state,
|
||||
currentGoal: 'I want to start my career',
|
||||
currentJobTitle: 'Goblin Lackey',
|
||||
careerInterests: ['Prospector', 'Mirror Breaker', 'Bombardment'],
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
expect(screen.getByText('Prospector')).toBeTruthy();
|
||||
expect(screen.getByText('Mirror Breaker')).toBeTruthy();
|
||||
expect(screen.getByText('Bombardment')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('controlled behavior', () => {
|
||||
it('should remove a <CareerInterestCard> when the corresponding close button is selected', () => {
|
||||
render(
|
||||
SkillsBuilderWrapperWithContext(
|
||||
{
|
||||
...contextValue,
|
||||
state: {
|
||||
...contextValue.state,
|
||||
currentGoal: 'I want to start my career',
|
||||
currentJobTitle: 'Goblin Lackey',
|
||||
careerInterests: ['Prospector', 'Mirror Breaker', 'Bombardment'],
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
const expected = {
|
||||
payload: 'Prospector',
|
||||
type: 'REMOVE_CAREER_INTEREST',
|
||||
};
|
||||
|
||||
fireEvent.click(screen.getByLabelText('Remove career interest: Prospector'));
|
||||
expect(dispatchMock).toHaveBeenCalledWith(expected);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
.skills-builder-modal {
|
||||
button[aria-label="Close"][type="button"]{
|
||||
color: #ffffff;
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import React from 'react';
|
||||
import { CardCarousel } from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import RecommendationCard from './RecommendationCard';
|
||||
import messages from './messages';
|
||||
|
||||
const CarouselStack = ({ selectedRecommendations }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { name: jobName, recommendations } = selectedRecommendations;
|
||||
const productTypeNames = Object.keys(recommendations);
|
||||
|
||||
const normalizeProductTypeName = (productType) => {
|
||||
// If the productType is more than one word (i.e. boot_camp)
|
||||
if (productType.includes('_')) {
|
||||
// split to remove underscore and return an array of strings (i.e. ['boot', 'camp'])
|
||||
const splitStrings = productType.split('_');
|
||||
|
||||
// map through the array and normalize each string (i.e. ['Boot', 'Camp'])
|
||||
const normalizeStrings = splitStrings.map(word => word[0].toUpperCase() + word.slice(1).toLowerCase());
|
||||
|
||||
// return the array as a string joined by white spaces (i.e. Boot Camp)
|
||||
return normalizeStrings.join(' ');
|
||||
}
|
||||
// Otherwise, return a normalized string
|
||||
const normalizeString = productType[0].toUpperCase() + productType.slice(1).toLowerCase();
|
||||
return normalizeString;
|
||||
};
|
||||
|
||||
const renderCarouselTitle = (productType) => (
|
||||
<h3>
|
||||
{formatMessage(messages.productRecommendationsHeaderText, {
|
||||
productType: normalizeProductTypeName(productType),
|
||||
jobName,
|
||||
})}
|
||||
</h3>
|
||||
);
|
||||
|
||||
return (
|
||||
productTypeNames.map(productType => (
|
||||
<CardCarousel
|
||||
key={productType}
|
||||
ariaLabel="card carousel"
|
||||
title={renderCarouselTitle(productType)}
|
||||
>
|
||||
{recommendations[productType].map(rec => (
|
||||
<RecommendationCard rec={rec} key={rec.uuid} />
|
||||
))}
|
||||
</CardCarousel>
|
||||
)));
|
||||
};
|
||||
|
||||
export default CarouselStack;
|
||||
@@ -1,54 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Card, Chip, Hyperlink } from '@edx/paragon';
|
||||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import cardImageCapFallbackSrc from '../../images/card-imagecap-fallback.png';
|
||||
|
||||
const RecommendationCard = ({ rec }) => {
|
||||
const {
|
||||
card_image_url: cardImageUrl,
|
||||
marketing_url: marketingUrl,
|
||||
owners,
|
||||
partner,
|
||||
title,
|
||||
} = rec;
|
||||
|
||||
const { logoImageUrl } = owners[0];
|
||||
|
||||
return (
|
||||
<Hyperlink destination={marketingUrl} target="_blank" showLaunchIcon={false}>
|
||||
<Card className={classNames('carousel-card')}>
|
||||
<Card.ImageCap
|
||||
src={cardImageUrl}
|
||||
logoSrc={logoImageUrl}
|
||||
fallackSrc={cardImageCapFallbackSrc}
|
||||
fallBackLogo={cardImageCapFallbackSrc}
|
||||
/>
|
||||
<Card.Header title={title} />
|
||||
<Card.Section>
|
||||
{partner.map((orgName, index) => (
|
||||
// eslint-disable-next-line react/no-array-index-key
|
||||
<Chip key={index}>
|
||||
{orgName}
|
||||
</Chip>
|
||||
))}
|
||||
</Card.Section>
|
||||
</Card>
|
||||
</Hyperlink>
|
||||
);
|
||||
};
|
||||
|
||||
RecommendationCard.propTypes = {
|
||||
rec: PropTypes.shape({
|
||||
title: PropTypes.string,
|
||||
card_image_url: PropTypes.string,
|
||||
marketing_url: PropTypes.string,
|
||||
partner: PropTypes.arrayOf(PropTypes.string),
|
||||
owners: PropTypes.arrayOf(PropTypes.shape({
|
||||
key: PropTypes.string,
|
||||
logoImageUrl: PropTypes.string,
|
||||
})),
|
||||
}).isRequired,
|
||||
};
|
||||
|
||||
export default RecommendationCard;
|
||||
@@ -1,57 +0,0 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import {
|
||||
SelectableBox, Chip, Stack, useMediaQuery, breakpoints,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import messages from './messages';
|
||||
|
||||
const RelatedSkillsSelectableBoxSet = ({ jobSkillsList, selectedJobTitle, onChange }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });
|
||||
|
||||
const renderTopFiveSkills = (skills) => {
|
||||
const topFiveSkills = skills.sort((a, b) => b.significance - a.significance).slice(0, 5);
|
||||
return (
|
||||
topFiveSkills.map(skill => (
|
||||
<Chip key={skill.external_id}>
|
||||
{skill.name}
|
||||
</Chip>
|
||||
))
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<SelectableBox.Set
|
||||
name="selected job title"
|
||||
type="radio"
|
||||
value={selectedJobTitle}
|
||||
onChange={onChange}
|
||||
columns={isExtraSmall ? 1 : 3}
|
||||
>
|
||||
{jobSkillsList.map(job => (
|
||||
<SelectableBox
|
||||
key={job.id}
|
||||
type="radio"
|
||||
value={job.name}
|
||||
aria-label={job.name}
|
||||
inputHidden={false}
|
||||
>
|
||||
<p>{job.name}</p>
|
||||
<Stack gap={2} className="align-items-start">
|
||||
<p className="heading-label x-small">{formatMessage(messages.relatedSkillsHeading)}</p>
|
||||
{renderTopFiveSkills(job.skills)}
|
||||
</Stack>
|
||||
</SelectableBox>
|
||||
))}
|
||||
</SelectableBox.Set>
|
||||
);
|
||||
};
|
||||
|
||||
RelatedSkillsSelectableBoxSet.propTypes = {
|
||||
jobSkillsList: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
|
||||
selectedJobTitle: PropTypes.string.isRequired,
|
||||
onChange: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default RelatedSkillsSelectableBoxSet;
|
||||
@@ -1,118 +0,0 @@
|
||||
import React, { useContext, useEffect, useState } from 'react';
|
||||
import {
|
||||
Stack, Row, Alert, Spinner,
|
||||
} from '@edx/paragon';
|
||||
import { useIntl } from '@edx/frontend-platform/i18n';
|
||||
import { CheckCircle, ErrorOutline } from '@edx/paragon/icons';
|
||||
import { SkillsBuilderContext } from '../../skills-builder-context';
|
||||
import RelatedSkillsSelectableBoxSet from './RelatedSkillsSelectableBoxSet';
|
||||
import { searchJobs, getProductRecommendations } from '../../utils/search';
|
||||
import messages from './messages';
|
||||
import { productTypes } from './data/constants';
|
||||
import CarouselStack from './CarouselStack';
|
||||
|
||||
const ViewResults = () => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { algolia, state } = useContext(SkillsBuilderContext);
|
||||
const { jobSearchIndex, productSearchIndex } = algolia;
|
||||
const { careerInterests } = state;
|
||||
|
||||
const [selectedJobTitle, setSelectedJobTitle] = useState('');
|
||||
const [jobSkillsList, setJobSkillsList] = useState([]);
|
||||
const [productRecommendations, setProductRecommendations] = useState([]);
|
||||
const [selectedRecommendations, setSelectedRecommendations] = useState({});
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const [fetchError, setFetchError] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
const getRecommendations = async () => {
|
||||
// fetch list of jobs with related skills
|
||||
const jobInfo = await searchJobs(jobSearchIndex, careerInterests);
|
||||
|
||||
// fetch course recommendations based on related skills for each job
|
||||
const results = await Promise.all(jobInfo.map(async (job) => {
|
||||
const formattedSkills = job.skills.map(skill => skill.name);
|
||||
|
||||
// create a data object for each job
|
||||
const data = {
|
||||
id: job.id,
|
||||
name: job.name,
|
||||
recommendations: {},
|
||||
};
|
||||
|
||||
// get recommendations for each product type based on the skills for the current job
|
||||
await Promise.all(productTypes.map(async (productType) => {
|
||||
const response = await getProductRecommendations(productSearchIndex, productType, formattedSkills);
|
||||
|
||||
// replace all white spaces with an underscore
|
||||
const formattedProductType = productType.replace(' ', '_');
|
||||
|
||||
// add a new key to the recommendations object and set the value to the response
|
||||
data.recommendations[formattedProductType] = response;
|
||||
}));
|
||||
|
||||
return data;
|
||||
}));
|
||||
|
||||
setJobSkillsList(jobInfo);
|
||||
setSelectedJobTitle(jobInfo[0].name);
|
||||
setProductRecommendations(results);
|
||||
setIsLoading(false);
|
||||
};
|
||||
getRecommendations()
|
||||
.catch(() => {
|
||||
setFetchError(true);
|
||||
setIsLoading(false);
|
||||
});
|
||||
}, [careerInterests, jobSearchIndex, productSearchIndex]);
|
||||
|
||||
useEffect(() => {
|
||||
setSelectedRecommendations(productRecommendations.find(rec => rec.name === selectedJobTitle));
|
||||
}, [productRecommendations, selectedJobTitle]);
|
||||
|
||||
if (fetchError) {
|
||||
return (
|
||||
<Alert
|
||||
variant="danger"
|
||||
icon={ErrorOutline}
|
||||
>
|
||||
<Alert.Heading>
|
||||
{formatMessage(messages.matchesNotFoundDangerAlert)}
|
||||
</Alert.Heading>
|
||||
</Alert>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
isLoading ? (
|
||||
<Row>
|
||||
<Spinner
|
||||
animation="border"
|
||||
screenReaderText="loading"
|
||||
className="mx-auto"
|
||||
/>
|
||||
</Row>
|
||||
) : (
|
||||
<Stack gap={4.5} className="pb-4.5">
|
||||
<Alert
|
||||
variant="success"
|
||||
icon={CheckCircle}
|
||||
>
|
||||
<Alert.Heading>
|
||||
{formatMessage(messages.matchesFoundSuccessAlert)}
|
||||
</Alert.Heading>
|
||||
</Alert>
|
||||
|
||||
<RelatedSkillsSelectableBoxSet
|
||||
jobSkillsList={jobSkillsList}
|
||||
selectedJobTitle={selectedJobTitle}
|
||||
onChange={(e) => setSelectedJobTitle(e.target.value)}
|
||||
/>
|
||||
|
||||
<CarouselStack selectedRecommendations={selectedRecommendations} />
|
||||
</Stack>
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
export default ViewResults;
|
||||
@@ -1,11 +0,0 @@
|
||||
const COURSE = 'course';
|
||||
|
||||
/* The below strings can be used to demonstrate how we are able to retrieve recommendations for other product types
|
||||
const BOOT_CAMP = 'boot camp';
|
||||
const EXECUTIVE_EDUCATION = 'executive education';
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const productTypes = [
|
||||
COURSE,
|
||||
];
|
||||
@@ -1,2 +0,0 @@
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export { default as ViewResults } from './ViewResults';
|
||||
@@ -1,31 +0,0 @@
|
||||
import { defineMessages } from '@edx/frontend-platform/i18n';
|
||||
|
||||
const messages = defineMessages({
|
||||
matchesFoundSuccessAlert: {
|
||||
id: 'matches.found.success.alert',
|
||||
defaultMessage: 'We found skills and courses that match your preferences!',
|
||||
description: 'Success alert message to display when recommendations are presented to the learner.',
|
||||
},
|
||||
matchesNotFoundDangerAlert: {
|
||||
id: 'matches.not.found.danger.alert',
|
||||
defaultMessage: 'We were not able to retrieve recommendations at this time. Please try again later.',
|
||||
description: 'Danger alert message to display when the component fails to get recommendations.',
|
||||
},
|
||||
relatedSkillsHeading: {
|
||||
id: 'related.skills.heading',
|
||||
defaultMessage: 'Related Skills',
|
||||
description: 'Heading text for a selectable box that displays related skills for a corresponding selected job title.',
|
||||
},
|
||||
relatedSkillsSelectableBoxLabelText: {
|
||||
id: 'related.skills.selectable.box.label.text',
|
||||
defaultMessage: 'Related skills:',
|
||||
description: 'Label text for a selectable box that displays related skills for a corresponding selected job title.',
|
||||
},
|
||||
productRecommendationsHeaderText: {
|
||||
id: 'product.recommendations.header.text',
|
||||
defaultMessage: '{productType} recommendations for {jobName}',
|
||||
description: 'Header text for a carousel of product recommendations.',
|
||||
},
|
||||
});
|
||||
|
||||
export default messages;
|
||||
@@ -1,79 +0,0 @@
|
||||
import {
|
||||
screen, render, cleanup, fireEvent, act,
|
||||
} from '@testing-library/react';
|
||||
import { mergeConfig } from '@edx/frontend-platform';
|
||||
import { SkillsBuilderWrapperWithContext, contextValue } from '../../../test/setupSkillsBuilder';
|
||||
import { getProductRecommendations } from '../../../utils/search';
|
||||
|
||||
const renderSkillsBuilderWrapper = (
|
||||
value = {
|
||||
...contextValue,
|
||||
state: {
|
||||
...contextValue.state,
|
||||
currentGoal: 'I want to start my career',
|
||||
currentJobTitle: 'Goblin Lackey',
|
||||
careerInterests: ['Prospector', 'Mirror Breaker', 'Bombardment'],
|
||||
},
|
||||
},
|
||||
) => {
|
||||
render(SkillsBuilderWrapperWithContext(value));
|
||||
};
|
||||
|
||||
describe('view-results', () => {
|
||||
beforeAll(() => {
|
||||
mergeConfig({
|
||||
ALGOLIA_JOBS_INDEX_NAME: 'test-job-index-name',
|
||||
});
|
||||
});
|
||||
|
||||
describe('user interface', () => {
|
||||
beforeEach(async () => {
|
||||
cleanup();
|
||||
// Render the form filled out
|
||||
renderSkillsBuilderWrapper();
|
||||
// Click the next button to trigger "fetching" the data
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Next Step' }));
|
||||
});
|
||||
});
|
||||
|
||||
it('should render a <JobSillsSelectableBox> for each career interest the learner has submitted', async () => {
|
||||
expect(screen.getByText('Prospector')).toBeTruthy();
|
||||
expect(screen.getByText('Mirror Breaker')).toBeTruthy();
|
||||
|
||||
const chipComponents = document.querySelectorAll('.pgn__chip');
|
||||
expect(chipComponents[0].textContent).toEqual('finding shiny things');
|
||||
expect(chipComponents[1].textContent).toEqual('mining');
|
||||
});
|
||||
|
||||
it('renders a carousel of <Card> components', async () => {
|
||||
expect(screen.getByText('Course recommendations for Prospector')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('changes the recommendations based on the selected job title', () => {
|
||||
fireEvent.click(screen.getByRole('radio', { name: 'Mirror Breaker' }));
|
||||
expect(screen.getByText('Course recommendations for Mirror Breaker')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetch recommendations', () => {
|
||||
beforeEach(() => {
|
||||
cleanup();
|
||||
// Render the form filled out
|
||||
renderSkillsBuilderWrapper();
|
||||
});
|
||||
|
||||
it('renders an alert if an error is thrown while fetching', async () => {
|
||||
getProductRecommendations.mockImplementationOnce(() => {
|
||||
throw new Error();
|
||||
});
|
||||
|
||||
// Click the next button to trigger "fetching" the data
|
||||
await act(async () => {
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Next Step' }));
|
||||
});
|
||||
|
||||
expect(screen.getByText('We were not able to retrieve recommendations at this time. Please try again later.')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,23 +0,0 @@
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import React from 'react';
|
||||
import {
|
||||
screen, render, act,
|
||||
} from '@testing-library/react';
|
||||
import { SkillsBuilder } from '..';
|
||||
import { SkillsBuilderProvider } from '../skills-builder-context';
|
||||
|
||||
describe('skills-builder', () => {
|
||||
it('should render a Skills Builder modal with a prompt for the user', () => {
|
||||
act(() => {
|
||||
render(
|
||||
<IntlProvider locale="en">
|
||||
<SkillsBuilderProvider>
|
||||
<SkillsBuilder />
|
||||
</SkillsBuilderProvider>
|
||||
</IntlProvider>,
|
||||
);
|
||||
});
|
||||
expect(screen.getByText('Skills Builder')).toBeTruthy();
|
||||
expect(screen.getByText('First, tell us what you want to achieve')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -1,67 +0,0 @@
|
||||
export const mockData = {
|
||||
hits: [
|
||||
{
|
||||
id: 0,
|
||||
name: 'Text File Engineer'
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: 'Screen Viewer'
|
||||
},
|
||||
],
|
||||
searchJobs: [
|
||||
{
|
||||
id: 0,
|
||||
name: 'Prospector',
|
||||
skills: [
|
||||
{ external_id: 0,
|
||||
name: 'mining',
|
||||
significance: 50,
|
||||
},
|
||||
{ external_id: 1,
|
||||
name: 'finding shiny things',
|
||||
significance: 100,
|
||||
}],
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: 'Mirror Breaker',
|
||||
skills: [
|
||||
{ external_id: 0,
|
||||
name: 'mining',
|
||||
significance: 50,
|
||||
},
|
||||
{ external_id: 1,
|
||||
name: 'finding shiny things',
|
||||
significance: 100,
|
||||
}],
|
||||
},
|
||||
],
|
||||
productRecommendations: [
|
||||
{
|
||||
title: 'Mining with the Mons',
|
||||
uuid: 'thisIsARandomString01',
|
||||
partner: ['edx'],
|
||||
card_image_url: 'https://thisIsAUrl.ForAnImage.01.jpeg',
|
||||
marketing_url: 'https://thisIsAUrl.ForTheRecommendedContent.01.com',
|
||||
owners: [
|
||||
{
|
||||
logoImageUrl: 'https://thisIsAUrl.ForALogoImage.01.jpeg',
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
title: 'The Art of Warren Upkeep',
|
||||
uuid: 'thisIsARandomString02',
|
||||
partner: ['edx'],
|
||||
card_image_url: 'https://thisIsAUrl.ForAnImage.02.jpeg',
|
||||
marketing_url: 'https://thisIsAUrl.ForTheRecommendedContent.02.com',
|
||||
owners: [
|
||||
{
|
||||
logoImageUrl: 'https://thisIsAUrl.ForALogoImage.02.jpeg',
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
useAlgoliaSearch: [{}, {}, {}],
|
||||
};
|
||||
@@ -1,49 +0,0 @@
|
||||
import { IntlProvider } from '@edx/frontend-platform/i18n';
|
||||
import React from 'react';
|
||||
import { SkillsBuilderModal } from '../skills-builder-modal';
|
||||
import { SkillsBuilderContext } from '../skills-builder-context';
|
||||
import { skillsInitialState } from '../data/reducer';
|
||||
import { mockData } from './__mocks__/jobSkills.mockData';
|
||||
import { getProductRecommendations, searchJobs, useAlgoliaSearch } from '../utils/search';
|
||||
|
||||
jest.mock('@edx/frontend-platform/logging');
|
||||
|
||||
jest.mock('react-instantsearch-hooks-web', () => ({
|
||||
// eslint-disable-next-line react/prop-types
|
||||
InstantSearch: ({ children }) => (<div>{children}</div>),
|
||||
useSearchBox: jest.fn(() => ({ refine: jest.fn() })),
|
||||
useHits: jest.fn(() => ({ hits: mockData.hits })),
|
||||
}));
|
||||
|
||||
jest.mock('../utils/search', () => ({
|
||||
searchJobs: jest.fn(),
|
||||
getProductRecommendations: jest.fn(),
|
||||
useAlgoliaSearch: jest.fn(),
|
||||
}));
|
||||
|
||||
searchJobs.mockReturnValue(mockData.searchJobs);
|
||||
getProductRecommendations.mockReturnValue(mockData.productRecommendations);
|
||||
useAlgoliaSearch.mockReturnValue(mockData.useAlgoliaSearch);
|
||||
|
||||
export const dispatchMock = jest.fn();
|
||||
|
||||
export const contextValue = {
|
||||
state: {
|
||||
...skillsInitialState,
|
||||
},
|
||||
dispatch: dispatchMock,
|
||||
algolia: {
|
||||
// Without this, tests would fail to destructure `searchClient` in the <JobTitleSelect> component
|
||||
searchClient: {},
|
||||
productSearchIndex: {},
|
||||
jobSearchIndex: {},
|
||||
},
|
||||
};
|
||||
|
||||
export const SkillsBuilderWrapperWithContext = (value = contextValue) => (
|
||||
<IntlProvider locale="en">
|
||||
<SkillsBuilderContext.Provider value={value}>
|
||||
<SkillsBuilderModal />
|
||||
</SkillsBuilderContext.Provider>
|
||||
</IntlProvider>
|
||||
);
|
||||
@@ -1,110 +0,0 @@
|
||||
/*
|
||||
Algolia utility functions used by the Skills Builder feature.
|
||||
*/
|
||||
import { useMemo } from 'react';
|
||||
import { getConfig } from '@edx/frontend-platform';
|
||||
import { logError } from '@edx/frontend-platform/logging';
|
||||
|
||||
import algoliasearch from 'algoliasearch';
|
||||
|
||||
/*
|
||||
* Utility function to create and return an Algolia client, as well as Index objects for our product and job data.
|
||||
*
|
||||
* @return {SearchClient} searchClient - An instantiated Algolia client
|
||||
* @return {SearchIndex} productSearchIndex - An Algolia index of product data. Used to retrieve product
|
||||
* recommendations for learners
|
||||
* @return {SearchIndex} jobSearchIndex - An Algolia index of job taxonomy data. Used to retrieve job metadata that a
|
||||
* learner is interested in.
|
||||
*/
|
||||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const useAlgoliaSearch = () => {
|
||||
const config = getConfig();
|
||||
|
||||
const [searchClient, productSearchIndex, jobSearchIndex] = useMemo(
|
||||
() => {
|
||||
const client = algoliasearch(
|
||||
config.ALGOLIA_APP_ID,
|
||||
config.ALGOLIA_SEARCH_API_KEY,
|
||||
);
|
||||
const productIndex = client.initIndex(config.ALGOLIA_PRODUCT_INDEX_NAME);
|
||||
const jobIndex = client.initIndex(config.ALGOLIA_JOBS_INDEX_NAME);
|
||||
return [client, productIndex, jobIndex];
|
||||
},
|
||||
[
|
||||
config.ALGOLIA_APP_ID,
|
||||
config.ALGOLIA_PRODUCT_INDEX_NAME,
|
||||
config.ALGOLIA_JOBS_INDEX_NAME,
|
||||
config.ALGOLIA_SEARCH_API_KEY,
|
||||
],
|
||||
);
|
||||
return [searchClient, productSearchIndex, jobSearchIndex];
|
||||
};
|
||||
|
||||
/*
|
||||
* Utility function used to format a list of data so it matches syntax Algolia expects.
|
||||
*
|
||||
* @param {String} facetFilterType - A string declaring the facet filter type to prepend each search item (e.g. `name`)
|
||||
* @param {Array[String]} data - An array of job or skills used to query data in Algolia.
|
||||
*
|
||||
* @return {Array[String]} formattedData - The transformed array of data to search prepended with the facet filter type
|
||||
*/
|
||||
export function formatFacetFilterData(facetFilterType, data) {
|
||||
const formattedData = [];
|
||||
if (data) {
|
||||
data.forEach(item => formattedData.push(`${facetFilterType}:${item}`));
|
||||
}
|
||||
|
||||
return formattedData;
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility function responsible for querying and returning job information based on input received from a learner.
|
||||
*
|
||||
* @param {SearchIndex} jobIndex - An Algolia index of taxonomy connector data used to retrieve job information a
|
||||
* learner is interested in
|
||||
* @param {Array[String]} jobNames - A list of job names a learner is interested in
|
||||
*
|
||||
* @return {Array[Object]} results - Job information retrieved from Algolia
|
||||
*/
|
||||
export const searchJobs = async (jobIndex, jobNames) => {
|
||||
const formattedJobNames = formatFacetFilterData('name', jobNames);
|
||||
try {
|
||||
const { hits } = await jobIndex.search('', {
|
||||
facetFilters: [
|
||||
formattedJobNames,
|
||||
],
|
||||
});
|
||||
return hits;
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
|
||||
/*
|
||||
* Utility function responsible for returning recommendations on products based on the skills of a job a learner is
|
||||
* interested in.
|
||||
*
|
||||
* @param {SearchIndex} productIndex - An Algolia index of product data used to retrieve recommendations for learners.
|
||||
* @param {String} productType - The type of product information you are trying to retrieve (e.g. `course` or `program`)
|
||||
* @param {Array[String]} skills - An array of skill names related to a job/career a learner expressed interest in
|
||||
*
|
||||
* @return {Array[Object]} results - Product information retrieved from Algolia
|
||||
*/
|
||||
export const getProductRecommendations = async (productIndex, productType, skills) => {
|
||||
const formattedSkillNames = formatFacetFilterData('skills.skill', skills);
|
||||
try {
|
||||
const { hits } = await productIndex.search('', {
|
||||
filters: `product: "${productType}"`,
|
||||
facetFilters: [
|
||||
formattedSkillNames,
|
||||
],
|
||||
});
|
||||
return hits;
|
||||
} catch (error) {
|
||||
logError(error);
|
||||
}
|
||||
|
||||
return [];
|
||||
};
|
||||
@@ -1,74 +0,0 @@
|
||||
import {
|
||||
formatFacetFilterData,
|
||||
getProductRecommendations,
|
||||
searchJobs,
|
||||
} from '../search';
|
||||
|
||||
jest.mock('@edx/frontend-platform/logging');
|
||||
|
||||
const mockAlgoliaResult = {
|
||||
hits: [
|
||||
{
|
||||
key: 'test-course-key',
|
||||
title: 'Test Title',
|
||||
skill_names: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Skill Name',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const mockIndex = {
|
||||
search: jest.fn().mockImplementation(() => mockAlgoliaResult),
|
||||
};
|
||||
|
||||
describe('Algolias utility function', () => {
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('formatFacetFilterData() should return a new array with data formatted as expected', () => {
|
||||
const result = formatFacetFilterData('name', ['Organic Farmer']);
|
||||
expect(result).toEqual(['name:Organic Farmer']);
|
||||
});
|
||||
|
||||
it('searchJobs() queries Algolia with the expected search parameters', async () => {
|
||||
const expectedSearchParameters = {
|
||||
facetFilters: [
|
||||
['name:Enchanter'],
|
||||
],
|
||||
};
|
||||
|
||||
const results = await searchJobs(mockIndex, ['Enchanter']);
|
||||
expect(mockIndex.search).toHaveBeenCalledTimes(1);
|
||||
expect(mockIndex.search).toHaveBeenCalledWith('', expectedSearchParameters);
|
||||
expect(results).toEqual(mockAlgoliaResult.hits);
|
||||
});
|
||||
|
||||
it('searchJobs() returns an empty array when an exception occurs querying Algolia', async () => {
|
||||
const results = await searchJobs(null, ['Organic Farmer']);
|
||||
expect(results).toEqual([]);
|
||||
});
|
||||
|
||||
it('getProductRecommendations() queries Algolia with the expected search parameters', async () => {
|
||||
const expectedSearchParameters = {
|
||||
filters: 'product: "Course"',
|
||||
facetFilters: [
|
||||
['skills.skill:Sword Lobbing'],
|
||||
],
|
||||
};
|
||||
|
||||
const results = await getProductRecommendations(mockIndex, 'Course', ['Sword Lobbing']);
|
||||
expect(mockIndex.search).toHaveBeenCalledTimes(1);
|
||||
expect(mockIndex.search).toHaveBeenCalledWith('', expectedSearchParameters);
|
||||
expect(results).toEqual(mockAlgoliaResult.hits);
|
||||
});
|
||||
|
||||
it('getProductRecommendations() returns an empty array when an exception occurs querying Algolia', async () => {
|
||||
const results = await getProductRecommendations(null, 'Course', ['Management']);
|
||||
expect(results).toEqual([]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user