Skip to content

Commit 571c6ed

Browse files
committed
Navi fixes #4020
1 parent 6de9db1 commit 571c6ed

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

src/shared/actions/contentful.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,18 @@ async function getMenuDone(menuProps) {
180180
sI2.subMenu = await Promise.all(_.map(
181181
cR2.fields.childRoutes,
182182
cR3 => service.getEntry(cR3.sys.id).then(
183-
c3 => menuItemBuilder(urlTarget(url2, cR2), c3),
183+
async (c3) => {
184+
const sI3 = menuItemBuilder(url2, c3);
185+
if (c3.fields.childRoutes) {
186+
sI3.subMenu = await Promise.all(_.map(
187+
c3.fields.childRoutes,
188+
cR4 => service.getEntry(cR4.sys.id).then(
189+
c4 => menuItemBuilder(urlTarget(url2, c3), c4),
190+
),
191+
));
192+
}
193+
return sI3;
194+
},
184195
),
185196
));
186197
}

src/shared/components/Contentful/Menu/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ export default function ContentfulMenu(props) {
244244
render={(menuData) => {
245245
const { fields } = Object.values(menuData.entries.items)[0];
246246
if (!fields) return null;
247-
if (fields.theme === 'General') {
247+
if (fields.theme === 'General - light' || fields.theme === 'General - dark') {
248248
// New navi style menu
249249
// we deligate to special custom component and lib
250250
return (

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

+8-4
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ class MenuLoaderContainer extends React.Component {
6868

6969
render() {
7070
const {
71-
menu, auth, loading, menuLogo,
71+
menu, auth, loading, menuLogo, fields,
7272
} = this.props;
7373
const { openMore, path, activeLevel1Id } = this.state;
7474
if (loading) {
@@ -78,8 +78,12 @@ class MenuLoaderContainer extends React.Component {
7878
// eslint-disable-next-line global-require
7979
const { TopNav, LoginNav } = require('navigation-component');
8080
const logoToUse = !_.isEmpty(menuLogo) ? <img src={menuLogo.fields.file.url} alt="menu logo" /> : <Logo />;
81-
const comboMenu = _.clone(config.HEADER_MENU);
82-
comboMenu[1].subMenu = _.clone(menu[0].subMenu);
81+
const menuTheme = fields.theme.split('- ');
82+
const comboMenu = _.flatten(_.map(menu, menuItem => menuItem.subMenu));
83+
// This is a hack fix that should be removed when possible!
84+
// Its orifing is in the https://github.com/topcoder-platform/navigation-component module
85+
// which breaks if there is NOT an menu item with id = `community`
86+
comboMenu[0].id = 'community';
8387
let normalizedProfile = auth.profile && _.clone(auth.profile);
8488
if (auth.profile) {
8589
normalizedProfile.photoURL = (_.has(auth.profile, 'photoURL') && auth.profile.photoURL !== null)
@@ -106,7 +110,7 @@ class MenuLoaderContainer extends React.Component {
106110
/>
107111
)}
108112
logo={logoToUse}
109-
theme={config.HEADER_MENU_THEME}
113+
theme={menuTheme[1]}
110114
currentLevel1Id={activeLevel1Id}
111115
onChangeLevel1Id={this.handleChangeLevel1Id}
112116
path={path}

src/shared/utils/contentful.js

+2
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,13 @@ export function menuItemBuilder(baseUrl, item) {
9595
return {
9696
title: item.fields.naviMenuLinkText || item.fields.name,
9797
href: target(baseUrl, item),
98+
id: item.sys.id,
9899
};
99100
case 'navigationMenuItem':
100101
return {
101102
title: item.fields.linkText || item.fields.name,
102103
href: target(baseUrl, item),
104+
id: item.sys.id,
103105
};
104106
default: return {};
105107
}

0 commit comments

Comments
 (0)