Skip to content

Commit

Permalink
Update loaders of navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
karelhala committed Sep 14, 2020
1 parent 581386a commit bf437b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
5 changes: 0 additions & 5 deletions src/js/App/Header/Loader.js

This file was deleted.

5 changes: 2 additions & 3 deletions src/js/App/Header/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { lazy, Suspense } from 'react';
import React, { lazy, Suspense, Fragment } from 'react';
import { Provider } from 'react-redux';
import { render } from 'react-dom';
import HeaderLoader from './Loader';
import { spinUpStore } from '../../redux-config';

const Header = lazy(() => import(/* webpackChunkName: "Sidenav" */ './Header'));
Expand All @@ -11,7 +10,7 @@ export const headerLoader = () => {
if (document.querySelector('header')) {
render(
<Provider store={store}>
<Suspense fallback={<HeaderLoader />}>
<Suspense fallback={<Fragment />}>
<Header />
</Suspense>
</Provider>,
Expand Down
4 changes: 2 additions & 2 deletions src/js/App/Sidenav/__snapshots__/Navigation.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ exports[`Navigation should render corectly 1`] = `
ariaRightScroll="Scroll right"
>
<NavExpandable
className="ins-m-navigation-align"
className=""
groupId={null}
id=""
isActive={true}
Expand Down Expand Up @@ -348,7 +348,7 @@ exports[`Navigation should render correctly 2 1`] = `
ariaRightScroll="Scroll right"
>
<NavExpandable
className="ins-m-navigation-align"
className=""
groupId={null}
id=""
isActive={true}
Expand Down
9 changes: 4 additions & 5 deletions src/js/nav/globalNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export let getNavFromConfig = async (masterConfig) => {
};

const isCurrVisible = (permissions) => Promise.all(
flatMap([permissions], ({ method } = {}) => (
flatMap([permissions], async ({ method, args } = {}) => (
// (null, undefined, true) !== false
visibilityFunctions?.[method]?.(...permissions.args || []) !== false || false
await visibilityFunctions?.[method]?.(...args || []) !== false
))
).then(visibility => visibility.every(Boolean));

Expand Down Expand Up @@ -81,13 +81,12 @@ export async function loadNav(yamlConfig) {
const groupedNav = await getNavFromConfig(safeLoad(yamlConfig));

const [active, section] = [getUrl('bundle'), getUrl('app')];
const globalNav = (groupedNav[active] || groupedNav.insights).routes;
let activeSection = globalNav.find(({ id }) => id === section);
const globalNav = (groupedNav[active] || groupedNav.insights)?.routes;
return groupedNav[active] ? {
globalNav,
activeTechnology: groupedNav[active].title,
activeLocation: active,
activeSection
activeSection: globalNav?.find?.(({ id }) => id === section)
} : {
globalNav,
activeTechnology: 'Applications'
Expand Down
3 changes: 2 additions & 1 deletion testdata/masterConfigPermissions.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@
"title": "Bla"
},
"permissions": {
"method": "isEntitled"
"method": "isEntitled",
"args": ["something"]
},
"title": "appF"
}
Expand Down

0 comments on commit bf437b5

Please sign in to comment.