Adjust signer modal with Columns (#2662)
* Adjust signer modal with Columns * Small multisig adjustments
This commit is contained in:
parent
9c0f9c84da
commit
c72aa99195
@ -20,6 +20,7 @@ function NetworkModal ({ className, onClose }: Props): React.ReactElement<Props>
|
||||
<Modal
|
||||
className={className}
|
||||
header={t('Select Network')}
|
||||
size='large'
|
||||
>
|
||||
<Modal.Content>
|
||||
<General
|
||||
|
||||
@ -7,7 +7,7 @@ import { Option } from '@polkadot/apps-config/settings/types';
|
||||
import React, { useCallback, useEffect, useState, useMemo } from 'react';
|
||||
import { createLanguages, createSs58 } from '@polkadot/apps-config/settings';
|
||||
import { isLedgerCapable } from '@polkadot/react-api';
|
||||
import { Button, ButtonCancel, Dropdown } from '@polkadot/react-components';
|
||||
import { Button, ButtonCancel, Dropdown, Modal } from '@polkadot/react-components';
|
||||
import uiSettings, { SettingsStruct } from '@polkadot/ui-settings';
|
||||
|
||||
import { useTranslation } from './translate';
|
||||
@ -70,10 +70,21 @@ function General ({ className, isModalContent, onClose }: Props): React.ReactEle
|
||||
);
|
||||
|
||||
const { i18nLang, icon, ledgerConn, prefix, uiMode } = settings;
|
||||
const networkSelector = <SelectUrl onChange={_handleChange('apiUrl')} />;
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<SelectUrl onChange={_handleChange('apiUrl')} />
|
||||
{isModalContent
|
||||
? (
|
||||
<Modal.Columns>
|
||||
<Modal.Column>{networkSelector}</Modal.Column>
|
||||
<Modal.Column>
|
||||
{t('The RPC node can be selected from the pre-defined list or manually entered, depending on the chain you wish to connect to.')}
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
)
|
||||
: networkSelector
|
||||
}
|
||||
{!isModalContent && (
|
||||
<>
|
||||
<div className='ui--row'>
|
||||
|
||||
@ -188,6 +188,7 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
<Modal
|
||||
className={`ui--signer-Signer ${className}`}
|
||||
header={t('Authorize transaction')}
|
||||
size='large'
|
||||
>
|
||||
<ErrorBoundary onError={this.onRenderError}>{this.renderContent()}</ErrorBoundary>
|
||||
{this.renderButtons()}
|
||||
@ -219,7 +220,6 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
>
|
||||
{!isRenderError && (!isQrVisible || !isQrScanning) && !signedTx && (
|
||||
<>
|
||||
{!currentItem.isUnsigned && this.renderSignToggle()}
|
||||
<Button
|
||||
className='ui--signer-Signer-Submit'
|
||||
icon={isQrVisible ? 'qrcode' : currentItem.isUnsigned ? 'sign-in' : (isExternal && !isMultisig) ? 'qrcode' : 'sign-in'}
|
||||
@ -243,6 +243,7 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
onClick={isQrVisible ? this.activateQrScanning : this.onSend}
|
||||
tabIndex={2}
|
||||
/>
|
||||
{!currentItem.isUnsigned && this.renderSignToggle()}
|
||||
</>
|
||||
)}
|
||||
</Modal.Actions>
|
||||
@ -250,6 +251,7 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
private renderContent (): React.ReactNode {
|
||||
const { t } = this.props;
|
||||
const { currentItem, isQrScanning, isQrVisible, isSendable, isSubmit, qrAddress, qrPayload, tip } = this.state;
|
||||
|
||||
if (!currentItem) {
|
||||
@ -266,12 +268,22 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
>
|
||||
{isQrVisible
|
||||
? (
|
||||
<Qr
|
||||
address={qrAddress}
|
||||
isScanning={isQrScanning}
|
||||
onSignature={this.addQrSignature}
|
||||
payload={qrPayload}
|
||||
/>
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<Qr
|
||||
address={qrAddress}
|
||||
isScanning={isQrScanning}
|
||||
onSignature={this.addQrSignature}
|
||||
payload={qrPayload}
|
||||
/>
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
{isQrScanning
|
||||
? <p>{t('Present the QR code containing the signature to the UI. Once scanned it will be submitted for on-chain processing and execution.')}</p>
|
||||
: <p>{t('Scan the QR code with your QR scanner. Once approved, you will be required to present the signed QR back to the UI for submission.')}</p>
|
||||
}
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
)
|
||||
: (
|
||||
<>
|
||||
@ -297,25 +309,30 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<InputAddress
|
||||
filter={who}
|
||||
help={t('The multisig signatory for this transaction.')}
|
||||
label={t('signatory')}
|
||||
onChange={this.onChangeSignatory}
|
||||
type='account'
|
||||
/>
|
||||
<Toggle
|
||||
className='tipToggle'
|
||||
label={
|
||||
multiApproval
|
||||
? t('Multisig approval with hash (not message with call)')
|
||||
: t('Multisig message with call (not approval with hash)')
|
||||
}
|
||||
onChange={this.onToggleMultiApproval}
|
||||
value={multiApproval}
|
||||
/>
|
||||
</>
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<InputAddress
|
||||
filter={who}
|
||||
help={t('The multisig signatory for this transaction.')}
|
||||
label={t('signatory')}
|
||||
onChange={this.onChangeSignatory}
|
||||
type='account'
|
||||
/>
|
||||
<Toggle
|
||||
className='tipToggle'
|
||||
label={
|
||||
multiApproval
|
||||
? t('Multisig approval with hash (not message with call)')
|
||||
: t('Multisig message with call (not approval with hash)')
|
||||
}
|
||||
onChange={this.onToggleMultiApproval}
|
||||
value={multiApproval}
|
||||
/>
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
<p>{t('The signatory is one of the allowed accounts on the multisig. The transaction could either be the call or an approval for the hash of a call.')}</p>
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
);
|
||||
}
|
||||
|
||||
@ -328,29 +345,34 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Toggle
|
||||
className='tipToggle'
|
||||
isDisabled={!!signedTx}
|
||||
label={
|
||||
showTip
|
||||
? t('Include an optional tip for faster processing')
|
||||
: t('Do not include a tip for the block author')
|
||||
}
|
||||
onChange={this.onShowTip}
|
||||
value={showTip}
|
||||
/>
|
||||
{showTip && (
|
||||
<InputBalance
|
||||
defaultValue={new BN(0)}
|
||||
help={t('Add a tip to this extrinsic, paying the block author for greater priority')}
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<Toggle
|
||||
className='tipToggle'
|
||||
isDisabled={!!signedTx}
|
||||
isZeroable
|
||||
label={t('Tip (optional)')}
|
||||
onChange={this.onChangeTip}
|
||||
label={
|
||||
showTip
|
||||
? t('Include an optional tip for faster processing')
|
||||
: t('Do not include a tip for the block author')
|
||||
}
|
||||
onChange={this.onShowTip}
|
||||
value={showTip}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
{showTip && (
|
||||
<InputBalance
|
||||
defaultValue={new BN(0)}
|
||||
help={t('Add a tip to this extrinsic, paying the block author for greater priority')}
|
||||
isDisabled={!!signedTx}
|
||||
isZeroable
|
||||
label={t('Tip (optional)')}
|
||||
onChange={this.onChangeTip}
|
||||
/>
|
||||
)}
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
<p>{t('Adding an optional tip to the transaction could allow for higher priority, especially when the chain is busy.')}</p>
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
);
|
||||
}
|
||||
|
||||
@ -383,23 +405,29 @@ class Signer extends React.PureComponent<Props, State> {
|
||||
|
||||
return (
|
||||
<>
|
||||
<br />
|
||||
<InputNumber
|
||||
isDisabled={!!signedTx}
|
||||
isZeroable
|
||||
label={t('Nonce')}
|
||||
labelExtra={t('Current account nonce: {{accountNonce}}', { replace: { accountNonce } })}
|
||||
onChange={this.onChangeNonce}
|
||||
value={accountNonce}
|
||||
/>
|
||||
<InputNumber
|
||||
isDisabled={!!signedTx}
|
||||
isZeroable
|
||||
label={t('Lifetime (# of blocks)')}
|
||||
labelExtra={t('Set to 0 to make transaction immortal')}
|
||||
onChange={this.onChangeBlocks}
|
||||
value={blocks}
|
||||
/>
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<InputNumber
|
||||
isDisabled={!!signedTx}
|
||||
isZeroable
|
||||
label={t('Nonce')}
|
||||
labelExtra={t('Current account nonce: {{accountNonce}}', { replace: { accountNonce } })}
|
||||
onChange={this.onChangeNonce}
|
||||
value={accountNonce}
|
||||
/>
|
||||
<InputNumber
|
||||
isDisabled={!!signedTx}
|
||||
isZeroable
|
||||
label={t('Lifetime (# of blocks)')}
|
||||
labelExtra={t('Set to 0 to make transaction immortal')}
|
||||
onChange={this.onChangeBlocks}
|
||||
value={blocks}
|
||||
/>
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
<p>{t('Override any applicable values for the specific signed output. These will be used to construct and display the signed transaction.')}</p>
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
{!!signedTx && (
|
||||
<Output
|
||||
label={t('Signed transaction')}
|
||||
|
||||
@ -37,43 +37,57 @@ function Transaction ({ children, className, hideDetails, isSendable, onError, t
|
||||
{!hideDetails && (
|
||||
<>
|
||||
{!isUnsigned && accountId && (
|
||||
<InputAddress
|
||||
className='full'
|
||||
defaultValue={accountId}
|
||||
isDisabled
|
||||
isInput
|
||||
label={t('sending from my account')}
|
||||
withLabel
|
||||
/>
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<InputAddress
|
||||
className='full'
|
||||
defaultValue={accountId}
|
||||
isDisabled
|
||||
isInput
|
||||
label={t('sending from my account')}
|
||||
withLabel
|
||||
/>
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
<p>{t('The sending account that will be used to send this transaction. Any applicable fees will be paid by this account.')}</p>
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
)}
|
||||
<Expander
|
||||
className='tx-details'
|
||||
summary={
|
||||
<>
|
||||
{t('Sending transaction')} <span className='highlight'>{section}.{method}({
|
||||
meta?.args.map(({ name }) => name).join(', ') || ''
|
||||
})</span>
|
||||
</>
|
||||
}
|
||||
summaryMeta={meta}
|
||||
>
|
||||
<Call
|
||||
onError={onError}
|
||||
value={extrinsic}
|
||||
withBorder={false}
|
||||
/>
|
||||
</Expander>
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<Expander
|
||||
className='tx-details'
|
||||
summary={
|
||||
<>
|
||||
{t('Sending transaction')} <span className='highlight'>{section}.{method}({
|
||||
meta?.args.map(({ name }) => name).join(', ') || ''
|
||||
})</span>
|
||||
</>
|
||||
}
|
||||
summaryMeta={meta}
|
||||
>
|
||||
<Call
|
||||
onError={onError}
|
||||
value={extrinsic}
|
||||
withBorder={false}
|
||||
/>
|
||||
</Expander>
|
||||
{!isUnsigned && (
|
||||
<Checks
|
||||
accountId={accountId}
|
||||
className='tx-details'
|
||||
extrinsic={extrinsic}
|
||||
isSendable={isSendable}
|
||||
tip={tip}
|
||||
/>
|
||||
)}
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
<p>{t('The details of the transaction including the type, the description (as available from the chain metadata) as well as any parameters and fee estimations (as available) for the specific type of call.')}</p>
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
</>
|
||||
)}
|
||||
{!hideDetails && !isUnsigned && (
|
||||
<Checks
|
||||
accountId={accountId}
|
||||
className='tx-details'
|
||||
extrinsic={extrinsic}
|
||||
isSendable={isSendable}
|
||||
tip={tip}
|
||||
/>
|
||||
)}
|
||||
{children}
|
||||
</Modal.Content>
|
||||
);
|
||||
|
||||
@ -6,7 +6,7 @@ import { KeyringPair } from '@polkadot/keyring/types';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { Password } from '@polkadot/react-components';
|
||||
import { Modal, Password } from '@polkadot/react-components';
|
||||
import keyring from '@polkadot/ui-keyring';
|
||||
|
||||
import { useTranslation } from './translate';
|
||||
@ -43,16 +43,23 @@ function Unlock ({ className, error, onChange, onEnter, password, tabIndex, valu
|
||||
|
||||
return (
|
||||
<div className={`ui--signer-Signer-Unlock ${className}`}>
|
||||
<Password
|
||||
autoFocus
|
||||
isError={!!error}
|
||||
label={t('unlock account with password')}
|
||||
labelExtra={error && <div className='errorLabel'>{t('wrong password supplied')}</div>}
|
||||
onChange={onChange}
|
||||
onEnter={onEnter}
|
||||
tabIndex={tabIndex}
|
||||
value={password}
|
||||
/>
|
||||
<Modal.Columns>
|
||||
<Modal.Column>
|
||||
<Password
|
||||
autoFocus
|
||||
isError={!!error}
|
||||
label={t('unlock account with password')}
|
||||
labelExtra={error && <div className='errorLabel'>{t('wrong password supplied')}</div>}
|
||||
onChange={onChange}
|
||||
onEnter={onEnter}
|
||||
tabIndex={tabIndex}
|
||||
value={password}
|
||||
/>
|
||||
</Modal.Column>
|
||||
<Modal.Column>
|
||||
<p>{t('Unlock the sending account to allow signing of this transaction.')}</p>
|
||||
</Modal.Column>
|
||||
</Modal.Columns>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@ -69,6 +69,6 @@ export default React.memo(styled(Signer)`
|
||||
|
||||
.signToggle {
|
||||
position: absolute;
|
||||
left: 1rem;
|
||||
left: 1.5rem;
|
||||
}
|
||||
`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user