'use strict'; import './lib/public-path'; import React, {Component} from 'react'; import ReactDOM from 'react-dom'; import {I18nextProvider} from 'react-i18next'; import i18n, {withTranslation} 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 campaigns from './campaigns/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"; import {langCodes} from "../../shared/langs"; const topLevelMenuKeys = ['lists', 'templates', 'campaigns']; if (mailtrainConfig.reportsEnabmed) { topLevelMenuKeys.push('reports'); } @withTranslation() class Root extends Component { constructor(props) { super(props); } render() { const t = this.props.t; const structure = {}; // The MainMenu component is defined here in order to avoid recreating menu structure on every change in the main menu // This is because Root component depends only on the language, thus it is redrawn (and the structure is recomputed) only when the language changes class MainMenu extends Component { constructor(props) { super(props); } async logout() { await axios.post(getUrl('rest/logout')); window.location = getUrl(); } render() { const languageOptions = []; for (const lng of mailtrainConfig.enabledLanguages) { const langDesc = langCodes[lng]; const label = langDesc.getLabel(t); languageOptions.push(