import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { observer } from 'mobx-react'; 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'; import AppUpdateInfoBar from '../AppUpdateInfoBar'; import { GITHUB_FERDI_URL } from '../../config'; export default @observer class AuthLayout extends Component { static propTypes = { children: oneOrManyChildElements.isRequired, error: globalErrorPropType.isRequired, isOnline: PropTypes.bool.isRequired, isAPIHealthy: PropTypes.bool.isRequired, retryHealthCheck: PropTypes.func.isRequired, isHealthCheckLoading: PropTypes.bool.isRequired, isFullScreen: PropTypes.bool.isRequired, nextAppReleaseVersion: PropTypes.string, installAppUpdate: PropTypes.func.isRequired, appUpdateIsDownloaded: PropTypes.bool.isRequired, }; state = { shouldShowAppUpdateInfoBar: true, }; static defaultProps = { nextAppReleaseVersion: null, }; static contextTypes = { intl: intlShape, }; render() { const { children, error, isOnline, isAPIHealthy, retryHealthCheck, isHealthCheckLoading, isFullScreen, nextAppReleaseVersion, installAppUpdate, appUpdateIsDownloaded, } = this.props; const { intl } = this.context; return ( <> {isWindows && !isFullScreen && ( )}
{!isOnline && ( {intl.formatMessage(globalMessages.notConnectedToTheInternet)} )} {appUpdateIsDownloaded && this.state.shouldShowAppUpdateInfoBar && ( { this.setState({ shouldShowAppUpdateInfoBar: false }); }} /> )} {isOnline && !isAPIHealthy && ( {intl.formatMessage(globalMessages.APIUnhealthy)} )}
{/* Inject globalError into children */} {React.cloneElement(children, { error, })}
{/*
*/} ); } }