2018-04-16 23:30:58 +00:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2018-05-11 15:15:32 +00:00
|
|
|
import { Footer, Header } from 'components';
|
2018-04-16 23:30:58 +00:00
|
|
|
import { AppState } from 'reducers';
|
|
|
|
import Notifications from './Notifications';
|
|
|
|
import OfflineTab from './OfflineTab';
|
|
|
|
import { getOffline, getLatestBlock } from 'selectors/config';
|
|
|
|
import { Query } from 'components/renderCbs';
|
2018-05-29 14:51:42 +00:00
|
|
|
import { makeAutoNodeName } from 'libs/nodes';
|
2018-04-16 23:30:58 +00:00
|
|
|
import './WebTemplate.scss';
|
|
|
|
|
|
|
|
interface StateProps {
|
|
|
|
isOffline: AppState['config']['meta']['offline'];
|
|
|
|
latestBlock: AppState['config']['meta']['latestBlock'];
|
|
|
|
}
|
|
|
|
|
|
|
|
interface OwnProps {
|
|
|
|
isUnavailableOffline?: boolean;
|
|
|
|
children: string | React.ReactElement<string> | React.ReactElement<string>[];
|
|
|
|
}
|
|
|
|
|
|
|
|
type Props = OwnProps & StateProps;
|
|
|
|
|
|
|
|
class WebTemplate extends Component<Props, {}> {
|
|
|
|
public render() {
|
|
|
|
const { isUnavailableOffline, children, isOffline, latestBlock } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="WebTemplate">
|
|
|
|
<Query
|
|
|
|
params={['network']}
|
|
|
|
withQuery={({ network }) => (
|
2018-05-29 14:51:42 +00:00
|
|
|
<Header networkParam={network && makeAutoNodeName(network)} />
|
2018-04-16 23:30:58 +00:00
|
|
|
)}
|
|
|
|
/>
|
|
|
|
<div className="Tab container">
|
|
|
|
{isUnavailableOffline && isOffline ? <OfflineTab /> : children}
|
|
|
|
</div>
|
|
|
|
<div className="WebTemplate-spacer" />
|
|
|
|
<Footer latestBlock={latestBlock} />
|
|
|
|
<Notifications />
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapStateToProps(state: AppState): StateProps {
|
|
|
|
return {
|
|
|
|
isOffline: getOffline(state),
|
|
|
|
latestBlock: getLatestBlock(state)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, {})(WebTemplate);
|