'use strict'; import './lib/public-path'; import React, {Component} from 'react'; import ReactDOM from 'react-dom'; import { I18nextProvider, translate } from 'react-i18next'; import i18n from './lib/i18n'; import account from './account/root'; import blacklist from './blacklist/root'; import lists from './lists/root'; import namespaces from './namespaces/root'; import reports from './reports/root'; import templates from './templates/root'; import users from './users/root'; import sendConfigurations from './send-configurations/root'; import settings from './settings/root'; import { MenuLink, Section } from "./lib/page"; import mailtrainConfig from 'mailtrainConfig'; import Home from "./Home"; import { ActionLink, DropdownMenuItem, Icon } from "./lib/bootstrap-components"; import {Link} from "react-router-dom"; import axios from './lib/axios'; import {getUrl} from "./lib/urls"; @translate() class Root extends Component { constructor(props) { super(props); const t = props.t; const self = this; const topLevelMenuKeys = ['lists', 'templates', 'reports']; class MainMenu extends Component { render() { const path = this.props.location.pathname; const topLevelMenu = []; const topLevelItems = self.structure[''].children; for (const entryKey of topLevelMenuKeys) { const entry = topLevelItems[entryKey]; const link = entry.link || entry.externalLink; if (link && path.startsWith(link)) { topLevelMenu.push({entry.title} {t('(current)')}); } else { topLevelMenu.push({entry.title}); } } return ( ); } } this.structure = { '': { title: t('Home'), link: '/', panelComponent: Home, primaryMenuComponent: MainMenu, children: { ...lists.getMenus(t), ...reports.getMenus(t), ...templates.getMenus(t), ...namespaces.getMenus(t), ...users.getMenus(t), ...blacklist.getMenus(t), ...account.getMenus(t), ...settings.getMenus(t), ...sendConfigurations.getMenus(t) } } }; } async logout() { await axios.post(getUrl('rest/logout')); window.location = getUrl(); } render() { const t = this.props.t; return (
); } } export default function() { ReactDOM.render(,document.getElementById('root')); };