From 43cb425b564e4dea6c2bbf798f47c324e7a636ee Mon Sep 17 00:00:00 2001 From: kwingram25 Date: Fri, 26 Jul 2019 11:21:05 +0100 Subject: [PATCH] Vote for council candidates (#1427) * Change council to collective/elections * fix proposal type * package * Submit candidacy * update index * Minor eslint cleanups * rename back to council * blank line * council voting * interface * Cleanup * tslint * retract vote * travis ci * rv console * SetIndex type * types.ts SetIndex import * bump api & fix retractVoter --- packages/app-council/src/Motions/Propose.tsx | 4 +- .../app-council/src/Overview/Candidate.tsx | 4 +- packages/app-council/src/Overview/Member.tsx | 4 +- packages/app-council/src/Overview/Members.tsx | 10 +- .../src/Overview/SubmitCandidacy.tsx | 23 +- packages/app-council/src/Overview/Summary.tsx | 13 +- packages/app-council/src/Overview/Vote.tsx | 319 ++++++++++++++++++ packages/app-council/src/Overview/index.tsx | 77 ++--- packages/app-council/src/Overview/types.ts | 17 +- packages/app-council/src/index.tsx | 2 +- packages/app-settings/src/General.tsx | 1 + packages/ui-app/src/Toggle.tsx | 11 +- packages/ui-app/src/TxButton.tsx | 4 +- packages/ui-params/src/Param/Vector.tsx | 34 +- 14 files changed, 418 insertions(+), 105 deletions(-) create mode 100644 packages/app-council/src/Overview/Vote.tsx diff --git a/packages/app-council/src/Motions/Propose.tsx b/packages/app-council/src/Motions/Propose.tsx index eae76311f9..fe1aab53eb 100644 --- a/packages/app-council/src/Motions/Propose.tsx +++ b/packages/app-council/src/Motions/Propose.tsx @@ -14,9 +14,9 @@ import { withApi, withCalls, withMulti } from '@polkadot/ui-api'; import translate from '../translate'; -type Props = TxModalProps & ApiProps & { +interface Props extends TxModalProps, ApiProps { memberCount: number; -}; +} interface State extends TxModalState { method: Method | null; diff --git a/packages/app-council/src/Overview/Candidate.tsx b/packages/app-council/src/Overview/Candidate.tsx index ef15ed9a12..0b5c57eb10 100644 --- a/packages/app-council/src/Overview/Candidate.tsx +++ b/packages/app-council/src/Overview/Candidate.tsx @@ -2,11 +2,13 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. +import { AccountId } from '@polkadot/types'; + import React from 'react'; import { AddressCard } from '@polkadot/ui-app'; interface Props { - address: string; + address: AccountId; } export default class Candidate extends React.PureComponent { diff --git a/packages/app-council/src/Overview/Member.tsx b/packages/app-council/src/Overview/Member.tsx index b09b15de13..7d7100c0f9 100644 --- a/packages/app-council/src/Overview/Member.tsx +++ b/packages/app-council/src/Overview/Member.tsx @@ -2,9 +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 { BlockNumber } from '@polkadot/types'; import { I18nProps } from '@polkadot/ui-app/types'; -import BN from 'bn.js'; import React from 'react'; import { AddressCard } from '@polkadot/ui-app'; import { formatNumber } from '@polkadot/util'; @@ -13,7 +13,7 @@ import translate from '../translate'; interface Props extends I18nProps { address: string; - block: BN; + block: BlockNumber; } class Member extends React.PureComponent { diff --git a/packages/app-council/src/Overview/Members.tsx b/packages/app-council/src/Overview/Members.tsx index 6ef0b578f5..ab0b7280a5 100644 --- a/packages/app-council/src/Overview/Members.tsx +++ b/packages/app-council/src/Overview/Members.tsx @@ -4,7 +4,7 @@ // of the Apache-2.0 license. See the LICENSE file for details. import { I18nProps } from '@polkadot/ui-app/types'; -import { ElectionsInfo } from './types'; +import { ComponentProps } from './types'; import React from 'react'; import { Columar, Column } from '@polkadot/ui-app'; @@ -13,9 +13,7 @@ import translate from '../translate'; import Candidate from './Candidate'; import Member from './Member'; -interface Props extends I18nProps { - electionsInfo: ElectionsInfo; -} +interface Props extends I18nProps, ComponentProps {} class Members extends React.PureComponent { public render (): React.ReactNode { @@ -28,7 +26,7 @@ class Members extends React.PureComponent { emptyText={t('No members found')} headerText={t('members')} > - {members.map(([address, block]): React.ReactNode => ( + {Object.entries(members).map(([address, block]): React.ReactNode => ( { {candidates.map((address): React.ReactNode => ( ))} diff --git a/packages/app-council/src/Overview/SubmitCandidacy.tsx b/packages/app-council/src/Overview/SubmitCandidacy.tsx index 3e85023851..405f389d7a 100644 --- a/packages/app-council/src/Overview/SubmitCandidacy.tsx +++ b/packages/app-council/src/Overview/SubmitCandidacy.tsx @@ -2,20 +2,16 @@ // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. -import { ElectionsInfo } from './types'; +import { ComponentProps } from './types'; import BN from 'bn.js'; import React from 'react'; import { Button } from '@polkadot/ui-app'; -import TxModal, { TxModalState, TxModalProps } from '@polkadot/ui-app/TxModal'; +import TxModal, { TxModalState as State, TxModalProps } from '@polkadot/ui-app/TxModal'; import translate from '../translate'; -interface Props extends TxModalProps { - electionsInfo: ElectionsInfo; -} - -type State = TxModalState; +interface Props extends ComponentProps, TxModalProps {} class SubmitCandidacy extends TxModal { protected headerText = (): string => this.props.t('Submit your council candidacy'); @@ -44,14 +40,11 @@ class SubmitCandidacy extends TxModal { const { t } = this.props; return ( - -