From e577bfbd8219b7f222bf57780a0e3f003e2c5a3e Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 11 Jan 2021 07:54:47 +0100 Subject: [PATCH] Adjust non-preimage display (#4359) --- packages/react-components/src/ActionItem.tsx | 49 -------- .../react-components/src/ProposedAction.tsx | 107 +++++++----------- packages/react-components/src/index.tsx | 1 - 3 files changed, 42 insertions(+), 115 deletions(-) delete mode 100644 packages/react-components/src/ActionItem.tsx diff --git a/packages/react-components/src/ActionItem.tsx b/packages/react-components/src/ActionItem.tsx deleted file mode 100644 index 1acd6a183d..0000000000 --- a/packages/react-components/src/ActionItem.tsx +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017-2021 @polkadot/react-components authors & contributors -// SPDX-License-Identifier: Apache-2.0 - -import type { Proposal } from '@polkadot/types/interfaces'; - -import BN from 'bn.js'; -import React from 'react'; -import styled from 'styled-components'; - -import Card from './Card'; -import ProposedAction, { styles as proposedActionStyles } from './ProposedAction'; -import { styles as rowStyles } from './Row'; - -interface Props { - className?: string; - children?: React.ReactNode; - accessory?: React.ReactNode; - proposal?: Proposal | null; - idNumber: BN | number | string; - expandNested?: boolean; -} - -export const styles = ` - ${rowStyles} - ${proposedActionStyles} -`; - -function ActionItem ({ accessory, children, className = '', expandNested, idNumber, proposal }: Props): React.ReactElement { - return ( - -
-
-
- -
- {accessory} -
- {children} -
-
- ); -} - -export default React.memo(styled(ActionItem)`${styles}`); diff --git a/packages/react-components/src/ProposedAction.tsx b/packages/react-components/src/ProposedAction.tsx index 2f2f89cf0b..9643c6726f 100644 --- a/packages/react-components/src/ProposedAction.tsx +++ b/packages/react-components/src/ProposedAction.tsx @@ -11,21 +11,58 @@ import { formatNumber, isString } from '@polkadot/util'; import Call from './Call'; import Expander from './Expander'; -import Inset, { InsetProps } from './Inset'; +import { useTranslation } from './translate'; import TreasuryProposal from './TreasuryProposal'; import { isTreasuryProposalVote } from './util'; interface Props { className?: string; - asInset?: boolean; - insetProps?: Partial; proposal?: Proposal | null; idNumber: BN | number | string; withLinks?: boolean; expandNested?: boolean; } -export const styles = ` +function ProposedAction ({ className = '', expandNested, idNumber, proposal, withLinks }: Props): React.ReactElement { + const { t } = useTranslation(); + const stringId = isString(idNumber) + ? idNumber + : formatNumber(idNumber); + + if (!proposal) { + return ( +

#{stringId} {t('No execution details available for this proposal')}

+ ); + } + + const { meta, method, section } = proposal.registry.findMetaCall(proposal.callIndex); + + const header = `#${stringId}: ${section}.${method}`; + + return ( +
+

{header}

+ + {(isTreasuryProposalVote(proposal) && expandNested) + ? ( + + ) + : + } + +
+ ); +} + +export default React.memo(styled(ProposedAction)` margin-left: 2rem; .ui--ProposedAction-extrinsic { @@ -37,64 +74,4 @@ export const styles = ` .ui--ProposedAction-header { margin-bottom: 1rem; } -`; - -function ProposedAction ({ asInset, className = '', expandNested, idNumber, insetProps, proposal, withLinks }: Props): React.ReactElement { - const stringId = isString(idNumber) - ? idNumber - : formatNumber(idNumber); - - if (!proposal) { - return ( -

#{stringId}

- ); - } - - const { meta, method, section } = proposal.registry.findMetaCall(proposal.callIndex); - - const header = `#${stringId}: ${section}.${method}`; - const documentation = meta?.documentation - ? ( - {meta.documentation.join(' ')} - ) - : null; - const params = (isTreasuryProposalVote(proposal) && expandNested) - ? ( - - ) - : ; - - if (asInset) { - return ( - - <> - {documentation} - {params} - - - ); - } - - return ( -
-

{header}

- - {params} - -
- ); -} - -export default React.memo(styled(ProposedAction)`${styles}`); +`); diff --git a/packages/react-components/src/index.tsx b/packages/react-components/src/index.tsx index d94a4ce662..8ecf7e411a 100644 --- a/packages/react-components/src/index.tsx +++ b/packages/react-components/src/index.tsx @@ -5,7 +5,6 @@ export * from '@polkadot/react-qr'; export { default as AccountIndex } from './AccountIndex'; export { default as AccountName } from './AccountName'; -export { default as ActionItem } from './ActionItem'; export { default as AddressInfo } from './AddressInfo'; export { default as AddressMini } from './AddressMini'; export { default as AddressRow } from './AddressRow';