useRef for table headers (no changes) (#3429)
* useRef for table headers (no changes) * Cleanup Tabs hidden (constants)
This commit is contained in:
parent
de2581faad
commit
8f47873942
@ -7,7 +7,7 @@ import { AccountId, ProxyDefinition, ProxyType, Voting } from '@polkadot/types/i
|
||||
import { Delegation, SortedAccount } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import keyring from '@polkadot/ui-keyring';
|
||||
import { getLedger, isLedger } from '@polkadot/react-api';
|
||||
@ -84,6 +84,17 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
|
||||
});
|
||||
const isLoading = useLoadingDelay();
|
||||
|
||||
const headerRef = useRef([
|
||||
[t('accounts'), 'start', 3],
|
||||
[t('parent'), 'address ui--media-1400'],
|
||||
[t('type')],
|
||||
[t('tags'), 'start'],
|
||||
[t('transactions'), 'ui--media-1500'],
|
||||
[t('balances')],
|
||||
[],
|
||||
[undefined, 'mini ui--media-1400']
|
||||
]);
|
||||
|
||||
useEffect((): void => {
|
||||
const sortedAccounts = sortAccounts(allAccounts, favorites);
|
||||
const sortedAddresses = sortedAccounts.map((a) => a.account.address);
|
||||
@ -131,17 +142,6 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
|
||||
[]
|
||||
);
|
||||
|
||||
const header = useMemo(() => [
|
||||
[t('accounts'), 'start', 3],
|
||||
[t('parent'), 'address ui--media-1400'],
|
||||
[t('type')],
|
||||
[t('tags'), 'start'],
|
||||
[t('transactions'), 'ui--media-1500'],
|
||||
[t('balances')],
|
||||
[],
|
||||
[undefined, 'mini ui--media-1400']
|
||||
], [t]);
|
||||
|
||||
const footer = useMemo(() => (
|
||||
<tr>
|
||||
<td colSpan={3} />
|
||||
@ -247,7 +247,7 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
|
||||
empty={!isLoading && sortedAccountsWithDelegation && t<string>("You don't have any accounts. Some features are currently hidden and will only become available once you have accounts.")}
|
||||
filter={filter}
|
||||
footer={footer}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{isLoading ? undefined : sortedAccountsWithDelegation?.map(({ account, delegation, isFavorite }, index): React.ReactNode => (
|
||||
<Account
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { ComponentProps as Props } from '../types';
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Button, Input, Table } from '@polkadot/react-components';
|
||||
import { useAddresses, useFavorites, useLoadingDelay, useToggle } from '@polkadot/react-hooks';
|
||||
@ -26,6 +26,15 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
|
||||
const [filterOn, setFilter] = useState<string>('');
|
||||
const isLoading = useLoadingDelay();
|
||||
|
||||
const headerRef = useRef([
|
||||
[t('contacts'), 'start', 2],
|
||||
[t('tags'), 'start'],
|
||||
[t('transactions'), 'ui--media-1500'],
|
||||
[t('balances')],
|
||||
[],
|
||||
[undefined, 'mini ui--media-1400']
|
||||
]);
|
||||
|
||||
useEffect((): void => {
|
||||
setSortedAddresses(
|
||||
allAddresses
|
||||
@ -40,15 +49,6 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
|
||||
);
|
||||
}, [allAddresses, favorites]);
|
||||
|
||||
const header = useMemo(() => [
|
||||
[t('contacts'), 'start', 2],
|
||||
[t('tags'), 'start'],
|
||||
[t('transactions'), 'ui--media-1500'],
|
||||
[t('balances')],
|
||||
[],
|
||||
[undefined, 'mini ui--media-1400']
|
||||
], [t]);
|
||||
|
||||
const filter = useMemo(() => (
|
||||
<div className='filter--tags'>
|
||||
<Input
|
||||
@ -79,7 +79,7 @@ function Overview ({ className = '', onStatusChange }: Props): React.ReactElemen
|
||||
<Table
|
||||
empty={!isLoading && sortedAddresses && t<string>('no addresses saved yet, add any existing address')}
|
||||
filter={filter}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{isLoading ? undefined : sortedAddresses?.map(({ address, isFavorite }): React.ReactNode => (
|
||||
<Address
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { useAccounts, useIpfs } from '@polkadot/react-hooks';
|
||||
import { HelpOverlay, Tabs } from '@polkadot/react-components';
|
||||
@ -18,11 +18,14 @@ import Vanity from './Vanity';
|
||||
|
||||
export { useCounter };
|
||||
|
||||
const HIDDEN_ACC = ['vanity'];
|
||||
|
||||
function AccountsApp ({ basePath, onStatusChange }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { hasAccounts } = useAccounts();
|
||||
const { isIpfs } = useIpfs();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'overview',
|
||||
@ -36,11 +39,7 @@ function AccountsApp ({ basePath, onStatusChange }: Props): React.ReactElement<P
|
||||
name: 'vanity',
|
||||
text: t<string>('Vanity generator')
|
||||
}
|
||||
], [t]);
|
||||
const hidden = useMemo(
|
||||
() => (hasAccounts && !isIpfs) ? [] : ['vanity'],
|
||||
[hasAccounts, isIpfs]
|
||||
);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className='accounts--App'>
|
||||
@ -48,8 +47,8 @@ function AccountsApp ({ basePath, onStatusChange }: Props): React.ReactElement<P
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={hidden}
|
||||
items={items}
|
||||
hidden={(hasAccounts && !isIpfs) ? undefined : HIDDEN_ACC}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -3,10 +3,9 @@
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
import { TabItem } from '@polkadot/react-components/Tabs/types';
|
||||
import { ComponentProps } from './types';
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { HelpOverlay, Tabs } from '@polkadot/react-components';
|
||||
import { useAccounts, useContracts, useToggle } from '@polkadot/react-hooks';
|
||||
@ -28,6 +27,18 @@ function ContractsApp ({ basePath, onStatusChange }: Props): React.ReactElement<
|
||||
const [updated, setUpdated] = useState(0);
|
||||
const [allCodes, setAllCodes] = useState(store.getAllCode());
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
name: 'code',
|
||||
text: t('Code')
|
||||
},
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'contracts',
|
||||
text: t('Contracts')
|
||||
}
|
||||
]);
|
||||
|
||||
const _triggerUpdate = useCallback(
|
||||
(): void => {
|
||||
setUpdated(Date.now());
|
||||
@ -78,27 +89,13 @@ function ContractsApp ({ basePath, onStatusChange }: Props): React.ReactElement<
|
||||
[_triggerUpdate]
|
||||
);
|
||||
|
||||
const hidden: string[] = [];
|
||||
|
||||
return (
|
||||
<main className='contracts--App'>
|
||||
<HelpOverlay md={introMd as string} />
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={hidden}
|
||||
items={[
|
||||
{
|
||||
name: 'code',
|
||||
text: 'Code'
|
||||
},
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'contracts',
|
||||
text: 'Contracts'
|
||||
}
|
||||
].map((tab): TabItem => ({ ...tab, text: t(tab.text) }))
|
||||
}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { DeriveCollectiveProposals, DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Button, Table } from '@polkadot/react-components';
|
||||
import { useMembers } from '@polkadot/react-hooks';
|
||||
|
||||
@ -25,7 +25,7 @@ function Proposals ({ className = '', motions, prime }: Props): React.ReactEleme
|
||||
const { t } = useTranslation();
|
||||
const { isMember, members } = useMembers();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('motions'), 'start', 2],
|
||||
[t('threshold')],
|
||||
[t('voting end')],
|
||||
@ -34,7 +34,7 @@ function Proposals ({ className = '', motions, prime }: Props): React.ReactEleme
|
||||
[],
|
||||
[undefined, 'badge'],
|
||||
[undefined, 'mini']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
@ -54,7 +54,7 @@ function Proposals ({ className = '', motions, prime }: Props): React.ReactEleme
|
||||
</Button.Group>
|
||||
<Table
|
||||
empty={motions && t<string>('No council motions')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{motions?.map((motion: DeriveCollectiveProposal): React.ReactNode => (
|
||||
<Motion
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { DeriveElectionsInfo } from '@polkadot/api-derive/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -20,23 +20,23 @@ interface Props {
|
||||
function Candidates ({ allVotes = {}, electionsInfo }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const headerCandidates = useMemo(() => [
|
||||
const headerCandidatesRef = useRef([
|
||||
[t('candidates'), 'start', 2],
|
||||
[],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const headerRunners = useMemo(() => [
|
||||
const headerRunnersRef = useRef([
|
||||
[t('runners up'), 'start', 2],
|
||||
[t('backing')],
|
||||
[t('votes')]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Table
|
||||
empty={electionsInfo && t<string>('No runners up found')}
|
||||
header={headerRunners}
|
||||
header={headerRunnersRef.current}
|
||||
>
|
||||
{electionsInfo?.runnersUp.map(([accountId, balance]): React.ReactNode => (
|
||||
<Candidate
|
||||
@ -49,7 +49,7 @@ function Candidates ({ allVotes = {}, electionsInfo }: Props): React.ReactElemen
|
||||
</Table>
|
||||
<Table
|
||||
empty={electionsInfo && t<string>('No candidates found')}
|
||||
header={headerCandidates}
|
||||
header={headerCandidatesRef.current}
|
||||
>
|
||||
{electionsInfo?.candidates.map((accountId): React.ReactNode => (
|
||||
<Candidate
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { DeriveElectionsInfo } from '@polkadot/api-derive/types';
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -21,17 +21,17 @@ interface Props {
|
||||
function Members ({ allVotes = {}, className = '', electionsInfo, prime }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('members'), 'start', 2],
|
||||
[t('backing')],
|
||||
[t('votes')]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={electionsInfo && t<string>('No members found')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{electionsInfo?.members.map(([accountId, balance]): React.ReactNode => (
|
||||
<Candidate
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveDispatch } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -20,18 +20,18 @@ function DispatchQueue ({ className }: Props): React.ReactElement<Props> | null
|
||||
const { api } = useApi();
|
||||
const queued = useCall<DeriveDispatch[]>(api.derive.democracy.dispatchQueue, []);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('dispatch queue'), 'start', 2],
|
||||
[t('enact')],
|
||||
[],
|
||||
[undefined, 'mini ui--media-1000']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={queued && t<string>('Nothing queued for execution')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{queued?.map((entry): React.ReactNode => (
|
||||
<DispatchEntry
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveProposalExternal } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -20,18 +20,18 @@ function Externals ({ className }: Props): React.ReactElement<Props> | null {
|
||||
const { api } = useApi();
|
||||
const external = useCall<DeriveProposalExternal | null>(api.derive.democracy.nextExternal, []);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('external'), 'start'],
|
||||
[t('proposer'), 'address'],
|
||||
[t('locked')],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={external === null && t<string>('No external proposal')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{external && <External value={external} />}
|
||||
</Table>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveProposal } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -20,19 +20,19 @@ function Proposals ({ className }: Props): React.ReactElement<Props> {
|
||||
const { api } = useApi();
|
||||
const proposals = useCall<DeriveProposal[]>(api.derive.democracy.proposals, []);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('proposals'), 'start', 2],
|
||||
[t('proposer'), 'address'],
|
||||
[t('locked'), 'ui--media-1200'],
|
||||
[undefined, undefined, 2],
|
||||
[undefined, 'mini ui--media-1000']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={proposals && t<string>('No active proposals')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{proposals?.map((proposal): React.ReactNode => (
|
||||
<ProposalDisplay
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveReferendumExt } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
import Referendum from './Referendum';
|
||||
@ -18,7 +18,7 @@ interface Props {
|
||||
function Referendums ({ className = '', referendums }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('referenda'), 'start', 2],
|
||||
[t('remaining'), 'ui--media-1200'],
|
||||
[t('activate'), 'ui--media-1400'],
|
||||
@ -28,13 +28,13 @@ function Referendums ({ className = '', referendums }: Props): React.ReactElemen
|
||||
[undefined, undefined, 2],
|
||||
[undefined, 'badge'],
|
||||
[undefined, 'mini ui--media-1000']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={referendums && t<string>('No active referendums')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{referendums?.map((referendum): React.ReactNode => (
|
||||
<Referendum
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { BlockNumber, Scheduled } from '@polkadot/types/interfaces';
|
||||
import { ScheduledExt } from './types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
import { Option } from '@polkadot/types';
|
||||
@ -17,39 +17,42 @@ interface Props {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function transformEntries (entries: [{ args: [BlockNumber] }, Option<Scheduled>[]][]): ScheduledExt[] {
|
||||
return entries
|
||||
.filter(([, vecSchedOpt]) => vecSchedOpt.some((schedOpt) => schedOpt.isSome))
|
||||
.reduce((items: ScheduledExt[], [key, vecSchedOpt]): ScheduledExt[] => {
|
||||
const blockNumber = key.args[0];
|
||||
|
||||
return vecSchedOpt
|
||||
.filter((schedOpt) => schedOpt.isSome)
|
||||
.map((schedOpt) => schedOpt.unwrap())
|
||||
.reduce((items: ScheduledExt[], { call, maybeId, maybePeriodic, priority }, index) => {
|
||||
items.push({ blockNumber, call, key: `${blockNumber.toString()}-${index}`, maybeId, maybePeriodic, priority });
|
||||
|
||||
return items;
|
||||
}, items);
|
||||
}, []);
|
||||
}
|
||||
|
||||
function Schedule ({ className = '' }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const items = useCall<ScheduledExt[]>(api.query.scheduler.agenda.entries as any, [], {
|
||||
transform: (entries: [{ args: [BlockNumber] }, Option<Scheduled>[]][]): ScheduledExt[] =>
|
||||
entries
|
||||
.filter(([, vecSchedOpt]) => vecSchedOpt.some((schedOpt) => schedOpt.isSome))
|
||||
.reduce((items: ScheduledExt[], [key, vecSchedOpt]): ScheduledExt[] => {
|
||||
const blockNumber = key.args[0];
|
||||
|
||||
return vecSchedOpt
|
||||
.filter((schedOpt) => schedOpt.isSome)
|
||||
.map((schedOpt) => schedOpt.unwrap())
|
||||
.reduce((items: ScheduledExt[], { call, maybeId, maybePeriodic, priority }, index) => {
|
||||
items.push({ blockNumber, call, key: `${blockNumber.toString()}-${index}`, maybeId, maybePeriodic, priority });
|
||||
|
||||
return items;
|
||||
}, items);
|
||||
}, [])
|
||||
transform: transformEntries
|
||||
});
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('scheduled'), 'start'],
|
||||
[t('remaining')],
|
||||
[t('period')],
|
||||
[t('count')]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={items?.length === 0 && t<string>('No active schedules')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{items?.map((scheduled): React.ReactNode => (
|
||||
<ScheduledView
|
||||
|
||||
@ -2,10 +2,9 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { HelpOverlay, Tabs } from '@polkadot/react-components';
|
||||
import uiSettings from '@polkadot/ui-settings';
|
||||
|
||||
import basicMd from './md/basic.md';
|
||||
import Overview from './Overview';
|
||||
@ -17,19 +16,16 @@ interface Props {
|
||||
basePath: string;
|
||||
}
|
||||
|
||||
const hidden = uiSettings.uiMode === 'full'
|
||||
? []
|
||||
: ['propose'];
|
||||
|
||||
function DemocracyApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'overview',
|
||||
text: t<string>('Democracy overview')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className='democracy--App'>
|
||||
@ -37,8 +33,7 @@ function DemocracyApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={hidden}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { HeaderExtended } from '@polkadot/api-derive';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
@ -16,14 +16,14 @@ interface Props {
|
||||
function BlockHeaders ({ headers }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('recent blocks'), 'start', 3]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
empty={t<string>('No blocks available')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{headers
|
||||
.filter((header) => !!header)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { DigestItem } from '@polkadot/types/interfaces';
|
||||
import { Codec, TypeDef } from '@polkadot/types/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Struct, Tuple, Raw, Vec, getTypeDef } from '@polkadot/types';
|
||||
import { Expander, Table } from '@polkadot/react-components';
|
||||
import Params from '@polkadot/react-params';
|
||||
@ -103,12 +103,12 @@ function Logs (props: Props): React.ReactElement<Props> | null {
|
||||
const { value } = props;
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [[t('logs'), 'start']], [t]);
|
||||
const headerRef = useRef([[t('logs'), 'start']]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
empty={t<string>('No logs available')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{value?.map((log, index) => (
|
||||
<tr key={`log:${index}`}>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { PeerInfo } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
|
||||
@ -19,18 +19,18 @@ interface Props {
|
||||
function Peers ({ className = '', peers }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('connected peers'), 'start'],
|
||||
[t('role'), 'start'],
|
||||
[t('best #'), 'number'],
|
||||
[t('best hash'), 'hash']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={t<string>('no peers connected')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{peers?.sort((a, b): number => b.bestNumber.cmp(a.bestNumber)).map((peer) => (
|
||||
<tr key={peer.peerId.toString()}>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { DeriveSessionProgress } from '@polkadot/api-derive/types';
|
||||
import { Forcing } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React from 'react';
|
||||
import { CardSummary } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
import { formatNumber } from '@polkadot/util';
|
||||
@ -22,14 +22,11 @@ function SummarySession ({ withEra = true, withSession = true }: Props): React.R
|
||||
const { api } = useApi();
|
||||
const sessionInfo = useCall<DeriveSessionProgress>(api.query.staking && api.derive.session?.progress, []);
|
||||
const forcing = useCall<Forcing>(api.query.staking?.forceEra, []);
|
||||
const eraLabel = useMemo(() =>
|
||||
t<string>('era')
|
||||
, [t]);
|
||||
const sessionLabel = useMemo(() =>
|
||||
sessionInfo?.isEpoch
|
||||
? t<string>('epoch')
|
||||
: t<string>('session')
|
||||
, [sessionInfo?.isEpoch, t]);
|
||||
|
||||
const eraLabel = t<string>('era');
|
||||
const sessionLabel = sessionInfo?.isEpoch
|
||||
? t<string>('epoch')
|
||||
: t<string>('session');
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@ -4,13 +4,11 @@
|
||||
|
||||
import { KeyedEvent } from '@polkadot/react-query/types';
|
||||
|
||||
import React, { useContext, useMemo } from 'react';
|
||||
import React, { useContext, useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
// import styled from 'styled-components';
|
||||
import Tabs from '@polkadot/react-components/Tabs';
|
||||
import { useApi } from '@polkadot/react-hooks';
|
||||
import { BlockAuthorsContext, EventsContext } from '@polkadot/react-query';
|
||||
import uiSettings from '@polkadot/ui-settings';
|
||||
|
||||
import BlockInfo from './BlockInfo';
|
||||
import Forks from './Forks';
|
||||
@ -24,12 +22,15 @@ interface Props {
|
||||
newEvents?: KeyedEvent[];
|
||||
}
|
||||
|
||||
const HIDDESN_NOBABE = ['forks'];
|
||||
|
||||
function ExplorerApp ({ basePath, className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const { lastHeaders } = useContext(BlockAuthorsContext);
|
||||
const events = useContext(EventsContext);
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'chain',
|
||||
@ -48,19 +49,15 @@ function ExplorerApp ({ basePath, className }: Props): React.ReactElement<Props>
|
||||
name: 'node',
|
||||
text: t<string>('Node info')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className={className}>
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={
|
||||
uiSettings.uiMode === 'full'
|
||||
? api.query.babe ? [] : ['forks']
|
||||
: ['node', 'forks']
|
||||
}
|
||||
items={items}
|
||||
hidden={api.query.babe ? undefined : HIDDESN_NOBABE}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Tabs } from '@polkadot/react-components';
|
||||
|
||||
import Selection from './Selection';
|
||||
@ -13,18 +13,18 @@ import { useTranslation } from './translate';
|
||||
function ExtrinsicsApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const items = useMemo(() => [{
|
||||
const itemsRef = useRef([{
|
||||
isRoot: true,
|
||||
name: 'create',
|
||||
text: t<string>('Extrinsic submission')
|
||||
}], [t]);
|
||||
}]);
|
||||
|
||||
return (
|
||||
<main className='extrinsics--App'>
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Selection />
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { Tabs } from '@polkadot/react-components';
|
||||
|
||||
@ -17,7 +17,8 @@ interface Props {
|
||||
|
||||
function AssetApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'assets',
|
||||
@ -27,14 +28,14 @@ function AssetApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
name: 'transfer',
|
||||
text: t<string>('Transfer')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className='treasury--App'>
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveParachain } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
@ -18,18 +18,18 @@ interface Props {
|
||||
function Parachains ({ parachains }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('parachains'), 'start', 3],
|
||||
[t('heads'), 'start'],
|
||||
[t('swap to id')],
|
||||
[t('scheduling')],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
empty={t<string>('There are no registered parachains')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{parachains?.map((parachain): React.ReactNode => (
|
||||
<Parachain
|
||||
|
||||
@ -7,7 +7,6 @@ import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { HelpOverlay, Tabs } from '@polkadot/react-components';
|
||||
import uiSettings from '@polkadot/ui-settings';
|
||||
|
||||
import md from './md/basics.md';
|
||||
import { useTranslation } from './translate';
|
||||
@ -19,10 +18,6 @@ import useCounter from './useCounter';
|
||||
|
||||
export { useCounter };
|
||||
|
||||
const hidden = uiSettings.uiMode === 'full'
|
||||
? []
|
||||
: ['developer'];
|
||||
|
||||
function SettingsApp ({ basePath, onStatusChange }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const numExtensions = useCounter();
|
||||
@ -56,7 +51,6 @@ function SettingsApp ({ basePath, onStatusChange }: Props): React.ReactElement<P
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={hidden}
|
||||
items={items}
|
||||
/>
|
||||
</header>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { Bid } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -20,18 +20,18 @@ function Bids ({ className }: Props): React.ReactElement<Props> {
|
||||
const { api } = useApi();
|
||||
const bids = useCall<Bid[]>(api.query.society.bids, []);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('bids'), 'start'],
|
||||
[t('kind')],
|
||||
[t('value')],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={bids && t<string>('No bids')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{bids?.map((bid, index): React.ReactNode => (
|
||||
<BidRow
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { useToggle } from '@polkadot/react-hooks';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -19,10 +19,11 @@ function CandidateVoting ({ candidateId, isMember, ownMembers }: Props): React.R
|
||||
const [isVisible, toggleVisible] = useToggle();
|
||||
const [vote, setVote] = useState(true);
|
||||
const [accountId, setAccountId] = useState<string | null>(null);
|
||||
const voteOpts = useMemo(() => [
|
||||
|
||||
const voteOptsRef = useRef([
|
||||
{ text: t<string>('Aye, I approve'), value: true },
|
||||
{ text: t<string>('Nay, I do not approve'), value: false }
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -39,7 +40,7 @@ function CandidateVoting ({ candidateId, isMember, ownMembers }: Props): React.R
|
||||
help={t<string>('Approve this candidacy.')}
|
||||
label={t<string>('vote for candidate')}
|
||||
onChange={setVote}
|
||||
options={voteOpts}
|
||||
options={voteOptsRef.current}
|
||||
value={vote}
|
||||
/>
|
||||
</Modal.Content>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveSocietyCandidate } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -23,18 +23,18 @@ function Candidates ({ allMembers, className = '', isMember, ownMembers }: Props
|
||||
const { api } = useApi();
|
||||
const candidates = useCall<DeriveSocietyCandidate[]>(api.derive.society.candidates, []);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('candidates'), 'start'],
|
||||
[t('kind')],
|
||||
[t('value')],
|
||||
[t('votes'), 'start']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={candidates && t<string>('No candidates')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{candidates?.map((candidate): React.ReactNode => (
|
||||
<Candidate
|
||||
|
||||
@ -6,7 +6,7 @@ import { DeriveSociety, DeriveSocietyMember } from '@polkadot/api-derive/types';
|
||||
import { SocietyVote } from '@polkadot/types/interfaces';
|
||||
import { VoteType } from '../types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { AddressSmall, Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -21,21 +21,24 @@ interface Props {
|
||||
ownMembers: string[];
|
||||
}
|
||||
|
||||
function transformVotes (members: DeriveSocietyMember[]): VoteType[] {
|
||||
return members
|
||||
.filter(({ vote }): boolean => !!vote)
|
||||
.map(({ accountId, vote }): VoteType => [accountId.toString(), vote as SocietyVote]);
|
||||
}
|
||||
|
||||
function Defender ({ className = '', info, isMember, ownMembers }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const votes = useCall<VoteType[]>(api.derive.society.members, [], {
|
||||
transform: (members: DeriveSocietyMember[]): VoteType[] =>
|
||||
members
|
||||
.filter(({ vote }): boolean => !!vote)
|
||||
.map(({ accountId, vote }): VoteType => [accountId.toString(), vote as SocietyVote])
|
||||
transform: transformVotes
|
||||
});
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('defender'), 'start'],
|
||||
[t('votes'), 'start'],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
if (!info || !info.hasDefender || !info.defender) {
|
||||
return null;
|
||||
@ -44,7 +47,7 @@ function Defender ({ className = '', info, isMember, ownMembers }: Props): React
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
<tr>
|
||||
<td className='address all'>
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import React, { useRef, useState } from 'react';
|
||||
import { useToggle } from '@polkadot/react-hooks';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -18,10 +18,11 @@ function DefenderVoting ({ isMember, ownMembers }: Props): React.ReactElement<Pr
|
||||
const [isVisible, toggleVisible] = useToggle();
|
||||
const [vote, setVote] = useState(true);
|
||||
const [accountId, setAccountId] = useState<string | null>(null);
|
||||
const voteOpts = useMemo(() => [
|
||||
|
||||
const voteOptsRef = useRef([
|
||||
{ text: t<string>('Aye, I approve'), value: true },
|
||||
{ text: t<string>('Nay, I do not approve'), value: false }
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -38,7 +39,7 @@ function DefenderVoting ({ isMember, ownMembers }: Props): React.ReactElement<Pr
|
||||
help={t<string>('Approve or reject this defender.')}
|
||||
label={t<string>('vote for defender')}
|
||||
onChange={setVote}
|
||||
options={voteOpts}
|
||||
options={voteOptsRef.current}
|
||||
value={vote}
|
||||
/>
|
||||
</Modal.Content>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { DeriveSociety, DeriveSocietyMember } from '@polkadot/api-derive/types';
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import React, { useMemo, useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -20,25 +20,23 @@ function Members ({ className = '', info }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
const members = useCall<DeriveSocietyMember[]>(api.derive.society.members, []);
|
||||
const [filtered, setFiltered] = useState<DeriveSocietyMember[]>([]);
|
||||
|
||||
useEffect((): void => {
|
||||
members && setFiltered(
|
||||
members.filter((member): boolean => !info || !info.hasDefender || !member.accountId.eq(info.defender))
|
||||
);
|
||||
}, [info, members]);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('members'), 'start', 3],
|
||||
[t('strikes')],
|
||||
[undefined, 'mini']
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const filtered = useMemo(
|
||||
() => (members || []).filter((member) => !info || !info.hasDefender || !member.accountId.eq(info.defender)),
|
||||
[info, members]
|
||||
);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={info && t<string>('No active members')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{filtered.map((member): React.ReactNode => (
|
||||
<Member
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { Tabs } from '@polkadot/react-components';
|
||||
|
||||
@ -19,20 +19,21 @@ export { useCounter };
|
||||
|
||||
function SocietyApp ({ basePath, className }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'overview',
|
||||
text: t<string>('Society overview')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className={className}>
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { KeypairType } from '@polkadot/util-crypto/types';
|
||||
|
||||
import React, { useCallback, useContext, useEffect, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Button, Dropdown, Input, Modal, StatusContext } from '@polkadot/react-components';
|
||||
import keyring from '@polkadot/ui-keyring';
|
||||
import { assert, u8aToHex } from '@polkadot/util';
|
||||
@ -34,13 +34,14 @@ function InjectKeys ({ onClose }: Props): React.ReactElement<Props> | null {
|
||||
const [publicKey, setPublicKey] = useState(EMPTY_KEY);
|
||||
const [suri, setSuri] = useState('');
|
||||
const [keyType, setKeyType] = useState('babe');
|
||||
const keyTypeOpt = useMemo(() => [
|
||||
|
||||
const keyTypeOptRef = useRef([
|
||||
{ text: t<string>('Aura'), value: 'aura' },
|
||||
{ text: t<string>('Babe'), value: 'babe' },
|
||||
{ text: t<string>('Grandpa'), value: 'gran' },
|
||||
{ text: t<string>('I\'m Online'), value: 'imon' },
|
||||
{ text: t<string>('Parachains'), value: 'para' }
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
useEffect((): void => {
|
||||
setCrypto(CRYPTO_MAP[keyType][0]);
|
||||
@ -66,6 +67,7 @@ function InjectKeys ({ onClose }: Props): React.ReactElement<Props> | null {
|
||||
}),
|
||||
[keyType, publicKey, queueRpc, suri]
|
||||
);
|
||||
|
||||
const _cryptoOptions = useMemo(
|
||||
() => CRYPTO_MAP[keyType].map((value): { text: string; value: KeypairType } => ({
|
||||
text: value === 'ed25519'
|
||||
@ -104,7 +106,7 @@ function InjectKeys ({ onClose }: Props): React.ReactElement<Props> | null {
|
||||
<Dropdown
|
||||
label={t<string>('key type to set')}
|
||||
onChange={setKeyType}
|
||||
options={keyTypeOpt}
|
||||
options={keyTypeOptRef.current}
|
||||
value={keyType}
|
||||
/>
|
||||
<Dropdown
|
||||
|
||||
@ -6,7 +6,7 @@ import { StakerState } from '@polkadot/react-hooks/types';
|
||||
import { SortedTargets } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useMemo, useRef } from 'react';
|
||||
import { Button, Table } from '@polkadot/react-components';
|
||||
import { useAvailableSlashes } from '@polkadot/react-hooks';
|
||||
import { FormatBalance } from '@polkadot/react-query';
|
||||
@ -56,18 +56,18 @@ function Actions ({ className = '', isInElection, ownStashes, targets }: Props):
|
||||
const { t } = useTranslation();
|
||||
const allSlashes = useAvailableSlashes();
|
||||
|
||||
const { bondedTotal, foundStashes } = useMemo(
|
||||
() => extractState(ownStashes),
|
||||
[ownStashes]
|
||||
);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('stashes'), 'start', 2],
|
||||
[t('controller'), 'address'],
|
||||
[t('rewards'), 'number ui--media-1200'],
|
||||
[t('bonded'), 'number'],
|
||||
[undefined, undefined, 2]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const { bondedTotal, foundStashes } = useMemo(
|
||||
() => extractState(ownStashes),
|
||||
[ownStashes]
|
||||
);
|
||||
|
||||
const footer = useMemo(() => (
|
||||
<tr>
|
||||
@ -93,7 +93,7 @@ function Actions ({ className = '', isInElection, ownStashes, targets }: Props):
|
||||
<Table
|
||||
empty={foundStashes && t<string>('No funds staked yet. Bond funds to validate or nominate a validator')}
|
||||
footer={footer}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{foundStashes?.map((info): React.ReactNode => (
|
||||
<Account
|
||||
|
||||
@ -6,7 +6,7 @@ import { DeriveHeartbeats, DeriveStakingOverview } from '@polkadot/api-derive/ty
|
||||
import { AccountId, EraIndex, Nominations } from '@polkadot/types/interfaces';
|
||||
import { Authors } from '@polkadot/react-query/BlockAuthors';
|
||||
|
||||
import React, { useCallback, useContext, useMemo, useState } from 'react';
|
||||
import React, { useCallback, useContext, useMemo, useRef, useState } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall, useLoadingDelay } from '@polkadot/react-hooks';
|
||||
import { BlockAuthorsContext } from '@polkadot/react-query';
|
||||
@ -113,15 +113,15 @@ function CurrentList ({ favorites, hasQueries, isIntentions, next, stakingOvervi
|
||||
[nominators]
|
||||
);
|
||||
|
||||
const headerWaiting = useMemo(() => [
|
||||
const headerWaitingRef = useRef([
|
||||
[t('intentions'), 'start', 2],
|
||||
[t('nominators'), 'start', 2],
|
||||
[t('commission'), 'number', 1],
|
||||
[],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const headerActive = useMemo(() => [
|
||||
const headerActiveRef = useRef([
|
||||
[t('validators'), 'start', 2],
|
||||
[t('other stake')],
|
||||
[t('own stake')],
|
||||
@ -130,7 +130,7 @@ function CurrentList ({ favorites, hasQueries, isIntentions, next, stakingOvervi
|
||||
[t('last #')],
|
||||
[],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const _renderRows = useCallback(
|
||||
(addresses?: AccountExtend[], isMain?: boolean): React.ReactNode[] =>
|
||||
@ -167,7 +167,7 @@ function CurrentList ({ favorites, hasQueries, isIntentions, next, stakingOvervi
|
||||
withIdentity={withIdentity}
|
||||
/>
|
||||
}
|
||||
header={headerWaiting}
|
||||
header={headerWaitingRef.current}
|
||||
>
|
||||
{isLoading ? undefined : _renderRows(elected, false).concat(_renderRows(waiting, false))}
|
||||
</Table>
|
||||
@ -183,7 +183,7 @@ function CurrentList ({ favorites, hasQueries, isIntentions, next, stakingOvervi
|
||||
withIdentity={withIdentity}
|
||||
/>
|
||||
}
|
||||
header={headerActive}
|
||||
header={headerActiveRef.current}
|
||||
>
|
||||
{isLoading ? undefined : _renderRows(validators, true)}
|
||||
</Table>
|
||||
|
||||
@ -8,7 +8,7 @@ import { StakerState } from '@polkadot/react-hooks/types';
|
||||
import { PayoutStash, PayoutValidator } from './types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import React, { useMemo, useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import { Button, Table } from '@polkadot/react-components';
|
||||
@ -182,13 +182,13 @@ function Payouts ({ className = '', isInElection, ownValidators }: Props): React
|
||||
[undefined, undefined, 3]
|
||||
], [myStashesIndex, t]);
|
||||
|
||||
const headerValidators = useMemo(() => [
|
||||
const headerValidatorsRef = useRef([
|
||||
[t('payout/validator'), 'start', 2],
|
||||
[t('eras'), 'start'],
|
||||
[t('available')],
|
||||
[('remaining')],
|
||||
[undefined, undefined, 3]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const valOptions = useMemo(() => [
|
||||
{ isDisabled: !hasOwnValidators, text: t('My validators'), value: 'val' },
|
||||
@ -245,7 +245,7 @@ function Payouts ({ className = '', isInElection, ownValidators }: Props): React
|
||||
</Table>
|
||||
{api.tx.staking.payoutStakers && (myStashesIndex === 1) && !isLoadingRewards && validators && (validators.length !== 0) && (
|
||||
<Table
|
||||
header={headerValidators}
|
||||
header={headerValidatorsRef.current}
|
||||
isFixed
|
||||
>
|
||||
{!isLoadingRewards && validators.map((payout): React.ReactNode => (
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { DeriveStakerPoints } from '@polkadot/api-derive/types';
|
||||
import { ChartInfo, LineDataEntry, Props } from './types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useMemo, useRef } from 'react';
|
||||
import { Chart, Spinner } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
|
||||
@ -50,10 +50,10 @@ function ChartPoints ({ validatorId }: Props): React.ReactElement<Props> {
|
||||
[stakerPoints]
|
||||
);
|
||||
|
||||
const legends = useMemo(() => [
|
||||
const legendsRef = useRef([
|
||||
t<string>('points'),
|
||||
t<string>('average')
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className='staking--Chart'>
|
||||
@ -63,7 +63,7 @@ function ChartPoints ({ validatorId }: Props): React.ReactElement<Props> {
|
||||
<Chart.Line
|
||||
colors={COLORS_POINTS}
|
||||
labels={labels}
|
||||
legends={legends}
|
||||
legends={legendsRef.current}
|
||||
values={chart}
|
||||
/>
|
||||
)
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { SlashEra } from './types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -17,20 +17,21 @@ interface Props {
|
||||
|
||||
function Slashes ({ slash }: Props): React.ReactElement<Props> | null {
|
||||
const { t } = useTranslation();
|
||||
const header = useMemo((): [string?, string?, number?][] => [
|
||||
|
||||
const headerRef = useRef<[string?, string?, number?][]>([
|
||||
[undefined, 'start', 3],
|
||||
[t('reporters'), 'address'],
|
||||
[t('own')],
|
||||
[t('other')],
|
||||
[t('total')],
|
||||
[t('payout')]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table header={[[t('era {{era}}/unapplied', { replace: { era: slash.era.toString() } }), 'start', 8]]}>
|
||||
<Summary slash={slash} />
|
||||
<tr className='transparent'>
|
||||
{header.map(([label, className, colSpan = 1], index): React.ReactNode => (
|
||||
{headerRef.current.map(([label, className, colSpan = 1], index): React.ReactNode => (
|
||||
<td
|
||||
className={className}
|
||||
colSpan={colSpan}
|
||||
|
||||
@ -27,6 +27,9 @@ import { STORE_FAVS_BASE } from './constants';
|
||||
import { useTranslation } from './translate';
|
||||
import useSortedTargets from './useSortedTargets';
|
||||
|
||||
const HIDDEN_ACC = ['actions', 'payouts', 'query'];
|
||||
const HIDDEN_QUE = ['returns', 'query'];
|
||||
|
||||
function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { api } = useApi();
|
||||
@ -95,22 +98,19 @@ function StakingApp ({ basePath, className = '' }: Props): React.ReactElement<Pr
|
||||
}
|
||||
].filter((q): q is { name: string; text: string } => !!q), [api, slashes, t]);
|
||||
|
||||
const hiddenTabs = useMemo(
|
||||
(): string[] => !hasAccounts
|
||||
? ['actions', 'payouts', 'query']
|
||||
: !hasQueries
|
||||
? ['returns', 'query']
|
||||
: [],
|
||||
[hasAccounts, hasQueries]
|
||||
);
|
||||
|
||||
return (
|
||||
<main className={`staking--App ${className}`}>
|
||||
<HelpOverlay md={basicMd as string} />
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={hiddenTabs}
|
||||
hidden={
|
||||
!hasAccounts
|
||||
? HIDDEN_ACC
|
||||
: !hasQueries
|
||||
? HIDDEN_QUE
|
||||
: undefined
|
||||
}
|
||||
items={items}
|
||||
/>
|
||||
</header>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { QueryTypes, ParitalQueryTypes } from '../types';
|
||||
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import React, { useCallback, useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { Tabs } from '@polkadot/react-components';
|
||||
|
||||
@ -22,7 +22,8 @@ let id = -1;
|
||||
|
||||
function Selection ({ basePath, onAdd }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'modules',
|
||||
@ -36,7 +37,7 @@ function Selection ({ basePath, onAdd }: Props): React.ReactElement<Props> {
|
||||
name: 'raw',
|
||||
text: t<string>('Raw storage')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
const _onAdd = useCallback(
|
||||
(query: ParitalQueryTypes): void => onAdd({ ...query, id: ++id }),
|
||||
@ -48,7 +49,7 @@ function Selection ({ basePath, onAdd }: Props): React.ReactElement<Props> {
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { Icon, Tabs } from '@polkadot/react-components';
|
||||
import { useSudo } from '@polkadot/react-hooks';
|
||||
@ -17,7 +17,8 @@ import { useTranslation } from './translate';
|
||||
function SudoApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { allAccounts, isMine, sudoKey } = useSudo();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'index',
|
||||
@ -27,14 +28,14 @@ function SudoApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
name: 'key',
|
||||
text: t<string>('Set sudo key')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main>
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
{isMine
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { AccountId } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { AddressSmall, Table, Tag } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -18,15 +18,15 @@ interface Props {
|
||||
function Members ({ className = '', members, prime }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('members'), 'start', 3]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={members && t<string>('No members found')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{members?.map((accountId): React.ReactNode => (
|
||||
<tr key={accountId.toString()}>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { Hash } from '@polkadot/types/interfaces';
|
||||
import { ComponentProps as Props } from '../types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Button, Table } from '@polkadot/react-components';
|
||||
|
||||
import { useTranslation } from '../translate';
|
||||
@ -15,14 +15,14 @@ import Propose from './Propose';
|
||||
function Proposals ({ className = '', isMember, members, prime, proposals }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('proposals'), 'start', 2],
|
||||
[t('threshold')],
|
||||
[t('voting end')],
|
||||
[t('aye'), 'address'],
|
||||
[t('nay'), 'address'],
|
||||
[]
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
@ -34,7 +34,7 @@ function Proposals ({ className = '', isMember, members, prime, proposals }: Pro
|
||||
</Button.Group>
|
||||
<Table
|
||||
empty={proposals && t<string>('No committee proposals')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{proposals?.map((hash: Hash): React.ReactNode => (
|
||||
<Proposal
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { AppProps as Props } from '@polkadot/react-components/types';
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import Tabs from '@polkadot/react-components/Tabs';
|
||||
import { useAccounts } from '@polkadot/react-hooks';
|
||||
@ -15,10 +15,13 @@ import Sign from './Sign';
|
||||
import Verify from './Verify';
|
||||
import { useTranslation } from './translate';
|
||||
|
||||
const HIDDEN_ACC = ['sign', 'verify'];
|
||||
|
||||
function ToolboxApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const { hasAccounts } = useAccounts();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'rpc',
|
||||
@ -36,19 +39,15 @@ function ToolboxApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
name: 'verify',
|
||||
text: t<string>('Verify signature')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className='toolbox--App'>
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
hidden={
|
||||
hasAccounts
|
||||
? []
|
||||
: ['sign', 'verify']
|
||||
}
|
||||
items={items}
|
||||
hidden={hasAccounts ? undefined : HIDDEN_ACC}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -6,7 +6,7 @@ import { SubmittableExtrinsic } from '@polkadot/api/types';
|
||||
import { DeriveCollectiveProposal } from '@polkadot/api-derive/types';
|
||||
import { ProposalIndex } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { getTreasuryThreshold } from '@polkadot/app-council/thresholds';
|
||||
import { Button, Dropdown, InputAddress, Modal, TxButton } from '@polkadot/react-components';
|
||||
import { useApi, useToggle } from '@polkadot/react-hooks';
|
||||
@ -36,10 +36,10 @@ function Submission ({ councilProposals, id, isDisabled, members }: Props): Reac
|
||||
|
||||
const threshold = Math.ceil((members?.length || 0) * getTreasuryThreshold(api));
|
||||
|
||||
const councilTypeOpt = useMemo(() => [
|
||||
const councilTypeOptRef = useRef([
|
||||
{ text: t<string>('Acceptance proposal to council'), value: 'accept' },
|
||||
{ text: t<string>('Rejection proposal to council'), value: 'reject' }
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
useEffect((): void => {
|
||||
setHasProposals(
|
||||
@ -91,7 +91,7 @@ function Submission ({ councilProposals, id, isDisabled, members }: Props): Reac
|
||||
help={t<string>('The type of council proposal to submit.')}
|
||||
label={t<string>('council proposal type')}
|
||||
onChange={setCouncilType}
|
||||
options={councilTypeOpt}
|
||||
options={councilTypeOptRef.current}
|
||||
value={councilType}
|
||||
/>
|
||||
</Modal.Column>
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
import { BlockNumber, OpenTip, OpenTipTo225 } from '@polkadot/types/interfaces';
|
||||
|
||||
import React, { useEffect, useMemo, useState } from 'react';
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Table } from '@polkadot/react-components';
|
||||
import { useApi, useCall } from '@polkadot/react-hooks';
|
||||
import { Option } from '@polkadot/types';
|
||||
@ -45,7 +45,7 @@ function Tips ({ className = '', hashes, isMember, members }: Props): React.Reac
|
||||
);
|
||||
}, [hashes, optTips]);
|
||||
|
||||
const header = useMemo(() => [
|
||||
const headerRef = useRef([
|
||||
[t('tips'), 'start'],
|
||||
[t('finder'), 'address'],
|
||||
[t('reason'), 'start'],
|
||||
@ -53,13 +53,13 @@ function Tips ({ className = '', hashes, isMember, members }: Props): React.Reac
|
||||
[],
|
||||
[undefined, 'badge ui--media-1700'],
|
||||
[undefined, 'mini ui--media-1700']
|
||||
].filter((v) => v), [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<Table
|
||||
className={className}
|
||||
empty={tips && t<string>('No open tips')}
|
||||
header={header}
|
||||
header={headerRef.current}
|
||||
>
|
||||
{tips?.map(([hash, tip]): React.ReactNode => (
|
||||
<Tip
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { Route, Switch } from 'react-router';
|
||||
import { HelpOverlay, Tabs } from '@polkadot/react-components';
|
||||
|
||||
@ -19,13 +19,14 @@ interface Props {
|
||||
|
||||
function TreasuryApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const items = useMemo(() => [
|
||||
|
||||
const itemsRef = useRef([
|
||||
{
|
||||
isRoot: true,
|
||||
name: 'overview',
|
||||
text: t<string>('Treasury overview')
|
||||
}
|
||||
], [t]);
|
||||
]);
|
||||
|
||||
return (
|
||||
<main className='treasury--App'>
|
||||
@ -33,7 +34,7 @@ function TreasuryApp ({ basePath }: Props): React.ReactElement<Props> {
|
||||
<header>
|
||||
<Tabs
|
||||
basePath={basePath}
|
||||
items={items}
|
||||
items={itemsRef.current}
|
||||
/>
|
||||
</header>
|
||||
<Switch>
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { Props } from '../types';
|
||||
|
||||
import BN from 'bn.js';
|
||||
import React, { useMemo } from 'react';
|
||||
import React, { useRef } from 'react';
|
||||
import { GenericVote } from '@polkadot/types';
|
||||
import { Dropdown } from '@polkadot/react-components';
|
||||
|
||||
@ -23,23 +23,22 @@ function doChange (onChange?: (value: any) => void): (_: number) => void {
|
||||
|
||||
function Vote ({ className = '', defaultValue: { value }, isDisabled, isError, onChange, withLabel }: Props): React.ReactElement<Props> {
|
||||
const { t } = useTranslation();
|
||||
const optAye = useMemo(() => {
|
||||
return [
|
||||
{ text: t<string>('Nay'), value: 0 },
|
||||
{ text: t<string>('Aye'), value: -1 }
|
||||
];
|
||||
}, [t]);
|
||||
const optConv = useMemo(() => {
|
||||
return [
|
||||
{ text: t<string>('None'), value: 0 },
|
||||
{ text: t<string>('Locked1x'), value: 1 },
|
||||
{ text: t<string>('Locked2x'), value: 2 },
|
||||
{ text: t<string>('Locked3x'), value: 3 },
|
||||
{ text: t<string>('Locked4x'), value: 4 },
|
||||
{ text: t<string>('Locked5x'), value: 5 },
|
||||
{ text: t<string>('Locked6x'), value: 6 }
|
||||
];
|
||||
}, [t]);
|
||||
|
||||
const optAyeRef = useRef([
|
||||
{ text: t<string>('Nay'), value: 0 },
|
||||
{ text: t<string>('Aye'), value: -1 }
|
||||
]);
|
||||
|
||||
const optConvRef = useRef([
|
||||
{ text: t<string>('None'), value: 0 },
|
||||
{ text: t<string>('Locked1x'), value: 1 },
|
||||
{ text: t<string>('Locked2x'), value: 2 },
|
||||
{ text: t<string>('Locked3x'), value: 3 },
|
||||
{ text: t<string>('Locked4x'), value: 4 },
|
||||
{ text: t<string>('Locked5x'), value: 5 },
|
||||
{ text: t<string>('Locked6x'), value: 6 }
|
||||
]);
|
||||
|
||||
const defaultValue = value instanceof BN
|
||||
? value.toNumber()
|
||||
: value instanceof GenericVote
|
||||
@ -58,7 +57,7 @@ function Vote ({ className = '', defaultValue: { value }, isDisabled, isError, o
|
||||
isError={isError}
|
||||
label={t<string>('aye: bool')}
|
||||
onChange={doChange(onChange)}
|
||||
options={optAye}
|
||||
options={optAyeRef.current}
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
{isDisabled && (
|
||||
@ -68,7 +67,7 @@ function Vote ({ className = '', defaultValue: { value }, isDisabled, isError, o
|
||||
isDisabled={isDisabled}
|
||||
isError={isError}
|
||||
label={t<string>('conviction: Conviction')}
|
||||
options={optConv}
|
||||
options={optConvRef.current}
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user