Configuration split to lists, send configurations and server config.

This is before testing.
This commit is contained in:
Tomas Bures 2018-04-22 17:33:43 +02:00
parent 4fce4b6f81
commit c12efeb97f
40 changed files with 819 additions and 311 deletions

View file

@ -11,6 +11,7 @@ import {Button, DismissibleAlert} from "./bootstrap-components";
import mailtrainConfig from "mailtrainConfig";
import styles from "./styles.scss";
import {getRoutes, needsResolve, resolve, withPageHelpers} from "./page-common";
import {getBaseDir} from "./urls";
class Breadcrumb extends Component {
static propTypes = {
@ -382,7 +383,7 @@ class Section extends Component {
render() {
return (
<Router basename={mailtrainConfig.urlBase}>
<Router basename={getBaseDir()}>
<SectionContent root={this.props.root} structure={this.structure} />
</Router>
);

View file

@ -63,7 +63,7 @@ export class UntrustedContentHost extends Component {
sendMessage(type, data) {
if (this.contentNodeIsLoaded) { // This is to avoid errors "common.js:45744 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('http://localhost:8081') does not match the recipient window's origin ('http://localhost:3000')"
this.contentNode.contentWindow.postMessage({type, data}, getSandboxUrl(''));
this.contentNode.contentWindow.postMessage({type, data}, getSandboxUrl());
}
}
@ -197,7 +197,7 @@ export class UntrustedContentRoot extends Component {
}
sendMessage(type, data) {
window.parent.postMessage({type, data}, getTrustedUrl(''));
window.parent.postMessage({type, data}, getTrustedUrl());
}
componentDidMount() {

View file

@ -2,36 +2,33 @@
import mailtrainConfig from "mailtrainConfig";
let urlBase;
let sandboxUrlBase;
if (mailtrainConfig.urlBase.startsWith('/')) {
urlBase = window.location.protocol + '//' + window.location.hostname + ':' + mailtrainConfig.port + mailtrainConfig.urlBase;
} else {
urlBase = mailtrainConfig.urlBase
}
if (mailtrainConfig.sandboxUrlBase) {
if (mailtrainConfig.urlBase.startsWith('/')) {
sandboxUrlBase = window.location.protocol + '//' + window.location.hostname + ':' + mailtrainConfig.sandboxPort + mailtrainConfig.sandboxUrlBase;
} else {
sandboxUrlBase = mailtrainConfig.sandboxUrlBase
}
} else {
const loc = document.createElement("a");
loc.href = urlBase;
sandboxUrlBase = loc.protocol + '//' + loc.hostname + ':' + mailtrainConfig.sandboxPort + loc.pathname;
}
function getTrustedUrl(path) {
return urlBase + path;
return mailtrainConfig.trustedUrlBase + (path || '');
}
function getSandboxUrl(path) {
return sandboxUrlBase + path;
return mailtrainConfig.sandboxUrlBase + (path || '');
}
function getUrl(path) {
if (mailtrainConfig.trusted) {
return getTrustedUrl(path);
} else {
return getSandboxUrl(path);
}
}
function getBaseDir() {
if (mailtrainConfig.trusted) {
return mailtrainConfig.trustedUrlBaseDir;
} else {
return mailtrainConfig.sandboxUrlBaseDir;
}
}
export {
getTrustedUrl,
getSandboxUrl
getSandboxUrl,
getUrl,
getBaseDir
}