add last block to staking overview, reposition warning (#959)
This commit is contained in:
parent
bdc6f34fd9
commit
fa8e13c562
@ -99,7 +99,7 @@ class Address extends React.PureComponent<Props, State> {
|
||||
</AddressRow>
|
||||
{
|
||||
isAuthor
|
||||
? <div className='blockNumber'>{lastBlock}</div>
|
||||
? <div className='blockNumber'>#{lastBlock}</div>
|
||||
: null
|
||||
}
|
||||
</article>
|
||||
@ -199,6 +199,7 @@ class Address extends React.PureComponent<Props, State> {
|
||||
<RecentlyOffline
|
||||
accountId={stashId}
|
||||
offline={offline}
|
||||
tooltip
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -7,9 +7,7 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import { Nominators, RecentlyOfflineMap } from '../types';
|
||||
|
||||
import React from 'react';
|
||||
import { AccountId, Balance, HeaderExtended } from '@polkadot/types';
|
||||
import { withCalls, withMulti } from '@polkadot/ui-api/with';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
import { AccountId, Balance } from '@polkadot/types';
|
||||
|
||||
import translate from '../translate';
|
||||
import Address from './Address';
|
||||
@ -17,8 +15,9 @@ import Address from './Address';
|
||||
type Props = I18nProps & {
|
||||
balances: DerivedBalancesMap,
|
||||
balanceArray: (_address: AccountId | string) => Array<Balance> | undefined,
|
||||
chain_subscribeNewHead?: HeaderExtended,
|
||||
current: Array<string>,
|
||||
lastAuthor?: string,
|
||||
lastBlock: string,
|
||||
next: Array<string>,
|
||||
nominators: Nominators,
|
||||
recentlyOffline: RecentlyOfflineMap
|
||||
@ -67,7 +66,7 @@ class CurrentList extends React.PureComponent<Props> {
|
||||
}
|
||||
|
||||
private renderColumn (addresses: Array<string>, defaultName: string) {
|
||||
const { balances, balanceArray, chain_subscribeNewHead, nominators, recentlyOffline, t } = this.props;
|
||||
const { balances, balanceArray, lastAuthor, lastBlock, nominators, recentlyOffline, t } = this.props;
|
||||
|
||||
if (addresses.length === 0) {
|
||||
return (
|
||||
@ -75,14 +74,6 @@ class CurrentList extends React.PureComponent<Props> {
|
||||
);
|
||||
}
|
||||
|
||||
let lastBlock: string = '';
|
||||
let lastAuthor: string;
|
||||
|
||||
if (chain_subscribeNewHead) {
|
||||
lastBlock = `#${formatNumber(chain_subscribeNewHead.blockNumber)}`;
|
||||
lastAuthor = (chain_subscribeNewHead.author || '').toString();
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{addresses.map((address) => (
|
||||
@ -103,10 +94,4 @@ class CurrentList extends React.PureComponent<Props> {
|
||||
}
|
||||
}
|
||||
|
||||
export default withMulti(
|
||||
CurrentList,
|
||||
translate,
|
||||
withCalls<Props>(
|
||||
'derive.chain.subscribeNewHead'
|
||||
)
|
||||
);
|
||||
export default translate(CurrentList);
|
||||
|
||||
@ -8,7 +8,7 @@ import { I18nProps } from '@polkadot/ui-app/types';
|
||||
import BN from 'bn.js';
|
||||
import React from 'react';
|
||||
import SummarySession from '@polkadot/app-explorer/SummarySession';
|
||||
import { SummaryBox, CardSummary } from '@polkadot/ui-app';
|
||||
import { AddressMini, SummaryBox, CardSummary } from '@polkadot/ui-app';
|
||||
import { withCall, withMulti } from '@polkadot/ui-api';
|
||||
|
||||
import translate from '../translate';
|
||||
@ -16,6 +16,8 @@ import translate from '../translate';
|
||||
type Props = I18nProps & {
|
||||
balances: DerivedBalancesMap,
|
||||
intentions: Array<string>,
|
||||
lastAuthor?: string,
|
||||
lastBlock: string,
|
||||
lastLengthChange?: BN,
|
||||
staking_validatorCount?: BN,
|
||||
validators: Array<string>
|
||||
@ -23,7 +25,7 @@ type Props = I18nProps & {
|
||||
|
||||
class Summary extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { className, intentions, style, t, staking_validatorCount, validators } = this.props;
|
||||
const { className, intentions, lastAuthor, lastBlock, style, t, staking_validatorCount, validators } = this.props;
|
||||
const waiting = intentions.length > validators.length
|
||||
? (intentions.length - validators.length)
|
||||
: 0;
|
||||
@ -41,7 +43,18 @@ class Summary extends React.PureComponent<Props> {
|
||||
{waiting}
|
||||
</CardSummary>
|
||||
</section>
|
||||
<section className='ui--media-medium'>
|
||||
<section>
|
||||
<CardSummary label={t('last block')}>
|
||||
{lastAuthor && (
|
||||
<AddressMini
|
||||
className='summary'
|
||||
isPadded={false}
|
||||
value={lastAuthor}
|
||||
withAddress={false}
|
||||
/>
|
||||
)}
|
||||
{lastBlock}
|
||||
</CardSummary>
|
||||
<SummarySession withBroken={false} />
|
||||
</section>
|
||||
</SummaryBox>
|
||||
|
||||
@ -2,24 +2,28 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { Balance, HeaderExtended } from '@polkadot/types';
|
||||
import { BareProps } from '@polkadot/ui-app/types';
|
||||
import { ComponentProps } from '../types';
|
||||
|
||||
import './index.css';
|
||||
|
||||
import React from 'react';
|
||||
import { Balance } from '@polkadot/types';
|
||||
import { withCalls, withMulti } from '@polkadot/ui-api/with';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
import CurrentList from './CurrentList';
|
||||
import Summary from './Summary';
|
||||
|
||||
type Props = BareProps & ComponentProps;
|
||||
type Props = BareProps & ComponentProps & {
|
||||
chain_subscribeNewHead?: HeaderExtended
|
||||
};
|
||||
|
||||
const ZERO = new Balance(0);
|
||||
|
||||
export default class Overview extends React.PureComponent<Props> {
|
||||
class Overview extends React.PureComponent<Props> {
|
||||
render () {
|
||||
const { balances, balanceArray, intentions, nominators, recentlyOffline, validators } = this.props;
|
||||
const { balances, balanceArray, chain_subscribeNewHead, intentions, nominators, recentlyOffline, validators } = this.props;
|
||||
const intentionsSorted = this.sortByBalance(
|
||||
intentions.filter((address) =>
|
||||
!validators.includes(address)
|
||||
@ -27,17 +31,29 @@ export default class Overview extends React.PureComponent<Props> {
|
||||
);
|
||||
const validatorsSorted = this.sortByBalance(validators);
|
||||
|
||||
let lastBlock: string = '—';
|
||||
let lastAuthor: string | undefined;
|
||||
|
||||
if (chain_subscribeNewHead) {
|
||||
lastBlock = formatNumber(chain_subscribeNewHead.blockNumber);
|
||||
lastAuthor = (chain_subscribeNewHead.author || '').toString();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className='staking--Overview'>
|
||||
<Summary
|
||||
balances={balances}
|
||||
intentions={intentions}
|
||||
lastBlock={lastBlock}
|
||||
lastAuthor={lastAuthor}
|
||||
validators={validators}
|
||||
/>
|
||||
<CurrentList
|
||||
balances={balances}
|
||||
balanceArray={balanceArray}
|
||||
current={validatorsSorted}
|
||||
lastBlock={lastBlock}
|
||||
lastAuthor={lastAuthor}
|
||||
next={intentionsSorted}
|
||||
nominators={nominators}
|
||||
recentlyOffline={recentlyOffline}
|
||||
@ -57,3 +73,10 @@ export default class Overview extends React.PureComponent<Props> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default withMulti(
|
||||
Overview,
|
||||
withCalls<Props>(
|
||||
'derive.chain.subscribeNewHead'
|
||||
)
|
||||
);
|
||||
|
||||
@ -113,6 +113,7 @@ export default class AddressMini extends React.PureComponent<Props> {
|
||||
accountId={value.toString()}
|
||||
offline={offlineStatus}
|
||||
tooltip
|
||||
inline
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@ -28,6 +28,7 @@ const Card = styled.article`
|
||||
> div {
|
||||
font-size: 2.1rem;
|
||||
font-weight: 100;
|
||||
position: relative;
|
||||
line-height: 2.1rem;
|
||||
text-align: right;
|
||||
|
||||
|
||||
@ -16,7 +16,8 @@ import translate from './translate';
|
||||
type Props = I18nProps & {
|
||||
accountId: AccountId | string,
|
||||
offline: Array<OfflineStatus>,
|
||||
tooltip?: boolean
|
||||
tooltip?: boolean,
|
||||
inline?: boolean
|
||||
};
|
||||
|
||||
type State = {
|
||||
@ -29,7 +30,7 @@ class RecentlyOffline extends React.PureComponent<Props, State> {
|
||||
};
|
||||
|
||||
render () {
|
||||
const { offline, tooltip = false, t } = this.props;
|
||||
const { offline, inline, tooltip = false, t } = this.props;
|
||||
const { isOpen } = this.state;
|
||||
const accountId = this.props.accountId.toString();
|
||||
|
||||
@ -54,7 +55,8 @@ class RecentlyOffline extends React.PureComponent<Props, State> {
|
||||
className={[
|
||||
'ui--RecentlyOffline',
|
||||
isOpen ? 'expand' : '',
|
||||
tooltip ? 'tooltip' : ''
|
||||
tooltip ? 'tooltip' : '',
|
||||
inline ? 'inline' : ''
|
||||
].join(' ')}
|
||||
{...(!tooltip ?
|
||||
{ onClick: this.toggleOpen } :
|
||||
|
||||
@ -49,6 +49,11 @@ header .ui--Button-Group {
|
||||
padding: 0.25rem 0 0 0;
|
||||
}
|
||||
|
||||
.ui--AddressMini.summary {
|
||||
position: relative;
|
||||
top: -0.2rem;
|
||||
}
|
||||
|
||||
.ui--AddressMini-info div {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
@ -264,12 +269,12 @@ header .ui--Button-Group {
|
||||
|
||||
.ui--RecentlyOffline {
|
||||
position: absolute;
|
||||
bottom: 0.75rem;
|
||||
top: 0.75rem;
|
||||
font-size: 12px;
|
||||
cursor: help;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
right: 0.75rem;
|
||||
left: 0.75rem;
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
padding: 0;
|
||||
@ -307,7 +312,7 @@ header .ui--Button-Group {
|
||||
}
|
||||
}
|
||||
|
||||
&.tooltip {
|
||||
&.inline {
|
||||
position: static;
|
||||
margin: .3rem 0 .3rem .5rem;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user