William O'Beirne aa0f9cd455 Electron Redesign (#1505)
* Frameless Electron. Separate electron template. Generecize navigation link. Move nav info to config.

* Add controls for language and node, network status to sidebar.

* Sticky headers

* Move custom node modal into standalone component. Render modals via portal. Add custom node modal opening to electron node list.

* Conditional styling based on environment.

* Fix active node highlight

* Add frame back in, draggable only on OSX, fix sidebar scroll.

* Remove panel content after delay.

* Adjust window sizes

* Style desktop help nav icon

* Remove unused var

* Move style to param

* Remove unused

* Update snapshot

* Fix oversized stretching, zindex fighting

* Make electron work better with various screen sizes

* Remove not-working https option for electron

* Add beta banner

* Fix web footer

* Address changes
2018-04-16 18:30:58 -05:00

50 lines
1.4 KiB
TypeScript

import React from 'react';
import { connect } from 'react-redux';
import translate from 'translations';
import { getNetworkConfig, getOffline, isNodeChanging } from 'selectors/config';
import { NetworkConfig } from 'types/network';
import { AppState } from 'reducers';
import './NetworkStatus.scss';
enum NETWORK_STATUS {
CONNECTING = 'NETWORK_STATUS_CONNECTING',
OFFLINE = 'NETWORK_STATUS_OFFLINE',
ONLINE = 'NETWORK_STATUS_ONLINE'
}
interface StateProps {
network: NetworkConfig;
isOffline: boolean;
isChangingNode: boolean;
}
const NetworkStatus: React.SFC<StateProps> = ({ isOffline, isChangingNode, network }) => {
let statusClass: string;
let statusText: string;
const $network = network.isCustom ? network.unit : network.name;
if (isChangingNode) {
statusClass = 'is-connecting';
statusText = NETWORK_STATUS.CONNECTING;
} else if (isOffline) {
statusClass = 'is-offline';
statusText = NETWORK_STATUS.OFFLINE;
} else {
statusClass = 'is-online';
statusText = NETWORK_STATUS.ONLINE;
}
return (
<div className="NetworkStatus">
<div className={`NetworkStatus-icon ${statusClass}`} />
<div className="NetworkStatus-text">{translate(statusText, { $network })}</div>
</div>
);
};
export default connect((state: AppState): StateProps => ({
network: getNetworkConfig(state),
isOffline: getOffline(state),
isChangingNode: isNodeChanging(state)
}))(NetworkStatus);