From 0257eaeae1344e3aa7af327f85cef0e52d592374 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Sat, 29 Dec 2018 20:15:04 +0100 Subject: [PATCH] Allow custom type registration (#543) --- packages/app-democracy/package.json | 2 +- packages/app-explorer/package.json | 2 +- packages/app-extrinsics/package.json | 2 +- packages/app-rpc/package.json | 2 +- packages/app-settings/package.json | 2 +- packages/app-settings/src/index.tsx | 161 +++++++++++++++------- packages/app-staking/package.json | 4 +- packages/app-toolbox/package.json | 2 +- packages/app-transfer/package.json | 2 +- packages/apps/package.json | 2 +- packages/apps/src/index.tsx | 14 ++ packages/ui-app/package.json | 8 +- packages/ui-app/src/styles/components.css | 2 + packages/ui-react-rx/package.json | 6 +- packages/ui-signer/package.json | 2 +- types.json | 15 ++ yarn.lock | 124 ++++++++--------- 17 files changed, 225 insertions(+), 127 deletions(-) create mode 100644 types.json diff --git a/packages/app-democracy/package.json b/packages/app-democracy/package.json index 275c64df58..17cb06524e 100644 --- a/packages/app-democracy/package.json +++ b/packages/app-democracy/package.json @@ -12,7 +12,7 @@ "dependencies": { "@babel/runtime": "^7.2.0", "@polkadot/keyring": "^0.33.27", - "@polkadot/storage": "^0.35.12", + "@polkadot/storage": "^0.35.13", "@polkadot/ui-react-rx": "^0.21.9" } } diff --git a/packages/app-explorer/package.json b/packages/app-explorer/package.json index 5db7df8f83..7a7811a386 100644 --- a/packages/app-explorer/package.json +++ b/packages/app-explorer/package.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/types": "^0.35.12", + "@polkadot/types": "^0.35.13", "@polkadot/ui-app": "^0.21.9", "@polkadot/util-crypto": "^0.33.27" } diff --git a/packages/app-extrinsics/package.json b/packages/app-extrinsics/package.json index 680685299c..e93d7c069b 100644 --- a/packages/app-extrinsics/package.json +++ b/packages/app-extrinsics/package.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.2.0", - "@polkadot/types": "^0.35.12", + "@polkadot/types": "^0.35.13", "@polkadot/ui-app": "^0.21.9", "@polkadot/ui-signer": "^0.21.9" } diff --git a/packages/app-rpc/package.json b/packages/app-rpc/package.json index 7eb752dafd..6c7ae518ff 100644 --- a/packages/app-rpc/package.json +++ b/packages/app-rpc/package.json @@ -12,7 +12,7 @@ "dependencies": { "@babel/runtime": "^7.2.0", "@polkadot/ui-app": "^0.21.9", - "@polkadot/ui-keyring": "^0.24.13", + "@polkadot/ui-keyring": "^0.24.14", "@polkadot/ui-signer": "^0.21.9" } } diff --git a/packages/app-settings/package.json b/packages/app-settings/package.json index 071490ffe4..6de5360373 100644 --- a/packages/app-settings/package.json +++ b/packages/app-settings/package.json @@ -13,6 +13,6 @@ "@babel/runtime": "^7.2.0", "@polkadot/ui-app": "^0.21.9", "@polkadot/ui-react-rx": "^0.21.9", - "@polkadot/ui-settings": "^0.24.13" + "@polkadot/ui-settings": "^0.24.14" } } diff --git a/packages/app-settings/src/index.tsx b/packages/app-settings/src/index.tsx index f201960e99..4ba5dbd203 100644 --- a/packages/app-settings/src/index.tsx +++ b/packages/app-settings/src/index.tsx @@ -6,9 +6,12 @@ import { I18nProps } from '@polkadot/ui-app/types'; import { SettingsStruct } from '@polkadot/ui-settings/types'; import React from 'react'; -import { Button, Dropdown } from '@polkadot/ui-app/index'; +import store from 'store'; +import typeRegistry from '@polkadot/types/codec/typeRegistry'; +import { Button, Dropdown, InputFile } from '@polkadot/ui-app/index'; import { ActionStatus } from '@polkadot/ui-app/Status/types'; import settings from '@polkadot/ui-settings'; +import { u8aToString } from '@polkadot/util'; import './index.css'; @@ -19,68 +22,101 @@ type Props = I18nProps & { onStatusChange: (status: ActionStatus) => void }; -type State = SettingsStruct; +type State = SettingsStruct & { + types?: { [index: string]: any } | null, + typesError?: boolean, + typesPlaceholder?: string +}; class App extends React.PureComponent { constructor (props: Props) { super(props); - this.state = settings.get(); + const types = store.get('types') || {}; + const names = Object.keys(types); + const state = settings.get(); + + this.state = { + ...state, + typesPlaceholder: names.length + ? names.join(', ') + : undefined + }; } render () { const { t } = this.props; - const { apiUrl, i18nLang, uiMode, uiTheme } = this.state; + const { apiUrl, i18nLang, typesPlaceholder, typesError, uiMode, uiTheme } = this.state; return (
-
-
- +
+

{t('settings.general', { + defaultValue: 'general' + })}

+
+
+ +
-
-
-
- +
+
+ +
+
+ +
-
- +
+
+ +
-
-
-
- + +
+

{t('settings.developer', { + defaultValue: 'developer' + })}

+
+
+ +
-
+