From 540a39ff481dbc786dbdacddbdee17dbdbb69b17 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 28 May 2018 22:31:24 +0200 Subject: [PATCH] Use apiSupport & apiConnected from withApi (#63) --- packages/app-explorer/src/index.css | 5 ++--- packages/app-explorer/src/index.js | 4 +++- packages/app-extrinsics/src/Extrinsic.js | 22 ++++------------------ packages/apps/src/Connecting/index.js | 16 ++++++---------- packages/ui-app/package.json | 4 ++-- packages/ui-keyring/package.json | 2 +- packages/ui-signer/src/Modal.js | 19 ++----------------- yarn.lock | 20 ++++++++++---------- 8 files changed, 30 insertions(+), 62 deletions(-) diff --git a/packages/app-explorer/src/index.css b/packages/app-explorer/src/index.css index a9730c9535..5deabf2ada 100644 --- a/packages/app-explorer/src/index.css +++ b/packages/app-explorer/src/index.css @@ -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, diff --git a/packages/app-explorer/src/index.js b/packages/app-explorer/src/index.js index b3423c18f9..abb5e5a250 100644 --- a/packages/app-explorer/src/index.js +++ b/packages/app-explorer/src/index.js @@ -35,7 +35,9 @@ function ExplorerApp ({ className, style, t }: Props): React$Node { defaultValue: 'client: ' })} /> - + , - apiSupport: EncodingVersions + values: Array }; class Extrinsic extends React.PureComponent { @@ -44,22 +42,10 @@ class Extrinsic extends React.PureComponent { 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 { nextState (newState: $Shape): 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) => diff --git a/packages/apps/src/Connecting/index.js b/packages/apps/src/Connecting/index.js index 75909a78d0..2300cb014c 100644 --- a/packages/apps/src/Connecting/index.js +++ b/packages/apps/src/Connecting/index.js @@ -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 (
{ }; } - 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 { ); 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 { } } - const { api, queueSetStatus } = this.props; - const { apiSupport } = this.state; + const { api, apiSupport, queueSetStatus } = this.props; queueSetStatus(id, 'sending'); diff --git a/yarn.lock b/yarn.lock index 9410a11fd6..a472872f8a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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"