2017-05-23 23:06:01 +00:00
|
|
|
// @flow
|
|
|
|
import React, { Component } from 'react';
|
2017-07-15 04:16:36 +00:00
|
|
|
import Navigation from './components/Navigation';
|
2017-07-20 17:06:10 +00:00
|
|
|
import GasPriceDropdown from './components/GasPriceDropdown';
|
2017-05-23 23:06:01 +00:00
|
|
|
import { Link } from 'react-router';
|
2017-06-26 22:27:55 +00:00
|
|
|
import { Dropdown } from 'components/ui';
|
2017-08-25 07:37:36 +00:00
|
|
|
import {
|
|
|
|
languages,
|
|
|
|
NODES,
|
|
|
|
VERSION,
|
|
|
|
ANNOUNCEMENT_TYPE,
|
|
|
|
ANNOUNCEMENT_MESSAGE
|
|
|
|
} from '../../config/data';
|
2017-07-14 17:04:08 +00:00
|
|
|
import logo from 'assets/images/logo-myetherwallet.svg';
|
2017-04-12 05:04:27 +00:00
|
|
|
|
2017-07-15 04:16:36 +00:00
|
|
|
import './index.scss';
|
|
|
|
|
2017-04-12 05:04:27 +00:00
|
|
|
export default class Header extends Component {
|
2017-07-04 03:21:19 +00:00
|
|
|
props: {
|
2017-07-15 04:16:36 +00:00
|
|
|
location: {},
|
2017-07-04 03:21:19 +00:00
|
|
|
languageSelection: string,
|
|
|
|
nodeSelection: string,
|
2017-07-20 17:06:10 +00:00
|
|
|
gasPriceGwei: number,
|
2017-06-18 19:56:12 +00:00
|
|
|
|
2017-07-04 03:21:19 +00:00
|
|
|
changeLanguage: (sign: string) => any,
|
2017-07-20 17:06:10 +00:00
|
|
|
changeNode: (key: string) => any,
|
|
|
|
changeGasPrice: (price: number) => any
|
2017-07-02 05:49:06 +00:00
|
|
|
};
|
2017-04-12 05:04:27 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
render() {
|
2017-07-04 03:21:19 +00:00
|
|
|
const { languageSelection, changeNode, nodeSelection } = this.props;
|
|
|
|
const selectedLanguage =
|
|
|
|
languages.find(l => l.sign === languageSelection) || languages[0];
|
|
|
|
const selectedNode = NODES[nodeSelection];
|
2017-04-14 06:20:39 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
return (
|
2017-07-15 04:16:36 +00:00
|
|
|
<div className="Header">
|
2017-08-25 07:37:36 +00:00
|
|
|
{ANNOUNCEMENT_MESSAGE &&
|
|
|
|
<div
|
|
|
|
className={`Header-announcement is-${ANNOUNCEMENT_TYPE}`}
|
|
|
|
dangerouslySetInnerHTML={{
|
|
|
|
__html: ANNOUNCEMENT_MESSAGE
|
|
|
|
}}
|
|
|
|
/>}
|
|
|
|
|
2017-07-15 04:16:36 +00:00
|
|
|
<section className="Header-branding">
|
|
|
|
<section className="Header-branding-inner container">
|
|
|
|
<Link
|
|
|
|
to={'/'}
|
|
|
|
className="Header-branding-title"
|
|
|
|
aria-label="Go to homepage"
|
|
|
|
>
|
|
|
|
{/* TODO - don't hardcode image path*/}
|
|
|
|
<img
|
|
|
|
className="Header-branding-title-logo"
|
|
|
|
src={logo}
|
|
|
|
height="64px"
|
|
|
|
width="245px"
|
|
|
|
alt="MyEtherWallet"
|
|
|
|
/>
|
2017-07-02 05:49:06 +00:00
|
|
|
</Link>
|
2017-07-15 04:16:36 +00:00
|
|
|
<div className="Header-branding-title-tagline">
|
2017-08-25 07:37:36 +00:00
|
|
|
<span className="Header-branding-title-tagline-version">
|
|
|
|
Open-Source & Client-Side Ether Wallet · v{VERSION}
|
2017-07-02 05:49:06 +00:00
|
|
|
</span>
|
2017-07-15 04:16:36 +00:00
|
|
|
|
2017-07-20 17:06:10 +00:00
|
|
|
<GasPriceDropdown
|
|
|
|
value={this.props.gasPriceGwei}
|
|
|
|
onChange={this.props.changeGasPrice}
|
|
|
|
/>
|
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
<Dropdown
|
2017-07-04 03:21:19 +00:00
|
|
|
ariaLabel={`change language. current language ${selectedLanguage.name}`}
|
2017-07-02 05:49:06 +00:00
|
|
|
options={languages}
|
|
|
|
formatTitle={o => o.name}
|
2017-07-04 03:21:19 +00:00
|
|
|
value={selectedLanguage}
|
2017-07-02 05:49:06 +00:00
|
|
|
extra={[
|
|
|
|
<li key={'separator'} role="separator" className="divider" />,
|
|
|
|
<li key={'disclaimer'}>
|
|
|
|
<a data-toggle="modal" data-target="#disclaimerModal">
|
|
|
|
Disclaimer
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
]}
|
2017-07-04 03:21:19 +00:00
|
|
|
onChange={this.changeLanguage}
|
2017-07-02 05:49:06 +00:00
|
|
|
/>
|
2017-07-15 04:16:36 +00:00
|
|
|
|
2017-07-02 05:49:06 +00:00
|
|
|
<Dropdown
|
2017-07-04 03:21:19 +00:00
|
|
|
ariaLabel={`change node. current node ${selectedNode.network} node by ${selectedNode.service}`}
|
|
|
|
options={Object.keys(NODES)}
|
2017-07-02 05:49:06 +00:00
|
|
|
formatTitle={o => [
|
2017-07-04 03:21:19 +00:00
|
|
|
NODES[o].network,
|
2017-07-02 05:49:06 +00:00
|
|
|
' ',
|
2017-07-04 03:21:19 +00:00
|
|
|
<small key="service">
|
|
|
|
({NODES[o].service})
|
|
|
|
</small>
|
2017-07-02 05:49:06 +00:00
|
|
|
]}
|
|
|
|
value={nodeSelection}
|
|
|
|
extra={
|
|
|
|
<li>
|
2017-07-04 03:21:19 +00:00
|
|
|
<a onClick={() => {}}>Add Custom Node</a>
|
2017-07-02 05:49:06 +00:00
|
|
|
</li>
|
|
|
|
}
|
|
|
|
onChange={changeNode}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</section>
|
2017-04-18 23:36:29 +00:00
|
|
|
|
2017-07-15 04:16:36 +00:00
|
|
|
<Navigation location={this.props.location} />
|
2017-07-02 05:49:06 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2017-07-04 01:25:01 +00:00
|
|
|
|
2017-07-04 03:21:19 +00:00
|
|
|
changeLanguage = (value: { sign: string }) => {
|
|
|
|
this.props.changeLanguage(value.sign);
|
|
|
|
};
|
2017-04-12 05:04:27 +00:00
|
|
|
}
|