WIP UI (dialog available)

This commit is contained in:
Jaco Greeff 2016-12-12 15:51:36 +01:00
parent c784ab55d2
commit 1135674eaa
8 changed files with 227 additions and 10 deletions

View File

@ -0,0 +1,31 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// 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/>.
import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
@observer
export default class Info extends Component {
static propTypes = {
store: PropTypes.object.isRequired
}
render () {
return (
<div>info</div>
);
}
}

View File

@ -0,0 +1,17 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// 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/>.
export default from './upgrade';

View File

@ -0,0 +1,33 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// 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/>.
import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import styles from './.css';
@observer
export default class Upgrade extends Component {
static propTypes = {
store: PropTypes.object.isRequired
}
render () {
return (
<div className={ styles.body }>hello</div>
);
}
}

View File

@ -0,0 +1,86 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// 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/>.
import { action, observable, transaction } from 'mobx';
import store from 'store';
const AN_HOUR = 60 * 60 * 1000;
const A_DAY = 24 * AN_HOUR;
const CHECK_INTERVAL = AN_HOUR;
const LS_UPDATE = '_parity::update';
export default class Store {
@observable availableUpgrade = null;
@observable remindAt = 0;
@observable showUpgrade = false;
constructor (api) {
this._api = api;
this.checkUpgrade();
setInterval(this.pollUpgrade, CHECK_INTERVAL);
}
@action loadStorage () {
const values = store.get(LS_UPDATE) || {};
this.remindAt = values.remindAt ? values.remindAt : 0;
return values;
}
@action setAvailableUpgrade (availableUpgrade, consensusCapability) {
transaction(() => {
this.setConsensusCapability(consensusCapability);
this.availableUpgrade = availableUpgrade;
if (availableUpgrade && Date.now() >= this.remindAt) {
this.showUpgrade = true;
}
});
}
@action setConsensusCapability (consensusCapability) {
this.consensusCapability = consensusCapability;
}
@action snoozeTillTomorrow () {
store.set(LS_UPDATE, Object.assign(this.loadStorage(), {
remindAt: Date.now() + A_DAY
}));
}
checkUpgrade = () => {
this.loadStorage();
return Promise
.all([
this._api.parity.upgradeReady(),
this._api.parity.consensusCapability()
])
.then(([availableUpgrade, consensusCapability]) => {
this.setAvailableUpgrade(availableUpgrade, consensusCapability);
})
.catch((error) => {
console.warn('checkUpgrade', error);
});
}
executeUpgrade = () => {
return this._api.parity
.executeUpgrade();
}
}

View File

@ -0,0 +1,47 @@
// Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// 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/>.
import { observer } from 'mobx-react';
import React, { Component, PropTypes } from 'react';
import { Button, Modal } from '~/ui';
import Store from './store';
@observer
export default class UpgradeParity extends Component {
static contextTypes = {
api: PropTypes.object.isRequired
};
store = new Store(this.context.api);
render () {
if (!this.store.showUpgrade) {
return null;
}
return (
<Modal
buttons={ [
<Button />
] }
visible>
<div />
</Modal>
);
}
}

View File

@ -23,12 +23,13 @@ import DeployContract from './DeployContract';
import EditMeta from './EditMeta';
import ExecuteContract from './ExecuteContract';
import FirstRun from './FirstRun';
import LoadContract from './LoadContract';
import SaveContract from './SaveContract';
import Shapeshift from './Shapeshift';
import SMSVerification from './SMSVerification';
import Transfer from './Transfer';
import PasswordManager from './PasswordManager';
import SaveContract from './SaveContract';
import LoadContract from './LoadContract';
import UpgradeParity from './UpgradeParity';
import WalletSettings from './WalletSettings';
export {
@ -41,11 +42,12 @@ export {
EditMeta,
ExecuteContract,
FirstRun,
LoadContract,
SaveContract,
Shapeshift,
SMSVerification,
Transfer,
PasswordManager,
LoadContract,
SaveContract,
UpgradeParity,
WalletSettings
};

View File

@ -16,7 +16,7 @@
import React, { Component, PropTypes } from 'react';
import { FirstRun } from '~/modals';
import { FirstRun, UpgradeParity } from '~/modals';
import { Errors, ParityBackground, Tooltips } from '~/ui';
import styles from '../application.css';
@ -28,20 +28,21 @@ export default class Container extends Component {
static propTypes = {
children: PropTypes.node.isRequired,
showFirstRun: PropTypes.bool,
onCloseFirstRun: PropTypes.func
onCloseFirstRun: PropTypes.func,
showFirstRun: PropTypes.bool
};
render () {
const { children, showFirstRun, onCloseFirstRun } = this.props;
const { muiTheme } = this.context;
const { children, onCloseFirstRun, showFirstRun } = this.props;
return (
<ParityBackground className={ styles.container } muiTheme={ muiTheme }>
<FirstRun
visible={ showFirstRun }
onClose={ onCloseFirstRun } />
onClose={ onCloseFirstRun }
visible={ showFirstRun } />
<Tooltips />
<UpgradeParity />
<Errors />
{ children }
</ParityBackground>