Change council to collective/elections (#1398)

* Change council to collective/elections

* fix proposal type

* package
This commit is contained in:
kwingram25 2019-07-14 20:26:32 +01:00 committed by GitHub
parent 031040715a
commit e9b5f72e8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 82 additions and 82 deletions

View File

@ -0,0 +1 @@
# @polkadot/app-collective

View File

@ -1,7 +1,7 @@
{
"name": "@polkadot/app-council",
"name": "@polkadot/app-collective",
"version": "0.34.0-beta.60",
"description": "Council",
"description": "Collective",
"main": "index.js",
"scripts": {},
"author": "Jaco Greeff <jacogr@gmail.com>",

View File

@ -23,7 +23,7 @@ class Member extends React.PureComponent<Props> {
return (
<AddressCard
buttons={<div><label>{t('active until')}</label>#{formatNumber(block)}</div>}
defaultName='council member'
defaultName='collective member'
value={address}
/>
);

View File

@ -14,13 +14,13 @@ import Candidate from './Candidate';
import Member from './Member';
type Props = I18nProps & {
council_activeCouncil?: Array<[string, BlockNumber]>
council_candidates?: Array<string>
elections_members?: Array<[string, BlockNumber]>
elections_candidates?: Array<string>
};
class Members extends React.PureComponent<Props> {
render () {
const { council_activeCouncil = [], council_candidates = [], t } = this.props;
const { elections_members = [], elections_candidates = [], t } = this.props;
return (
<Columar>
@ -28,7 +28,7 @@ class Members extends React.PureComponent<Props> {
emptyText={t('No members found')}
headerText={t('members')}
>
{council_activeCouncil.map(([address, block]) => (
{elections_members.map(([address, block]) => (
<Member
address={address}
block={block}
@ -40,7 +40,7 @@ class Members extends React.PureComponent<Props> {
emptyText={t('No members found')}
headerText={t('candidates')}
>
{council_candidates.map((address) => (
{elections_candidates.map((address) => (
<Candidate
address={address}
key={address}
@ -54,11 +54,11 @@ class Members extends React.PureComponent<Props> {
export default translate(
withCalls<Props>(
['query.council.activeCouncil', {
['query.elections.members', {
transform: (active: Array<[AccountId, BlockNumber]>) =>
active.map(([accountId, blockNumber]) => [accountId.toString(), blockNumber])
}],
['query.council.candidates', {
['query.elections.candidates', {
transform: (candidates: Array<AccountId>) =>
candidates.map((accountId) => accountId.toString())
}]

View File

@ -14,36 +14,36 @@ import { formatNumber } from '@polkadot/util';
import translate from '../translate';
type Props = I18nProps & {
council_activeCouncil?: Array<[AccountId, BlockNumber]>
council_candidateCount?: BN,
council_desiredSeats?: BN,
council_termDuration?: BN,
council_voteCount?: BN
elections_members?: Array<[AccountId, BlockNumber]>
elections_candidateCount?: BN,
elections_desiredSeats?: BN,
elections_termDuration?: BN,
elections_voteCount?: BN
};
class Summary extends React.PureComponent<Props> {
render () {
const { council_activeCouncil = [], council_candidateCount = new BN(0), council_desiredSeats = new BN(1), council_termDuration = new BN(0), council_voteCount = new BN(0), t } = this.props;
const { elections_members = [], elections_candidateCount = new BN(0), elections_desiredSeats = new BN(1), elections_termDuration = new BN(0), elections_voteCount = new BN(0), t } = this.props;
return (
<SummaryBox>
<section>
<CardSummary label={t('seats')}>
{formatNumber(council_activeCouncil.length)}/{formatNumber(council_desiredSeats)}
{formatNumber(elections_members.length)}/{formatNumber(elections_desiredSeats)}
</CardSummary>
<CardSummary label={t('candidates')}>
{formatNumber(council_candidateCount)}
{formatNumber(elections_candidateCount)}
</CardSummary>
</section>
<section>
<CardSummary label={t('total votes')}>
{formatNumber(council_voteCount)}
{formatNumber(elections_voteCount)}
</CardSummary>
</section>
<section>
<CardSummary label={t('term duration')}>
{formatNumber(council_termDuration)}
{formatNumber(elections_termDuration)}
</CardSummary>
</section>
</SummaryBox>
@ -53,10 +53,10 @@ class Summary extends React.PureComponent<Props> {
export default translate(
withCalls<Props>(
'query.council.activeCouncil',
'query.council.candidateCount',
'query.council.desiredSeats',
'query.council.termDuration',
'query.council.voteCount'
'query.elections.members',
'query.elections.candidateCount',
'query.elections.desiredSeats',
'query.elections.termDuration',
'query.elections.voteCount'
)(Summary)
);

View File

@ -3,7 +3,7 @@
// of the Apache-2.0 license. See the LICENSE file for details.
import { I18nProps } from '@polkadot/ui-app/types';
import { Option, Proposal, Votes } from '@polkadot/types';
import { Option, Proposal as ProposalType, Votes } from '@polkadot/types';
import BN from 'bn.js';
import React from 'react';
@ -16,7 +16,7 @@ import translate from '../translate';
type Props = I18nProps & {
chain_bestNumber?: BN,
hash: string,
proposal: Proposal | null,
proposal: ProposalType | null,
votes: Votes | null
};
@ -26,7 +26,7 @@ type State = {
votedAye: number
};
class Motion extends React.PureComponent<Props, State> {
class Proposal extends React.PureComponent<Props, State> {
state: State = {
votedTotal: 0,
votedAye: 0,
@ -64,7 +64,7 @@ class Motion extends React.PureComponent<Props, State> {
accessory={
<Voting
hash={hash}
isCouncil
isCollective
idNumber={index}
proposal={proposal}
/>
@ -140,8 +140,8 @@ class Motion extends React.PureComponent<Props, State> {
}
export default withMulti(
styled(Motion as React.ComponentClass<Props>)`
.democracy--Motion-results {
styled(Proposal as React.ComponentClass<Props>)`
.democracy--Proposal-results {
margin-bottom: 1em;
&.chart {
@ -152,15 +152,15 @@ export default withMulti(
translate,
withCalls<Props>(
[
'query.councilMotions.proposalOf',
'query.collective.proposalOf',
{
paramName: 'hash',
propName: 'proposal',
transform: (value: Option<Proposal>) => value.unwrapOr(null)
transform: (value: Option<ProposalType>) => value.unwrapOr(null)
}
],
[
'query.councilMotions.voting',
'query.collective.voting',
{
paramName: 'hash',
propName: 'votes',

View File

@ -43,9 +43,9 @@ class Propose extends TxModal<Props, State> {
return null;
}
headerText = () => this.props.t('Propose a council motion');
headerText = () => this.props.t('Make a collective proposal');
txMethod = () => 'councilMotions.propose';
txMethod = () => 'collective.propose';
txParams = () => {
const { method, threshold } = this.state;
@ -72,7 +72,7 @@ class Propose extends TxModal<Props, State> {
<Button.Group>
<Button
isPrimary
label={t('Propose a council motion')}
label={t('Make a collective proposal')}
labelIcon='add'
onClick={this.showModal}
/>
@ -89,7 +89,7 @@ class Propose extends TxModal<Props, State> {
<InputNumber
className='medium'
label={t('threshold')}
help={t('The minimum number of council votes required to approve this motion')}
help={t('The minimum number of collective votes required to approve this proposal')}
isError={!threshold || threshold.eqn(0) || threshold.gtn(memberCount)}
onChange={this.onChangeThreshold}
onEnter={this.sendTx}
@ -134,7 +134,7 @@ export default withMulti(
withApi,
withCalls(
[
'query.council.activeCouncil',
'query.elections.members',
{
propName: 'memberCount',
transform: (value: Array<any>) => value.length

View File

@ -9,36 +9,36 @@ import React from 'react';
import { withCalls } from '@polkadot/ui-api';
import { CardGrid } from '@polkadot/ui-app';
import Motion from './Motion';
import Proposal from './Proposal';
import Propose from './Propose';
import translate from '../translate';
type Props = I18nProps & {
councilMotions_proposals?: Array<Hash>
collective_proposals?: Array<Hash>
};
class Motions extends React.PureComponent<Props> {
class Proposals extends React.PureComponent<Props> {
render () {
const { t } = this.props;
return (
<CardGrid
emptyText={t('No council motions')}
headerText={t('Motions')}
emptyText={t('No proposals')}
headerText={t('Proposals')}
buttons={
<Propose />
}
>
{this.renderMotions()}
{this.renderProposals()}
</CardGrid>
);
}
private renderMotions () {
const { councilMotions_proposals = [] } = this.props;
private renderProposals () {
const { collective_proposals = [] } = this.props;
return councilMotions_proposals.map((hash) => (
<Motion
return collective_proposals.map((hash) => (
<Proposal
hash={hash.toHex()}
key={hash.toHex()}
/>
@ -48,6 +48,6 @@ class Motions extends React.PureComponent<Props> {
export default translate(
withCalls<Props>(
'query.councilMotions.proposals'
)(Motions)
'query.collective.proposals'
)(Proposals)
);

View File

@ -10,7 +10,7 @@ import { Route, Switch } from 'react-router';
import { Tabs } from '@polkadot/ui-app';
import Overview from './Overview';
import Motions from './Motions';
import Proposals from './Proposals';
import translate from './translate';
type Props = AppProps & BareProps & I18nProps;
@ -30,11 +30,11 @@ class App extends React.PureComponent<Props, State> {
{
isRoot: true,
name: 'overview',
text: t('Council overview')
text: t('Collective overview')
},
{
name: 'motions',
text: t('Motions')
name: 'proposals',
text: t('Proposals')
}
]
};
@ -53,7 +53,7 @@ class App extends React.PureComponent<Props, State> {
/>
</header>
<Switch>
<Route path={`${basePath}/motions`} component={Motions} />
<Route path={`${basePath}/proposals`} component={Proposals} />
<Route component={Overview} />
</Switch>
</main>

View File

@ -1,7 +1,7 @@
// Copyright 2017-2019 @polkadot/app-council authors & contributors
// Copyright 2017-2019 @polkadot/app-collective authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { withTranslation } from 'react-i18next';
export default withTranslation(['council', 'ui']);
export default withTranslation(['collective', 'ui']);

View File

@ -1 +0,0 @@
# @polkadot/app-council

View File

@ -71,7 +71,7 @@ class Extrinsics extends React.PureComponent<Props> {
`mortal${blockNumber ? ' - ends at #{{blockNumber}}' : ''}`,
{
replace: {
blockNumber: (eraEnd && blockNumber) ? eraEnd.toString() : ''
blockNumber: (eraEnd && blockNumber) ? formatNumber(eraEnd) : ''
}
}
)

View File

@ -37,7 +37,7 @@ class Approve extends TxModal<Props, State> {
headerText = () => this.props.t('Approve or reject proposal');
txMethod = () => 'councilMotions.propose';
txMethod = () => 'collective.propose';
txParams = () => {
const { api, proposalId, threshold } = this.props;
const { isApproving } = this.state;
@ -79,8 +79,8 @@ class Approve extends TxModal<Props, State> {
return (
<Dropdown
help={t('Propose a majority council motion to either approve or reject this spend proposal')}
label={t('proposed council action')}
help={t('Propose a majority collective proposal to either approve or reject this spend proposal')}
label={t('proposed collective action')}
options={this.approveOptions()}
onChange={this.onChangeApproving}
value={isApproving}
@ -99,7 +99,7 @@ export default withMulti(
withApi,
withCalls(
[
'query.council.activeCouncil',
'query.elections.members',
{
propName: 'threshold',
transform: (value: Array<[AccountId, BlockNumber]>) => 1 + (value.length / 2)

View File

@ -84,7 +84,7 @@ class ProposalsBase extends React.PureComponent<Props> {
onRespond = () => {
const { history } = this.props;
history.push('/council/motions');
history.push('/collective/proposals');
}
private onPopulateProposal = () => {

View File

@ -4,20 +4,20 @@
import { Routes } from './types';
import Council from '@polkadot/app-council';
import Collective from '@polkadot/app-collective';
export default ([
{
Component: Council,
Component: Collective,
display: {
needsApi: [
'query.council.candidates'
'query.elections.candidates'
]
},
i18n: {
defaultValue: 'Council'
defaultValue: 'Collective'
},
icon: 'building',
name: 'council'
name: 'collective'
}
] as Routes);

View File

@ -10,7 +10,7 @@ import template from './123code';
import accounts from './accounts';
import addressbook from './addressbook';
import contracts from './contracts';
import council from './council';
import collective from './collective';
import dashboard from './dashboard';
import democracy from './democracy';
import explorer from './explorer';
@ -35,7 +35,7 @@ const routes: Routes = appSettings.uiMode === 'light'
null,
staking,
democracy,
council,
collective,
// TODO Not sure about the inclusion of treasury & parachains here
null,
settings,
@ -50,7 +50,7 @@ const routes: Routes = appSettings.uiMode === 'light'
null,
staking,
democracy,
council,
collective,
treasury,
parachains,
null,

View File

@ -22,7 +22,7 @@ type Props = I18nProps & TxModalProps & {
allAccounts?: SubjectInfo,
hash?: string,
idNumber: BN | number,
isCouncil: boolean,
isCollective: boolean,
proposal?: Proposal | null,
preContent?: React.ReactNode
};
@ -36,25 +36,25 @@ class Voting extends TxModal<Props, State> {
state: State;
headerText = () => {
const { isCouncil, t } = this.props;
const { isCollective, t } = this.props;
return t(isCouncil ? 'Vote on council motion' : 'Vote on proposal');
return t(isCollective ? 'Vote on collective proposal' : 'Vote on proposal');
}
accountLabel = () => this.props.t('Vote with account');
accountHelp = () => this.props.t('Select the account you wish to vote with. You can approve "aye" or deny "nay" the proposal.');
txMethod = () => {
const { isCouncil } = this.props;
const { isCollective } = this.props;
return isCouncil ? 'councilMotions.vote' : 'democracy.vote';
return isCollective ? 'collective.vote' : 'democracy.vote';
}
txParams = () => {
const { hash, idNumber, isCouncil } = this.props;
const { hash, idNumber, isCollective } = this.props;
const { voteValue } = this.state;
return isCouncil
return isCollective
? [hash!, idNumber, voteValue]
: [idNumber, voteValue];
}

View File

@ -11,8 +11,8 @@
"@polkadot/app-address-book/*": [ "packages/app-address-book/src/*" ],
"@polkadot/app-contracts": [ "packages/app-contracts/src" ],
"@polkadot/app-contracts/*": [ "packages/app-contracts/src/*" ],
"@polkadot/app-council": [ "packages/app-council/src" ],
"@polkadot/app-council/*": [ "packages/app-council/src/*" ],
"@polkadot/app-collective": [ "packages/app-collective/src" ],
"@polkadot/app-collective/*": [ "packages/app-collective/src/*" ],
"@polkadot/app-dashboard": [ "packages/app-dashboard/src" ],
"@polkadot/app-dashboard/*": [ "packages/app-dashboard/src/*" ],
"@polkadot/app-democracy": [ "packages/app-democracy/src" ],