From 2c0fff2931375e8f6db7b865ee00bf046c3f5898 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 17 Sep 2020 12:44:54 +0200 Subject: [PATCH] Single-click close for tips & motions (#3669) * Single-click close for tips & motions * Protect against non-close chains --- packages/page-council/src/Motions/Close.tsx | 94 ------------------- packages/page-council/src/Motions/Motion.tsx | 59 +++++++----- .../page-tech-comm/src/Proposals/Close.tsx | 93 ------------------ .../page-tech-comm/src/Proposals/Proposal.tsx | 37 +++++--- packages/page-treasury/src/Tips/Tip.tsx | 16 +++- packages/page-treasury/src/Tips/TipClose.tsx | 67 ------------- packages/react-hooks/src/useVotingStatus.ts | 9 +- 7 files changed, 80 insertions(+), 295 deletions(-) delete mode 100644 packages/page-council/src/Motions/Close.tsx delete mode 100644 packages/page-tech-comm/src/Proposals/Close.tsx delete mode 100644 packages/page-treasury/src/Tips/TipClose.tsx diff --git a/packages/page-council/src/Motions/Close.tsx b/packages/page-council/src/Motions/Close.tsx deleted file mode 100644 index a790da6baa..0000000000 --- a/packages/page-council/src/Motions/Close.tsx +++ /dev/null @@ -1,94 +0,0 @@ -// 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 { Hash, Proposal, ProposalIndex } from '@polkadot/types/interfaces'; - -import React, { useState } from 'react'; -import { Button, InputAddress, Modal, ProposedAction, TxButton } from '@polkadot/react-components'; -import { useApi, useToggle, useWeight } from '@polkadot/react-hooks'; - -import { useTranslation } from '../translate'; - -interface Props { - hasFailed: boolean; - hash: Hash; - idNumber: ProposalIndex; - isDisabled: boolean; - members: string[]; - proposal: Proposal; -} - -function Close ({ hasFailed, hash, idNumber, isDisabled, members, proposal }: Props): React.ReactElement | null { - const { t } = useTranslation(); - const { api } = useApi(); - const [isOpen, toggleOpen] = useToggle(); - const [accountId, setAccountId] = useState(null); - const [proposalWeight, proposalLength] = useWeight(proposal); - - // protect against older versions - if (!api.tx.council.close) { - return null; - } - - return ( - <> - {isOpen && ( - ('Close proposal')} - size='large' - > - - - - - - -

{t('The proposal that will be affected. Once closed for the current voting round, it would need to be re-submitted to council for a subsequent voting round.')}

-
-
- - - ('Select the account you wish close the proposal with.')} - label={t('sending account')} - onChange={setAccountId} - type='account' - /> - - -

{t('The council account that will apply the close for the current round.')}

-
-
-
- - - -
- )} -