Skip to content

Commit 52e0b0d

Browse files
authored
Merge pull request #2715 from topcoder-platform/feature-contentful
New navi Contentful integration - refactor menu links build
2 parents 8d813df + 096bf16 commit 52e0b0d

File tree

4 files changed

+93
-18
lines changed

4 files changed

+93
-18
lines changed

config/default.js

+24-14
Original file line numberDiff line numberDiff line change
@@ -211,27 +211,37 @@ module.exports = {
211211
GRANT_TYPE: '',
212212
},
213213
},
214-
HEADER_AUTH_URLS: {
215-
href: 'https://accounts.topcoder-dev.com/member/registration?utm_source=community-app-main',
216-
location: 'https://accounts.topcoder-dev.com/member?retUrl=%S&utm_source=community-app-main',
217-
},
218-
ACCOUNT_MENU: [
214+
SECONDARY_MENU_FOR_LOGGED_USER: [
215+
{
216+
title: 'Dashboard',
217+
href: '/my-dashboard',
218+
},
219+
{
220+
id: 'myprofile',
221+
title: 'My Profile',
222+
href: '/members/',
223+
},
224+
{
225+
title: 'Payments',
226+
href: 'https://community.topcoder-dev.com/PactsMemberServlet?module=PaymentHistory&full_list=false',
227+
},
228+
],
229+
SECONDARY_MENU_FOR_GUEST: [
219230
{
220-
title: 'Settings',
221-
href: '/settings/profile',
231+
title: 'Overview',
232+
href: 'https://www.topcoder-dev.com/about',
222233
},
223-
{ separator: true },
224234
{
225-
title: 'Help',
226-
href: 'https://help.topcoder-dev.com/',
235+
title: 'How It Works',
236+
href: 'https://www.topcoder-dev.com/how-it-works/faqs/',
227237
},
228238
{
229-
title: 'About Topcoder',
230-
href: 'https://www.topcoder.com/about/',
239+
title: 'Tracks',
240+
href: '/community/learn',
231241
},
232242
{
233-
title: 'Log Out',
234-
href: 'https://www.topcoder-dev.com/logout',
243+
title: 'Why Join',
244+
href: 'https://www.topcoder-dev.com/about/why-crowdsourcing/',
235245
},
236246
],
237247
ACCOUNT_MENU_SWITCH_TEXT: {

config/production.js

+37
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,41 @@ module.exports = {
5656
FILESTACK: {
5757
SUBMISSION_CONTAINER: 'topcoder-submissions-dmz',
5858
},
59+
SECONDARY_MENU_FOR_LOGGED_USER: [
60+
{
61+
title: 'Dashboard',
62+
href: '/my-dashboard',
63+
},
64+
{
65+
id: 'myprofile',
66+
title: 'My Profile',
67+
href: '/members/',
68+
},
69+
{
70+
title: 'Payments',
71+
href: 'https://community.topcoder.com/PactsMemberServlet?module=PaymentHistory&full_list=false',
72+
},
73+
],
74+
SECONDARY_MENU_FOR_GUEST: [
75+
{
76+
title: 'Overview',
77+
href: 'https://www.topcoder.com/about',
78+
},
79+
{
80+
title: 'How It Works',
81+
href: 'https://www.topcoder.com/how-it-works/faqs/',
82+
},
83+
{
84+
title: 'Tracks',
85+
href: '/community/learn',
86+
},
87+
{
88+
title: 'Why Join',
89+
href: 'https://www.topcoder.com/about/why-crowdsourcing/',
90+
},
91+
],
92+
ACCOUNT_MENU_SWITCH_TEXT: {
93+
title: 'Switch to BUSINESS',
94+
href: 'https://connect.topcoder.com',
95+
},
5996
};

src/shared/actions/contentful.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import _ from 'lodash';
22
import { getService } from 'services/contentful';
3-
import { redux } from 'topcoder-react-utils';
3+
import { redux, config } from 'topcoder-react-utils';
44
import { removeTrailingSlash } from 'utils/url';
55
import { menuItemBuilder, target as urlTarget } from 'utils/contentful';
66
import { services } from 'topcoder-react-lib';
@@ -228,6 +228,9 @@ async function getMenuDone(menuProps) {
228228
} else {
229229
menu = menuData;
230230
}
231+
// add the preconfigured secondary menus
232+
menu[0].secondaryMenuForLoggedInUser = config.SECONDARY_MENU_FOR_LOGGED_USER;
233+
menu[0].secondaryMenuForGuest = config.SECONDARY_MENU_FOR_GUEST;
231234

232235
return {
233236
id: menuProps.id,

src/shared/containers/Contentful/MenuLoader/index.jsx

+28-3
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,43 @@ class MenuLoaderContainer extends React.Component {
8787
openMore={openMore}
8888
setOpenMore={this.handleChangeOpenMore}
8989
loggedIn={!_.isEmpty(auth.profile)}
90+
// profileHandle={auth.profile ? auth.profile.handle : ''}
9091
rightMenu={(
9192
<LoginNav
9293
loggedIn={!_.isEmpty(auth.profile)}
9394
notificationButtonState="none"
9495
notifications={[]}
95-
accountMenu={config.ACCOUNT_MENU}
96+
accountMenu={[
97+
{
98+
title: 'Settings',
99+
href: '/settings/profile',
100+
},
101+
{ separator: true },
102+
{
103+
title: 'Help',
104+
href: config.URL.HELP,
105+
},
106+
{
107+
title: 'About Topcoder',
108+
href: `${config.URL.BASE}/about/`,
109+
},
110+
{
111+
title: 'Log Out',
112+
href: `${config.URL.BASE}/logout`,
113+
},
114+
]}
96115
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
97116
onSwitch={this.handleSwitchMenu}
98117
onMenuOpen={this.handleCloseOpenMore}
99118
showNotification={false}
100-
profile={auth.profile}
101-
authURLs={config.HEADER_AUTH_URLS}
119+
profile={{
120+
...auth.profile,
121+
roles: auth.user ? auth.user.roles : [],
122+
}}
123+
authURLs={{
124+
href: `${config.URL.AUTH}/member/registration?utm_source=community-app-main`,
125+
location: `${config.URL.AUTH}/member?retUrl=%S&utm_source=community-app-main`,
126+
}}
102127
/>
103128
)}
104129
/>

0 commit comments

Comments
 (0)