import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; import { RouteTransition } from 'react-router-transition'; import { intlShape } from 'react-intl'; import { TitleBar } from 'electron-react-titlebar'; import Link from '../ui/Link'; import InfoBar from '../ui/InfoBar'; import { oneOrManyChildElements, globalError as globalErrorPropType } from '../../prop-types'; import globalMessages from '../../i18n/globalMessages'; import { isWindows } from '../../environment'; export default @observer class AuthLayout extends Component { static propTypes = { children: oneOrManyChildElements.isRequired, pathname: PropTypes.string.isRequired, error: globalErrorPropType.isRequired, isOnline: PropTypes.bool.isRequired, isAPIHealthy: PropTypes.bool.isRequired, retryHealthCheck: PropTypes.func.isRequired, isHealthCheckLoading: PropTypes.bool.isRequired, isFullScreen: PropTypes.bool.isRequired, darkMode: PropTypes.bool.isRequired, }; static contextTypes = { intl: intlShape, }; render() { const { children, pathname, error, isOnline, isAPIHealthy, retryHealthCheck, isHealthCheckLoading, isFullScreen, darkMode, } = this.props; const { intl } = this.context; return (
{isWindows && !isFullScreen && }
{!isOnline && ( {intl.formatMessage(globalMessages.notConnectedToTheInternet)} )} {isOnline && !isAPIHealthy && ( {intl.formatMessage(globalMessages.APIUnhealthy)} )}
({ transform: `translateX(${styles.translateX}%)`, opacity: styles.opacity, })} component="span" > {/* Inject globalError into children */} {React.cloneElement(children, { error, })}
{/*
*/}
); } }