Update council candidate refresh (#1790)

* Display council voters

* Show voting stake

* Adjust AddressMini widths

* Swap to (mostly) AccountIndex display

* Create modals (no default opacity)

* Trigger PR build
This commit is contained in:
Jaco Greeff 2019-10-28 16:24:34 +01:00 committed by GitHub
parent df49bf217e
commit c6beca5a4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 100 additions and 76 deletions

View File

@ -1 +1 @@
2
3

View File

@ -10,10 +10,10 @@
"packages/*"
],
"resolutions": {
"@polkadot/api": "^0.96.0-beta.5",
"@polkadot/api-contract": "^0.96.0-beta.5",
"@polkadot/api": "^0.96.0-beta.7",
"@polkadot/api-contract": "^0.96.0-beta.7",
"@polkadot/keyring": "^1.6.1",
"@polkadot/types": "^0.96.0-beta.5",
"@polkadot/types": "^0.96.0-beta.7",
"@polkadot/util": "^1.6.1",
"@polkadot/util-crypto": "^1.6.1",
"babel-core": "^7.0.0-bridge.0",

View File

@ -128,7 +128,7 @@ function Account ({ address, className, t }: Props): React.ReactElement<Props> {
type='account'
value={address}
withExplorer
withIndex
withIndexOrAddress={false}
withTags
>
{address && (

View File

@ -193,6 +193,7 @@ function Create ({ className, onClose, onStatusChange, seed: propsSeed, t, type:
<Modal.Content>
<AddressRow
defaultName={name}
noDefaultNameOpacity
value={isSeedValid ? address : ''}
>
<Input

View File

@ -29,6 +29,7 @@ function CreateConfirmation ({ address, name, onClose, onCommit, t }: Props): Re
<AddressRow
defaultName={name}
isInline
noDefaultNameOpacity
value={address}
>
<p>{t('We will provide you with a generated backup file after your account is created. As long as you have access to your account you can always download this file later by clicking on "Backup" button from the Accounts section.')}</p>

View File

@ -76,6 +76,7 @@ class Import extends TxComponent<Props, State> {
<Modal.Content>
<AddressRow
defaultName={isFileValid && json ? json.meta.name : null}
noDefaultNameOpacity
value={isFileValid && address ? address : null}
>
<InputFile

View File

@ -61,6 +61,7 @@ function QrModal ({ className, onClose, onStatusChange, t }: Props): React.React
<>
<AddressRow
defaultName={name}
noDefaultNameOpacity
value={scanned.address}
/>
<Input

View File

@ -107,7 +107,7 @@ function Address ({ address, className, t }: Props): React.ReactElement<Props> {
type='address'
value={address}
withExplorer
withIndex
withIndexOrAddress={false}
withTags
>
{address && current && (

View File

@ -85,6 +85,7 @@ function Create ({ onClose, onStatusChange, t }: Props): React.ReactElement<Prop
<Modal.Content>
<AddressRow
defaultName={name}
noDefaultNameOpacity
value={address}
>
<Input

View File

@ -11,7 +11,7 @@
"license": "Apache-2.0",
"dependencies": {
"@babel/runtime": "^7.6.3",
"@polkadot/api-contract": "^0.96.0-beta.5",
"@polkadot/api-contract": "^0.96.0-beta.7",
"@polkadot/react-components": "^0.37.0-beta.9"
}
}

View File

@ -21,8 +21,11 @@ function Candidate ({ address, t, voters }: Props): React.ReactElement<Props> {
<AddressCard
defaultName={t('candidate')}
value={address}
withIndexOrAddress
>
<Voters voters={voters} />
{voters && voters.length !== 0 && (
<Voters voters={voters} />
)}
</AddressCard>
);
}

View File

@ -21,8 +21,11 @@ function Member ({ address, t, voters }: Props): React.ReactElement<Props> {
<AddressCard
defaultName={t('council member')}
value={address}
withIndexOrAddress
>
<Voters voters={voters} />
{voters && voters.length !== 0 && (
<Voters voters={voters} />
)}
</AddressCard>
);
}

View File

@ -52,7 +52,7 @@ const Candidate = styled.div`
min-width: calc(50% - 1rem);
border-radius: 0.5rem;
border: 1px solid #eee;
padding: 0.25rem;
padding: 0.75rem 0.5rem 0.25rem;
margin: 0.25rem;
transition: all 0.2s;
@ -71,6 +71,11 @@ const Candidate = styled.div`
&.nay {
background-color: rgba(0, 0, 0, 0.05);
}
.ui--Row-children {
text-align: right;
width: 100%;
}
`;
class Vote extends TxModal<Props, State> {
@ -212,6 +217,7 @@ class Vote extends TxModal<Props, State> {
defaultName={isMember ? t('member') : t('candidate')}
isInline
value={accountId}
withIndexOrAddress
>
<Toggle
label={

View File

@ -11,14 +11,10 @@ import { AddressMini } from '@polkadot/react-components';
import translate from '../translate';
interface Props extends I18nProps {
voters?: AccountId[];
voters: AccountId[];
}
function Voters ({ voters, t }: Props): React.ReactElement<Props> | null {
if (!voters || !voters.length) {
return null;
}
return (
<details>
<summary>

View File

@ -43,7 +43,7 @@ function Accounts ({ allAccounts, allStashes, className, myControllers, recently
const [isNewStakeOpen, setIsNewStateOpen] = useState(false);
const myStashes = getMyStashes(myControllers, allAccounts);
const stashOptions = allStashes.map((stashId): KeyringSectionOption =>
createOption(stashId, getAddressName(stashId, 'account'))
createOption(stashId, getAddressName(stashId, 'account') as string)
);
const isEmpty = !isNewStakeOpen && (!myStashes || myStashes.length === 0);

View File

@ -31,7 +31,7 @@
"homepage": "https://github.com/polkadot-js/ui/tree/master/packages/ui-reactive#readme",
"dependencies": {
"@babel/runtime": "^7.6.3",
"@polkadot/api": "^0.96.0-beta.5",
"@polkadot/api": "^0.96.0-beta.7",
"@polkadot/extension-dapp": "^0.14.0-beta.0",
"edgeware-node-types": "^1.0.10",
"rxjs-compat": "^6.5.3"

View File

@ -30,10 +30,12 @@ export interface Props extends I18nProps, RowProps {
isValid?: boolean;
label?: string;
nicks_nameOf?: Option<[Bytes, Balance] & Codec>;
noDefaultNameOpacity?: boolean;
value: AccountId | AccountIndex | Address | string | null;
withAddressOrName?: boolean;
withBalance?: boolean | BalanceActiveType;
withIndex?: boolean;
withIndexOrAddress?: boolean;
withValidatorPrefs?: boolean | ValidatorPrefsType;
}
@ -49,7 +51,7 @@ class AddressRow extends Row<ApiProps & Props, State> {
this.state = this.createState();
}
public static getDerivedStateFromProps ({ accounts_idAndIndex = [], defaultName, nicks_nameOf, type, value }: Props, prevState: State): State | null {
public static getDerivedStateFromProps ({ accounts_idAndIndex = [], defaultName, nicks_nameOf, noDefaultNameOpacity, type, value }: Props, prevState: State): State | null {
const [_accountId] = accounts_idAndIndex;
const accountId = _accountId || value;
const address = accountId
@ -58,7 +60,8 @@ class AddressRow extends Row<ApiProps & Props, State> {
const nickName = nicks_nameOf && nicks_nameOf.isSome
? u8aToString(nicks_nameOf.unwrap()[0])
: undefined;
const name = nickName || getAddressName(address, type, false, defaultName || '<unknown>') || '';
const nameHolder = defaultName || '<unknown>';
const name = nickName || getAddressName(address, type, false, noDefaultNameOpacity ? nameHolder : <span className='ui--Row-placeholder'>{nameHolder}</span>) || '';
const tags = getAddressTags(address, type);
const state: Partial<State> = { tags };
let hasChanged = false;
@ -69,7 +72,7 @@ class AddressRow extends Row<ApiProps & Props, State> {
}
if (!prevState.isEditingName && name !== prevState.name) {
state.name = name;
state.name = name as string;
hasChanged = true;
}
@ -117,7 +120,7 @@ class AddressRow extends Row<ApiProps & Props, State> {
return {
...this.state,
address,
name,
name: name as string,
tags
};
}
@ -138,7 +141,13 @@ class AddressRow extends Row<ApiProps & Props, State> {
}
private renderAddress (): React.ReactNode {
const { accounts_idAndIndex = [], withIndexOrAddress = true } = this.props;
const { address } = this.state;
const [, accountIndex] = accounts_idAndIndex;
if (accountIndex && withIndexOrAddress) {
return null;
}
return (
<div className='ui--Row-accountId'>
@ -153,10 +162,10 @@ class AddressRow extends Row<ApiProps & Props, State> {
}
private renderAccountIndex (): React.ReactNode {
const { accounts_idAndIndex = [], withIndex = true } = this.props;
const { accounts_idAndIndex = [], withIndex = true, withIndexOrAddress = true } = this.props;
const [, accountIndex] = accounts_idAndIndex;
if (!accountIndex || !withIndex) {
if (!accountIndex || !(withIndex || withIndexOrAddress)) {
return null;
}
@ -247,9 +256,9 @@ class AddressRow extends Row<ApiProps & Props, State> {
} catch (error) {
keyring.saveAddress(address, meta);
}
this.setState({ isEditingName: false });
}
this.setState({ isEditingName: false });
}
protected saveTags = (): void => {
@ -280,9 +289,9 @@ export {
export default withMulti(
styled(AddressRow as React.ComponentClass<Props & ApiProps, State>)`
${styles},
.ui--Row-accountId+.ui--Row-accountIndex {
margin-top: -0.25rem;
${styles}
.ui--Row-placeholder {
opacity: 0.5;
}
`,
translate,

View File

@ -198,7 +198,7 @@ class InputAddress extends React.PureComponent<Props, State> {
);
}
private renderLabel = ({ value }: KeyringSectionOption): string | undefined => {
private renderLabel = ({ value }: KeyringSectionOption): React.ReactNode => {
if (!value) {
return undefined;
}

View File

@ -275,7 +275,7 @@ export default class Row<P extends RowProps, S extends RowState> extends React.P
const { address, isEditingName, name } = this.state;
const withName = name !== defaultName;
// can't be both editable and copiable
// can't be both editable and copyable
return isEditingName
? (
<Input

View File

@ -4,10 +4,12 @@
import { KeyringItemType } from '@polkadot/ui-keyring/types';
import React from 'react';
import getAddressMeta from './getAddressMeta';
import toShortAddress from './toShortAddress';
export default function getAddressName (address: string, type: KeyringItemType | null = null, withShort?: boolean, defaultName?: string): string | undefined {
export default function getAddressName (address: string, type: KeyringItemType | null = null, withShort?: boolean, defaultName?: React.ReactNode): React.ReactNode | string | undefined {
const meta = getAddressMeta(address, type);
const name = meta.name || defaultName;

View File

@ -2016,45 +2016,45 @@
once "^1.4.0"
universal-user-agent "^4.0.0"
"@polkadot/api-contract@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-0.96.0-beta.5.tgz#4a0abe91e7d88b819391d0f2af0253e4aeb3b53d"
integrity sha512-sZkG4vfJaIV74nVt/yM3jqF0/gw5WeBwV4yfAw190hTZkeHMc2XsxUenxaDIflyECV9skVNH9qbf4L7AseyJvw==
"@polkadot/api-contract@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-0.96.0-beta.7.tgz#f9128030d711bd32695b7072b6c8302b777cca94"
integrity sha512-oIIbJnzUfDHLgOoVQO204xFZSzSc8HgfODOBmB56NtJVMvD5Vb3joUvlFQxc+4p360I+KovtK0acpy17xyLbCQ==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/types" "^0.96.0-beta.5"
"@polkadot/types" "^0.96.0-beta.7"
"@polkadot/api-derive@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.96.0-beta.5.tgz#842d0561f67cfe97449208cab1889e60cc94162f"
integrity sha512-tgTuK1c9qetE0ZYHex2NkdLeBVsD5VM71mHg19EYls3fzhqDQot/mN1xRrF8bWFyjdx3oF3OfJISpH7alOgLPA==
"@polkadot/api-derive@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-0.96.0-beta.7.tgz#64f1509250ddbfe45383af774d8f2fa375bba16b"
integrity sha512-dGhHxrTPtZJ0JRbuSe2jzWdE8sP0ts3WcNdIDTmMUFetiJC24GV1vyK0jfDXfCtFN75icsdCvvYHhn7S5m+Byg==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/api" "^0.96.0-beta.5"
"@polkadot/types" "^0.96.0-beta.5"
"@polkadot/api" "^0.96.0-beta.7"
"@polkadot/types" "^0.96.0-beta.7"
"@polkadot/api-metadata@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/api-metadata/-/api-metadata-0.96.0-beta.5.tgz#69257e3993a702b6d3419d8c6f2f7b163ec0c512"
integrity sha512-RmDpUIwfdCX/v+fqqZGH8bbGjPNLry/KH56Zc8ZgTV22/Pfnvqc+PeEVorgsCw1pmaUlc8bFsr5cvv0KGjK9TA==
"@polkadot/api-metadata@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/api-metadata/-/api-metadata-0.96.0-beta.7.tgz#6926d35381c5da438764555f01785a0ea8ad7af9"
integrity sha512-Bu8jdFCxp4/2a270pZ3jIsibaSaEgk+iyntBpZt+s85Vm/Qe5e3up9x43JE5wufbQsfYVLJciaWJ3Ls5BOYxoQ==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/types" "^0.96.0-beta.5"
"@polkadot/types" "^0.96.0-beta.7"
"@polkadot/util" "^1.6.1"
"@polkadot/util-crypto" "^1.6.1"
"@polkadot/api@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.96.0-beta.5.tgz#1ca032cd327d45289fbc5da5134550a5d7a4ee13"
integrity sha512-dTfZKkqIudB1PfnTZRrszHDMhUiznLJTR/PXcMnLhC2zQx4DJBhe8IfkPZYaokrzwMdmcWHRQ5d1O9jLuPa4cw==
"@polkadot/api@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-0.96.0-beta.7.tgz#9a00686b82f7b16d39fae8f12fe7498ae5d79993"
integrity sha512-puqNTLvDxYmyxyx3TcDD6OnRsm13XpUAhMjaCltKz3HEJKPcIvOYAOgLlqL6qdim2bkuNbEAbL2fvV4zkgVOLg==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/api-derive" "^0.96.0-beta.5"
"@polkadot/api-metadata" "^0.96.0-beta.5"
"@polkadot/api-derive" "^0.96.0-beta.7"
"@polkadot/api-metadata" "^0.96.0-beta.7"
"@polkadot/keyring" "^1.6.1"
"@polkadot/rpc-core" "^0.96.0-beta.5"
"@polkadot/rpc-provider" "^0.96.0-beta.5"
"@polkadot/types" "^0.96.0-beta.5"
"@polkadot/rpc-core" "^0.96.0-beta.7"
"@polkadot/rpc-provider" "^0.96.0-beta.7"
"@polkadot/types" "^0.96.0-beta.7"
"@polkadot/util-crypto" "^1.6.1"
"@polkadot/dev-react@^0.32.0-beta.11":
@ -2156,10 +2156,10 @@
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/jsonrpc@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.96.0-beta.5.tgz#d19f93b0eb9a36219197321154d638276ac9aa59"
integrity sha512-zGDUDG2/pUtCl2FBrNN9mnlQPKBAIuCl/D4svmNSvz9JbCbZxIdWG9kjSYOC9tvjjG1tdVH6RcLD96XdH0Uifg==
"@polkadot/jsonrpc@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/jsonrpc/-/jsonrpc-0.96.0-beta.7.tgz#7689879f36983827e6613cfb0db65d57d576c423"
integrity sha512-kxJ8ObkVB5A9JPg4FoYCjFLIPe5UvXcDDsWtHCOj1fCIWqOJ/g8p9MNugNIRR+ZBJYbetG6/XeH/bUpf8WH+QA==
dependencies:
"@babel/runtime" "^7.6.3"
@ -2197,25 +2197,25 @@
qrcode-generator "^1.4.4"
react-qr-reader "^2.2.1"
"@polkadot/rpc-core@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.96.0-beta.5.tgz#33a9552143a1ecf224e4778172451d1064a0c310"
integrity sha512-zgAGbHUB7iU7xKwC8cfG32rm9EtZkBLhDtvpl/gHldUvM09LZkQ63BlVznHzd3Ga+uDUSStpK4XTJgHtCb3QpA==
"@polkadot/rpc-core@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-0.96.0-beta.7.tgz#b3e8c2c9995af9669910eb8d8e3f0ca6c517f55b"
integrity sha512-J8SUB8z/Epft3ZBAVIBFyiY2mbI91QeKiDlKfnhKvpMBxRMNtKb/liy+dHjOOh9HalCEg2Fi2ddCHnEZxo9CJA==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/jsonrpc" "^0.96.0-beta.5"
"@polkadot/rpc-provider" "^0.96.0-beta.5"
"@polkadot/types" "^0.96.0-beta.5"
"@polkadot/jsonrpc" "^0.96.0-beta.7"
"@polkadot/rpc-provider" "^0.96.0-beta.7"
"@polkadot/types" "^0.96.0-beta.7"
"@polkadot/util" "^1.6.1"
rxjs "^6.5.3"
"@polkadot/rpc-provider@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.96.0-beta.5.tgz#ed7766a7974db6a1cd21d8ee5a023943600faf6a"
integrity sha512-kCQDm6YpOGtGc0FyhT/YNNmvlrPoQTeny4JSPHdD7PsqCPGpUYIc1fn5iHreMrHwIioqohxDvAfK7SxjUaFCaw==
"@polkadot/rpc-provider@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-0.96.0-beta.7.tgz#cf873fb88874cfdce5567b9714667ca0be87cbac"
integrity sha512-et/FPRcBEi+MNZxQIDFD145Mh8hRx4xEf5K665Sq+almQtP3dU0zNzd0JwH52fQc8pywx16clZb5pkhSpQAqZg==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/api-metadata" "^0.96.0-beta.5"
"@polkadot/api-metadata" "^0.96.0-beta.7"
"@polkadot/util" "^1.6.1"
"@polkadot/util-crypto" "^1.6.1"
"@types/nock" "^11.1.0"
@ -2230,10 +2230,10 @@
dependencies:
"@types/chrome" "^0.0.91"
"@polkadot/types@^0.96.0-beta.5":
version "0.96.0-beta.5"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.96.0-beta.5.tgz#66b05939d979840e77ee854319849aac8eabbd9f"
integrity sha512-/2sUKN81INueb8jwWCaPMau++c+rlvhkVUOUbPJ30akneM63AW1dni+Dqb/cqa+sNBkomKqT/LDKxDT82d9L3g==
"@polkadot/types@^0.96.0-beta.7":
version "0.96.0-beta.7"
resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.96.0-beta.7.tgz#e1e24ba917510f9c5e1cd5e990261a83d2464eeb"
integrity sha512-R0noKwqe3imDJ4besX1X9hfCJDLozG+g72oEOna/BOlzvFOTZb+jOyfrvOXO0A5FOum4AZqt1A8jAI31DLMMtg==
dependencies:
"@babel/runtime" "^7.6.3"
"@polkadot/util" "^1.6.1"