Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/app-accounts/src/modals/Transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ function Transfer ({ className, onClose, recipientId: propRecipientId, senderId:
type='allPlus'
/>
<InputBalance
autoFocus
help={t('Type the amount you want to transfer. Note that you can select the unit on the right e.g sending 1 milli is equivalent to sending 0.001.')}
isError={!hasAvailable}
isZeroable
label={t('amount')}
maxValue={maxBalance}
onChange={setAmount}
Expand Down
6 changes: 5 additions & 1 deletion packages/react-components/src/Password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ interface Props extends BareProps {
help?: string;
isDisabled?: boolean;
isError?: boolean;
isFull?: boolean;
label?: string;
labelExtra?: React.ReactNode;
name?: string;
onChange: (value: string) => void;
onEnter?: () => void;
Expand All @@ -28,7 +30,7 @@ interface Props extends BareProps {
withLabel?: boolean;
}

export default function Password ({ autoFocus, children, className, defaultValue, help, isDisabled, isError, label, name, onChange, onEnter, onEscape, style, tabIndex, value, withLabel }: Props): React.ReactElement<Props> {
export default function Password ({ autoFocus, children, className, defaultValue, help, isDisabled, isError, isFull, label, labelExtra, name, onChange, onEnter, onEscape, style, tabIndex, value, withLabel }: Props): React.ReactElement<Props> {
const [isVisible, setIsVisible] = useState(false);

const _toggleVisible = (): void => setIsVisible(!isVisible);
Expand All @@ -42,7 +44,9 @@ export default function Password ({ autoFocus, children, className, defaultValue
isAction
isDisabled={isDisabled}
isError={isError}
isFull={isFull}
label={label}
labelExtra={labelExtra}
maxLength={MAX_PASS_LEN}
name={name}
onChange={onChange}
Expand Down
23 changes: 9 additions & 14 deletions packages/react-signer/src/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { assert, isFunction } from '@polkadot/util';
import { format } from '@polkadot/util/logger';

import ledgerSigner from './LedgerSigner';
import PasswordCheck from './PasswordCheck';
import Transaction from './Transaction';
import Qr from './Qr';
import Unlock from './Unlock';
Expand Down Expand Up @@ -320,19 +319,15 @@ class Signer extends React.PureComponent<Props, State> {
}

return (
<>
<Unlock
autoFocus
error={unlockError || undefined}
onChange={this.onChangePassword}
password={password}
value={currentItem.accountId}
tabIndex={1}
/>
<PasswordCheck
unlockError={unlockError}
/>
</>
<Unlock
autoFocus
error={unlockError || undefined}
onChange={this.onChangePassword}
onEnter={this.onSend}
password={password}
value={currentItem.accountId}
tabIndex={1}
/>
);
}

Expand Down
26 changes: 0 additions & 26 deletions packages/react-signer/src/PasswordCheck.tsx

This file was deleted.

15 changes: 13 additions & 2 deletions packages/react-signer/src/Unlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
import { KeyringPair } from '@polkadot/keyring/types';

import React, { useState } from 'react';
import styled from 'styled-components';
import { Password } from '@polkadot/react-components';
import keyring from '@polkadot/ui-keyring';

import { useTranslation } from './translate';

interface Props {
autoFocus?: boolean;
className?: string;
error?: string;
onChange: (password: string) => void;
onEnter?: () => void;
Expand All @@ -28,7 +30,7 @@ function getPair (address?: string | null): KeyringPair | null {
}
}

export default function Unlock ({ autoFocus, error, onChange, onEnter, password, tabIndex, value }: Props): React.ReactElement<Props> | null {
function Unlock ({ autoFocus, className, error, onChange, onEnter, password, tabIndex, value }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const [pair] = useState<KeyringPair | null>(getPair(value));

Expand All @@ -37,11 +39,13 @@ export default function Unlock ({ autoFocus, error, onChange, onEnter, password,
}

return (
<div className='ui--signer-Signer-Unlock'>
<div className={`ui--signer-Signer-Unlock ${className}`}>
<Password
autoFocus={autoFocus}
isError={!!error}
isFull
label={t('unlock account with password')}
labelExtra={error && <div className='errorLabel'>{t('wrong password supplied')}</div>}
onChange={onChange}
onEnter={onEnter}
tabIndex={tabIndex}
Expand All @@ -50,3 +54,10 @@ export default function Unlock ({ autoFocus, error, onChange, onEnter, password,
</div>
);
}

export default styled(Unlock)`
.errorLabel {
margin-right: 2rem;
color: #9f3a38 !important;
}
`;