WIP UI (dialog available)
This commit is contained in:
parent
c784ab55d2
commit
1135674eaa
0
js/src/modals/UpgradeParity/Info/index.js
Normal file
0
js/src/modals/UpgradeParity/Info/index.js
Normal file
31
js/src/modals/UpgradeParity/Info/info.js
Normal file
31
js/src/modals/UpgradeParity/Info/info.js
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
17
js/src/modals/UpgradeParity/Upgrade/index.js
Normal file
17
js/src/modals/UpgradeParity/Upgrade/index.js
Normal 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';
|
33
js/src/modals/UpgradeParity/Upgrade/upgrade.js
Normal file
33
js/src/modals/UpgradeParity/Upgrade/upgrade.js
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
86
js/src/modals/UpgradeParity/store.js
Normal file
86
js/src/modals/UpgradeParity/store.js
Normal 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();
|
||||
}
|
||||
}
|
47
js/src/modals/UpgradeParity/upgradeParity.js
Normal file
47
js/src/modals/UpgradeParity/upgradeParity.js
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
@ -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
|
||||
};
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user