diff --git a/.env b/.env index f73d2e4..4af7473 100644 --- a/.env +++ b/.env @@ -31,5 +31,4 @@ SEARCH_CATALOG_URL='' ENABLE_SKILLS_BUILDER_PROFILE='' # Fallback in local style files PARAGON_THEME_URLS={} -ENABLE_NEW_PROFILE_VIEW='' DISABLE_VISIBILITY_EDITING='' diff --git a/.env.development b/.env.development index a9a5e96..fa5041d 100644 --- a/.env.development +++ b/.env.development @@ -32,5 +32,4 @@ SEARCH_CATALOG_URL='http://localhost:18000/courses' ENABLE_SKILLS_BUILDER_PROFILE='' # Fallback in local style files PARAGON_THEME_URLS={} -ENABLE_NEW_PROFILE_VIEW='' DISABLE_VISIBILITY_EDITING='' diff --git a/.env.test b/.env.test index 839f7fe..15f0042 100644 --- a/.env.test +++ b/.env.test @@ -26,5 +26,4 @@ COLLECT_YEAR_OF_BIRTH=true APP_ID='' MFE_CONFIG_API_URL='' PARAGON_THEME_URLS={} -ENABLE_NEW_PROFILE_VIEW='' DISABLE_VISIBILITY_EDITING='' diff --git a/src/data/reducers.js b/src/data/reducers.js index 98b95d2..fa8f1bf 100755 --- a/src/data/reducers.js +++ b/src/data/reducers.js @@ -1,14 +1,9 @@ import { combineReducers } from 'redux'; -import { getConfig } from '@edx/frontend-platform'; - import { reducer as profilePageReducer } from '../profile'; -import { reducer as newProfilePageReducer } from '../profile-v2'; - -const isNewProfileEnabled = getConfig().ENABLE_NEW_PROFILE_VIEW; const createRootReducer = () => combineReducers({ - profilePage: isNewProfileEnabled ? newProfilePageReducer : profilePageReducer, + profilePage: profilePageReducer, }); export default createRootReducer; diff --git a/src/data/sagas.js b/src/data/sagas.js index fab5eca..91762b8 100644 --- a/src/data/sagas.js +++ b/src/data/sagas.js @@ -1,12 +1,8 @@ import { all } from 'redux-saga/effects'; -import { getConfig } from '@edx/frontend-platform'; import { saga as profileSaga } from '../profile'; -import { saga as newProfileSaga } from '../profile-v2'; - -const isNewProfileEnabled = getConfig().ENABLE_NEW_PROFILE_VIEW; export default function* rootSaga() { yield all([ - isNewProfileEnabled ? newProfileSaga() : profileSaga(), + profileSaga(), ]); } diff --git a/src/index-v2.scss b/src/index-v2.scss deleted file mode 100755 index d120211..0000000 --- a/src/index-v2.scss +++ /dev/null @@ -1,6 +0,0 @@ -@use "@openedx/paragon/styles/css/core/custom-media-breakpoints" as paragonCustomMediaBreakpoints; - -@import "~@edx/frontend-component-header/dist/index"; -@import "~@edx/frontend-component-footer/dist/footer"; - -@import './profile-v2/index'; diff --git a/src/index.jsx b/src/index.jsx index 44779d4..0b00264 100755 --- a/src/index.jsx +++ b/src/index.jsx @@ -7,7 +7,6 @@ import { initialize, mergeConfig, subscribe, - getConfig, } from '@edx/frontend-platform'; import { AppProvider, @@ -28,20 +27,16 @@ import Head from './head/Head'; import AppRoutes from './routes/AppRoutes'; +import './index.scss'; + const rootNode = createRoot(document.getElementById('root')); subscribe(APP_READY, async () => { - const isNewProfileEnabled = getConfig().ENABLE_NEW_PROFILE_VIEW === 'true'; - if (isNewProfileEnabled) { - await import('./index-v2.scss'); - } else { - await import('./index.scss'); - } rootNode.render(
- +
, @@ -61,7 +56,6 @@ initialize({ mergeConfig({ COLLECT_YEAR_OF_BIRTH: process.env.COLLECT_YEAR_OF_BIRTH, ENABLE_SKILLS_BUILDER_PROFILE: process.env.ENABLE_SKILLS_BUILDER_PROFILE, - ENABLE_NEW_PROFILE_VIEW: process.env.ENABLE_NEW_PROFILE_VIEW || null, }, 'App loadConfig override handler'); }, }, diff --git a/src/index.scss b/src/index.scss index 69756e8..d1c0cd9 100755 --- a/src/index.scss +++ b/src/index.scss @@ -3,4 +3,4 @@ @import "~@edx/frontend-component-header/dist/index"; @import "~@edx/frontend-component-footer/dist/footer"; -@import './profile/index'; +@import 'profile/index'; diff --git a/src/profile-v2/DateJoined.jsx b/src/profile-v2/DateJoined.jsx deleted file mode 100644 index 5b02d4b..0000000 --- a/src/profile-v2/DateJoined.jsx +++ /dev/null @@ -1,29 +0,0 @@ -import React, { memo } from 'react'; -import PropTypes from 'prop-types'; -import { FormattedMessage, FormattedDate } from '@edx/frontend-platform/i18n'; - -const DateJoined = ({ date }) => { - if (!date) { return null; } - - return ( - - , - }} - /> - - ); -}; - -DateJoined.propTypes = { - date: PropTypes.string, -}; -DateJoined.defaultProps = { - date: null, -}; - -export default memo(DateJoined); diff --git a/src/profile-v2/NotFoundPage.jsx b/src/profile-v2/NotFoundPage.jsx deleted file mode 100644 index b33f0db..0000000 --- a/src/profile-v2/NotFoundPage.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import React from 'react'; -import { FormattedMessage } from '@edx/frontend-platform/i18n'; - -const NotFoundPage = () => ( -
-

- -

-
-); - -export default NotFoundPage; diff --git a/src/profile-v2/PageLoading.jsx b/src/profile-v2/PageLoading.jsx deleted file mode 100644 index a730b39..0000000 --- a/src/profile-v2/PageLoading.jsx +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; - -const PageLoading = ({ srMessage }) => ( -
-
-
- {srMessage && {srMessage}} -
-
-
-); - -PageLoading.propTypes = { - srMessage: PropTypes.string.isRequired, -}; - -export default PageLoading; diff --git a/src/profile-v2/ProfilePage.jsx b/src/profile-v2/ProfilePage.jsx deleted file mode 100644 index 2411755..0000000 --- a/src/profile-v2/ProfilePage.jsx +++ /dev/null @@ -1,463 +0,0 @@ -import React, { - useEffect, useState, useContext, useCallback, -} from 'react'; -import PropTypes from 'prop-types'; -import { useDispatch, useSelector } from 'react-redux'; -import { useNavigate } from 'react-router-dom'; - -import { sendTrackingLogEvent } from '@edx/frontend-platform/analytics'; -import { ensureConfig } from '@edx/frontend-platform'; -import { AppContext } from '@edx/frontend-platform/react'; -import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; -import { - Alert, Hyperlink, OverlayTrigger, Tooltip, -} from '@openedx/paragon'; -import { InfoOutline } from '@openedx/paragon/icons'; -import classNames from 'classnames'; - -import { - fetchProfile, - saveProfile, - saveProfilePhoto, - deleteProfilePhoto, - openForm, - closeForm, - updateDraft, -} from './data/actions'; - -import ProfileAvatar from './forms/ProfileAvatar'; -import Name from './forms/Name'; -import Country from './forms/Country'; -import PreferredLanguage from './forms/PreferredLanguage'; -import Education from './forms/Education'; -import SocialLinks from './forms/SocialLinks'; -import Bio from './forms/Bio'; -import DateJoined from './DateJoined'; -import UserCertificateSummary from './UserCertificateSummary'; -import PageLoading from './PageLoading'; -import Certificates from './Certificates'; - -import { profilePageSelector } from './data/selectors'; -import messages from './ProfilePage.messages'; -import withParams from '../utils/hoc'; -import { useIsOnMobileScreen, useIsOnTabletScreen } from './data/hooks'; - -ensureConfig(['CREDENTIALS_BASE_URL', 'LMS_BASE_URL', 'ACCOUNT_SETTINGS_URL'], 'ProfilePage'); - -const ProfilePage = ({ params }) => { - const dispatch = useDispatch(); - const intl = useIntl(); - const context = useContext(AppContext); - const { - dateJoined, - courseCertificates, - name, - visibilityName, - profileImage, - savePhotoState, - isLoadingProfile, - photoUploadError, - country, - visibilityCountry, - levelOfEducation, - visibilityLevelOfEducation, - socialLinks, - draftSocialLinksByPlatform, - visibilitySocialLinks, - languageProficiencies, - visibilityLanguageProficiencies, - bio, - visibilityBio, - saveState, - username, - } = useSelector(profilePageSelector); - - const navigate = useNavigate(); - const [viewMyRecordsUrl, setViewMyRecordsUrl] = useState(null); - const isMobileView = useIsOnMobileScreen(); - const isTabletView = useIsOnTabletScreen(); - - useEffect(() => { - const { CREDENTIALS_BASE_URL } = context.config; - if (CREDENTIALS_BASE_URL) { - setViewMyRecordsUrl(`${CREDENTIALS_BASE_URL}/records`); - } - - dispatch(fetchProfile(params.username)); - sendTrackingLogEvent('edx.profile.viewed', { - username: params.username, - }); - }, [dispatch, params.username, context.config]); - - useEffect(() => { - if (!username && saveState === 'error' && navigate) { - navigate('/notfound'); - } - }, [username, saveState, navigate]); - - const authenticatedUserName = context.authenticatedUser.username; - - const handleSaveProfilePhoto = useCallback((formData) => { - dispatch(saveProfilePhoto(authenticatedUserName, formData)); - }, [dispatch, authenticatedUserName]); - - const handleDeleteProfilePhoto = useCallback(() => { - dispatch(deleteProfilePhoto(authenticatedUserName)); - }, [dispatch, authenticatedUserName]); - - const handleClose = useCallback((formId) => { - dispatch(closeForm(formId)); - }, [dispatch]); - - const handleOpen = useCallback((formId) => { - dispatch(openForm(formId)); - }, [dispatch]); - - const handleSubmit = useCallback((formId) => { - dispatch(saveProfile(formId, authenticatedUserName)); - }, [dispatch, authenticatedUserName]); - - const handleChange = useCallback((fieldName, value) => { - dispatch(updateDraft(fieldName, value)); - }, [dispatch]); - - const isAuthenticatedUserProfile = () => params.username === authenticatedUserName; - - const isBlockVisible = (blockInfo) => isAuthenticatedUserProfile() - || (!isAuthenticatedUserProfile() && Boolean(blockInfo)); - - const renderViewMyRecordsButton = () => { - if (!(viewMyRecordsUrl && isAuthenticatedUserProfile())) { - return null; - } - - return ( - - {intl.formatMessage(messages['profile.viewMyRecords'])} - - ); - }; - - const renderPhotoUploadErrorMessage = () => ( - photoUploadError && ( -
-
- - {photoUploadError.userMessage} - -
-
- ) - ); - - const commonFormProps = { - openHandler: handleOpen, - closeHandler: handleClose, - submitHandler: handleSubmit, - changeHandler: handleChange, - }; - - return ( -
- {isLoadingProfile ? ( - - ) : ( - <> -
-
-
-
- -
-

- {params.username} -

- {isBlockVisible(name) && ( -

- {name} -

- )} -
- - -
-
-
- {renderViewMyRecordsButton()} -
-
-
-
- {renderPhotoUploadErrorMessage()} -
-
-
-
-
-
-
-

- {isMobileView ? ( - - ) - : ( - - )} -

-
-
-
-
-
-
-

- {intl.formatMessage(messages['profile.username'])} -

- -

- {intl.formatMessage(messages['profile.username.tooltip'])} -

- - )} - > - -
-
-

- {params.username} -

-
- {isBlockVisible(name) && ( - - )} - {isBlockVisible(country) && ( - - )} - {isBlockVisible((languageProficiencies || []).length) && ( - - )} - {isBlockVisible(levelOfEducation) && ( - - )} -
-
- {isBlockVisible(bio) && ( - - )} - {isBlockVisible((socialLinks || []).some((link) => link?.socialLink !== null)) && ( - - )} -
-
-
-
-
- {isBlockVisible((courseCertificates || []).length) && ( - - )} -
- - )} -
- ); -}; - -ProfilePage.propTypes = { - params: PropTypes.shape({ - username: PropTypes.string.isRequired, - }).isRequired, - requiresParentalConsent: PropTypes.bool, - dateJoined: PropTypes.string, - username: PropTypes.string, - bio: PropTypes.string, - visibilityBio: PropTypes.string, - courseCertificates: PropTypes.arrayOf(PropTypes.shape({ - title: PropTypes.string, - })), - country: PropTypes.string, - visibilityCountry: PropTypes.string, - levelOfEducation: PropTypes.string, - visibilityLevelOfEducation: PropTypes.string, - languageProficiencies: PropTypes.arrayOf(PropTypes.shape({ - code: PropTypes.string.isRequired, - })), - visibilityLanguageProficiencies: PropTypes.string, - name: PropTypes.string, - visibilityName: PropTypes.string, - socialLinks: PropTypes.arrayOf(PropTypes.shape({ - platform: PropTypes.string, - socialLink: PropTypes.string, - })), - draftSocialLinksByPlatform: PropTypes.objectOf(PropTypes.shape({ - platform: PropTypes.string, - socialLink: PropTypes.string, - })), - visibilitySocialLinks: PropTypes.string, - profileImage: PropTypes.shape({ - src: PropTypes.string, - isDefault: PropTypes.bool, - }), - saveState: PropTypes.oneOf([null, 'pending', 'complete', 'error']), - savePhotoState: PropTypes.oneOf([null, 'pending', 'complete', 'error']), - isLoadingProfile: PropTypes.bool, - photoUploadError: PropTypes.objectOf(PropTypes.string), -}; - -ProfilePage.defaultProps = { - saveState: null, - username: '', - savePhotoState: null, - photoUploadError: {}, - profileImage: {}, - name: null, - levelOfEducation: null, - country: null, - socialLinks: [], - draftSocialLinksByPlatform: {}, - bio: null, - languageProficiencies: [], - courseCertificates: [], - requiresParentalConsent: null, - dateJoined: null, - visibilityName: null, - visibilityCountry: null, - visibilityLevelOfEducation: null, - visibilitySocialLinks: null, - visibilityLanguageProficiencies: null, - visibilityBio: null, - isLoadingProfile: false, -}; - -export default withParams(ProfilePage); diff --git a/src/profile-v2/ProfilePage.messages.jsx b/src/profile-v2/ProfilePage.messages.jsx deleted file mode 100644 index c7cec79..0000000 --- a/src/profile-v2/ProfilePage.messages.jsx +++ /dev/null @@ -1,26 +0,0 @@ -import { defineMessages } from '@edx/frontend-platform/i18n'; - -const messages = defineMessages({ - 'profile.viewMyRecords': { - id: 'profile.viewMyRecords', - defaultMessage: 'View My Records', - description: 'A link to go view my academic records', - }, - 'profile.loading': { - id: 'profile.loading', - defaultMessage: 'Profile loading...', - description: 'Message displayed when the profile data is loading.', - }, - 'profile.username': { - id: 'profile.username', - defaultMessage: 'Username', - description: 'Label for the username field.', - }, - 'profile.username.tooltip': { - id: 'profile.username.tooltip', - defaultMessage: 'The name that identifies you on edX. You cannot change your username.', - description: 'Tooltip for the username field.', - }, -}); - -export default messages; diff --git a/src/profile-v2/ProfilePage.test.jsx b/src/profile-v2/ProfilePage.test.jsx deleted file mode 100644 index d186c48..0000000 --- a/src/profile-v2/ProfilePage.test.jsx +++ /dev/null @@ -1,259 +0,0 @@ -import { getConfig } from '@edx/frontend-platform'; -import * as analytics from '@edx/frontend-platform/analytics'; -import { AppContext } from '@edx/frontend-platform/react'; -import { configure as configureI18n, IntlProvider } from '@edx/frontend-platform/i18n'; -import { render } from '@testing-library/react'; -import React from 'react'; -import PropTypes from 'prop-types'; -import { Provider } from 'react-redux'; -import configureMockStore from 'redux-mock-store'; -import thunk from 'redux-thunk'; -import { - MemoryRouter, - Routes, - Route, - useNavigate, -} from 'react-router-dom'; - -import messages from '../i18n'; -import ProfilePage from './ProfilePage'; -import loadingApp from './__mocks__/loadingApp.mockStore'; -import viewOwnProfile from './__mocks__/viewOwnProfile.mockStore'; -import viewOtherProfile from './__mocks__/viewOtherProfile.mockStore'; -import invalidUser from './__mocks__/invalidUser.mockStore'; - -jest.mock('react-router-dom', () => ({ - ...jest.requireActual('react-router-dom'), - useNavigate: jest.fn(), -})); - -const mockStore = configureMockStore([thunk]); - -const storeMocks = { - loadingApp, - viewOwnProfile, - viewOtherProfile, - invalidUser, -}; - -const requiredProfilePageProps = { - params: { username: 'staff' }, -}; - -Object.defineProperty(global.document, 'cookie', { - writable: true, - value: `${getConfig().LANGUAGE_PREFERENCE_COOKIE_NAME}=en`, -}); - -jest.mock('@edx/frontend-platform/auth', () => ({ - configure: () => {}, - getAuthenticatedUser: () => null, - fetchAuthenticatedUser: () => null, - getAuthenticatedHttpClient: jest.fn(), - AUTHENTICATED_USER_CHANGED: 'user_changed', -})); - -jest.mock('@edx/frontend-platform/analytics', () => ({ - configure: () => {}, - identifyAnonymousUser: jest.fn(), - identifyAuthenticatedUser: jest.fn(), - sendTrackingLogEvent: jest.fn(), -})); - -configureI18n({ - loggingService: { logError: jest.fn() }, - config: { - ENVIRONMENT: 'production', - LANGUAGE_PREFERENCE_COOKIE_NAME: 'yum', - }, - messages, -}); - -beforeEach(() => { - analytics.sendTrackingLogEvent.mockReset(); - useNavigate.mockReset(); -}); - -const ProfilePageWrapper = ({ - contextValue, store, params, -}) => ( - - - - - - } - /> - - - - - -); - -ProfilePageWrapper.defaultProps = { - // eslint-disable-next-line react/default-props-match-prop-types - params: { username: 'staff' }, -}; - -ProfilePageWrapper.propTypes = { - contextValue: PropTypes.shape({}).isRequired, - store: PropTypes.shape({}).isRequired, - params: PropTypes.shape({ - username: PropTypes.string.isRequired, - }).isRequired, -}; - -describe('', () => { - describe('Renders correctly in various states', () => { - it('app loading', () => { - const contextValue = { - authenticatedUser: { userId: null, username: null, administrator: false }, - config: getConfig(), - }; - const component = ( - - ); - const { container: tree } = render(component); - expect(tree).toMatchSnapshot(); - }); - - it('viewing own profile', () => { - const contextValue = { - authenticatedUser: { userId: 123, username: 'staff', administrator: true }, - config: getConfig(), - }; - const component = ( - - ); - const { container: tree } = render(component); - expect(tree).toMatchSnapshot(); - }); - - it('viewing other profile with all fields', () => { - const contextValue = { - authenticatedUser: { userId: 123, username: 'staff', administrator: true }, - config: getConfig(), - }; - const component = ( - - ); - const { container: tree } = render(component); - expect(tree).toMatchSnapshot(); - }); - - it('without credentials service', () => { - const config = getConfig(); - config.CREDENTIALS_BASE_URL = ''; - - const contextValue = { - authenticatedUser: { userId: 123, username: 'staff', administrator: true }, - config: getConfig(), - }; - const component = ( - - ); - const { container: tree } = render(component); - expect(tree).toMatchSnapshot(); - }); - - it('successfully redirected to not found page', () => { - const contextValue = { - authenticatedUser: { userId: 123, username: 'staff', administrator: true }, - config: getConfig(), - }; - const navigate = jest.fn(); - useNavigate.mockReturnValue(navigate); - const component = ( - - ); - const { container: tree } = render(component); - expect(tree).toMatchSnapshot(); - expect(navigate).toHaveBeenCalledWith('/notfound'); - }); - }); - - describe('handles analytics', () => { - it('calls sendTrackingLogEvent when mounting', () => { - const contextValue = { - authenticatedUser: { userId: 123, username: 'staff', administrator: true }, - config: getConfig(), - }; - render( - , - ); - - expect(analytics.sendTrackingLogEvent).toHaveBeenCalledTimes(1); - expect(analytics.sendTrackingLogEvent).toHaveBeenCalledWith('edx.profile.viewed', { - username: 'test-username', - }); - }); - }); - - describe('handles navigation', () => { - it('navigates to notfound on save error with no username', () => { - const contextValue = { - authenticatedUser: { userId: 123, username: 'staff', administrator: true }, - config: getConfig(), - }; - const navigate = jest.fn(); - useNavigate.mockReturnValue(navigate); - render( - , - ); - - expect(navigate).toHaveBeenCalledWith('/notfound'); - }); - }); -}); diff --git a/src/profile-v2/__mocks__/invalidUser.mockStore.js b/src/profile-v2/__mocks__/invalidUser.mockStore.js deleted file mode 100644 index 253ef87..0000000 --- a/src/profile-v2/__mocks__/invalidUser.mockStore.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = { - userAccount: { - loading: false, - error: null, - username: 'staff', - email: null, - bio: null, - name: null, - country: null, - socialLinks: null, - profileImage: { - imageUrlMedium: null, - imageUrlLarge: null - }, - levelOfEducation: null, - learningGoal: null - }, - profilePage: { - errors: {}, - saveState: 'error', - savePhotoState: null, - currentlyEditingField: null, - account: { - username: '', - socialLinks: [] - }, - preferences: {}, - courseCertificates: [], - drafts: {}, - isLoadingProfile: false, - isAuthenticatedUserProfile: true, - countriesCodesList: ['US', 'CA', 'GB', 'ME'] - }, - router: { - location: { - pathname: '/u/staffTest', - search: '', - hash: '' - }, - action: 'POP' - } -}; diff --git a/src/profile-v2/__mocks__/loadingApp.mockStore.js b/src/profile-v2/__mocks__/loadingApp.mockStore.js deleted file mode 100644 index aaf1f63..0000000 --- a/src/profile-v2/__mocks__/loadingApp.mockStore.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = { - userAccount: { - loading: false, - error: null, - username: 'staff', - email: null, - bio: null, - name: null, - country: null, - socialLinks: null, - profileImage: { - imageUrlMedium: null, - imageUrlLarge: null - }, - levelOfEducation: null, - learningGoal: null - }, - profilePage: { - errors: {}, - saveState: null, - savePhotoState: null, - currentlyEditingField: null, - account: { - username: 'staff', - socialLinks: [] - }, - preferences: {}, - courseCertificates: [], - drafts: {}, - isLoadingProfile: true, - isAuthenticatedUserProfile: true, - countriesCodesList: ['US', 'CA', 'GB', 'ME'] - }, - router: { - location: { - pathname: '/u/staff', - search: '', - hash: '' - }, - action: 'POP' - } -}; diff --git a/src/profile-v2/__mocks__/savingEditedBio.mockStore.js b/src/profile-v2/__mocks__/savingEditedBio.mockStore.js deleted file mode 100644 index a104762..0000000 --- a/src/profile-v2/__mocks__/savingEditedBio.mockStore.js +++ /dev/null @@ -1,139 +0,0 @@ -module.exports = { - userAccount: { - loading: false, - error: null, - username: 'staff', - email: 'staff@example.com', - bio: 'This is my bio', - name: 'Lemon Seltzer', - country: 'ME', - socialLinks: [ - { - platform: 'facebook', - socialLink: 'https://www.facebook.com/aloha' - }, - { - platform: 'twitter', - socialLink: 'https://www.twitter.com/ALOHA' - } - ], - profileImage: { - imageUrlFull: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_500.jpg?v=1552495012', - imageUrlLarge: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_120.jpg?v=1552495012', - imageUrlMedium: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_50.jpg?v=1552495012', - imageUrlSmall: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_30.jpg?v=1552495012', - hasImage: true - }, - levelOfEducation: 'el', - mailingAddress: null, - extendedProfile: [], - dateJoined: '2017-06-07T00:44:23Z', - accomplishmentsShared: false, - isActive: true, - yearOfBirth: 1901, - goals: null, - languageProficiencies: [ - { - code: 'yo' - } - ], - courseCertificates: null, - requiresParentalConsent: false, - secondaryEmail: null, - timeZone: null, - gender: null, - accountPrivacy: 'custom', - learningGoal: null, - }, - profilePage: { - errors: {}, - saveState: 'pending', - savePhotoState: null, - currentlyEditingField: 'bio', - isAuthenticatedUserProfile: true, - account: { - mailingAddress: null, - profileImage: { - imageUrlFull: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_500.jpg?v=1552495012', - imageUrlLarge: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_120.jpg?v=1552495012', - imageUrlMedium: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_50.jpg?v=1552495012', - imageUrlSmall: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_30.jpg?v=1552495012', - hasImage: true - }, - extendedProfile: [], - dateJoined: '2017-06-07T00:44:23Z', - accomplishmentsShared: false, - email: 'staff@example.com', - username: 'staff', - bio: 'This is my bio', - isActive: true, - yearOfBirth: 1901, - goals: null, - languageProficiencies: [ - { - code: 'yo' - } - ], - courseCertificates: null, - requiresParentalConsent: false, - name: 'Lemon Seltzer', - secondaryEmail: null, - country: 'ME', - socialLinks: [ - { - platform: 'facebook', - socialLink: 'https://www.facebook.com/aloha' - }, - { - platform: 'twitter', - socialLink: 'https://www.twitter.com/ALOHA' - } - ], - timeZone: null, - levelOfEducation: 'el', - gender: null, - accountPrivacy: 'custom', - learningGoal: null, - }, - preferences: { - visibilityUserLocation: 'all_users', - visibilitySocialLinks: 'all_users', - visibilityCertificates: 'private', - visibilityLevelOfEducation: 'private', - visibilityCourseCertificates: 'all_users', - prefLang: 'en', - visibilityBio: 'all_users', - visibilityName: 'private', - visibilityLanguageProficiencies: 'all_users', - visibilityCountry: 'all_users', - accountPrivacy: 'custom', - visibilityLearningGoal: 'private', - }, - courseCertificates: [ - { - username: 'staff', - status: 'downloadable', - courseDisplayName: 'edX Demonstration Course', - grade: '0.89', - courseId: 'course-v1:edX+DemoX+Demo_Course', - courseOrganization: 'edX', - modifiedDate: '2019-03-04T19:31:39.930255Z', - isPassing: true, - downloadUrl: 'http://www.example.com/', - certificateType: 'verified', - createdDate: '2019-03-04T19:31:39.896806Z' - } - ], - drafts: {}, - isLoadingProfile: false, - disabledCountries: [], - }, - router: { - location: { - pathname: '/u/staff', - search: '', - hash: '' - }, - action: 'POP' - } -}; diff --git a/src/profile-v2/__mocks__/viewOtherProfile.mockStore.js b/src/profile-v2/__mocks__/viewOtherProfile.mockStore.js deleted file mode 100644 index 7afdac1..0000000 --- a/src/profile-v2/__mocks__/viewOtherProfile.mockStore.js +++ /dev/null @@ -1,105 +0,0 @@ -module.exports = { - userAccount: { - loading: false, - error: null, - username: 'staff', - email: 'staff@example.com', - bio: 'This is my bio', - name: 'Lemon Seltzer', - country: 'ME', - socialLinks: [ - { - platform: 'facebook', - socialLink: 'https://www.facebook.com/aloha' - }, - { - platform: 'twitter', - socialLink: 'https://www.twitter.com/ALOHA' - } - ], - profileImage: { - imageUrlFull: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_500.jpg?v=1552495012', - imageUrlLarge: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_120.jpg?v=1552495012', - imageUrlMedium: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_50.jpg?v=1552495012', - imageUrlSmall: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_30.jpg?v=1552495012', - hasImage: true - }, - levelOfEducation: 'el', - mailingAddress: null, - extendedProfile: [], - dateJoined: '2017-06-07T00:44:23Z', - accomplishmentsShared: false, - isActive: true, - yearOfBirth: 1901, - goals: null, - languageProficiencies: [ - { - code: 'yo' - } - ], - courseCertificates: null, - requiresParentalConsent: false, - secondaryEmail: null, - timeZone: null, - gender: null, - accountPrivacy: 'custom', - learningGoal: 'advance_career', - }, - profilePage: { - errors: {}, - saveState: null, - savePhotoState: null, - currentlyEditingField: null, - isAuthenticatedUserProfile: false, - account: { - mailingAddress: null, - profileImage: { - imageUrlFull: 'http://localhost:18000/static/images/profiles/default_500.png', - imageUrlLarge: 'http://localhost:18000/static/images/profiles/default_120.png', - imageUrlMedium: 'http://localhost:18000/static/images/profiles/default_50.png', - imageUrlSmall: 'http://localhost:18000/static/images/profiles/default_30.png', - hasImage: false - }, - extendedProfile: [], - dateJoined: '2017-06-07T00:44:19Z', - accomplishmentsShared: false, - email: 'verified@example.com', - username: 'verified', - bio: null, - isActive: true, - yearOfBirth: null, - goals: null, - languageProficiencies: [], - courseCertificates: null, - requiresParentalConsent: true, - name: '', - secondaryEmail: null, - country: null, - socialLinks: [], - timeZone: null, - levelOfEducation: null, - gender: null, - accountPrivacy: 'private' - }, - preferences: { - visibilityName: 'all_users', - visibilityCountry: 'all_users', - visibilityLevelOfEducation: 'all_users', - visibilityLanguageProficiencies: 'all_users', - visibilitySocialLinks: 'all_users', - visibilityBio: 'all_users' - }, - courseCertificates: [], - drafts: {}, - isLoadingProfile: false, - countriesCodesList: ['US', 'CA', 'GB', 'ME'] - }, - router: { - location: { - pathname: '/u/verified', - search: '', - hash: '' - }, - action: 'POP' - } -}; diff --git a/src/profile-v2/__mocks__/viewOwnProfile.mockStore.js b/src/profile-v2/__mocks__/viewOwnProfile.mockStore.js deleted file mode 100644 index 4fb2510..0000000 --- a/src/profile-v2/__mocks__/viewOwnProfile.mockStore.js +++ /dev/null @@ -1,139 +0,0 @@ -module.exports = { - userAccount: { - loading: false, - error: null, - username: 'staff', - email: 'staff@example.com', - bio: 'This is my bio', - name: 'Lemon Seltzer', - country: 'ME', - socialLinks: [ - { - platform: 'facebook', - socialLink: 'https://www.facebook.com/aloha' - }, - { - platform: 'twitter', - socialLink: 'https://www.twitter.com/ALOHA' - } - ], - profileImage: { - imageUrlFull: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_500.jpg?v=1552495012', - imageUrlLarge: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_120.jpg?v=1552495012', - imageUrlMedium: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_50.jpg?v=1552495012', - imageUrlSmall: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_30.jpg?v=1552495012', - hasImage: true - }, - levelOfEducation: 'el', - mailingAddress: null, - extendedProfile: [], - dateJoined: '2017-06-07T00:44:23Z', - accomplishmentsShared: false, - isActive: true, - yearOfBirth: 1901, - goals: null, - languageProficiencies: [ - { - code: 'yo' - } - ], - courseCertificates: null, - requiresParentalConsent: false, - secondaryEmail: null, - timeZone: null, - gender: null, - accountPrivacy: 'custom', - learningGoal: 'advance_career' - }, - profilePage: { - errors: {}, - saveState: null, - savePhotoState: null, - currentlyEditingField: null, - isAuthenticatedUserProfile: true, - account: { - mailingAddress: null, - profileImage: { - imageUrlFull: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_500.jpg?v=1552495012', - imageUrlLarge: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_120.jpg?v=1552495012', - imageUrlMedium: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_50.jpg?v=1552495012', - imageUrlSmall: 'http://localhost:18000/media/profile-images/d2a9bdc2ba165dcefc73265c54bf9a20_30.jpg?v=1552495012', - hasImage: true - }, - extendedProfile: [], - dateJoined: '2017-06-07T00:44:23Z', - accomplishmentsShared: false, - email: 'staff@example.com', - username: 'staff', - bio: 'This is my bio', - isActive: true, - yearOfBirth: 1901, - goals: null, - languageProficiencies: [ - { - code: 'yo' - } - ], - courseCertificates: null, - requiresParentalConsent: false, - name: 'Lemon Seltzer', - secondaryEmail: null, - country: 'ME', - socialLinks: [ - { - platform: 'facebook', - socialLink: 'https://www.facebook.com/aloha' - }, - { - platform: 'twitter', - socialLink: 'https://www.twitter.com/ALOHA' - } - ], - timeZone: null, - levelOfEducation: 'el', - gender: null, - accountPrivacy: 'custom', - learningGoal: 'advance_career' - }, - preferences: { - visibilityUserLocation: 'all_users', - visibilitySocialLinks: 'all_users', - visibilityCertificates: 'private', - visibilityLevelOfEducation: 'private', - visibilityCourseCertificates: 'all_users', - prefLang: 'en', - visibilityBio: 'all_users', - visibilityName: 'private', - visibilityLanguageProficiencies: 'all_users', - visibilityCountry: 'all_users', - accountPrivacy: 'custom', - visibilityLearningGoal: 'private', - }, - courseCertificates: [ - { - username: 'staff', - status: 'downloadable', - courseDisplayName: 'edX Demonstration Course', - grade: '0.89', - courseId: 'course-v1:edX+DemoX+Demo_Course', - courseOrganization: 'edX', - modifiedDate: '2019-03-04T19:31:39.930255Z', - isPassing: true, - downloadUrl: 'http://www.example.com/', - certificateType: 'verified', - createdDate: '2019-03-04T19:31:39.896806Z' - } - ], - drafts: {}, - isLoadingProfile: false, - countriesCodesList: ['US', 'CA', 'GB', 'ME'] - }, - router: { - location: { - pathname: '/u/staff', - search: '', - hash: '' - }, - action: 'POP' - } -}; diff --git a/src/profile-v2/__snapshots__/ProfilePage.test.jsx.snap b/src/profile-v2/__snapshots__/ProfilePage.test.jsx.snap deleted file mode 100644 index 2280c10..0000000 --- a/src/profile-v2/__snapshots__/ProfilePage.test.jsx.snap +++ /dev/null @@ -1,2019 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[` Renders correctly in various states app loading 1`] = ` -
-
-
-
-
- - Profile loading... - -
-
-
-
-
-`; - -exports[` Renders correctly in various states successfully redirected to not found page 1`] = ` -
-
-
-
-
-
-
-
- -
- -
-
-
-

- staffTest -

-
-
-
-
-
-
-
-
-
-
-
-
-

- Profile information -

-
-
-
-
-
-
-

- Username -

- - - -
-

- staffTest -

-
-
-
-
-
-
-
-
-
-`; - -exports[` Renders correctly in various states viewing other profile with all fields 1`] = ` -
-
-
-
-
-
-
-
- -
- -
-
-
-

- verified -

-

- Verified User -

-
- - Member since - - - 2017 - - - -
-
-
-
-
-
-
-
-
-
-
-
-

- Profile information -

-
-
-
-
-
-
-

- Username -

- - - -
-

- verified -

-
-
-
-
-

- Full name -

- - - -
-
-
-

- Verified User -

-
-
-
-
-
-
-
-
-

- Country -

-
-
-

- United States of America -

-
-
-
-
-
-
-
-
-

- Primary language spoken -

-
-
-

- English -

-
-
-
-
-
-
-
-
-

- Education -

-
-
-

- Other education -

-
-
-
-
-
-
-
-
-
-
-

- Bio -

-
-
-

- About me -

-
-
-
-
-
-
-
-
-
-
-
-

- X -

-
-
-

- https://twitter.com/user -

-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`; - -exports[` Renders correctly in various states viewing own profile 1`] = ` -
-
-
-
-
-
-
-
- profile avatar -
-
- -
-
- -
-
-
-

- staff -

-

- Lemon Seltzer -

-
- - Member since - - - 2017 - - - - - - 1 - - certifications - -
-
- -
-
-
-
-
-
-
-
-
-

- Profile information -

-
-
-
-
-
-
-

- Username -

- - - -
-

- staff -

-
-
-
-
-

- Full name -

- - - -
-
-
-

- Lemon Seltzer -

-
-
- -
-
-
-
-
-
-
-

- Country -

-
-
-

- Montenegro -

-
-
- -
-
-
-
-
-
-
-

- Primary language spoken -

-
-
-

- Yoruba -

-
-
- -
-
-
-
-
-
-
-

- Education -

-
-
-

- Elementary/primary school -

-
-
- -
-
-
-
-
-
-
-
-
-

- Bio -

-
-
-

- This is my bio -

-
-
- -
-
-
-
-
-
-
-
-
-
-

- X -

-
-
-
-

- https://www.twitter.com/ALOHA -

-
-
- -
-
-
-
-
-
-

- Facebook -

-
-
-
-

- https://www.facebook.com/aloha -

-
-
- -
-
-
-
-
-
-

- LinkedIn -

-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Your certificates -

-
-
-

- Your learner records information is only visible to you. Only your username and profile image are visible to others on localhost. -

-
-
-
-
-
-
-
-
-
-

- Verified Certificate -

-

- edX Demonstration Course -

-

- From -

-
- edX -
-

- Completed on - 3/4/2019 -

-
- -

- Credential ID -

-
-
-
-
-
-
-
-
-
-`; - -exports[` Renders correctly in various states without credentials service 1`] = ` -
-
-
-
-
-
-
-
- profile avatar -
-
- -
-
- -
-
-
-

- staff -

-

- Lemon Seltzer -

-
- - Member since - - - 2017 - - - - - - 1 - - certifications - -
-
-
-
-
-
-
-
-
-
-
-
-

- Profile information -

-
-
-
-
-
-
-

- Username -

- - - -
-

- staff -

-
-
-
-
-

- Full name -

- - - -
-
-
-

- Lemon Seltzer -

-
-
- -
-
-
-
-
-
-
-

- Country -

-
-
-

- Montenegro -

-
-
- -
-
-
-
-
-
-
-

- Primary language spoken -

-
-
-

- Yoruba -

-
-
- -
-
-
-
-
-
-
-

- Education -

-
-
-

- Elementary/primary school -

-
-
- -
-
-
-
-
-
-
-
-
-

- Bio -

-
-
-

- This is my bio -

-
-
- -
-
-
-
-
-
-
-
-
-
-

- X -

-
-
-
-

- https://www.twitter.com/ALOHA -

-
-
- -
-
-
-
-
-
-

- Facebook -

-
-
-
-

- https://www.facebook.com/aloha -

-
-
- -
-
-
-
-
-
-

- LinkedIn -

-
- -
-
-
-
-
-
-
-
-
-
-
-
-
-
-

- Your certificates -

-
-
-

- Your learner records information is only visible to you. Only your username and profile image are visible to others on localhost. -

-
-
-
-
-
-
-
-
-
-

- Verified Certificate -

-

- edX Demonstration Course -

-

- From -

-
- edX -
-

- Completed on - 3/4/2019 -

-
- -

- Credential ID -

-
-
-
-
-
-
-
-
-
-`; diff --git a/src/profile-v2/assets/avatar.svg b/src/profile-v2/assets/avatar.svg deleted file mode 100644 index d7fe4bc..0000000 --- a/src/profile-v2/assets/avatar.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - - avatar - Created with Sketch. - - - - diff --git a/src/profile-v2/assets/dot-pattern-light.png b/src/profile-v2/assets/dot-pattern-light.png deleted file mode 100644 index c84a3c5..0000000 Binary files a/src/profile-v2/assets/dot-pattern-light.png and /dev/null differ diff --git a/src/profile-v2/assets/micro-masters.svg b/src/profile-v2/assets/micro-masters.svg deleted file mode 100644 index bca900d..0000000 --- a/src/profile-v2/assets/micro-masters.svg +++ /dev/null @@ -1,13 +0,0 @@ - - - - micro-masters - Created with Sketch. - - - - - - - - \ No newline at end of file diff --git a/src/profile-v2/assets/professional-certificate.svg b/src/profile-v2/assets/professional-certificate.svg deleted file mode 100644 index 2940d10..0000000 --- a/src/profile-v2/assets/professional-certificate.svg +++ /dev/null @@ -1 +0,0 @@ -cert-bg-logo \ No newline at end of file diff --git a/src/profile-v2/assets/verified-certificate.svg b/src/profile-v2/assets/verified-certificate.svg deleted file mode 100644 index 2940d10..0000000 --- a/src/profile-v2/assets/verified-certificate.svg +++ /dev/null @@ -1 +0,0 @@ -cert-bg-logo \ No newline at end of file diff --git a/src/profile-v2/data/actions.js b/src/profile-v2/data/actions.js deleted file mode 100644 index b960400..0000000 --- a/src/profile-v2/data/actions.js +++ /dev/null @@ -1,137 +0,0 @@ -import { AsyncActionType } from '../utils'; - -export const FETCH_PROFILE = new AsyncActionType('PROFILE', 'FETCH_PROFILE'); -export const SAVE_PROFILE = new AsyncActionType('PROFILE', 'SAVE_PROFILE'); -export const SAVE_PROFILE_PHOTO = new AsyncActionType('PROFILE', 'SAVE_PROFILE_PHOTO'); -export const DELETE_PROFILE_PHOTO = new AsyncActionType('PROFILE', 'DELETE_PROFILE_PHOTO'); -export const OPEN_FORM = 'OPEN_FORM'; -export const CLOSE_FORM = 'CLOSE_FORM'; -export const UPDATE_DRAFT = 'UPDATE_DRAFT'; -export const RESET_DRAFTS = 'RESET_DRAFTS'; - -export const fetchProfile = username => ({ - type: FETCH_PROFILE.BASE, - payload: { username }, -}); - -export const fetchProfileBegin = () => ({ - type: FETCH_PROFILE.BEGIN, -}); - -export const fetchProfileSuccess = ( - account, - preferences, - courseCertificates, - isAuthenticatedUserProfile, -) => ({ - type: FETCH_PROFILE.SUCCESS, - account, - preferences, - courseCertificates, - isAuthenticatedUserProfile, -}); - -export const fetchProfileReset = () => ({ - type: FETCH_PROFILE.RESET, -}); - -export const saveProfile = (formId, username) => ({ - type: SAVE_PROFILE.BASE, - payload: { - formId, - username, - }, -}); - -export const saveProfileBegin = () => ({ - type: SAVE_PROFILE.BEGIN, -}); - -export const saveProfileSuccess = (account, preferences) => ({ - type: SAVE_PROFILE.SUCCESS, - payload: { - account, - preferences, - }, -}); - -export const saveProfileReset = () => ({ - type: SAVE_PROFILE.RESET, -}); - -export const saveProfileFailure = errors => ({ - type: SAVE_PROFILE.FAILURE, - payload: { errors }, -}); - -export const saveProfilePhoto = (username, formData) => ({ - type: SAVE_PROFILE_PHOTO.BASE, - payload: { - username, - formData, - }, -}); - -export const saveProfilePhotoBegin = () => ({ - type: SAVE_PROFILE_PHOTO.BEGIN, -}); - -export const saveProfilePhotoSuccess = profileImage => ({ - type: SAVE_PROFILE_PHOTO.SUCCESS, - payload: { profileImage }, -}); - -export const saveProfilePhotoReset = () => ({ - type: SAVE_PROFILE_PHOTO.RESET, -}); - -export const saveProfilePhotoFailure = error => ({ - type: SAVE_PROFILE_PHOTO.FAILURE, - payload: { error }, -}); - -export const deleteProfilePhoto = username => ({ - type: DELETE_PROFILE_PHOTO.BASE, - payload: { - username, - }, -}); - -export const deleteProfilePhotoBegin = () => ({ - type: DELETE_PROFILE_PHOTO.BEGIN, -}); - -export const deleteProfilePhotoSuccess = profileImage => ({ - type: DELETE_PROFILE_PHOTO.SUCCESS, - payload: { profileImage }, -}); - -export const deleteProfilePhotoReset = () => ({ - type: DELETE_PROFILE_PHOTO.RESET, -}); - -export const openForm = formId => ({ - type: OPEN_FORM, - payload: { - formId, - }, -}); - -export const closeForm = formId => ({ - type: CLOSE_FORM, - payload: { - formId, - }, -}); - -export const updateDraft = (name, value) => ({ - type: UPDATE_DRAFT, - payload: { - name, - value, - }, -}); - -export const resetDrafts = () => ({ - type: RESET_DRAFTS, -}); diff --git a/src/profile-v2/data/actions.test.js b/src/profile-v2/data/actions.test.js deleted file mode 100644 index 275d695..0000000 --- a/src/profile-v2/data/actions.test.js +++ /dev/null @@ -1,98 +0,0 @@ -import { - SAVE_PROFILE_PHOTO, - saveProfilePhotoBegin, - saveProfilePhotoSuccess, - saveProfilePhotoFailure, - saveProfilePhotoReset, - saveProfilePhoto, - DELETE_PROFILE_PHOTO, - deleteProfilePhotoBegin, - deleteProfilePhotoSuccess, - deleteProfilePhotoReset, - deleteProfilePhoto, -} from './actions'; - -describe('SAVE profile photo actions', () => { - it('should create an action to signal the start of a profile photo save', () => { - const formData = 'multipart form data'; - const expectedAction = { - type: SAVE_PROFILE_PHOTO.BASE, - payload: { - username: 'myusername', - formData, - }, - }; - expect(saveProfilePhoto('myusername', formData)).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo save beginning', () => { - const expectedAction = { - type: SAVE_PROFILE_PHOTO.BEGIN, - }; - expect(saveProfilePhotoBegin()).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo save success', () => { - const newPhotoData = { hasImage: true }; - const expectedAction = { - type: SAVE_PROFILE_PHOTO.SUCCESS, - payload: { - profileImage: newPhotoData, - }, - }; - expect(saveProfilePhotoSuccess(newPhotoData)).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo save reset', () => { - const expectedAction = { - type: SAVE_PROFILE_PHOTO.RESET, - }; - expect(saveProfilePhotoReset()).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo save failure', () => { - const error = 'Test failure'; - const expectedAction = { - type: SAVE_PROFILE_PHOTO.FAILURE, - payload: { error }, - }; - expect(saveProfilePhotoFailure(error)).toEqual(expectedAction); - }); -}); - -describe('DELETE profile photo actions', () => { - it('should create an action to signal the start of a profile photo deletion', () => { - const expectedAction = { - type: DELETE_PROFILE_PHOTO.BASE, - payload: { - username: 'myusername', - }, - }; - expect(deleteProfilePhoto('myusername')).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo deletion beginning', () => { - const expectedAction = { - type: DELETE_PROFILE_PHOTO.BEGIN, - }; - expect(deleteProfilePhotoBegin()).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo deletion success', () => { - const defaultPhotoData = { hasImage: false }; - const expectedAction = { - type: DELETE_PROFILE_PHOTO.SUCCESS, - payload: { - profileImage: defaultPhotoData, - }, - }; - expect(deleteProfilePhotoSuccess(defaultPhotoData)).toEqual(expectedAction); - }); - - it('should create an action to signal user profile photo deletion reset', () => { - const expectedAction = { - type: DELETE_PROFILE_PHOTO.RESET, - }; - expect(deleteProfilePhotoReset()).toEqual(expectedAction); - }); -}); diff --git a/src/profile-v2/data/constants.js b/src/profile-v2/data/constants.js deleted file mode 100644 index de97069..0000000 --- a/src/profile-v2/data/constants.js +++ /dev/null @@ -1,33 +0,0 @@ -const EDUCATION_LEVELS = [ - 'p', - 'm', - 'b', - 'a', - 'hs', - 'jhs', - 'el', - 'none', - 'other', -]; - -const SOCIAL = { - linkedin: { - title: 'LinkedIn', - }, - twitter: { - title: 'Twitter', - }, - facebook: { - title: 'Facebook', - }, -}; - -const FIELD_LABELS = { - COUNTRY: 'country', -}; - -export { - EDUCATION_LEVELS, - SOCIAL, - FIELD_LABELS, -}; diff --git a/src/profile-v2/data/mock_data.js b/src/profile-v2/data/mock_data.js deleted file mode 100644 index c43ed98..0000000 --- a/src/profile-v2/data/mock_data.js +++ /dev/null @@ -1,7 +0,0 @@ -const mockData = { - learningGoal: 'advance_career', - editMode: 'static', - visibilityLearningGoal: 'private', -}; - -export default mockData; diff --git a/src/profile-v2/data/pact-profile.test.js b/src/profile-v2/data/pact-profile.test.js deleted file mode 100644 index abd14e6..0000000 --- a/src/profile-v2/data/pact-profile.test.js +++ /dev/null @@ -1,84 +0,0 @@ -// This test file simply creates a contract that defines -// expectations and correct responses from the Pact stub server. - -import path from 'path'; - -import { PactV3, MatchersV3 } from '@pact-foundation/pact'; - -import { initializeMockApp, getConfig, setConfig } from '@edx/frontend-platform'; -import { getAccount } from './services'; - -const expectedUserInfo200 = { - username: 'staff', - email: 'staff@example.com', - bio: 'This is my bio', - name: 'Lemon Seltzer', - country: 'ME', - dateJoined: '2017-06-07T00:44:23Z', - isActive: true, - yearOfBirth: 1901, - languageProficiencies: [], - levelOfEducation: null, - profileImage: {}, - socialLinks: [], -}; - -const provider = new PactV3({ - log: path.resolve(process.cwd(), 'src/pact-logs/pact.log'), - dir: path.resolve(process.cwd(), 'src/pacts'), - consumer: 'frontend-app-profile', - provider: 'edx-platform', -}); - -describe('getAccount for one username', () => { - beforeAll(async () => { - initializeMockApp(); - }); - it('returns a HTTP 200 and user information', async () => { - const username200 = 'staff'; - await provider.addInteraction({ - states: [{ description: "I have a user's basic information" }], - uponReceiving: "A request for user's basic information", - withRequest: { - method: 'GET', - path: `/api/user/v1/accounts/${username200}`, - headers: {}, - }, - willRespondWith: { - status: 200, - headers: {}, - body: MatchersV3.like(expectedUserInfo200), - }, - }); - return provider.executeTest(async (mockserver) => { - setConfig({ - ...getConfig(), - LMS_BASE_URL: mockserver.url, - }); - const response = await getAccount(username200); - expect(response).toEqual(expectedUserInfo200); - }); - }); - - it('Account does not exist', async () => { - const username404 = 'staff_not_found'; - await provider.addInteraction({ - states: [{ description: "Account and user's information does not exist" }], - uponReceiving: "A request for user's basic information", - withRequest: { - method: 'GET', - path: `/api/user/v1/accounts/${username404}`, - }, - willRespondWith: { - status: 404, - }, - }); - await provider.executeTest(async (mockserver) => { - setConfig({ - ...getConfig(), - LMS_BASE_URL: mockserver.url, - }); - await expect(getAccount(username404).then((response) => response.data)).rejects.toThrow('Request failed with status code 404'); - }); - }); -}); diff --git a/src/profile-v2/data/reducers.js b/src/profile-v2/data/reducers.js deleted file mode 100644 index 3e4760c..0000000 --- a/src/profile-v2/data/reducers.js +++ /dev/null @@ -1,181 +0,0 @@ -import { - SAVE_PROFILE, - SAVE_PROFILE_PHOTO, - DELETE_PROFILE_PHOTO, - CLOSE_FORM, - OPEN_FORM, - FETCH_PROFILE, - UPDATE_DRAFT, - RESET_DRAFTS, -} from './actions'; - -export const initialState = { - errors: {}, - saveState: null, - savePhotoState: null, - currentlyEditingField: null, - account: { - socialLinks: [], - languageProficiencies: [], - name: '', - bio: '', - country: '', - levelOfEducation: '', - profileImage: {}, - yearOfBirth: '', - }, - preferences: { - visibilityName: '', - visibilityBio: '', - visibilityCountry: '', - visibilityLevelOfEducation: '', - visibilitySocialLinks: '', - visibilityLanguageProficiencies: '', - }, - courseCertificates: [], - drafts: {}, - isLoadingProfile: true, - isAuthenticatedUserProfile: false, - disabledCountries: ['RU'], - countriesCodesList: [], -}; - -const profilePage = (state = initialState, action = {}) => { - switch (action.type) { - case FETCH_PROFILE.BEGIN: - return { - ...state, - // TODO: uncomment this line after ARCH-438 Image Post API returns the url - // is complete. Right now we refetch the whole profile causing us to show a full reload - // instead of a partial one. - // isLoadingProfile: true, - }; - case FETCH_PROFILE.SUCCESS: - return { - ...state, - account: { - ...state.account, - ...action.account, - socialLinks: action.account.socialLinks || [], - languageProficiencies: action.account.languageProficiencies || [], - }, - preferences: action.preferences, - courseCertificates: action.courseCertificates || [], - isLoadingProfile: false, - isAuthenticatedUserProfile: action.isAuthenticatedUserProfile, - countriesCodesList: action.countriesCodesList || [], - }; - case SAVE_PROFILE.BEGIN: - return { - ...state, - saveState: 'pending', - errors: {}, - }; - case SAVE_PROFILE.SUCCESS: - return { - ...state, - saveState: 'complete', - errors: {}, - account: action.payload.account !== null ? { - ...state.account, - ...action.payload.account, - socialLinks: action.payload.account.socialLinks || [], - languageProficiencies: action.payload.account.languageProficiencies || [], - } : state.account, - preferences: { ...state.preferences, ...action.payload.preferences }, - }; - case SAVE_PROFILE.FAILURE: - return { - ...state, - saveState: 'error', - isLoadingProfile: false, - errors: { ...state.errors, ...action.payload.errors }, - }; - case SAVE_PROFILE.RESET: - return { - ...state, - saveState: null, - isLoadingProfile: false, - errors: {}, - }; - case SAVE_PROFILE_PHOTO.BEGIN: - return { - ...state, - savePhotoState: 'pending', - errors: {}, - }; - case SAVE_PROFILE_PHOTO.SUCCESS: - return { - ...state, - account: { ...state.account, profileImage: action.payload.profileImage }, - savePhotoState: 'complete', - errors: {}, - }; - case SAVE_PROFILE_PHOTO.FAILURE: - return { - ...state, - savePhotoState: 'error', - errors: { ...state.errors, photo: action.payload.error }, - }; - case SAVE_PROFILE_PHOTO.RESET: - return { - ...state, - savePhotoState: null, - errors: {}, - }; - case DELETE_PROFILE_PHOTO.BEGIN: - return { - ...state, - savePhotoState: 'pending', - errors: {}, - }; - case DELETE_PROFILE_PHOTO.SUCCESS: - return { - ...state, - account: { ...state.account, profileImage: action.payload.profileImage }, - savePhotoState: 'complete', - errors: {}, - }; - case DELETE_PROFILE_PHOTO.FAILURE: - return { - ...state, - savePhotoState: 'error', - errors: { ...state.errors, ...action.payload.errors }, - }; - case DELETE_PROFILE_PHOTO.RESET: - return { - ...state, - savePhotoState: null, - errors: {}, - }; - case UPDATE_DRAFT: - return { - ...state, - drafts: { ...state.drafts, [action.payload.name]: action.payload.value }, - }; - case RESET_DRAFTS: - return { - ...state, - drafts: {}, - }; - case OPEN_FORM: - return { - ...state, - currentlyEditingField: action.payload.formId, - drafts: {}, - }; - case CLOSE_FORM: - if (action.payload.formId === state.currentlyEditingField) { - return { - ...state, - currentlyEditingField: null, - drafts: {}, - }; - } - return state; - default: - return state; - } -}; - -export default profilePage; diff --git a/src/profile-v2/data/sagas.js b/src/profile-v2/data/sagas.js deleted file mode 100644 index b64c3fe..0000000 --- a/src/profile-v2/data/sagas.js +++ /dev/null @@ -1,191 +0,0 @@ -import { history } from '@edx/frontend-platform'; -import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; -import pick from 'lodash.pick'; -import { - all, - call, - delay, - put, - select, - takeEvery, -} from 'redux-saga/effects'; -import { - closeForm, - deleteProfilePhotoBegin, - deleteProfilePhotoReset, - deleteProfilePhotoSuccess, - DELETE_PROFILE_PHOTO, - fetchProfileBegin, - fetchProfileReset, - fetchProfileSuccess, - FETCH_PROFILE, - resetDrafts, - saveProfileBegin, - saveProfileFailure, - saveProfileReset, - saveProfileSuccess, - SAVE_PROFILE, - saveProfilePhotoBegin, - saveProfilePhotoReset, - saveProfilePhotoSuccess, - SAVE_PROFILE_PHOTO, -} from './actions'; -import { handleSaveProfileSelector, userAccountSelector } from './selectors'; -import * as ProfileApiService from './services'; - -export function* handleFetchProfile(action) { - const { username } = action.payload; - const userAccount = yield select(userAccountSelector); - const isAuthenticatedUserProfile = username === getAuthenticatedUser().username; - let preferences = {}; - let account = userAccount; - let courseCertificates = null; - let countriesCodesList = []; - - try { - yield put(fetchProfileBegin()); - - const calls = [ - call(ProfileApiService.getAccount, username), - call(ProfileApiService.getCourseCertificates, username), - call(ProfileApiService.getCountryList), - ]; - - if (isAuthenticatedUserProfile) { - calls.push(call(ProfileApiService.getPreferences, username)); - } - - const result = yield all(calls); - - if (isAuthenticatedUserProfile) { - [account, courseCertificates, countriesCodesList, preferences] = result; - } else { - [account, courseCertificates, countriesCodesList] = result; - } - - 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, - courseCertificates, - isAuthenticatedUserProfile, - countriesCodesList, - )); - - yield put(fetchProfileReset()); - } catch (e) { - if (e.response.status === 404) { - history.push('/notfound'); - } else { - throw e; - } - } -} - -export function* handleSaveProfile(action) { - try { - const { drafts, preferences } = yield select(handleSaveProfileSelector); - - const accountDrafts = pick(drafts, [ - 'bio', - 'country', - 'levelOfEducation', - 'languageProficiencies', - 'name', - 'socialLinks', - ]); - - const preferencesDrafts = pick(drafts, [ - 'visibilityBio', - 'visibilityCountry', - 'visibilityLevelOfEducation', - 'visibilityLanguageProficiencies', - 'visibilityName', - 'visibilitySocialLinks', - ]); - - if (Object.keys(preferencesDrafts).length > 0) { - preferencesDrafts.accountPrivacy = 'custom'; - } - - yield put(saveProfileBegin()); - let accountResult = null; - - if (Object.keys(accountDrafts).length > 0) { - accountResult = yield call( - ProfileApiService.patchProfile, - action.payload.username, - accountDrafts, - ); - } - - let preferencesResult = preferences; - if (Object.keys(preferencesDrafts).length > 0) { - yield call(ProfileApiService.patchPreferences, action.payload.username, preferencesDrafts); - // TODO: Temporary deoptimization since the patchPreferences call doesn't return anything. - - preferencesResult = yield call(ProfileApiService.getPreferences, action.payload.username); - } - - yield put(saveProfileSuccess(accountResult, preferencesResult)); - yield delay(1000); - yield put(closeForm(action.payload.formId)); - yield delay(300); - yield put(saveProfileReset()); - yield put(resetDrafts()); - } catch (e) { - if (e.processedData && e.processedData.fieldErrors) { - yield put(saveProfileFailure(e.processedData.fieldErrors)); - } else { - yield put(saveProfileReset()); - throw e; - } - } -} - -export function* handleSaveProfilePhoto(action) { - const { username, formData } = action.payload; - - try { - yield put(saveProfilePhotoBegin()); - const photoResult = yield call(ProfileApiService.postProfilePhoto, username, formData); - yield put(saveProfilePhotoSuccess(photoResult)); - yield put(saveProfilePhotoReset()); - } catch (e) { - yield put(saveProfilePhotoReset()); - } -} - -export function* handleDeleteProfilePhoto(action) { - const { username } = action.payload; - - try { - yield put(deleteProfilePhotoBegin()); - const photoResult = yield call(ProfileApiService.deleteProfilePhoto, username); - yield put(deleteProfilePhotoSuccess(photoResult)); - yield put(deleteProfilePhotoReset()); - } catch (e) { - yield put(deleteProfilePhotoReset()); - } -} - -export default function* profileSaga() { - yield takeEvery(FETCH_PROFILE.BASE, handleFetchProfile); - yield takeEvery(SAVE_PROFILE.BASE, handleSaveProfile); - yield takeEvery(SAVE_PROFILE_PHOTO.BASE, handleSaveProfilePhoto); - yield takeEvery(DELETE_PROFILE_PHOTO.BASE, handleDeleteProfilePhoto); -} diff --git a/src/profile-v2/data/sagas.test.js b/src/profile-v2/data/sagas.test.js deleted file mode 100644 index 2da09b3..0000000 --- a/src/profile-v2/data/sagas.test.js +++ /dev/null @@ -1,167 +0,0 @@ -import { - takeEvery, - put, - call, - delay, - select, - all, -} from 'redux-saga/effects'; -import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; - -import * as profileActions from './actions'; -import { handleSaveProfileSelector, userAccountSelector } from './selectors'; - -jest.mock('./services', () => ({ - getProfile: jest.fn(), - patchProfile: jest.fn(), - postProfilePhoto: jest.fn(), - deleteProfilePhoto: jest.fn(), - getPreferences: jest.fn(), - getAccount: jest.fn(), - getCourseCertificates: jest.fn(), - getCountryList: jest.fn(), -})); - -jest.mock('@edx/frontend-platform/auth', () => ({ - getAuthenticatedUser: jest.fn(), -})); - -/* eslint-disable import/first */ -import profileSaga, { - handleFetchProfile, - handleSaveProfile, - handleSaveProfilePhoto, - handleDeleteProfilePhoto, -} from './sagas'; -import * as ProfileApiService from './services'; -/* eslint-enable import/first */ - -describe('RootSaga', () => { - describe('profileSaga', () => { - it('should pass actions to the correct sagas', () => { - const gen = profileSaga(); - - expect(gen.next().value) - .toEqual(takeEvery(profileActions.FETCH_PROFILE.BASE, handleFetchProfile)); - expect(gen.next().value) - .toEqual(takeEvery(profileActions.SAVE_PROFILE.BASE, handleSaveProfile)); - expect(gen.next().value) - .toEqual(takeEvery(profileActions.SAVE_PROFILE_PHOTO.BASE, handleSaveProfilePhoto)); - expect(gen.next().value) - .toEqual(takeEvery(profileActions.DELETE_PROFILE_PHOTO.BASE, handleDeleteProfilePhoto)); - - expect(gen.next().value).toBeUndefined(); - }); - }); - - describe('handleFetchProfile', () => { - it('should fetch certificates and preferences for the current user profile', () => { - const userAccount = { - username: 'gonzo', - other: 'data', - }; - getAuthenticatedUser.mockReturnValue(userAccount); - const selectorData = { - userAccount, - }; - - const action = profileActions.fetchProfile('gonzo'); - const gen = handleFetchProfile(action); - - const result = [userAccount, [1, 2, 3], [], { preferences: 'stuff' }]; - - expect(gen.next().value).toEqual(select(userAccountSelector)); - expect(gen.next(selectorData).value).toEqual(put(profileActions.fetchProfileBegin())); - expect(gen.next().value).toEqual(all([ - call(ProfileApiService.getAccount, 'gonzo'), - call(ProfileApiService.getCourseCertificates, 'gonzo'), - call(ProfileApiService.getCountryList), - call(ProfileApiService.getPreferences, 'gonzo'), - ])); - expect(gen.next(result).value) - .toEqual(put(profileActions.fetchProfileSuccess(userAccount, result[3], result[1], true, []))); - expect(gen.next().value).toEqual(put(profileActions.fetchProfileReset())); - expect(gen.next().value).toBeUndefined(); - }); - - it('should fetch certificates and profile for some other user profile', () => { - const userAccount = { - username: 'gonzo', - other: 'data', - }; - const countriesCodesList = [{ code: 'AX' }, { code: 'AL' }]; - getAuthenticatedUser.mockReturnValue(userAccount); - const selectorData = { - userAccount, - }; - - const action = profileActions.fetchProfile('booyah'); - const gen = handleFetchProfile(action); - - const result = [{}, [1, 2, 3], countriesCodesList]; - - expect(gen.next().value).toEqual(select(userAccountSelector)); - expect(gen.next(selectorData).value).toEqual(put(profileActions.fetchProfileBegin())); - expect(gen.next().value).toEqual(all([ - call(ProfileApiService.getAccount, 'booyah'), - call(ProfileApiService.getCourseCertificates, 'booyah'), - call(ProfileApiService.getCountryList), - ])); - expect(gen.next(result).value) - .toEqual(put(profileActions.fetchProfileSuccess(result[0], {}, result[1], false, countriesCodesList))); - expect(gen.next().value).toEqual(put(profileActions.fetchProfileReset())); - expect(gen.next().value).toBeUndefined(); - }); - }); - - describe('handleSaveProfile', () => { - const selectorData = { - username: 'my username', - drafts: { - name: 'Full Name', - }, - preferences: {}, - }; - - it('should successfully process a saveProfile request if there are no exceptions', () => { - const action = profileActions.saveProfile('ze form id', 'my username'); - const gen = handleSaveProfile(action); - const profile = { - name: 'Full Name', - levelOfEducation: 'b', - }; - expect(gen.next().value).toEqual(select(handleSaveProfileSelector)); - expect(gen.next(selectorData).value).toEqual(put(profileActions.saveProfileBegin())); - expect(gen.next().value).toEqual(call(ProfileApiService.patchProfile, 'my username', { - name: 'Full Name', - })); - expect(gen.next(profile).value).toEqual(put(profileActions.saveProfileSuccess(profile, {}))); - expect(gen.next().value).toEqual(delay(1000)); - expect(gen.next().value).toEqual(put(profileActions.closeForm('ze form id'))); - expect(gen.next().value).toEqual(delay(300)); - expect(gen.next().value).toEqual(put(profileActions.saveProfileReset())); - expect(gen.next().value).toEqual(put(profileActions.resetDrafts())); - expect(gen.next().value).toBeUndefined(); - }); - - it('should successfully publish a failure action on exception', () => { - const error = new Error('uhoh'); - error.processedData = { - fieldErrors: { - uhoh: 'not good', - }, - }; - const action = profileActions.saveProfile( - 'ze form id', - 'my username', - ); - const gen = handleSaveProfile(action); - - expect(gen.next().value).toEqual(select(handleSaveProfileSelector)); - expect(gen.next(selectorData).value).toEqual(put(profileActions.saveProfileBegin())); - const result = gen.throw(error); - expect(result.value).toEqual(put(profileActions.saveProfileFailure({ uhoh: 'not good' }))); - expect(gen.next().value).toBeUndefined(); - }); - }); -}); diff --git a/src/profile-v2/data/selectors.js b/src/profile-v2/data/selectors.js deleted file mode 100644 index d398295..0000000 --- a/src/profile-v2/data/selectors.js +++ /dev/null @@ -1,338 +0,0 @@ -import { createSelector } from 'reselect'; -import { - getLocale, - getLanguageList, - getCountryList, - getCountryMessages, - getLanguageMessages, -} from '@edx/frontend-platform/i18n'; - -export const formIdSelector = (state, props) => props.formId; -export const userAccountSelector = state => state.userAccount; -export const profileAccountSelector = state => state.profilePage.account; -export const profileDraftsSelector = state => state.profilePage.drafts; -export const accountPrivacySelector = state => state.profilePage.preferences.accountPrivacy; -export const profilePreferencesSelector = state => state.profilePage.preferences; -export const profileCourseCertificatesSelector = state => state.profilePage.courseCertificates; -export const saveStateSelector = state => state.profilePage.saveState; -export const savePhotoStateSelector = state => state.profilePage.savePhotoState; -export const isLoadingProfileSelector = state => state.profilePage.isLoadingProfile; -export const currentlyEditingFieldSelector = state => state.profilePage.currentlyEditingField; -export const accountErrorsSelector = state => state.profilePage.errors; -export const isAuthenticatedUserProfileSelector = state => state.profilePage.isAuthenticatedUserProfile; -export const countriesCodesListSelector = state => state.profilePage.countriesCodesList; - -export const editableFormModeSelector = createSelector( - profileAccountSelector, - isAuthenticatedUserProfileSelector, - profileCourseCertificatesSelector, - formIdSelector, - currentlyEditingFieldSelector, - (account, isAuthenticatedUserProfile, certificates, formId, currentlyEditingField) => { - let propExists = account[formId] != null && account[formId].length > 0; - propExists = formId === 'certificates' ? certificates.length > 0 : propExists; - if (!isAuthenticatedUserProfile) { - return 'static'; - } - if (formId === currentlyEditingField) { - return 'editing'; - } - - if (!propExists) { - return 'empty'; - } - - return 'editable'; - }, -); - -export const accountDraftsFieldSelector = createSelector( - formIdSelector, - profileDraftsSelector, - (formId, drafts) => drafts[formId], -); - -export const visibilityDraftsFieldSelector = createSelector( - formIdSelector, - profileDraftsSelector, - (formId, drafts) => drafts[`visibility${formId.charAt(0).toUpperCase() + formId.slice(1)}`], -); - -export const formErrorSelector = createSelector( - accountErrorsSelector, - formIdSelector, - (errors, formId) => (errors[formId] ? errors[formId].userMessage : null), -); - -export const editableFormSelector = createSelector( - editableFormModeSelector, - formErrorSelector, - saveStateSelector, - (editMode, error, saveState) => ({ - editMode, - error, - saveState, - }), -); - -export const localeSelector = () => getLocale(); -export const countryMessagesSelector = createSelector( - localeSelector, - locale => getCountryMessages(locale), -); -export const languageMessagesSelector = createSelector( - localeSelector, - locale => getLanguageMessages(locale), -); - -export const sortedLanguagesSelector = createSelector( - localeSelector, - locale => getLanguageList(locale), -); - -export const sortedCountriesSelector = createSelector( - localeSelector, - countriesCodesListSelector, - profileAccountSelector, - (locale, countriesCodesList, profileAccount) => { - const countryList = getCountryList(locale); - const userCountry = profileAccount.country; - - return countryList.filter(({ code }) => code === userCountry || countriesCodesList.find(x => x === code)); - }, -); - -export const preferredLanguageSelector = createSelector( - editableFormSelector, - sortedLanguagesSelector, - languageMessagesSelector, - (editableForm, sortedLanguages, languageMessages) => ({ - ...editableForm, - sortedLanguages, - languageMessages, - }), -); - -export const countrySelector = createSelector( - editableFormSelector, - sortedCountriesSelector, - countryMessagesSelector, - countriesCodesListSelector, - profileAccountSelector, - (editableForm, translatedCountries, countryMessages, countriesCodesList, account) => ({ - ...editableForm, - translatedCountries, - countryMessages, - countriesCodesList, - committedCountry: account.country, - }), -); - -export const certificatesSelector = createSelector( - editableFormSelector, - profileCourseCertificatesSelector, - (editableForm, certificates) => ({ - ...editableForm, - certificates, - value: certificates, - }), -); - -export const profileImageSelector = createSelector( - profileAccountSelector, - account => (account.profileImage != null - ? { - src: account.profileImage.imageUrlFull, - isDefault: !account.profileImage.hasImage, - } - : {}), -); - -export const handleSaveProfileSelector = createSelector( - profileDraftsSelector, - profilePreferencesSelector, - (drafts, preferences) => ({ - drafts, - preferences, - }), -); - -const socialLinksByPlatformSelector = createSelector( - profileAccountSelector, - (account) => { - const linksByPlatform = {}; - if (Array.isArray(account.socialLinks)) { - account.socialLinks.forEach((socialLink) => { - linksByPlatform[socialLink.platform] = socialLink; - }); - } - return linksByPlatform; - }, -); - -const draftSocialLinksByPlatformSelector = createSelector( - profileDraftsSelector, - (drafts) => { - const linksByPlatform = {}; - if (Array.isArray(drafts.socialLinks)) { - drafts.socialLinks.forEach((socialLink) => { - linksByPlatform[socialLink.platform] = socialLink; - }); - } - return linksByPlatform; - }, -); - -export const formSocialLinksSelector = createSelector( - socialLinksByPlatformSelector, - draftSocialLinksByPlatformSelector, - (linksByPlatform, draftLinksByPlatform) => { - const knownPlatforms = ['twitter', 'facebook', 'linkedin']; - const socialLinks = []; - knownPlatforms.forEach((platform) => { - if (draftLinksByPlatform[platform] !== undefined) { - socialLinks.push(draftLinksByPlatform[platform]); - } else if (linksByPlatform[platform] !== undefined) { - socialLinks.push(linksByPlatform[platform]); - } else { - socialLinks.push({ - platform, - socialLink: null, - }); - } - }); - return socialLinks; - }, -); - -export const visibilitiesSelector = createSelector( - profilePreferencesSelector, - accountPrivacySelector, - (preferences, accountPrivacy) => { - switch (accountPrivacy) { - case 'custom': - return { - visibilityBio: preferences.visibilityBio || '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 { - visibilityBio: 'private', - visibilityCountry: 'private', - visibilityLevelOfEducation: 'private', - visibilityLanguageProficiencies: 'private', - visibilityName: 'private', - visibilitySocialLinks: 'private', - }; - case 'all_users': - default: - return { - visibilityBio: 'all_users', - visibilityCountry: 'all_users', - visibilityLevelOfEducation: 'all_users', - visibilityLanguageProficiencies: 'all_users', - visibilityName: 'all_users', - visibilitySocialLinks: 'all_users', - }; - } - }, -); - -function chooseFormValue(draft, committed) { - return draft !== undefined ? draft : committed; -} - -export const formValuesSelector = createSelector( - profileAccountSelector, - visibilitiesSelector, - profileDraftsSelector, - profileCourseCertificatesSelector, - formSocialLinksSelector, - (account, visibilities, drafts, courseCertificates, socialLinks) => ({ - bio: chooseFormValue(drafts.bio, account.bio), - visibilityBio: chooseFormValue(drafts.visibilityBio, visibilities.visibilityBio), - courseCertificates, - country: chooseFormValue(drafts.country, account.country), - visibilityCountry: chooseFormValue(drafts.visibilityCountry, visibilities.visibilityCountry), - levelOfEducation: chooseFormValue(drafts.levelOfEducation, account.levelOfEducation), - visibilityLevelOfEducation: chooseFormValue( - drafts.visibilityLevelOfEducation, - visibilities.visibilityLevelOfEducation, - ), - languageProficiencies: chooseFormValue( - drafts.languageProficiencies, - account.languageProficiencies, - ), - visibilityLanguageProficiencies: chooseFormValue( - drafts.visibilityLanguageProficiencies, - visibilities.visibilityLanguageProficiencies, - ), - name: chooseFormValue(drafts.name, account.name), - visibilityName: chooseFormValue(drafts.visibilityName, visibilities.visibilityName), - socialLinks, - visibilitySocialLinks: chooseFormValue( - drafts.visibilitySocialLinks, - visibilities.visibilitySocialLinks, - ), - }), -); - -export const profilePageSelector = createSelector( - profileAccountSelector, - formValuesSelector, - profileImageSelector, - saveStateSelector, - savePhotoStateSelector, - isLoadingProfileSelector, - draftSocialLinksByPlatformSelector, - accountErrorsSelector, - isAuthenticatedUserProfileSelector, - ( - account, - formValues, - profileImage, - saveState, - savePhotoState, - isLoadingProfile, - draftSocialLinksByPlatform, - errors, - isAuthenticatedUserProfile, - ) => ({ - username: account.username, - profileImage, - requiresParentalConsent: account.requiresParentalConsent, - dateJoined: account.dateJoined, - yearOfBirth: account.yearOfBirth, - - bio: formValues.bio, - visibilityBio: formValues.visibilityBio, - - courseCertificates: formValues.courseCertificates, - - country: formValues.country, - visibilityCountry: formValues.visibilityCountry, - - levelOfEducation: formValues.levelOfEducation, - visibilityLevelOfEducation: formValues.visibilityLevelOfEducation, - - languageProficiencies: formValues.languageProficiencies, - visibilityLanguageProficiencies: formValues.visibilityLanguageProficiencies, - - name: formValues.name, - visibilityName: formValues.visibilityName, - - socialLinks: formValues.socialLinks, - visibilitySocialLinks: formValues.visibilitySocialLinks, - draftSocialLinksByPlatform, - - saveState, - savePhotoState, - isLoadingProfile, - photoUploadError: errors.photo || null, - isAuthenticatedUserProfile, - }), -); diff --git a/src/profile-v2/data/services.js b/src/profile-v2/data/services.js deleted file mode 100644 index e6104df..0000000 --- a/src/profile-v2/data/services.js +++ /dev/null @@ -1,168 +0,0 @@ -import { ensureConfig, getConfig } from '@edx/frontend-platform'; -import { getAuthenticatedHttpClient as getHttpClient } from '@edx/frontend-platform/auth'; -import { logError } from '@edx/frontend-platform/logging'; -import { camelCaseObject, convertKeyNames, snakeCaseObject } from '../utils'; -import { FIELD_LABELS } from './constants'; - -ensureConfig(['LMS_BASE_URL'], 'Profile API service'); - -function processAccountData(data) { - const processedData = camelCaseObject(data); - return { - ...processedData, - socialLinks: Array.isArray(processedData.socialLinks) ? processedData.socialLinks : [], - languageProficiencies: Array.isArray(processedData.languageProficiencies) - ? processedData.languageProficiencies : [], - name: processedData.name || null, - bio: processedData.bio || null, - country: processedData.country || null, - levelOfEducation: processedData.levelOfEducation || null, - profileImage: processedData.profileImage || {}, - yearOfBirth: processedData.yearOfBirth || null, - }; -} - -function processAndThrowError(error, errorDataProcessor) { - const processedError = Object.create(error); - if (error.response && error.response.data && typeof error.response.data === 'object') { - processedError.processedData = errorDataProcessor(error.response.data); - throw processedError; - } else { - throw error; - } -} - -export async function getAccount(username) { - const { data } = await getHttpClient().get(`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}`); - - return processAccountData(data); -} - -export async function patchProfile(username, params) { - const processedParams = snakeCaseObject(params); - - const { data } = await getHttpClient() - .patch(`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}`, processedParams, { - headers: { - 'Content-Type': 'application/merge-patch+json', - }, - }) - .catch((error) => { - processAndThrowError(error, processAccountData); - }); - - return processAccountData(data); -} - -export async function postProfilePhoto(username, formData) { - // eslint-disable-next-line no-unused-vars - const { data } = await getHttpClient().post( - `${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}/image`, - formData, - { - headers: { - 'Content-Type': 'multipart/form-data', - }, - }, - ).catch((error) => { - processAndThrowError(error, camelCaseObject); - }); - - // TODO: Someday in the future the POST photo endpoint - // will return the new values. At that time we should - // use the commented line below instead of the separate - // getAccount request that follows. - // return camelCaseObject(data); - const updatedData = await getAccount(username); - return updatedData.profileImage; -} - -export async function deleteProfilePhoto(username) { - // eslint-disable-next-line no-unused-vars - const { data } = await getHttpClient().delete(`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}/image`); - - // TODO: Someday in the future the POST photo endpoint - // will return the new values. At that time we should - // use the commented line below instead of the separate - // getAccount request that follows. - // return camelCaseObject(data); - const updatedData = await getAccount(username); - return updatedData.profileImage; -} - -export async function getPreferences(username) { - const { data } = await getHttpClient().get(`${getConfig().LMS_BASE_URL}/api/user/v1/preferences/${username}`); - - return camelCaseObject(data); -} - -export async function patchPreferences(username, params) { - let processedParams = snakeCaseObject(params); - processedParams = convertKeyNames(processedParams, { - visibility_bio: 'visibility.bio', - visibility_course_certificates: 'visibility.course_certificates', - visibility_country: 'visibility.country', - visibility_date_joined: 'visibility.date_joined', - visibility_level_of_education: 'visibility.level_of_education', - visibility_language_proficiencies: 'visibility.language_proficiencies', - visibility_name: 'visibility.name', - visibility_social_links: 'visibility.social_links', - visibility_time_zone: 'visibility.time_zone', - }); - - await getHttpClient().patch(`${getConfig().LMS_BASE_URL}/api/user/v1/preferences/${username}`, processedParams, { - headers: { 'Content-Type': 'application/merge-patch+json' }, - }); - - return params; // TODO: Once the server returns the updated preferences object, return that. -} - -function transformCertificateData(data) { - const transformedData = []; - data.forEach((cert) => { - // download_url may be full url or absolute path. - // note: using the URL() api breaks in ie 11 - const urlIsPath = typeof cert.download_url === 'string' - && cert.download_url.search(/http[s]?:\/\//) !== 0; - - const downloadUrl = urlIsPath - ? `${getConfig().LMS_BASE_URL}${cert.download_url}` - : cert.download_url; - - transformedData.push({ - ...camelCaseObject(cert), - certificateType: cert.certificate_type, - downloadUrl, - }); - }); - return transformedData; -} - -export async function getCourseCertificates(username) { - const url = `${getConfig().LMS_BASE_URL}/api/certificates/v0/certificates/${username}/`; - try { - const { data } = await getHttpClient().get(url); - return transformCertificateData(data); - } catch (e) { - logError(e); - return []; - } -} - -function extractCountryList(data) { - return data?.fields - .find(({ name }) => name === FIELD_LABELS.COUNTRY) - ?.options?.map(({ value }) => (value)) || []; -} - -export async function getCountryList() { - const url = `${getConfig().LMS_BASE_URL}/user_api/v1/account/registration/`; - - try { - const { data } = await getHttpClient().get(url); - return extractCountryList(data); - } catch (e) { - logError(e); - return []; - } -} diff --git a/src/profile-v2/forms/Bio.jsx b/src/profile-v2/forms/Bio.jsx deleted file mode 100644 index 797bbb6..0000000 --- a/src/profile-v2/forms/Bio.jsx +++ /dev/null @@ -1,151 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { connect } from 'react-redux'; -import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; -import { Form } from '@openedx/paragon'; - -import classNames from 'classnames'; -import messages from './Bio.messages'; - -import FormControls from './elements/FormControls'; -import EditableItemHeader from './elements/EditableItemHeader'; -import EmptyContent from './elements/EmptyContent'; -import SwitchContent from './elements/SwitchContent'; - -import { editableFormSelector } from '../data/selectors'; -import { - useCloseOpenHandler, - useHandleChange, - useHandleSubmit, - useIsOnMobileScreen, - useIsVisibilityEnabled, -} from '../data/hooks'; - -const Bio = ({ - formId, - bio, - visibilityBio, - editMode, - saveState, - error, - changeHandler, - submitHandler, - closeHandler, - openHandler, -}) => { - const isMobileView = useIsOnMobileScreen(); - const isVisibilityEnabled = useIsVisibilityEnabled(); - const intl = useIntl(); - - const handleChange = useHandleChange(changeHandler); - const handleSubmit = useHandleSubmit(submitHandler, formId); - const handleOpen = useCloseOpenHandler(openHandler, formId); - const handleClose = useCloseOpenHandler(closeHandler, formId); - - return ( - -
- -

- {intl.formatMessage(messages['profile.bio.about.me'])} -

- -
-
-
- - - - - - - -
-
- - -
-
- -
-
-
-
-
-
-

- My Certificates - -

-

- - - - Everyone on localhost - -

-
-
-
-
-
-
-

- Verified Certificate -

-

- edX Demonstration Course -

-
-

- From -

-

- edX -

-
-

- Completed on - 3/4/2019 -

- -
-
-
-
-
-
-
-
-
-
-
-`; - -exports[` Renders correctly in various states while saving an edited bio with error 1`] = ` -
-
-
-
-
-
-
-
-
-
- -
- profile avatar -
-
- -
-
-
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
- -
-
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
- -
-
-
-

- Full Name - -

-

- - - - Just me - -

-
-

- Lemon Seltzer -

- - This is the name that appears in your account and on your certificates. - -
-
-
-
-
-

- Location - -

-

- - - - Everyone on localhost - -

-
-

- Montenegro -

-
-
-
-
-
-

- Primary Language Spoken - -

-

- - - - Everyone on localhost - -

-
-

- Yoruba -

-
-
-
-
-
-

- Education - -

-

- - - - Just me - -

-
-

- Elementary/primary school -

-
-
-
-
-
-

- Social Links - -

-

- - - - Everyone on localhost - -

-
- -
-
-
-
-
-
-
-
-
- - -
-
- bio error -
-
-
-
-
- - - - - - - -
-
- - -
-
-
-
-
-
-
-
-
-

- My Certificates - -

-

- - - - Everyone on localhost - -

-
-
-
-
-
-

- Verified Certificate -

-

- edX Demonstration Course -

-
-

- From -

-

- edX -

-
-

- Completed on - 3/4/2019 -

- -
+ Verified Certificate +

+

+ edX Demonstration Course +

+

+ From +

+
+ edX +
+

+ Completed on + 3/4/2019 +

+ +

+ Credential ID +

@@ -9420,19 +1472,16 @@ exports[` Renders correctly in various states without credentials class="profile-page" >
-
Renders correctly in various states without credentials
-
- -
profile avatar
+
+ +
@@ -9477,726 +1552,723 @@ exports[` Renders correctly in various states without credentials />
-
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
-
-
-
-
-
-
- -

- staff -

-

- Member since - 2017 -

-
-
-
-
-
-
-

- Full Name - -

-

- - - - Just me - -

-

+ staff +

+

Lemon Seltzer

- - This is the name that appears in your account and on your certificates. - -
-
-
-
-

- Location - -

-

+ Member since - - - Everyone on localhost - -

-
-

- Montenegro -

-
-
-
-
-
-

- Primary Language Spoken - -

-

- - - - Everyone on localhost - -

-
-

- Yoruba -

-
-
-
-
-
-

- Education - -

-

- - - - Just me - -

-
-

- Elementary/primary school -

-
-
-
-
-
-

- Social Links - -

-

- - - - Everyone on localhost - -

-
- + 1 + + certifications + +
+
+
+
+
+
+
+

+ Profile information +

+
+
+
+
-

- About Me - -

- - - - Everyone on localhost - + Username

+ + +
-

- This is my bio -

+ staff + +
+
+
+
+

+ Full name +

+ + + +
+
+
+

+ Lemon Seltzer +

+
+
+ +
+
+
+

+ + + + Just me + +

+
+
+
+
+
+

+ Country +

+
+
+

+ Montenegro +

+
+
+ +
+
+
+

+ + + + Everyone on localhost + +

+
+
+
+
+
+

+ Primary language spoken +

+
+
+

+ Yoruba +

+
+
+ +
+
+
+

+ + + + Everyone on localhost + +

+
+
+
+
+
+

+ Education +

+
+
+

+ Elementary/primary school +

+
+
+ +
+
+
+

+ + + + Just me + +

+
+
-

- My Certificates - -

- - - - Everyone on localhost - + Bio

-
-
-
-
-
+
+
+
+ + + +
+
+
+

+ + + + Everyone on localhost + +

+
+
+
+
+
+
+ +
+

+ Facebook +

+
+
+
+

+ https://www.facebook.com/aloha +

+
+
+ +
+
+
+

+ + + + Everyone on localhost + +

+
+
+
+
+

+ LinkedIn +

+
+
@@ -10207,6 +2279,105 @@ exports[` Renders correctly in various states without credentials
+
+
+
+
+

+ Your certificates +

+
+
+

+ Your learner records information is only visible to you. Only your username and profile image are visible to others on localhost. +

+
+
+
+
+
+
+
+
+
+

+ Verified Certificate +

+

+ edX Demonstration Course +

+

+ From +

+
+ edX +
+

+ Completed on + 3/4/2019 +

+
+ +

+ Credential ID +

+
+
+
+
+
+
+
`; diff --git a/src/profile/data/actions.js b/src/profile/data/actions.js index 85edb5b..b960400 100644 --- a/src/profile/data/actions.js +++ b/src/profile/data/actions.js @@ -9,8 +9,6 @@ export const CLOSE_FORM = 'CLOSE_FORM'; export const UPDATE_DRAFT = 'UPDATE_DRAFT'; export const RESET_DRAFTS = 'RESET_DRAFTS'; -// FETCH PROFILE ACTIONS - export const fetchProfile = username => ({ type: FETCH_PROFILE.BASE, payload: { username }, @@ -25,22 +23,18 @@ export const fetchProfileSuccess = ( preferences, courseCertificates, isAuthenticatedUserProfile, - countriesCodesList, ) => ({ type: FETCH_PROFILE.SUCCESS, account, preferences, courseCertificates, isAuthenticatedUserProfile, - countriesCodesList, }); export const fetchProfileReset = () => ({ type: FETCH_PROFILE.RESET, }); -// SAVE PROFILE ACTIONS - export const saveProfile = (formId, username) => ({ type: SAVE_PROFILE.BASE, payload: { @@ -70,8 +64,6 @@ export const saveProfileFailure = errors => ({ payload: { errors }, }); -// SAVE PROFILE PHOTO ACTIONS - export const saveProfilePhoto = (username, formData) => ({ type: SAVE_PROFILE_PHOTO.BASE, payload: { @@ -98,8 +90,6 @@ export const saveProfilePhotoFailure = error => ({ payload: { error }, }); -// DELETE PROFILE PHOTO ACTIONS - export const deleteProfilePhoto = username => ({ type: DELETE_PROFILE_PHOTO.BASE, payload: { @@ -120,8 +110,6 @@ export const deleteProfilePhotoReset = () => ({ type: DELETE_PROFILE_PHOTO.RESET, }); -// FIELD STATE ACTIONS - export const openForm = formId => ({ type: OPEN_FORM, payload: { @@ -136,8 +124,6 @@ export const closeForm = formId => ({ }, }); -// FORM STATE ACTIONS - export const updateDraft = (name, value) => ({ type: UPDATE_DRAFT, payload: { diff --git a/src/profile/data/actions.test.js b/src/profile/data/actions.test.js index 6268888..275d695 100644 --- a/src/profile/data/actions.test.js +++ b/src/profile/data/actions.test.js @@ -1,14 +1,4 @@ import { - openForm, - closeForm, - OPEN_FORM, - CLOSE_FORM, - SAVE_PROFILE, - saveProfileBegin, - saveProfileSuccess, - saveProfileFailure, - saveProfileReset, - saveProfile, SAVE_PROFILE_PHOTO, saveProfilePhotoBegin, saveProfilePhotoSuccess, @@ -22,76 +12,6 @@ import { deleteProfilePhoto, } from './actions'; -describe('editable field actions', () => { - it('should create an open action', () => { - const expectedAction = { - type: OPEN_FORM, - payload: { - formId: 'name', - }, - }; - expect(openForm('name')).toEqual(expectedAction); - }); - - it('should create a closed action', () => { - const expectedAction = { - type: CLOSE_FORM, - payload: { - formId: 'name', - }, - }; - expect(closeForm('name')).toEqual(expectedAction); - }); -}); - -describe('SAVE profile actions', () => { - it('should create an action to signal the start of a profile save', () => { - const expectedAction = { - type: SAVE_PROFILE.BASE, - payload: { - formId: 'name', - }, - }; - expect(saveProfile('name')).toEqual(expectedAction); - }); - - it('should create an action to signal user profile save success', () => { - const accountData = { name: 'Full Name' }; - const preferencesData = { visibility: { name: 'private' } }; - const expectedAction = { - type: SAVE_PROFILE.SUCCESS, - payload: { - account: accountData, - preferences: preferencesData, - }, - }; - expect(saveProfileSuccess(accountData, preferencesData)).toEqual(expectedAction); - }); - - it('should create an action to signal user profile save beginning', () => { - const expectedAction = { - type: SAVE_PROFILE.BEGIN, - }; - expect(saveProfileBegin()).toEqual(expectedAction); - }); - - it('should create an action to signal user profile save success', () => { - const expectedAction = { - type: SAVE_PROFILE.RESET, - }; - expect(saveProfileReset()).toEqual(expectedAction); - }); - - it('should create an action to signal user account save failure', () => { - const errors = ['Test failure']; - const expectedAction = { - type: SAVE_PROFILE.FAILURE, - payload: { errors }, - }; - expect(saveProfileFailure(errors)).toEqual(expectedAction); - }); -}); - describe('SAVE profile photo actions', () => { it('should create an action to signal the start of a profile photo save', () => { const formData = 'multipart form data'; @@ -123,7 +43,7 @@ describe('SAVE profile photo actions', () => { expect(saveProfilePhotoSuccess(newPhotoData)).toEqual(expectedAction); }); - it('should create an action to signal user profile photo save success', () => { + it('should create an action to signal user profile photo save reset', () => { const expectedAction = { type: SAVE_PROFILE_PHOTO.RESET, }; @@ -169,34 +89,10 @@ describe('DELETE profile photo actions', () => { expect(deleteProfilePhotoSuccess(defaultPhotoData)).toEqual(expectedAction); }); - it('should create an action to signal user profile photo deletion success', () => { + it('should create an action to signal user profile photo deletion reset', () => { const expectedAction = { type: DELETE_PROFILE_PHOTO.RESET, }; expect(deleteProfilePhotoReset()).toEqual(expectedAction); }); }); - -describe('Editable field opening and closing actions', () => { - const formId = 'name'; - - it('should create an action to signal the opening a field', () => { - const expectedAction = { - type: OPEN_FORM, - payload: { - formId, - }, - }; - expect(openForm(formId)).toEqual(expectedAction); - }); - - it('should create an action to signal the closing a field', () => { - const expectedAction = { - type: CLOSE_FORM, - payload: { - formId, - }, - }; - expect(closeForm(formId)).toEqual(expectedAction); - }); -}); diff --git a/src/profile-v2/data/hooks.js b/src/profile/data/hooks.js similarity index 93% rename from src/profile-v2/data/hooks.js rename to src/profile/data/hooks.js index 161a436..abf37c5 100644 --- a/src/profile-v2/data/hooks.js +++ b/src/profile/data/hooks.js @@ -12,7 +12,7 @@ export function useIsOnMobileScreen() { } export function useIsVisibilityEnabled() { - return getConfig().DISABLE_VISIBILITY_EDITING === 'true'; + return getConfig().DISABLE_VISIBILITY_EDITING !== 'true'; } export function useHandleChange(changeHandler) { diff --git a/src/profile/data/pact-profile.test.js b/src/profile/data/pact-profile.test.js index 3addaa4..abd14e6 100644 --- a/src/profile/data/pact-profile.test.js +++ b/src/profile/data/pact-profile.test.js @@ -17,6 +17,10 @@ const expectedUserInfo200 = { dateJoined: '2017-06-07T00:44:23Z', isActive: true, yearOfBirth: 1901, + languageProficiencies: [], + levelOfEducation: null, + profileImage: {}, + socialLinks: [], }; const provider = new PactV3({ diff --git a/src/profile/data/reducers.js b/src/profile/data/reducers.js index 0d374c6..3e4760c 100644 --- a/src/profile/data/reducers.js +++ b/src/profile/data/reducers.js @@ -16,12 +16,27 @@ export const initialState = { currentlyEditingField: null, account: { socialLinks: [], + languageProficiencies: [], + name: '', + bio: '', + country: '', + levelOfEducation: '', + profileImage: {}, + yearOfBirth: '', + }, + preferences: { + visibilityName: '', + visibilityBio: '', + visibilityCountry: '', + visibilityLevelOfEducation: '', + visibilitySocialLinks: '', + visibilityLanguageProficiencies: '', }, - preferences: {}, courseCertificates: [], drafts: {}, isLoadingProfile: true, isAuthenticatedUserProfile: false, + disabledCountries: ['RU'], countriesCodesList: [], }; @@ -38,12 +53,17 @@ const profilePage = (state = initialState, action = {}) => { case FETCH_PROFILE.SUCCESS: return { ...state, - account: action.account, + account: { + ...state.account, + ...action.account, + socialLinks: action.account.socialLinks || [], + languageProficiencies: action.account.languageProficiencies || [], + }, preferences: action.preferences, - courseCertificates: action.courseCertificates, + courseCertificates: action.courseCertificates || [], isLoadingProfile: false, isAuthenticatedUserProfile: action.isAuthenticatedUserProfile, - countriesCodesList: action.countriesCodesList, + countriesCodesList: action.countriesCodesList || [], }; case SAVE_PROFILE.BEGIN: return { @@ -56,9 +76,12 @@ const profilePage = (state = initialState, action = {}) => { ...state, saveState: 'complete', errors: {}, - // Account is always replaced completely. - account: action.payload.account !== null ? action.payload.account : state.account, - // Preferences changes get merged in. + account: action.payload.account !== null ? { + ...state.account, + ...action.payload.account, + socialLinks: action.payload.account.socialLinks || [], + languageProficiencies: action.payload.account.languageProficiencies || [], + } : state.account, preferences: { ...state.preferences, ...action.payload.preferences }, }; case SAVE_PROFILE.FAILURE: @@ -75,7 +98,6 @@ const profilePage = (state = initialState, action = {}) => { isLoadingProfile: false, errors: {}, }; - case SAVE_PROFILE_PHOTO.BEGIN: return { ...state, @@ -85,7 +107,6 @@ const profilePage = (state = initialState, action = {}) => { case SAVE_PROFILE_PHOTO.SUCCESS: return { ...state, - // Merge in new profile image data account: { ...state.account, profileImage: action.payload.profileImage }, savePhotoState: 'complete', errors: {}, @@ -102,7 +123,6 @@ const profilePage = (state = initialState, action = {}) => { savePhotoState: null, errors: {}, }; - case DELETE_PROFILE_PHOTO.BEGIN: return { ...state, @@ -112,7 +132,6 @@ const profilePage = (state = initialState, action = {}) => { case DELETE_PROFILE_PHOTO.SUCCESS: return { ...state, - // Merge in new profile image data (should be empty or default image) account: { ...state.account, profileImage: action.payload.profileImage }, savePhotoState: 'complete', errors: {}, @@ -129,13 +148,11 @@ const profilePage = (state = initialState, action = {}) => { savePhotoState: null, errors: {}, }; - case UPDATE_DRAFT: return { ...state, drafts: { ...state.drafts, [action.payload.name]: action.payload.value }, }; - case RESET_DRAFTS: return { ...state, @@ -148,7 +165,6 @@ const profilePage = (state = initialState, action = {}) => { drafts: {}, }; case CLOSE_FORM: - // Only close if the field to close is undefined or matches the field that is currently open if (action.payload.formId === state.currentlyEditingField) { return { ...state, diff --git a/src/profile-v2/data/reducers.test.js b/src/profile/data/reducers.test.js similarity index 100% rename from src/profile-v2/data/reducers.test.js rename to src/profile/data/reducers.test.js diff --git a/src/profile/data/sagas.js b/src/profile/data/sagas.js index e2ebba5..b64c3fe 100644 --- a/src/profile/data/sagas.js +++ b/src/profile/data/sagas.js @@ -1,3 +1,4 @@ +import { history } from '@edx/frontend-platform'; import { getAuthenticatedUser } from '@edx/frontend-platform/auth'; import pick from 'lodash.pick'; import { @@ -21,13 +22,12 @@ import { resetDrafts, saveProfileBegin, saveProfileFailure, - saveProfilePhotoBegin, - saveProfilePhotoFailure, - saveProfilePhotoReset, - saveProfilePhotoSuccess, saveProfileReset, saveProfileSuccess, SAVE_PROFILE, + saveProfilePhotoBegin, + saveProfilePhotoReset, + saveProfilePhotoSuccess, SAVE_PROFILE_PHOTO, } from './actions'; import { handleSaveProfileSelector, userAccountSelector } from './selectors'; @@ -37,7 +37,6 @@ export function* handleFetchProfile(action) { const { username } = action.payload; const userAccount = yield select(userAccountSelector); const isAuthenticatedUserProfile = username === getAuthenticatedUser().username; - // Default our data assuming the account is the current user's account. let preferences = {}; let account = userAccount; let courseCertificates = null; @@ -46,7 +45,6 @@ export function* handleFetchProfile(action) { try { yield put(fetchProfileBegin()); - // Depending on which profile we're loading, we need to make different calls. const calls = [ call(ProfileApiService.getAccount, username), call(ProfileApiService.getCourseCertificates, username), @@ -54,12 +52,9 @@ export function* handleFetchProfile(action) { ]; if (isAuthenticatedUserProfile) { - // If the profile is for the current user, get their preferences. - // We don't need them for other users. calls.push(call(ProfileApiService.getPreferences, username)); } - // Make all the calls in parallel. const result = yield all(calls); if (isAuthenticatedUserProfile) { @@ -68,9 +63,6 @@ export function* handleFetchProfile(action) { [account, courseCertificates, countriesCodesList] = 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', @@ -97,11 +89,7 @@ export function* handleFetchProfile(action) { yield put(fetchProfileReset()); } catch (e) { if (e.response.status === 404) { - if (e.processedData && e.processedData.fieldErrors) { - yield put(saveProfileFailure(e.processedData.fieldErrors)); - } else { - yield put(saveProfileFailure(e.customAttributes)); - } + history.push('/notfound'); } else { throw e; } @@ -114,7 +102,6 @@ export function* handleSaveProfile(action) { const accountDrafts = pick(drafts, [ 'bio', - 'courseCertificates', 'country', 'levelOfEducation', 'languageProficiencies', @@ -124,7 +111,6 @@ export function* handleSaveProfile(action) { const preferencesDrafts = pick(drafts, [ 'visibilityBio', - 'visibilityCourseCertificates', 'visibilityCountry', 'visibilityLevelOfEducation', 'visibilityLanguageProficiencies', @@ -138,7 +124,6 @@ export function* handleSaveProfile(action) { yield put(saveProfileBegin()); let accountResult = null; - // Build the visibility drafts into a structure the API expects. if (Object.keys(accountDrafts).length > 0) { accountResult = yield call( @@ -148,17 +133,14 @@ export function* handleSaveProfile(action) { ); } - let preferencesResult = preferences; // assume it hasn't changed. + let preferencesResult = preferences; if (Object.keys(preferencesDrafts).length > 0) { yield call(ProfileApiService.patchPreferences, action.payload.username, preferencesDrafts); // TODO: Temporary deoptimization since the patchPreferences call doesn't return anything. - // Remove this second call once we can get a result from the one above. + preferencesResult = yield call(ProfileApiService.getPreferences, action.payload.username); } - // The account result is returned from the server. - // The preferences draft is valid if the server didn't complain, so - // pass it through directly. yield put(saveProfileSuccess(accountResult, preferencesResult)); yield delay(1000); yield put(closeForm(action.payload.formId)); @@ -184,12 +166,7 @@ export function* handleSaveProfilePhoto(action) { yield put(saveProfilePhotoSuccess(photoResult)); yield put(saveProfilePhotoReset()); } catch (e) { - if (e.processedData) { - yield put(saveProfilePhotoFailure(e.processedData)); - } else { - yield put(saveProfilePhotoReset()); - throw e; - } + yield put(saveProfilePhotoReset()); } } @@ -203,7 +180,6 @@ export function* handleDeleteProfilePhoto(action) { yield put(deleteProfilePhotoReset()); } catch (e) { yield put(deleteProfilePhotoReset()); - throw e; } } diff --git a/src/profile/data/sagas.test.js b/src/profile/data/sagas.test.js index 291ab1b..2da09b3 100644 --- a/src/profile/data/sagas.test.js +++ b/src/profile/data/sagas.test.js @@ -26,7 +26,6 @@ jest.mock('@edx/frontend-platform/auth', () => ({ getAuthenticatedUser: jest.fn(), })); -// RootSaga and ProfileApiService must be imported AFTER the mock above. /* eslint-disable import/first */ import profileSaga, { handleFetchProfile, @@ -78,7 +77,6 @@ describe('RootSaga', () => { call(ProfileApiService.getCourseCertificates, 'gonzo'), call(ProfileApiService.getCountryList), call(ProfileApiService.getPreferences, 'gonzo'), - ])); expect(gen.next(result).value) .toEqual(put(profileActions.fetchProfileSuccess(userAccount, result[3], result[1], true, []))); @@ -137,8 +135,6 @@ describe('RootSaga', () => { expect(gen.next().value).toEqual(call(ProfileApiService.patchProfile, 'my username', { name: 'Full Name', })); - // The library would supply the result of the above call - // as the parameter to the NEXT yield. Here: expect(gen.next(profile).value).toEqual(put(profileActions.saveProfileSuccess(profile, {}))); expect(gen.next().value).toEqual(delay(1000)); expect(gen.next().value).toEqual(put(profileActions.closeForm('ze form id'))); diff --git a/src/profile/data/selectors.js b/src/profile/data/selectors.js index 41d69fa..d398295 100644 --- a/src/profile/data/selectors.js +++ b/src/profile/data/selectors.js @@ -5,18 +5,15 @@ import { getCountryList, getCountryMessages, getLanguageMessages, -} from '@edx/frontend-platform/i18n'; // eslint-disable-line +} from '@edx/frontend-platform/i18n'; export const formIdSelector = (state, props) => props.formId; export const userAccountSelector = state => state.userAccount; - export const profileAccountSelector = state => state.profilePage.account; export const profileDraftsSelector = state => state.profilePage.drafts; export const accountPrivacySelector = state => state.profilePage.preferences.accountPrivacy; export const profilePreferencesSelector = state => state.profilePage.preferences; export const profileCourseCertificatesSelector = state => state.profilePage.courseCertificates; -export const profileAccountDraftsSelector = state => state.profilePage.accountDrafts; -export const profileVisibilityDraftsSelector = state => state.profilePage.visibilityDrafts; export const saveStateSelector = state => state.profilePage.saveState; export const savePhotoStateSelector = state => state.profilePage.savePhotoState; export const isLoadingProfileSelector = state => state.profilePage.isLoadingProfile; @@ -32,22 +29,11 @@ export const editableFormModeSelector = createSelector( formIdSelector, currentlyEditingFieldSelector, (account, isAuthenticatedUserProfile, certificates, formId, currentlyEditingField) => { - // If the prop doesn't exist, that means it hasn't been set (for the current user's profile) - // 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 + propExists = formId === 'certificates' ? certificates.length > 0 : propExists; if (!isAuthenticatedUserProfile) { return 'static'; } - // the current user has no age set / under 13 ... - 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. - return propExists ? 'static' : null; - } - // Otherwise, if this is the current user's profile... if (formId === currentlyEditingField) { return 'editing'; } @@ -68,12 +54,10 @@ export const accountDraftsFieldSelector = createSelector( export const visibilityDraftsFieldSelector = createSelector( formIdSelector, - profileVisibilityDraftsSelector, - (formId, visibilityDrafts) => visibilityDrafts[formId], + profileDraftsSelector, + (formId, drafts) => drafts[`visibility${formId.charAt(0).toUpperCase() + formId.slice(1)}`], ); -// Note: Error messages are delivered from the server -// localized according to a user's account settings export const formErrorSelector = createSelector( accountErrorsSelector, formIdSelector, @@ -91,11 +75,6 @@ export const editableFormSelector = createSelector( }), ); -// Because this selector has no input selectors, it will only be evaluated once. This is fine -// for now because we don't allow users to change the locale after page load. -// Once we DO allow this, we should create an actual action which dispatches the locale into redux, -// then we can modify this to get the locale from state rather than from getLocale() directly. -// Once we do that, this will work as expected and be re-evaluated when the locale changes. export const localeSelector = () => getLocale(); export const countryMessagesSelector = createSelector( localeSelector, @@ -169,9 +148,6 @@ export const profileImageSelector = createSelector( : {}), ); -/** - * This is used by a saga to pull out data to process. - */ export const handleSaveProfileSelector = createSelector( profileDraftsSelector, profilePreferencesSelector, @@ -181,7 +157,6 @@ export const handleSaveProfileSelector = createSelector( }), ); -// Reformats the social links in a platform-keyed hash. const socialLinksByPlatformSelector = createSelector( profileAccountSelector, (account) => { @@ -208,24 +183,18 @@ const draftSocialLinksByPlatformSelector = createSelector( }, ); -// Fleshes out our list of existing social links with all the other ones the user can set. export const formSocialLinksSelector = createSelector( socialLinksByPlatformSelector, draftSocialLinksByPlatformSelector, (linksByPlatform, draftLinksByPlatform) => { const knownPlatforms = ['twitter', 'facebook', 'linkedin']; const socialLinks = []; - // For each known platform knownPlatforms.forEach((platform) => { - // If the link is in our drafts. if (draftLinksByPlatform[platform] !== undefined) { - // Use the draft one. socialLinks.push(draftLinksByPlatform[platform]); } else if (linksByPlatform[platform] !== undefined) { - // Otherwise use the real one. socialLinks.push(linksByPlatform[platform]); } else { - // And if it's not in either, use a stub. socialLinks.push({ platform, socialLink: null, @@ -244,7 +213,6 @@ export const visibilitiesSelector = createSelector( case 'custom': return { 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', @@ -254,7 +222,6 @@ export const visibilitiesSelector = createSelector( case 'private': return { visibilityBio: 'private', - visibilityCourseCertificates: 'private', visibilityCountry: 'private', visibilityLevelOfEducation: 'private', visibilityLanguageProficiencies: 'private', @@ -263,13 +230,8 @@ export const visibilitiesSelector = createSelector( }; case 'all_users': default: - // All users is intended to fall through to default. - // If there is no value for accountPrivacy in perferences, that means it has not been - // explicitly set yet. The server assumes - today - that this means "all_users", - // so we emulate that here in the client. return { visibilityBio: 'all_users', - visibilityCourseCertificates: 'all_users', visibilityCountry: 'all_users', visibilityLevelOfEducation: 'all_users', visibilityLanguageProficiencies: 'all_users', @@ -280,9 +242,6 @@ export const visibilitiesSelector = createSelector( }, ); -/** - * If there's no draft present at all (undefined), use the original committed value. - */ function chooseFormValue(draft, committed) { return draft !== undefined ? draft : committed; } @@ -297,10 +256,6 @@ export const formValuesSelector = createSelector( bio: chooseFormValue(drafts.bio, account.bio), visibilityBio: chooseFormValue(drafts.visibilityBio, visibilities.visibilityBio), courseCertificates, - visibilityCourseCertificates: chooseFormValue( - drafts.visibilityCourseCertificates, - visibilities.visibilityCourseCertificates, - ), country: chooseFormValue(drafts.country, account.country), visibilityCountry: chooseFormValue(drafts.visibilityCountry, visibilities.visibilityCountry), levelOfEducation: chooseFormValue(drafts.levelOfEducation, account.levelOfEducation), @@ -318,7 +273,7 @@ export const formValuesSelector = createSelector( ), name: chooseFormValue(drafts.name, account.name), visibilityName: chooseFormValue(drafts.visibilityName, visibilities.visibilityName), - socialLinks, // Social links is calculated in its own selector, since it's complicated. + socialLinks, visibilitySocialLinks: chooseFormValue( drafts.visibilitySocialLinks, visibilities.visibilitySocialLinks, @@ -335,6 +290,7 @@ export const profilePageSelector = createSelector( isLoadingProfileSelector, draftSocialLinksByPlatformSelector, accountErrorsSelector, + isAuthenticatedUserProfileSelector, ( account, formValues, @@ -344,47 +300,39 @@ export const profilePageSelector = createSelector( isLoadingProfile, draftSocialLinksByPlatform, errors, + isAuthenticatedUserProfile, ) => ({ - // Account data we need username: account.username, profileImage, requiresParentalConsent: account.requiresParentalConsent, dateJoined: account.dateJoined, yearOfBirth: account.yearOfBirth, - // Bio form data bio: formValues.bio, visibilityBio: formValues.visibilityBio, - // Certificates form data courseCertificates: formValues.courseCertificates, - visibilityCourseCertificates: formValues.visibilityCourseCertificates, - // Country form data country: formValues.country, visibilityCountry: formValues.visibilityCountry, - // Education form data levelOfEducation: formValues.levelOfEducation, visibilityLevelOfEducation: formValues.visibilityLevelOfEducation, - // Language proficiency form data languageProficiencies: formValues.languageProficiencies, visibilityLanguageProficiencies: formValues.visibilityLanguageProficiencies, - // Name form data name: formValues.name, visibilityName: formValues.visibilityName, - // Social links form data socialLinks: formValues.socialLinks, visibilitySocialLinks: formValues.visibilitySocialLinks, draftSocialLinksByPlatform, - // Other data we need saveState, savePhotoState, isLoadingProfile, photoUploadError: errors.photo || null, + isAuthenticatedUserProfile, }), ); diff --git a/src/profile/data/services.js b/src/profile/data/services.js index 17f15a4..e6104df 100644 --- a/src/profile/data/services.js +++ b/src/profile/data/services.js @@ -7,7 +7,19 @@ import { FIELD_LABELS } from './constants'; ensureConfig(['LMS_BASE_URL'], 'Profile API service'); function processAccountData(data) { - return camelCaseObject(data); + const processedData = camelCaseObject(data); + return { + ...processedData, + socialLinks: Array.isArray(processedData.socialLinks) ? processedData.socialLinks : [], + languageProficiencies: Array.isArray(processedData.languageProficiencies) + ? processedData.languageProficiencies : [], + name: processedData.name || null, + bio: processedData.bio || null, + country: processedData.country || null, + levelOfEducation: processedData.levelOfEducation || null, + profileImage: processedData.profileImage || {}, + yearOfBirth: processedData.yearOfBirth || null, + }; } function processAndThrowError(error, errorDataProcessor) { @@ -20,15 +32,12 @@ function processAndThrowError(error, errorDataProcessor) { } } -// GET ACCOUNT export async function getAccount(username) { const { data } = await getHttpClient().get(`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}`); - // Process response data return processAccountData(data); } -// PATCH PROFILE export async function patchProfile(username, params) { const processedParams = snakeCaseObject(params); @@ -42,12 +51,9 @@ export async function patchProfile(username, params) { processAndThrowError(error, processAccountData); }); - // Process response data return processAccountData(data); } -// POST PROFILE PHOTO - export async function postProfilePhoto(username, formData) { // eslint-disable-next-line no-unused-vars const { data } = await getHttpClient().post( @@ -71,8 +77,6 @@ export async function postProfilePhoto(username, formData) { return updatedData.profileImage; } -// DELETE PROFILE PHOTO - export async function deleteProfilePhoto(username) { // eslint-disable-next-line no-unused-vars const { data } = await getHttpClient().delete(`${getConfig().LMS_BASE_URL}/api/user/v1/accounts/${username}/image`); @@ -86,14 +90,12 @@ export async function deleteProfilePhoto(username) { return updatedData.profileImage; } -// GET PREFERENCES export async function getPreferences(username) { const { data } = await getHttpClient().get(`${getConfig().LMS_BASE_URL}/api/user/v1/preferences/${username}`); return camelCaseObject(data); } -// PATCH PREFERENCES export async function patchPreferences(username, params) { let processedParams = snakeCaseObject(params); processedParams = convertKeyNames(processedParams, { @@ -115,8 +117,6 @@ export async function patchPreferences(username, params) { return params; // TODO: Once the server returns the updated preferences object, return that. } -// GET COURSE CERTIFICATES - function transformCertificateData(data) { const transformedData = []; data.forEach((cert) => { diff --git a/src/profile/forms/Bio.jsx b/src/profile/forms/Bio.jsx index e847c97..797bbb6 100644 --- a/src/profile/forms/Bio.jsx +++ b/src/profile/forms/Bio.jsx @@ -1,149 +1,140 @@ import React from 'react'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { FormattedMessage, injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { FormattedMessage, useIntl } from '@edx/frontend-platform/i18n'; import { Form } from '@openedx/paragon'; +import classNames from 'classnames'; import messages from './Bio.messages'; -// Components import FormControls from './elements/FormControls'; import EditableItemHeader from './elements/EditableItemHeader'; import EmptyContent from './elements/EmptyContent'; import SwitchContent from './elements/SwitchContent'; -// Selectors import { editableFormSelector } from '../data/selectors'; +import { + useCloseOpenHandler, + useHandleChange, + useHandleSubmit, + useIsOnMobileScreen, + useIsVisibilityEnabled, +} from '../data/hooks'; -class Bio extends React.Component { - constructor(props) { - super(props); +const Bio = ({ + formId, + bio, + visibilityBio, + editMode, + saveState, + error, + changeHandler, + submitHandler, + closeHandler, + openHandler, +}) => { + const isMobileView = useIsOnMobileScreen(); + const isVisibilityEnabled = useIsVisibilityEnabled(); + const intl = useIntl(); - this.handleChange = this.handleChange.bind(this); - this.handleSubmit = this.handleSubmit.bind(this); - this.handleClose = this.handleClose.bind(this); - this.handleOpen = this.handleOpen.bind(this); - } + const handleChange = useHandleChange(changeHandler); + const handleSubmit = useHandleSubmit(submitHandler, formId); + const handleOpen = useCloseOpenHandler(openHandler, formId); + const handleClose = useCloseOpenHandler(closeHandler, formId); - handleChange(e) { - const { name, value } = e.target; - this.props.changeHandler(name, value); - } - - handleSubmit(e) { - e.preventDefault(); - this.props.submitHandler(this.props.formId); - } - - handleClose() { - this.props.closeHandler(this.props.formId); - } - - handleOpen() { - this.props.openHandler(this.props.formId); - } - - render() { - const { - formId, bio, visibilityBio, editMode, saveState, error, intl, - } = this.props; - - return ( - -
- - -