Use apiSupport & apiConnected from withApi (#63)

This commit is contained in:
Jaco Greeff 2018-05-28 22:31:24 +02:00 committed by GitHub
parent bcd7867ba7
commit 540a39ff48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 62 deletions

View File

@ -13,13 +13,12 @@
.explorer--NodeInfo {
font-size: 0.75rem;
opacity: 0.5;
margin-bottom: 0.5rem;
text-align: left;
text-align: right;
}
.explorer--NodeInfo div {
display: inline-block;
margin-right: 0.5rem;
margin-left: 0.5rem;
}
.explorer--BestHash,

View File

@ -35,7 +35,9 @@ function ExplorerApp ({ className, style, t }: Props): React$Node {
defaultValue: 'client: '
})}
/>
<NodeVersion label='v.' />
<NodeVersion label={t('app.name', {
defaultValue: 'version: '
})} />
</div>
<BestNumber
className='explorer--BestNumber'

View File

@ -3,7 +3,6 @@
// of the ISC license. See the LICENSE file for details.
// @flow
import type { EncodingVersions } from '@polkadot/extrinsics-codec/types';
import type { Extrinsic$Method } from '@polkadot/extrinsics/types';
import type { BareProps } from '@polkadot/ui-app/types';
import type { ApiProps } from '@polkadot/ui-react-rx/types';
@ -32,8 +31,7 @@ type Props = BareProps & ApiProps & {
type State = {
extrinsic: Extrinsic$Method,
values: Array<RawParam>,
apiSupport: EncodingVersions
values: Array<RawParam>
};
class Extrinsic extends React.PureComponent<Props, State> {
@ -44,22 +42,10 @@ class Extrinsic extends React.PureComponent<Props, State> {
this.state = {
extrinsic: props.defaultValue,
values: [],
apiSupport: 'poc-1'
values: []
};
}
componentDidMount () {
// FIXME should be shared component, no unmount here
this.props.api.system.version().subscribe((nodeVersion?: string) => {
this.setState({
apiSupport: nodeVersion === undefined || nodeVersion === '0.1.0'
? 'poc-1'
: 'latest'
});
});
}
render (): React$Node {
const { className, defaultValue, isError, isPrivate, labelMethod, labelSection, style } = this.props;
const { extrinsic } = this.state;
@ -88,8 +74,8 @@ class Extrinsic extends React.PureComponent<Props, State> {
nextState (newState: $Shape<State>): void {
this.setState(newState, () => {
const { onChange } = this.props;
const { apiSupport, extrinsic, values } = this.state;
const { apiSupport, onChange } = this.props;
const { extrinsic, values } = this.state;
const params = Object.values(extrinsic.params);
const isValid = values.length === params.length &&
params.reduce((isValid, param, index) =>

View File

@ -4,26 +4,24 @@
// @flow
import type { I18nProps } from '@polkadot/ui-app/types';
import type { ApiProps } from '@polkadot/ui-react-rx/types';
import './Connecting.css';
import React from 'react';
import classes from '@polkadot/ui-app/util/classes';
import withApiCall from '@polkadot/ui-react-rx/with/apiCall';
import withApi from '@polkadot/ui-react-rx/with/api';
import translate from '../translate';
type Props = I18nProps & {
value: boolean
};
type Props = I18nProps & ApiProps;
function Connecting ({ className, style, value, t }: Props): React$Node {
if (value) {
function Connecting ({ apiConnected, className, style, t }: Props): React$Node {
if (apiConnected) {
return null;
}
// 'ui inverted page modals dimmer transition visible active'
return (
<div
className={classes('apps--Connecting', className)}
@ -39,7 +37,5 @@ function Connecting ({ className, style, value, t }: Props): React$Node {
}
export default translate(
withApiCall({ name: 'isConnected' })(
Connecting
)
withApi(Connecting)
);

View File

@ -15,8 +15,8 @@
"@polkadot/extrinsics-substrate": "^0.16.15",
"@polkadot/storage-substrate": "^0.16.15",
"@polkadot/ui-keyring": "^0.6.11",
"@polkadot/ui-react": "^0.13.19",
"@polkadot/ui-react-rx": "^0.13.19",
"@polkadot/ui-react": "^0.13.22",
"@polkadot/ui-react-rx": "^0.13.22",
"i18next": "^11.1.1",
"i18next-browser-languagedetector": "^2.2.0",
"i18next-xhr-backend": "^1.5.1",

View File

@ -12,7 +12,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.47",
"@polkadot/ui-react": "^0.13.19",
"@polkadot/ui-react": "^0.13.22",
"@polkadot/util-keyring": "^0.22.2",
"store": "^2.0.12"
},

View File

@ -3,7 +3,6 @@
// of the ISC license. See the LICENSE file for details.
// @flow
import type { EncodingVersions } from '@polkadot/extrinsics-codec/types';
import type { ApiProps } from '@polkadot/ui-react-rx/types';
import type { I18nProps } from '@polkadot/ui-app/types';
import type { QueueTx, QueueTx$MessageSetStatus } from './types';
@ -33,7 +32,6 @@ type UnlockI18n = {
}
type State = {
apiSupport: EncodingVersions,
currentItem?: QueueTx,
password: string,
unlockError: UnlockI18n | null
@ -52,7 +50,7 @@ class Signer extends React.PureComponent<Props, State> {
};
}
static getDerivedStateFromProps ({ queue }: Props, { apiSupport, currentItem, password, unlockError }: State): State {
static getDerivedStateFromProps ({ queue }: Props, { currentItem, password, unlockError }: State): State {
const nextItem = queue.find(({ status }) =>
status === 'queued'
);
@ -67,24 +65,12 @@ class Signer extends React.PureComponent<Props, State> {
);
return {
apiSupport,
currentItem: nextItem,
password: isSame ? password : '',
unlockError: isSame ? unlockError : null
};
}
componentDidMount () {
// FIXME should be shared component, no unmount here
this.props.api.system.version().subscribe((nodeVersion?: string) => {
this.setState({
apiSupport: nodeVersion === undefined || nodeVersion === '0.1.0'
? 'poc-1'
: 'latest'
});
});
}
componentDidUpdate (prevProps: Props, prevState: State) {
const { currentItem } = this.state;
@ -240,8 +226,7 @@ class Signer extends React.PureComponent<Props, State> {
}
}
const { api, queueSetStatus } = this.props;
const { apiSupport } = this.state;
const { api, apiSupport, queueSetStatus } = this.props;
queueSetStatus(id, 'sending');

View File

@ -926,28 +926,28 @@
"@polkadot/util" "^0.22.2"
"@polkadot/util-keyring" "^0.22.2"
"@polkadot/ui-identicon@^0.13.19":
version "0.13.19"
resolved "https://registry.yarnpkg.com/@polkadot/ui-identicon/-/ui-identicon-0.13.19.tgz#b788b7c5a4c5d1b0a0178223629439c085f5e167"
"@polkadot/ui-identicon@^0.13.22":
version "0.13.22"
resolved "https://registry.yarnpkg.com/@polkadot/ui-identicon/-/ui-identicon-0.13.22.tgz#75a479cf4d22ecce676229e7719651c77172e2eb"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
color "^3.0.0"
"@polkadot/ui-react-rx@^0.13.19":
version "0.13.19"
resolved "https://registry.yarnpkg.com/@polkadot/ui-react-rx/-/ui-react-rx-0.13.19.tgz#30e398c1bbed3bfe906a53082ebcac447ab8ff93"
"@polkadot/ui-react-rx@^0.13.22":
version "0.13.22"
resolved "https://registry.yarnpkg.com/@polkadot/ui-react-rx/-/ui-react-rx-0.13.22.tgz#e96ce854651d4cf32980f6143f7fe4201fb2342d"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
"@polkadot/api-rx" "^0.12.15"
"@polkadot/extrinsics-codec" "^0.16.15"
"@polkadot/storage-substrate" "^0.16.15"
"@polkadot/ui-react@^0.13.19":
version "0.13.19"
resolved "https://registry.yarnpkg.com/@polkadot/ui-react/-/ui-react-0.13.19.tgz#8085524bfafbd04bea3c33c19b3ee87f8c83a398"
"@polkadot/ui-react@^0.13.22":
version "0.13.22"
resolved "https://registry.yarnpkg.com/@polkadot/ui-react/-/ui-react-0.13.22.tgz#a8c8d9f7ee667b29d45a8ddc8f8426613d2c55e0"
dependencies:
"@babel/runtime" "^7.0.0-beta.47"
"@polkadot/ui-identicon" "^0.13.19"
"@polkadot/ui-identicon" "^0.13.22"
"@polkadot/util-crypto@^0.22.2":
version "0.22.2"