Ui 2 move to packages/* (#6113)
* Move secureApi to shell
* Extract isTestnet test
* Use mobx + subscriptions for status
* Re-add status indicator
* Add lerna
* Move intial packages to js/packages
* Move 3rdparty/{email,sms}-verification to correct location
* Move package.json & README to library src
* Move tests for library packages
* Move views & dapps to packages
* Move i18n to root
* Move shell to actual src (main app)
* Remove ~ references
* Change ~ to root (explicit imports)
* Finalise convert of ~
* Move views into dapps as well
* Move dapps to packages/
* Fix references
* Update css
* Update test spec locations
* Update tests
* Case fix
* Skip flakey tests
* Update enzyme
* Skip previously ignored tests
* Allow empty api for hw
* Re-add theme for embed
This commit is contained in:
17
js/src/SyncWarning/index.js
Normal file
17
js/src/SyncWarning/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright 2015-2017 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, { showSyncWarning } from './syncWarning';
|
||||
64
js/src/SyncWarning/syncWarning.css
Normal file
64
js/src/SyncWarning/syncWarning.css
Normal file
@@ -0,0 +1,64 @@
|
||||
/* Copyright 2015-2017 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/>.
|
||||
*/
|
||||
|
||||
.overlay {
|
||||
background: rgba(255, 255, 255, 0.75);
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 10000;
|
||||
}
|
||||
|
||||
.modal {
|
||||
align-items: flex-start;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
left: 0;
|
||||
position: fixed;
|
||||
right: 0;
|
||||
top: 0;
|
||||
z-index: 10001;
|
||||
}
|
||||
|
||||
.body {
|
||||
background: rgba(25, 25, 25, 0.75);
|
||||
box-shadow: rgba(0, 0, 0, 0.25) 0 14px 45px, rgba(0, 0, 0, 0.22) 0 10px 18px;
|
||||
color: rgb(208, 208, 208);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
margin: 0 auto;
|
||||
max-width: 20em;
|
||||
padding: 2em 4em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
margin-top: 1em;
|
||||
}
|
||||
|
||||
.body,
|
||||
.button {
|
||||
> * {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
}
|
||||
|
||||
.status {
|
||||
font-size: 4rem;
|
||||
}
|
||||
131
js/src/SyncWarning/syncWarning.js
Normal file
131
js/src/SyncWarning/syncWarning.js
Normal file
@@ -0,0 +1,131 @@
|
||||
// Copyright 2015-2017 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 React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { FormattedMessage } from 'react-intl';
|
||||
import { connect } from 'react-redux';
|
||||
import store from 'store';
|
||||
|
||||
import { Button, Checkbox, StatusIndicator } from '@parity/ui';
|
||||
|
||||
import styles from './syncWarning.css';
|
||||
|
||||
const LS_DONT_SHOW_AGAIN = '_parity::syncWarning::dontShowAgain';
|
||||
|
||||
export const showSyncWarning = () => {
|
||||
const dontShowAgain = store.get(LS_DONT_SHOW_AGAIN);
|
||||
|
||||
if (dontShowAgain === undefined || dontShowAgain === null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return !dontShowAgain;
|
||||
};
|
||||
|
||||
class SyncWarning extends Component {
|
||||
static propTypes = {
|
||||
isOk: PropTypes.bool.isRequired,
|
||||
health: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
state = {
|
||||
dontShowAgain: false,
|
||||
show: true
|
||||
};
|
||||
|
||||
render () {
|
||||
const { isOk, health } = this.props;
|
||||
const { dontShowAgain, show } = this.state;
|
||||
|
||||
if (isOk || !show) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={ styles.overlay } />
|
||||
<div className={ styles.modal }>
|
||||
<div className={ styles.body }>
|
||||
<div className={ styles.status }>
|
||||
<StatusIndicator
|
||||
type='signal'
|
||||
id='healthWarning.indicator'
|
||||
status={ health.overall.status }
|
||||
/>
|
||||
</div>
|
||||
|
||||
{
|
||||
health.overall.message.map(message => (
|
||||
<p key={ message }>{ message }</p>
|
||||
))
|
||||
}
|
||||
|
||||
<div className={ styles.button }>
|
||||
<Checkbox
|
||||
label={
|
||||
<FormattedMessage
|
||||
id='syncWarning.dontShowAgain.label'
|
||||
defaultMessage='Do not show this warning again'
|
||||
/>
|
||||
}
|
||||
checked={ dontShowAgain }
|
||||
onClick={ this.handleCheck }
|
||||
/>
|
||||
<Button
|
||||
label={
|
||||
<FormattedMessage
|
||||
id='syncWarning.understandBtn.label'
|
||||
defaultMessage='I understand'
|
||||
/>
|
||||
}
|
||||
onClick={ this.handleAgreeClick }
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
handleCheck = () => {
|
||||
this.setState({ dontShowAgain: !this.state.dontShowAgain });
|
||||
}
|
||||
|
||||
handleAgreeClick = () => {
|
||||
if (this.state.dontShowAgain) {
|
||||
store.set(LS_DONT_SHOW_AGAIN, true);
|
||||
}
|
||||
|
||||
this.setState({ show: false });
|
||||
}
|
||||
}
|
||||
|
||||
function mapStateToProps (state) {
|
||||
const { health } = state.nodeStatus;
|
||||
const isNotAvailableYet = health.overall.isReady;
|
||||
const isOk = isNotAvailableYet || health.overall.status === 'ok';
|
||||
|
||||
return {
|
||||
isOk,
|
||||
health
|
||||
};
|
||||
}
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
)(SyncWarning);
|
||||
62
js/src/SyncWarning/syncWarning.spec.js
Normal file
62
js/src/SyncWarning/syncWarning.spec.js
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright 2015-2017 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 { shallow } from 'enzyme';
|
||||
import React from 'react';
|
||||
|
||||
import SyncWarning from './';
|
||||
|
||||
let component;
|
||||
|
||||
function createRedux (syncing = null) {
|
||||
return {
|
||||
getState: () => {
|
||||
return {
|
||||
nodeStatus: {
|
||||
health: {
|
||||
overall: {
|
||||
status: syncing ? 'needsAttention' : 'ok',
|
||||
message: []
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function render (store) {
|
||||
component = shallow(
|
||||
<SyncWarning />,
|
||||
{ context: { store: store || createRedux() } }
|
||||
).find('SyncWarning').shallow();
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
describe('SyncWarning', () => {
|
||||
it('renders defaults', () => {
|
||||
expect(render()).to.be.ok;
|
||||
});
|
||||
|
||||
it('does render when syncing', () => {
|
||||
expect(render(createRedux({})).find('div')).to.have.length.gte(1);
|
||||
});
|
||||
|
||||
it('does not render when not syncing', () => {
|
||||
expect(render(createRedux(false)).find('div')).to.have.length(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user