Commit 3cae9c50 authored by Maksym Tishchenko's avatar Maksym Tishchenko Committed by Matija Obreza
Browse files

Dynamic menus

parent 45b16de8
......@@ -292,6 +292,7 @@ module.exports = {
{ from: 'assets/images', to: 'images' },
{ from: 'assets/audio', to: 'audio' },
{ from: './generated/locales', to: 'locales' },
{ from: 'extensions', to: 'extensions' },
],
}),
......
......@@ -10,6 +10,7 @@ import { routerMiddleware, ConnectedRouter } from 'connected-react-router';
import { createBrowserHistory as createHistory } from 'history';
import * as moment from 'moment';
import { HelmetProvider } from 'react-helmet-async';
import axios from 'axios';
// middleware
import detectLocaleFromPath from 'server/middleware/detectLocaleFromPath';
import getDir from 'server/middleware/detectDirection';
......@@ -30,7 +31,22 @@ import renderRoutes from '_core/routing/renderRoutes';
declare const __PRELOADED_STATE__: any;
declare const window: Window & { devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any, initialLanguage: any, initialI18nStore: any, localeMapping: any };
declare const window: Window & {
extMenus: {title: string, link: string}[],
devToolsExtension: any, __REDUX_DEVTOOLS_EXTENSION_COMPOSE__: any,
initialLanguage: any, initialI18nStore: any, localeMapping: any,
};
if (typeof window !== 'undefined') {
axios.get('/extensions/menu.json').then((resp) => {
console.log('Retrieved menus', resp.data);
window.extMenus = Array.from(resp.data as {title: string, link: string}[]);
}).catch((err) => {
console.log('No menus', err);
window.extMenus = undefined;
});
}
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const initialLanguage = window.initialLanguage;
......
[
{
"title": "Intranet",
"link": "https://intranet.local"
},
{
"title": "Public website",
"link": "https://www.institute"
}
]
......@@ -9,6 +9,9 @@ import { UserRole } from '@gringlobal/client/model/gringlobal/SysUser';
import { bindActionCreators, compose } from 'redux';
import { logoutUserAction } from '@gringlobal/client/action/login';
declare const window: Window & {
extMenus: {title: string, link: string}[],
};
function PublicMenu(props): JSX.Element {
const { t } = useTranslation();
......@@ -28,6 +31,16 @@ function PublicMenu(props): JSX.Element {
</ListItem>
</Link>
<Divider />
{
typeof window !== 'undefined' && window.extMenus && window.extMenus.map(({ link, title }) => (
<a key={ `${link}-${title}` } href={ link }>
<ListItem button>
<ListItemText primary={ title } />
</ListItem>
</a>
))
}
<Divider />
<Authorize roles={ [ UserRole.USER ] }>
<>
<Link to="/request">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment