Cleanup ~/util (#5553)

This commit is contained in:
Jaco Greeff 2017-05-04 10:40:52 +02:00 committed by GitHub
parent c7949e2fc3
commit f34a0346bc
23 changed files with 100 additions and 160 deletions

View File

@ -18,8 +18,9 @@ import * as actions from './signerActions';
import { inHex } from '@parity/api/format/input'; import { inHex } from '@parity/api/format/input';
import { createSignedTx } from '~/shell/Signer/utils/qrscan';
import HardwareStore from '~/mobx/hardwareStore'; import HardwareStore from '~/mobx/hardwareStore';
import { createSignedTx } from '~/util/qrscan';
import { Signer } from '~/util/signer'; import { Signer } from '~/util/signer';
export default class SignerMiddleware { export default class SignerMiddleware {

View File

@ -1,105 +0,0 @@
/* 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/>.
*/
:root,
:root body {
margin: 0;
padding: 0;
border: 0;
clor: rgba(0, 0, 0, 0.870588);
font-size: 100%;
font: inherit;
vertical-align: baseline;
font-size: 16px;
font-family: 'Roboto', sans-serif;
font-weight: 300 !important;
}
:root * {
font-weight: 300 !important;
}
:root a,
:root a:visited {
text-decoration: none;
cursor: pointer;
color: rgb(0, 151, 167); /* #f80 */
}
:root a:hover {
color: rgb(0, 174, 193);
}
:root .reset { font-size: initial; width: 100%; height: 100%; }
:root .reset input {
margin-top: 0;
color: rgba(0, 0, 0, 0.870588) !important;
}
:root .reset input[disabled] {
color: rgba(0, 0, 0, 0.298039) !important;
}
/* shame:off */
// Prefixed version of
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
:root .reset div, :root .reset span, :root .reset applet, :root .reset object, :root .reset iframe,
:root .reset h1, :root .reset h2, :root .reset h3, :root .reset h4, :root .reset h5, :root .reset h6, :root .reset p, :root .reset blockquote, :root .reset pre,
:root .reset a, :root .reset abbr, :root .reset acronym, :root .reset address, :root .reset big, :root .reset cite, :root .reset code,
:root .reset del, :root .reset dfn, :root .reset em, :root .reset img, :root .reset ins, :root .reset kbd, :root .reset q, :root .reset s, :root .reset samp,
:root .reset small, :root .reset strike, :root .reset strong, :root .reset sub, :root .reset sup, :root .reset tt, :root .reset var,
:root .reset b, :root .reset u, :root .reset i, :root .reset center,
:root .reset dl, :root .reset dt, :root .reset dd, :root .reset ol, :root .reset ul, :root .reset li,
:root .reset fieldset, :root .reset form, :root .reset label, :root .reset legend,
:root .reset table, :root .reset caption, :root .reset tbody, :root .reset tfoot, :root .reset thead, :root .reset tr, :root .reset th, :root .reset td,
:root .reset article, :root .reset aside, :root .reset canvas, :root .reset details, :root .reset embed,
:root .reset figure, :root .reset figcaption, :root .reset footer, :root .reset header, :root .reset hgroup,
:root .reset menu, :root .reset nav, :root .reset output, :root .reset ruby, :root .reset section, :root .reset summary,
:root .reset time, :root .reset mark, :root .reset audio, :root .reset video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
:root .reset article, :root .reset aside, :root .reset details, :root .reset figcaption, :root .reset figure,
:root .reset footer, :root .reset header, :root .reset hgroup, :root .reset menu, :root .reset nav, :root .reset section {
display: block;
}
:root .reset body {
line-height: 1;
}
:root .reset ol, :root .reset ul {
list-style: none;
}
:root .reset blockquote, :root .reset q {
quotes: none;
}
:root .reset blockquote:before, :root .reset blockquote:after,
:root .reset q:before, :root .reset q:after {
content: '';
content: none;
}
:root .reset table {
border-collapse: collapse;
border-spacing: 0;
}

View File

@ -19,8 +19,9 @@ import { FormattedMessage } from 'react-intl';
import { PrevIcon } from '~/ui/Icons'; import { PrevIcon } from '~/ui/Icons';
import TransactionPendingFormConfirm from './TransactionPendingFormConfirm'; import TransactionPendingFormConfirm from '../TransactionPendingFormConfirm';
import TransactionPendingFormReject from './TransactionPendingFormReject'; import TransactionPendingFormReject from '../TransactionPendingFormReject';
import styles from './transactionPendingForm.css'; import styles from './transactionPendingForm.css';
export default class TransactionPendingForm extends Component { export default class TransactionPendingForm extends Component {

View File

@ -21,7 +21,7 @@ import { FormattedMessage } from 'react-intl';
import ReactTooltip from 'react-tooltip'; import ReactTooltip from 'react-tooltip';
import { Button, Form, Input, IdentityIcon, QrCode, QrScan } from '~/ui'; import { Button, Form, Input, IdentityIcon, QrCode, QrScan } from '~/ui';
import { generateTxQr, generateDataQr } from '~/util/qrscan'; import { generateTxQr, generateDataQr } from '~/shell/Signer/utils/qrscan';
import styles from './transactionPendingFormConfirm.css'; import styles from './transactionPendingFormConfirm.css';

View File

@ -17,7 +17,7 @@
import BigNumber from 'bignumber.js'; import BigNumber from 'bignumber.js';
import { getShortData, getFee, getTotalValue } from './transaction'; import { getShortData, getFee, getTotalValue } from './transaction';
describe('views/Signer/components/util/transaction', () => { describe('shell/Signer/components/util/transaction', () => {
describe('getEstimatedMiningTime', () => { describe('getEstimatedMiningTime', () => {
it('should return estimated mining time', () => { it('should return estimated mining time', () => {
}); });

View File

@ -14,6 +14,22 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
export function capitalize (str) {
return str[0].toUpperCase() + str.slice(1).toLowerCase();
}
export function identity (x) { export function identity (x) {
return x; return x;
} }
export function toPromise (fn) {
return new Promise((resolve, reject) => {
fn((err, res) => {
if (err) {
reject(err);
} else {
resolve(res);
}
});
});
}

View File

@ -14,22 +14,4 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
export function toPromise (fn) { export default from './overlay';
return new Promise((resolve, reject) => {
fn((err, res) => {
if (err) {
reject(err);
} else {
resolve(res);
}
});
});
}
export function identity (x) {
return x;
}
export function capitalize (str) {
return str[0].toUpperCase() + str.slice(1).toLowerCase();
}

View File

@ -0,0 +1,32 @@
/* 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/>.
*/
$overlayBackground: rgba(0, 0, 0, 0.85);
$overlayText: white;
$overlayIndex: 199;
.overlay {
background: $overlayBackground;
bottom: 0;
color: $overlayText;
left: 0;
padding: 1.5em;
position: absolute;
right: 0;
top: 0;
z-index: $overlayIndex;
}

View File

@ -0,0 +1,37 @@
// 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 from 'react';
import { nodeOrStringProptype } from '~/util/proptypes';
import styles from './overlay.css';
export default function Overlay ({ overlay }) {
if (!overlay) {
return null;
}
return (
<div className={ styles.overlay }>
{ overlay }
</div>
);
}
Overlay.propTypes = {
overlay: nodeOrStringProptype()
};

View File

@ -16,7 +16,7 @@
import { chunkArray } from './array'; import { chunkArray } from './array';
describe('util/array', () => { describe('ui/SectionList/array', () => {
describe('chunkArray', () => { describe('chunkArray', () => {
it('splits array into equal chunks', () => { it('splits array into equal chunks', () => {
expect(chunkArray([1, 2, 3, 4], 2)).to.deep.equal([[1, 2], [3, 4]]); expect(chunkArray([1, 2, 3, 4], 2)).to.deep.equal([[1, 2], [3, 4]]);

View File

@ -24,17 +24,6 @@ $widthContracted: 29%;
position: relative; position: relative;
width: 100%; width: 100%;
.overlay {
background: rgba(0, 0, 0, 0.85);
bottom: 0;
left: 0;
padding: 1.5em;
position: absolute;
right: 0;
top: 0;
z-index: 199;
}
.row { .row {
display: flex; display: flex;
justify-content: center; justify-content: center;

View File

@ -16,9 +16,10 @@
import React, { Component, PropTypes } from 'react'; import React, { Component, PropTypes } from 'react';
import { chunkArray } from '~/util/array';
import { arrayOrObjectProptype, nodeOrStringProptype } from '~/util/proptypes'; import { arrayOrObjectProptype, nodeOrStringProptype } from '~/util/proptypes';
import { chunkArray } from './array';
import Overlay from './Overlay';
import styles from './sectionList.css'; import styles from './sectionList.css';
// TODO: We probably want this to be passed via props - additional work required in that case to // TODO: We probably want this to be passed via props - additional work required in that case to
@ -40,7 +41,7 @@ export default class SectionList extends Component {
}; };
render () { render () {
const { className, items } = this.props; const { className, items, overlay } = this.props;
if (!items || !items.length) { if (!items || !items.length) {
return null; return null;
@ -56,26 +57,12 @@ export default class SectionList extends Component {
return ( return (
<section className={ [styles.section, className].join(' ') }> <section className={ [styles.section, className].join(' ') }>
{ this.renderOverlay() } <Overlay overlay={ overlay } />
{ chunkArray(rendered, ITEMS_PER_ROW).map(this.renderRow) } { chunkArray(rendered, ITEMS_PER_ROW).map(this.renderRow) }
</section> </section>
); );
} }
renderOverlay () {
const { overlay } = this.props;
if (!overlay) {
return null;
}
return (
<div className={ styles.overlay }>
{ overlay }
</div>
);
}
renderRow = (row, index) => { renderRow = (row, index) => {
return ( return (
<div <div

View File

@ -16,7 +16,7 @@
import base32 from 'base32.js'; import base32 from 'base32.js';
import { DOMAIN } from './constants'; import { DOMAIN } from '~/util/constants';
const BASE_URL = `.web${DOMAIN}`; const BASE_URL = `.web${DOMAIN}`;
const ENCODER_OPTS = { type: 'crockford' }; const ENCODER_OPTS = { type: 'crockford' };

View File

@ -18,7 +18,7 @@ import { action, computed, observable, transaction } from 'mobx';
import localStore from 'store'; import localStore from 'store';
import { parse as parseUrl } from 'url'; import { parse as parseUrl } from 'url';
import { encodePath, encodeUrl } from '~/util/dapplink'; import { encodePath, encodeUrl } from './dapplink';
const DEFAULT_URL = 'https://oasisdex.com'; const DEFAULT_URL = 'https://oasisdex.com';
const LS_LAST_ADDRESS = '_parity::webLastAddress'; const LS_LAST_ADDRESS = '_parity::webLastAddress';