From 55b8a60889250793490fb61dcc2750f43af71a79 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 23 Mar 2020 09:03:27 +0100 Subject: [PATCH] Cleanup some submission modals (#2439) * Housekeeping, rename copyright headers * Cleanup some submission modals --- .../src/Motions/ProposeExternal.tsx | 2 +- .../src/Motions/ProposeMotion.tsx | 2 +- .../page-council/src/Motions/Slashing.tsx | 2 +- .../src/Motions/useAvailableSlashes.ts | 2 +- .../src/Overview/SubmitCandidacy.tsx | 80 ++++++------ packages/page-council/src/Overview/Vote.tsx | 2 +- packages/page-council/src/Overview/index.tsx | 2 +- .../page-democracy/src/Overview/Fasttrack.tsx | 6 +- .../src/Actions/Account/BondExtra.tsx | 2 +- .../Actions/Account/InputValidateAmount.tsx | 2 +- .../Account/InputValidationController.tsx | 2 +- .../Account/InputValidationSessionKey.tsx | 2 +- .../InputValidationUnstakeThreshold.tsx | 2 +- .../src/Actions/Account/Nominate.tsx | 2 +- .../Actions/Account/SetControllerAccount.tsx | 2 +- .../Actions/Account/SetRewardDestination.tsx | 2 +- .../src/Actions/Account/SetSessionKey.tsx | 2 +- .../src/Actions/Account/Unbond.tsx | 2 +- .../src/Actions/Account/Validate.tsx | 2 +- .../src/Actions/Account/useInactives.ts | 2 +- .../page-staking/src/Actions/NewStake.tsx | 2 +- .../page-tech-comm/src/Overview/Summary.tsx | 1 - .../page-tech-comm/src/Overview/index.tsx | 3 +- .../page-tech-comm/src/Proposals/Propose.tsx | 119 ++++++++++-------- .../page-tech-comm/src/Proposals/index.tsx | 19 +-- packages/page-tech-comm/src/index.tsx | 8 +- packages/page-tech-comm/src/types.ts | 1 + packages/react-hooks/src/useMembers.ts | 32 ++--- 28 files changed, 160 insertions(+), 147 deletions(-) diff --git a/packages/page-council/src/Motions/ProposeExternal.tsx b/packages/page-council/src/Motions/ProposeExternal.tsx index e328321530..c02c271f3d 100644 --- a/packages/page-council/src/Motions/ProposeExternal.tsx +++ b/packages/page-council/src/Motions/ProposeExternal.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/ui-staking authors & contributors +// Copyright 2017-2020 @polkadot/app-council authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/page-council/src/Motions/ProposeMotion.tsx b/packages/page-council/src/Motions/ProposeMotion.tsx index cb74ec0335..8bec224b85 100644 --- a/packages/page-council/src/Motions/ProposeMotion.tsx +++ b/packages/page-council/src/Motions/ProposeMotion.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/ui-staking authors & contributors +// Copyright 2017-2020 @polkadot/app-council authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/page-council/src/Motions/Slashing.tsx b/packages/page-council/src/Motions/Slashing.tsx index 202569baf0..f59b472993 100644 --- a/packages/page-council/src/Motions/Slashing.tsx +++ b/packages/page-council/src/Motions/Slashing.tsx @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/ui-staking authors & contributors +// Copyright 2017-2020 @polkadot/app-council authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/page-council/src/Motions/useAvailableSlashes.ts b/packages/page-council/src/Motions/useAvailableSlashes.ts index 3026b4b821..3081b3978a 100644 --- a/packages/page-council/src/Motions/useAvailableSlashes.ts +++ b/packages/page-council/src/Motions/useAvailableSlashes.ts @@ -1,4 +1,4 @@ -// Copyright 2017-2020 @polkadot/ui-staking authors & contributors +// Copyright 2017-2020 @polkadot/app-council authors & contributors // This software may be modified and distributed under the terms // of the Apache-2.0 license. See the LICENSE file for details. diff --git a/packages/page-council/src/Overview/SubmitCandidacy.tsx b/packages/page-council/src/Overview/SubmitCandidacy.tsx index 4d032ce14c..2ff3dc5c6e 100644 --- a/packages/page-council/src/Overview/SubmitCandidacy.tsx +++ b/packages/page-council/src/Overview/SubmitCandidacy.tsx @@ -1,50 +1,54 @@ -// Copyright 2017-2020 @polkadot/ui-staking authors & contributors +// Copyright 2017-2020 @polkadot/app-council 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 { ApiProps } from '@polkadot/react-api/types'; -import { ComponentProps } from './types'; +import React, { useState } from 'react'; +import { Button, InputAddress, Modal, TxButton } from '@polkadot/react-components'; +import { useApi, useModal } from '@polkadot/react-hooks'; -import React from 'react'; -import { withApi } from '@polkadot/react-api/hoc'; -import { Button } from '@polkadot/react-components'; -import TxModal, { TxModalState as State, TxModalProps } from '@polkadot/react-components/TxModal'; +import { useTranslation } from '../translate'; -import translate from '../translate'; +function SubmitCandidacy (): React.ReactElement { + const { api } = useApi(); + const { t } = useTranslation(); + const [accountId, setAcountId] = useState(null); + const { isOpen, onOpen, onClose } = useModal(); -interface Props extends ApiProps, ComponentProps, TxModalProps {} - -class SubmitCandidacy extends TxModal { - protected headerText = (): string => this.props.t('Submit your council candidacy'); - - protected accountLabel = (): string => this.props.t('Candidate account'); - - protected accountHelp = (): string => this.props.t('This account will be nominated to fill the council slot you specify.'); - - protected txMethod = (): string => - this.props.api.tx.electionsPhragmen - ? 'electionsPhragmen.submitCandidacy' - : 'elections.submitCandidacy'; - - protected txParams = (): [] => []; - - protected isDisabled = (): boolean => { - const { accountId } = this.state; - - return !accountId; - } - - protected renderTrigger = (): React.ReactNode => { - const { t } = this.props; - - return ( + return ( + <> + {isOpen && ( + + + + + + + + + )}