2017-01-25 18:51:41 +01:00
|
|
|
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
2016-12-27 11:15:02 +01:00
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2017-02-04 09:52:14 +01:00
|
|
|
import { observer } from 'mobx-react';
|
2017-07-17 18:37:33 +02:00
|
|
|
import React, { Component } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2016-12-27 11:15:02 +01:00
|
|
|
|
2017-05-12 12:06:16 +02:00
|
|
|
import { Button, DappUrlInput } from '@parity/ui';
|
|
|
|
import { CloseIcon, RefreshIcon, GotoIcon } from '@parity/ui/Icons';
|
2016-12-27 11:15:02 +01:00
|
|
|
|
2017-02-04 09:52:14 +01:00
|
|
|
@observer
|
2016-12-27 11:15:02 +01:00
|
|
|
export default class AddressBar extends Component {
|
|
|
|
static propTypes = {
|
|
|
|
className: PropTypes.string,
|
2017-02-04 09:52:14 +01:00
|
|
|
store: PropTypes.object.isRequired
|
2016-12-27 11:15:02 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
render () {
|
2017-02-04 09:52:14 +01:00
|
|
|
const { isLoading, isPristine, nextUrl } = this.props.store;
|
2016-12-27 11:15:02 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={ this.props.className }>
|
|
|
|
<Button
|
|
|
|
disabled={ isLoading }
|
2017-02-04 09:52:14 +01:00
|
|
|
onClick={ this.onRefreshUrl }
|
2017-01-18 13:05:01 +01:00
|
|
|
icon={
|
|
|
|
isLoading
|
2017-02-04 09:52:14 +01:00
|
|
|
? <CloseIcon />
|
|
|
|
: <RefreshIcon />
|
2017-01-18 13:05:01 +01:00
|
|
|
}
|
|
|
|
/>
|
2017-02-04 09:52:14 +01:00
|
|
|
<DappUrlInput
|
|
|
|
onChange={ this.onChangeUrl }
|
|
|
|
onGoto={ this.onGotoUrl }
|
|
|
|
onRestore={ this.onRestoreUrl }
|
|
|
|
url={ nextUrl }
|
2017-01-18 13:05:01 +01:00
|
|
|
/>
|
2016-12-27 11:15:02 +01:00
|
|
|
<Button
|
|
|
|
disabled={ isPristine }
|
2017-02-04 09:52:14 +01:00
|
|
|
onClick={ this.onGotoUrl }
|
2017-04-27 13:28:02 +02:00
|
|
|
icon={ <GotoIcon /> }
|
2017-01-18 13:05:01 +01:00
|
|
|
/>
|
2016-12-27 11:15:02 +01:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-02-04 09:52:14 +01:00
|
|
|
onRefreshUrl = () => {
|
|
|
|
this.props.store.reload();
|
|
|
|
}
|
2016-12-27 11:15:02 +01:00
|
|
|
|
2017-02-04 09:52:14 +01:00
|
|
|
onChangeUrl = (url) => {
|
|
|
|
this.props.store.setNextUrl(url);
|
|
|
|
}
|
2016-12-27 11:15:02 +01:00
|
|
|
|
2017-02-04 09:52:14 +01:00
|
|
|
onGotoUrl = () => {
|
|
|
|
this.props.store.gotoUrl();
|
|
|
|
}
|
2016-12-27 11:15:02 +01:00
|
|
|
|
2017-02-04 09:52:14 +01:00
|
|
|
onRestoreUrl = () => {
|
|
|
|
this.props.store.restoreUrl();
|
|
|
|
}
|
2016-12-27 11:15:02 +01:00
|
|
|
}
|