Skip to content

New navi Contentful integration - refactor menu links build #2715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,37 @@ module.exports = {
GRANT_TYPE: '',
},
},
HEADER_AUTH_URLS: {
href: 'https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main',
location: 'https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main',
},
ACCOUNT_MENU: [
SECONDARY_MENU_FOR_LOGGED_USER: [
{
title: 'Dashboard',
href: '/my-dashboard',
},
{
id: 'myprofile',
title: 'My Profile',
href: '/members/',
},
{
title: 'Payments',
href: 'https://community.topcoder-dev.com/PactsMemberServlet?module=PaymentHistory&full_list=false',
},
],
SECONDARY_MENU_FOR_GUEST: [
{
title: 'Settings',
href: '/settings/profile',
title: 'Overview',
href: 'https://www.topcoder-dev.com/about',
},
{ separator: true },
{
title: 'Help',
href: 'https://help.topcoder-dev.com/',
title: 'How It Works',
href: 'https://www.topcoder-dev.com/how-it-works/faqs/',
},
{
title: 'About Topcoder',
href: 'https://www.topcoder.com/about/',
title: 'Tracks',
href: '/community/learn',
},
{
title: 'Log Out',
href: 'https://www.topcoder-dev.com/logout',
title: 'Why Join',
href: 'https://www.topcoder-dev.com/about/why-crowdsourcing/',
},
],
ACCOUNT_MENU_SWITCH_TEXT: {
Expand Down
37 changes: 37 additions & 0 deletions config/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,41 @@ module.exports = {
FILESTACK: {
SUBMISSION_CONTAINER: 'topcoder-submissions-dmz',
},
SECONDARY_MENU_FOR_LOGGED_USER: [
{
title: 'Dashboard',
href: '/my-dashboard',
},
{
id: 'myprofile',
title: 'My Profile',
href: '/members/',
},
{
title: 'Payments',
href: 'https://community.topcoder.com/PactsMemberServlet?module=PaymentHistory&full_list=false',
},
],
SECONDARY_MENU_FOR_GUEST: [
{
title: 'Overview',
href: 'https://www.topcoder.com/about',
},
{
title: 'How It Works',
href: 'https://www.topcoder.com/how-it-works/faqs/',
},
{
title: 'Tracks',
href: '/community/learn',
},
{
title: 'Why Join',
href: 'https://www.topcoder.com/about/why-crowdsourcing/',
},
],
ACCOUNT_MENU_SWITCH_TEXT: {
title: 'Switch to BUSINESS',
href: 'https://connect.topcoder.com',
},
};
5 changes: 4 additions & 1 deletion src/shared/actions/contentful.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import { getService } from 'services/contentful';
import { redux } from 'topcoder-react-utils';
import { redux, config } from 'topcoder-react-utils';
import { removeTrailingSlash } from 'utils/url';
import { menuItemBuilder, target as urlTarget } from 'utils/contentful';
import { services } from 'topcoder-react-lib';
Expand Down Expand Up @@ -228,6 +228,9 @@ async function getMenuDone(menuProps) {
} else {
menu = menuData;
}
// add the preconfigured secondary menus
menu[0].secondaryMenuForLoggedInUser = config.SECONDARY_MENU_FOR_LOGGED_USER;
menu[0].secondaryMenuForGuest = config.SECONDARY_MENU_FOR_GUEST;

return {
id: menuProps.id,
Expand Down
31 changes: 28 additions & 3 deletions src/shared/containers/Contentful/MenuLoader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,43 @@ class MenuLoaderContainer extends React.Component {
openMore={openMore}
setOpenMore={this.handleChangeOpenMore}
loggedIn={!_.isEmpty(auth.profile)}
// profileHandle={auth.profile ? auth.profile.handle : ''}
rightMenu={(
<LoginNav
loggedIn={!_.isEmpty(auth.profile)}
notificationButtonState="none"
notifications={[]}
accountMenu={config.ACCOUNT_MENU}
accountMenu={[
{
title: 'Settings',
href: '/settings/profile',
},
{ separator: true },
{
title: 'Help',
href: config.URL.HELP,
},
{
title: 'About Topcoder',
href: `${config.URL.BASE}/about/`,
},
{
title: 'Log Out',
href: `${config.URL.BASE}/logout`,
},
]}
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
onSwitch={this.handleSwitchMenu}
onMenuOpen={this.handleCloseOpenMore}
showNotification={false}
profile={auth.profile}
authURLs={config.HEADER_AUTH_URLS}
profile={{
...auth.profile,
roles: auth.user ? auth.user.roles : [],
}}
authURLs={{
href: `${config.URL.AUTH}/member/registration?utm_source=community-app-main`,
location: `${config.URL.AUTH}/member?retUrl=%S&utm_source=community-app-main`,
}}
/>
)}
/>
Expand Down