From ff4209455ef0b455dae2ac0c30a5b9b9942b010b Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 14 Dec 2020 12:18:39 +0100 Subject: [PATCH] Hide parent password/path when non-deriving (#586) * Hide parent password/path when non-deriving * add test Co-authored-by: Github Actions --- .../src/Popup/Derive/Derive.test.tsx | 6 ++ .../src/Popup/Derive/SelectParent.tsx | 72 ++++++++++--------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/packages/extension-ui/src/Popup/Derive/Derive.test.tsx b/packages/extension-ui/src/Popup/Derive/Derive.test.tsx index ef0625d0..55a44f40 100644 --- a/packages/extension-ui/src/Popup/Derive/Derive.test.tsx +++ b/packages/extension-ui/src/Popup/Derive/Derive.test.tsx @@ -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'); diff --git a/packages/extension-ui/src/Popup/Derive/SelectParent.tsx b/packages/extension-ui/src/Popup/Derive/SelectParent.tsx index c312a8a8..f87e7055 100644 --- a/packages/extension-ui/src/Popup/Derive/SelectParent.tsx +++ b/packages/extension-ui/src/Popup/Derive/SelectParent.tsx @@ -123,41 +123,45 @@ function SelectParent ({ className, isLocked, onDerivationConfirmed, parentAddre ) } -
- ('enter the password for the account you want to derive from')} - onChange={_onParentPasswordEnter} - type='password' - value={parentPassword} - /> - {!!parentPassword && !isProperParentPassword && ( - - {t('Wrong password')} - - )} -
- {isProperParentPassword && ( + {shouldAccountBeDerived && ( <> - - {!suriPath && ( - - {t('Incorrect derivation path')} - +
+ ('enter the password for the account you want to derive from')} + onChange={_onParentPasswordEnter} + type='password' + value={parentPassword} + /> + {!!parentPassword && !isProperParentPassword && ( + + {t('Wrong password')} + + )} +
+ {isProperParentPassword && ( + <> + + {!suriPath && ( + + {t('Incorrect derivation path')} + + )} + )} )}