import { mdiFlash } from '@mdi/js'; import type { Response } from 'electron'; import { TitleBar } from 'electron-react-titlebar/renderer'; import { observer } from 'mobx-react'; import { Component, type MouseEventHandler, type ReactElement, cloneElement, } from 'react'; import { type WrappedComponentProps, injectIntl } from 'react-intl'; import { serverName } from '../../api/apiBase'; import { GITHUB_FERDIUM_URL } from '../../config'; import { isWindows } from '../../environment'; import { Component as PublishDebugInfo } from '../../features/publishDebugInfo'; import { updateVersionParse } from '../../helpers/update-helpers'; import globalMessages from '../../i18n/globalMessages'; import AppUpdateInfoBar from '../AppUpdateInfoBar'; import InfoBar from '../ui/InfoBar'; import Link from '../ui/Link'; import Icon from '../ui/icon'; export interface IProps extends WrappedComponentProps { children: ReactElement; error: Response; isOnline: boolean; isAPIHealthy: boolean; retryHealthCheck: MouseEventHandler; isHealthCheckLoading: boolean; isFullScreen: boolean; installAppUpdate: MouseEventHandler; appUpdateIsDownloaded: boolean; updateVersion: string; } interface IState { shouldShowAppUpdateInfoBar: boolean; } @observer class AuthLayout extends Component { constructor(props: IProps) { super(props); this.state = { shouldShowAppUpdateInfoBar: true, }; } render(): ReactElement { const { children, error, isOnline, isAPIHealthy, retryHealthCheck, isHealthCheckLoading, isFullScreen, installAppUpdate, appUpdateIsDownloaded, updateVersion, intl, } = this.props; let serverNameParse = serverName(); serverNameParse = serverNameParse === 'Custom' ? 'your Custom Server' : serverNameParse; return ( <> {isWindows && !isFullScreen && ( )}
{!isOnline && ( {intl.formatMessage(globalMessages.notConnectedToTheInternet)} )} {appUpdateIsDownloaded && this.state.shouldShowAppUpdateInfoBar && ( { this.setState({ shouldShowAppUpdateInfoBar: false }); }} /> )} {isOnline && !isAPIHealthy && ( {intl.formatMessage(globalMessages.APIUnhealthy, { serverNameParse, })} )}
{/* Inject globalError into children */} {cloneElement(children, { error })}
{/*
*/} ); } } export default injectIntl(AuthLayout);