Some cleanup/small fixes.

This commit is contained in:
Tomas Bures 2019-08-23 13:50:43 +02:00
parent 5abf100776
commit 427f0ec2c2
7 changed files with 16 additions and 21 deletions

View file

@ -818,7 +818,7 @@ class TreeTableSelect extends Component {
dataUrl: PropTypes.string, dataUrl: PropTypes.string,
data: PropTypes.array, data: PropTypes.array,
help: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), help: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
format: PropTypes.string, format: PropTypes.string
} }
async onSelectionChangedAsync(sel) { async onSelectionChangedAsync(sel) {

View file

@ -4,6 +4,7 @@ import React, {Component} from 'react';
import {withTranslation} from './i18n'; import {withTranslation} from './i18n';
import {TreeTableSelect} from './form'; import {TreeTableSelect} from './form';
import {withComponentMixins} from "./decorator-helpers"; import {withComponentMixins} from "./decorator-helpers";
import mailtrainConfig from 'mailtrainConfig';
@withComponentMixins([ @withComponentMixins([

View file

@ -193,8 +193,8 @@ export function getRoutes(structure, parentRoute) {
structure: entry.structure, structure: entry.structure,
panelComponent: entry.panelComponent, panelComponent: entry.panelComponent,
panelRender: entry.panelRender, panelRender: entry.panelRender,
primaryMenuComponent: entry.primaryMenuComponent || primaryMenuComponent, primaryMenuComponent: (entry.primaryMenuComponent || entry.primaryMenuComponent === null) ? entry.primaryMenuComponent : primaryMenuComponent,
secondaryMenuComponent: entry.secondaryMenuComponent || secondaryMenuComponent, secondaryMenuComponent: (entry.secondaryMenuComponent || entry.secondaryMenuComponent === null) ? entry.secondaryMenuComponent : secondaryMenuComponent,
title: entry.title, title: entry.title,
link: entry.link, link: entry.link,
panelInFullScreen: entry.panelInFullScreen, panelInFullScreen: entry.panelInFullScreen,

View file

@ -485,7 +485,7 @@ export class SectionContent extends Component {
return renderRoute( return renderRoute(
route, route,
PanelRoute, PanelRoute,
() => renderFrameWithContent(t,false, false, null, null, getLoadingMessage(this.props.t)), () => renderFrameWithContent(t, false, false, null, null, getLoadingMessage(this.props.t)),
flashMessage, flashMessage,
props props
); );

View file

@ -155,7 +155,7 @@ class Table extends Component {
for (const row of response.data) { for (const row of response.data) {
const key = row[this.props.selectionKeyIndex]; const key = row[this.props.selectionKeyIndex];
if (oldSelectionMap.has(key)) { if (oldSelectionMap.has(key)) {
this.selectionMap.set(key, row) this.selectionMap.set(key, row);
} }
} }

View file

@ -32,6 +32,8 @@ export class UntrustedContentHost extends Component {
this.rpcCounter = 0; this.rpcCounter = 0;
this.rpcResolves = new Map(); this.rpcResolves = new Map();
this.unmounted = false;
} }
static propTypes = { static propTypes = {
@ -111,7 +113,7 @@ export class UntrustedContentHost extends Component {
this.accessToken = result.data; this.accessToken = result.data;
if (!this.state.hasAccessToken) { if (!this.state.hasAccessToken && !this.unmounted) {
this.setState({ this.setState({
hasAccessToken: true hasAccessToken: true
}) })
@ -152,6 +154,7 @@ export class UntrustedContentHost extends Component {
} }
componentWillUnmount() { componentWillUnmount() {
this.unmounted = true;
clearTimeout(this.refreshAccessTokenTimeout); clearTimeout(this.refreshAccessTokenTimeout);
window.removeEventListener('message', this.receiveMessageHandler, false); window.removeEventListener('message', this.receiveMessageHandler, false);
} }

View file

@ -7,15 +7,15 @@ import i18n from './i18n';
let restrictedAccessToken = anonymousRestrictedAccessToken; let restrictedAccessToken = anonymousRestrictedAccessToken;
function setRestrictedAccessToken(token) { export function setRestrictedAccessToken(token) {
restrictedAccessToken = token; restrictedAccessToken = token;
} }
function getTrustedUrl(path) { export function getTrustedUrl(path) {
return mailtrainConfig.trustedUrlBase + (path || ''); return mailtrainConfig.trustedUrlBase + (path || '');
} }
function getSandboxUrl(path, customRestrictedAccessToken, opts) { export function getSandboxUrl(path, customRestrictedAccessToken, opts) {
const localRestrictedAccessToken = customRestrictedAccessToken || restrictedAccessToken; const localRestrictedAccessToken = customRestrictedAccessToken || restrictedAccessToken;
const url = new URL(localRestrictedAccessToken + '/' + (path || ''), mailtrainConfig.sandboxUrlBase); const url = new URL(localRestrictedAccessToken + '/' + (path || ''), mailtrainConfig.sandboxUrlBase);
@ -26,7 +26,7 @@ function getSandboxUrl(path, customRestrictedAccessToken, opts) {
return url.toString(); return url.toString();
} }
function getPublicUrl(path, opts) { export function getPublicUrl(path, opts) {
const url = new URL(path || '', mailtrainConfig.publicUrlBase); const url = new URL(path || '', mailtrainConfig.publicUrlBase);
if (opts && opts.withLocale) { if (opts && opts.withLocale) {
@ -36,7 +36,7 @@ function getPublicUrl(path, opts) {
return url.toString(); return url.toString();
} }
function getUrl(path) { export function getUrl(path) {
if (mailtrainConfig.appType === AppType.TRUSTED) { if (mailtrainConfig.appType === AppType.TRUSTED) {
return getTrustedUrl(path); return getTrustedUrl(path);
} else if (mailtrainConfig.appType === AppType.SANDBOXED) { } else if (mailtrainConfig.appType === AppType.SANDBOXED) {
@ -46,7 +46,7 @@ function getUrl(path) {
} }
} }
function getBaseDir() { export function getBaseDir() {
if (mailtrainConfig.appType === AppType.TRUSTED) { if (mailtrainConfig.appType === AppType.TRUSTED) {
return mailtrainConfig.trustedUrlBaseDir; return mailtrainConfig.trustedUrlBaseDir;
} else if (mailtrainConfig.appType === AppType.SANDBOXED) { } else if (mailtrainConfig.appType === AppType.SANDBOXED) {
@ -55,12 +55,3 @@ function getBaseDir() {
return mailtrainConfig.publicUrlBaseDir; return mailtrainConfig.publicUrlBaseDir;
} }
} }
export {
getTrustedUrl,
getSandboxUrl,
getPublicUrl,
getUrl,
getBaseDir,
setRestrictedAccessToken
}