From 21c3e5c900c266b99163fc40a5dd826585a47eed Mon Sep 17 00:00:00 2001 From: Richard Dominick Date: Sun, 14 Aug 2022 16:32:07 +0800 Subject: [PATCH 1/8] Switch 'secret' field to use InputGroup element Uses the alternative implementation of creating input groups as specified by docs: https://blueprintjs.com/docs/#core/components/text-inputs.input-group --- .../RemoteExecutionDeviceDialog.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx b/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx index b90944d1cc..dc991b657e 100644 --- a/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx +++ b/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx @@ -1,4 +1,12 @@ -import { Button, Callout, Classes, Dialog, FormGroup, HTMLSelect } from '@blueprintjs/core'; +import { + Button, + Callout, + Classes, + Dialog, + FormGroup, + HTMLSelect, + InputGroup +} from '@blueprintjs/core'; import classNames from 'classnames'; import React from 'react'; import { useDispatch } from 'react-redux'; @@ -113,15 +121,11 @@ export default function RemoteExecutionDeviceDialog({ - Date: Sun, 14 Aug 2022 21:58:52 +0800 Subject: [PATCH 2/8] Add react-qr-reader dependency --- package.json | 1 + yarn.lock | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/package.json b/package.json index ffff97f925..1634b506b5 100644 --- a/package.json +++ b/package.json @@ -63,6 +63,7 @@ "react-latex-next": "^2.1.0", "react-mde": "^11.5.0", "react-papaparse": "^4.0.2", + "react-qr-reader": "^3.0.0-beta-1", "react-redux": "^8.0.2", "react-responsive": "^9.0.0-beta.10", "react-router-dom": "^5.3.0", diff --git a/yarn.lock b/yarn.lock index f8f68906ea..15118a7a3b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2761,6 +2761,27 @@ resolved "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== +"@zxing/browser@0.0.7": + version "0.0.7" + resolved "https://registry.yarnpkg.com/@zxing/browser/-/browser-0.0.7.tgz#5fa7680a867b660f48d3288fdf63e0174ad531c7" + integrity sha512-AepzMgDnD6EjxewqmXpHJsi4S3Gw9ilZJLIbTf6fWuWySEcHBodnGu3p7FWlgq1Sd5QyfPhTum5z3CBkkhMVng== + optionalDependencies: + "@zxing/text-encoding" "^0.9.0" + +"@zxing/library@^0.18.3": + version "0.18.6" + resolved "https://registry.yarnpkg.com/@zxing/library/-/library-0.18.6.tgz#717af8c6c1fd982865e21051afdd7b470ae6674c" + integrity sha512-bulZ9JHoLFd9W36pi+7e7DnEYNJhljYjZ1UTsKPOoLMU3qtC+REHITeCRNx40zTRJZx18W5TBRXt5pq2Uopjsw== + dependencies: + ts-custom-error "^3.0.0" + optionalDependencies: + "@zxing/text-encoding" "~0.9.0" + +"@zxing/text-encoding@^0.9.0", "@zxing/text-encoding@~0.9.0": + version "0.9.0" + resolved "https://registry.yarnpkg.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz#fb50ffabc6c7c66a0c96b4c03e3d9be74864b70b" + integrity sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA== + abab@^2.0.3, abab@^2.0.5: version "2.0.5" resolved "https://registry.npmjs.org/abab/-/abab-2.0.5.tgz" @@ -11304,6 +11325,15 @@ react-popper@^2.2.4: react-fast-compare "^3.0.1" warning "^4.0.2" +react-qr-reader@^3.0.0-beta-1: + version "3.0.0-beta-1" + resolved "https://registry.yarnpkg.com/react-qr-reader/-/react-qr-reader-3.0.0-beta-1.tgz#e04a20876409313439959d8e0ea6df3ba6e36d68" + integrity sha512-5HeFH9x/BlziRYQYGK2AeWS9WiKYZtGGMs9DXy3bcySTX3C9UJL9EwcPnWw8vlf7JP4FcrAlr1SnZ5nsWLQGyw== + dependencies: + "@zxing/browser" "0.0.7" + "@zxing/library" "^0.18.3" + rollup "^2.67.2" + react-reconciler@~0.26.2: version "0.26.2" resolved "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.26.2.tgz" @@ -12005,6 +12035,13 @@ rollup@^1.31.1: "@types/node" "*" acorn "^7.1.0" +rollup@^2.67.2: + version "2.78.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.78.0.tgz#00995deae70c0f712ea79ad904d5f6b033209d9e" + integrity sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg== + optionalDependencies: + fsevents "~2.3.2" + rst-selector-parser@^2.2.3: version "2.2.3" resolved "https://registry.npmjs.org/rst-selector-parser/-/rst-selector-parser-2.2.3.tgz" @@ -13281,6 +13318,11 @@ tryer@^1.0.1: resolved "https://registry.npmjs.org/tryer/-/tryer-1.0.1.tgz" integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA== +ts-custom-error@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/ts-custom-error/-/ts-custom-error-3.2.0.tgz#ff8f80a3812bab9dc448536312da52dce1b720fb" + integrity sha512-cBvC2QjtvJ9JfWLvstVnI45Y46Y5dMxIaG1TDMGAD/R87hpvqFL+7LhvUDhnRCfOnx/xitollFWWvUKKKhbN0A== + ts-node@^10.4.0: version "10.4.0" resolved "https://registry.npmjs.org/ts-node/-/ts-node-10.4.0.tgz" From df6a0df71958d1a4f7992f146d226caefa5e2d56 Mon Sep 17 00:00:00 2001 From: Richard Dominick Date: Sun, 14 Aug 2022 22:33:33 +0800 Subject: [PATCH 3/8] Add ability to paste secret from QR code --- .../RemoteExecutionDeviceDialog.tsx | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx b/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx index dc991b657e..2442579f46 100644 --- a/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx +++ b/src/features/remoteExecution/RemoteExecutionDeviceDialog.tsx @@ -7,8 +7,10 @@ import { HTMLSelect, InputGroup } from '@blueprintjs/core'; +import { Tooltip2 } from '@blueprintjs/popover2'; import classNames from 'classnames'; import React from 'react'; +import { QrReader } from 'react-qr-reader'; import { useDispatch } from 'react-redux'; import { editDevice, registerDevice } from '../../commons/sagas/RequestsSaga'; @@ -39,6 +41,7 @@ export default function RemoteExecutionDeviceDialog({ const [isSubmitting, setIsSubmitting] = React.useState(false); const [errorMessage, setErrorMessage] = React.useState(); + const [showScanner, setShowScanner] = React.useState(false); const onSubmit = async () => { const fields = collectFieldValues(nameField, typeField, secretField); @@ -67,6 +70,12 @@ export default function RemoteExecutionDeviceDialog({ setIsSubmitting(false); }; + const scanButton = ( + +