Repository: polkadot-js/extension
Pull request #586 (2020-12-14 09:52:11)

Hide parent password/path when non-deriving
Closes https://github.com/polkadot-js/extension/issues/583


Patch:
diff --git a/package.json b/package.json
index 67a9fa87..3a47c051 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
   "repository": "https://github.com/polkadot-js/extension",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "private": true,
   "workspaces": [
     "packages/*"
@@ -20,9 +20,10 @@
   },
   "scripts": {
     "build": "polkadot-dev-build-ts && yarn build:zip",
-    "build:extra": "yarn build:i18n && (cd packages/extension && yarn webpack --config webpack.extension.js)",
+    "build:extra": "yarn build:i18n && yarn build:ui",
     "build:i18n": "i18next-scanner --config i18next-scanner.config.js",
     "build:release": "polkadot-ci-ghact-build",
+    "build:ui": "cd packages/extension && yarn webpack --config webpack.extension.js --mode production",
     "build:zip": "yarn build:zip:dst && yarn build:zip:src",
     "build:zip:dst": "rm -rf ./master-build.zip && cd packages/extension/build && zip -r -FS ../../../master-build.zip .",
     "build:zip:src": "rm -rf ./master-src.zip && zip -r -x '*build/*' -x '*node_modules*' -FS ./master-src.zip packages .babelrc.js .editorconfig .eslintignore .eslintrc.js babel.config.js CHANGELOG.md CONTRIBUTING.md i18next-scanner.config.js jest.config.js lerna.json LICENSE package.json README.md tsconfig.json yarn.lock",
@@ -32,7 +33,7 @@
     "postinstall": "polkadot-dev-yarn-only",
     "start": "yarn watch",
     "test": "polkadot-dev-run-test",
-    "watch": "cd packages/extension && yarn polkadot-exec-webpack --config webpack.config.js --watch"
+    "watch": "cd packages/extension && yarn polkadot-exec-webpack --config webpack.watch.js --mode development --watch"
   },
   "devDependencies": {
     "@babel/core": "^7.12.10",
diff --git a/packages/extension-base/package.json b/packages/extension-base/package.json
index 123b6f5e..a80b4ba3 100644
--- a/packages/extension-base/package.json
+++ b/packages/extension-base/package.json
@@ -1,7 +1,7 @@
 {
   "name": "@polkadot/extension-base",
   "description": "Functions, classes and other utilities used in @polkadot/extension",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
   "main": "index.js",
@@ -9,7 +9,7 @@
   "dependencies": {
     "@babel/runtime": "^7.12.5",
     "@polkadot/api": "^3.0.1",
-    "@polkadot/extension-inject": "^0.35.2-10",
+    "@polkadot/extension-inject": "^0.35.2-11",
     "@polkadot/keyring": "^5.0.1",
     "@polkadot/phishing": "^0.3.1",
     "@polkadot/ui-keyring": "^0.62.2-28"
diff --git a/packages/extension-chains/package.json b/packages/extension-chains/package.json
index e41a1f1f..99ccf987 100644
--- a/packages/extension-chains/package.json
+++ b/packages/extension-chains/package.json
@@ -1,7 +1,7 @@
 {
   "name": "@polkadot/extension-chains",
   "description": "Definitions for all known chains as exposed by the extension.",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
   "main": "index.js",
diff --git a/packages/extension-dapp/package.json b/packages/extension-dapp/package.json
index 0dc72cff..5ebea53b 100644
--- a/packages/extension-dapp/package.json
+++ b/packages/extension-dapp/package.json
@@ -1,14 +1,14 @@
 {
   "name": "@polkadot/extension-dapp",
   "description": "Provides an interfaces around the injected globals for ease of access by dapp developers.",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
   "main": "index.js",
   "sideEffects": false,
   "dependencies": {
     "@babel/runtime": "^7.12.5",
-    "@polkadot/extension-inject": "^0.35.2-10",
+    "@polkadot/extension-inject": "^0.35.2-11",
     "@polkadot/util": "^5.0.1",
     "@polkadot/util-crypto": "^5.0.1"
   },
diff --git a/packages/extension-inject/package.json b/packages/extension-inject/package.json
index 67584494..b1fdee71 100644
--- a/packages/extension-inject/package.json
+++ b/packages/extension-inject/package.json
@@ -1,7 +1,7 @@
 {
   "name": "@polkadot/extension-inject",
   "description": "A generic injector (usable to any extension), that populates the base exposed interfaces to be used by dapps.",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
   "main": "index.js",
diff --git a/packages/extension-ui/package.json b/packages/extension-ui/package.json
index 94c44fe1..cd229bdf 100644
--- a/packages/extension-ui/package.json
+++ b/packages/extension-ui/package.json
@@ -1,7 +1,7 @@
 {
   "name": "@polkadot/extension-ui",
   "description": "A sample signer extension for the @polkadot/api",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
   "dependencies": {
@@ -10,8 +10,8 @@
     "@fortawesome/free-regular-svg-icons": "^5.15.1",
     "@fortawesome/free-solid-svg-icons": "^5.15.1",
     "@fortawesome/react-fontawesome": "^0.1.13",
-    "@polkadot/extension-base": "^0.35.2-10",
-    "@polkadot/extension-inject": "^0.35.2-10",
+    "@polkadot/extension-base": "^0.35.2-11",
+    "@polkadot/extension-inject": "^0.35.2-11",
     "@polkadot/keyring": "^5.0.1",
     "@polkadot/react-identicon": "^0.62.2-28",
     "@polkadot/react-qr": "^0.62.2-28",
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
               </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>
+                  )}
+                </>
               )}
             </>
           )}
diff --git a/packages/extension/package.json b/packages/extension/package.json
index 908f9fc7..7e88800f 100644
--- a/packages/extension/package.json
+++ b/packages/extension/package.json
@@ -1,14 +1,14 @@
 {
   "name": "@polkadot/extension",
   "description": "A sample signer extension for the @polkadot/api",
-  "version": "0.35.2-10",
+  "version": "0.35.2-11",
   "author": "Jaco Greeff <jacogr@gmail.com>",
   "license": "Apache-2",
   "dependencies": {
     "@babel/runtime": "^7.12.5",
-    "@polkadot/extension-base": "^0.35.2-10",
-    "@polkadot/extension-inject": "^0.35.2-10",
-    "@polkadot/extension-ui": "^0.35.2-10"
+    "@polkadot/extension-base": "^0.35.2-11",
+    "@polkadot/extension-inject": "^0.35.2-11",
+    "@polkadot/extension-ui": "^0.35.2-11"
   },
   "devDependencies": {
     "@polkadot/dev": "^0.61.2",
diff --git a/packages/extension/webpack.shared.js b/packages/extension/webpack.shared.js
index 38c7d25a..5fbe02f3 100644
--- a/packages/extension/webpack.shared.js
+++ b/packages/extension/webpack.shared.js
@@ -22,7 +22,6 @@ module.exports = (entry, alias = {}) => ({
   context: __dirname,
   devtool: false,
   entry,
-  mode: 'production',
   module: {
     rules: [
       {
diff --git a/packages/extension/webpack.watch.js b/packages/extension/webpack.watch.js
new file mode 100644
index 00000000..19218e29
--- /dev/null
+++ b/packages/extension/webpack.watch.js
@@ -0,0 +1,11 @@
+// Copyright 2019-2020 @polkadot/extension authors & contributors
+// SPDX-License-Identifier: Apache-2.0
+
+const createConfig = require('./webpack.shared.js');
+
+module.exports = createConfig({
+  background: './src/background.ts',
+  content: './src/content.ts',
+  extension: './src/extension.ts',
+  page: './src/page.ts'
+});
diff --git a/yarn.lock b/yarn.lock
index 32911c6e..9ae28e17 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1969,13 +1969,13 @@ __metadata:
   languageName: node
   linkType: hard
 
-"@polkadot/extension-base@^0.35.2-10, @polkadot/extension-base@workspace:packages/extension-base":
+"@polkadot/extension-base@^0.35.2-11, @polkadot/extension-base@workspace:packages/extension-base":
   version: 0.0.0-use.local
   resolution: "@polkadot/extension-base@workspace:packages/extension-base"
   dependencies:
     "@babel/runtime": ^7.12.5
     "@polkadot/api": ^3.0.1
-    "@polkadot/extension-inject": ^0.35.2-10
+    "@polkadot/extension-inject": ^0.35.2-11
     "@polkadot/keyring": ^5.0.1
     "@polkadot/phishing": ^0.3.1
     "@polkadot/ui-keyring": ^0.62.2-28
@@ -1998,7 +1998,7 @@ __metadata:
   resolution: "@polkadot/extension-dapp@workspace:packages/extension-dapp"
   dependencies:
     "@babel/runtime": ^7.12.5
-    "@polkadot/extension-inject": ^0.35.2-10
+    "@polkadot/extension-inject": ^0.35.2-11
     "@polkadot/util": ^5.0.1
     "@polkadot/util-crypto": ^5.0.1
   peerDependencies:
@@ -2006,7 +2006,7 @@ __metadata:
   languageName: unknown
   linkType: soft
 
-"@polkadot/extension-inject@^0.35.2-10, @polkadot/extension-inject@workspace:packages/extension-inject":
+"@polkadot/extension-inject@^0.35.2-11, @polkadot/extension-inject@workspace:packages/extension-inject":
   version: 0.0.0-use.local
   resolution: "@polkadot/extension-inject@workspace:packages/extension-inject"
   dependencies:
@@ -2018,7 +2018,7 @@ __metadata:
   languageName: unknown
   linkType: soft
 
-"@polkadot/extension-ui@^0.35.2-10, @polkadot/extension-ui@workspace:packages/extension-ui":
+"@polkadot/extension-ui@^0.35.2-11, @polkadot/extension-ui@workspace:packages/extension-ui":
   version: 0.0.0-use.local
   resolution: "@polkadot/extension-ui@workspace:packages/extension-ui"
   dependencies:
@@ -2027,8 +2027,8 @@ __metadata:
     "@fortawesome/free-regular-svg-icons": ^5.15.1
     "@fortawesome/free-solid-svg-icons": ^5.15.1
     "@fortawesome/react-fontawesome": ^0.1.13
-    "@polkadot/extension-base": ^0.35.2-10
-    "@polkadot/extension-inject": ^0.35.2-10
+    "@polkadot/extension-base": ^0.35.2-11
+    "@polkadot/extension-inject": ^0.35.2-11
     "@polkadot/keyring": ^5.0.1
     "@polkadot/react-identicon": ^0.62.2-28
     "@polkadot/react-qr": ^0.62.2-28
@@ -2065,9 +2065,9 @@ __metadata:
   dependencies:
     "@babel/runtime": ^7.12.5
     "@polkadot/dev": ^0.61.2
-    "@polkadot/extension-base": ^0.35.2-10
-    "@polkadot/extension-inject": ^0.35.2-10
-    "@polkadot/extension-ui": ^0.35.2-10
+    "@polkadot/extension-base": ^0.35.2-11
+    "@polkadot/extension-inject": ^0.35.2-11
+    "@polkadot/extension-ui": ^0.35.2-11
     babel-loader: ^8.2.2
     browser-resolve: ^2.0.0
     buffer: ^6.0.3


Test patch:
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');