Hide parent password/path when non-deriving (#586)

* Hide parent password/path when non-deriving

* add test

Co-authored-by: Github Actions <action@github.com>
This commit is contained in:
Jaco Greeff 2020-12-14 12:18:39 +01:00 committed by GitHub
parent db1eb0b3b8
commit ff4209455e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 34 deletions

View File

@ -103,6 +103,12 @@ describe('Derive', () => {
expect(wrapper.exists('[data-button-action="create derived account"]')).toBe(false);
});
it('Password entry is hidden after checkbox is unchecked', () => {
uncheck(wrapper.find('input[type="checkbox"]'));
expect(wrapper.exists('input[type="password"]')).toBe(false);
});
it('"Create new root" button redirects to /account/create', () => {
uncheck(wrapper.find('input[type="checkbox"]'));
wrapper.find('[data-button-action="create root account"] button').simulate('click');

View File

@ -123,41 +123,45 @@ function SelectParent ({ className, isLocked, onDerivationConfirmed, parentAddre
</Label>
)
}
<div ref={passwordInputRef}>
<InputWithLabel
data-export-password
isError={!isProperParentPassword}
isFocused
label={t<string>('enter the password for the account you want to derive from')}
onChange={_onParentPasswordEnter}
type='password'
value={parentPassword}
/>
{!!parentPassword && !isProperParentPassword && (
<Warning
isBelowInput
isDanger
>
{t('Wrong password')}
</Warning>
)}
</div>
{isProperParentPassword && (
{shouldAccountBeDerived && (
<>
<DerivationPath
defaultPath={defaultPath}
isError={!suriPath}
onChange={setSuriPath}
parentAddress={parentAddress}
parentPassword={parentPassword}
/>
{!suriPath && (
<Warning
isBelowInput
isDanger
>
{t('Incorrect derivation path')}
</Warning>
<div ref={passwordInputRef}>
<InputWithLabel
data-export-password
isError={!isProperParentPassword}
isFocused
label={t<string>('enter the password for the account you want to derive from')}
onChange={_onParentPasswordEnter}
type='password'
value={parentPassword}
/>
{!!parentPassword && !isProperParentPassword && (
<Warning
isBelowInput
isDanger
>
{t('Wrong password')}
</Warning>
)}
</div>
{isProperParentPassword && (
<>
<DerivationPath
defaultPath={defaultPath}
isError={!suriPath}
onChange={setSuriPath}
parentAddress={parentAddress}
parentPassword={parentPassword}
/>
{!suriPath && (
<Warning
isBelowInput
isDanger
>
{t('Incorrect derivation path')}
</Warning>
)}
</>
)}
</>
)}