on master help sign in
refactor: clean up all of the blinky tests
commite7c1371558e02522e5c89d8b5d99bc21d01d914d authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateTue 16 Jul 2019, 21:57 (7 years ago) parent764521d
6 files changed+29−33
src/components/Blinky.js+2 src/components/Buttons.js+6−5 src/components/DownloadKeyfileButton.js+4−3 src/components/InlineEthereumTransaction.js+13−21 src/views/Activate/ActivateCode.js+2−2 src/views/Admin/Reticket/ReticketConfirm.js+2−2
src/components/Blinky.js+2
@@ -26,6 +26,8 @@ export const matchBlinkyDate = obj =>
2626 Just: p => formatDots(p.value),
2727 });
2828
29+export const blinkIf = (test, right) => (test ? <Blinky /> : right);
30+
2931export default function Blinky({
3032 a = LOADING_CHARACTER,
3133 b = INTERSTITIAL_CHARACTER,
src/components/Buttons.js+6−5
@@ -1,17 +1,18 @@
11import React from 'react';
22import { Button } from 'indigo-react';
3−import Blinky from './Blinky';
3+
4+import { blinkIf } from './Blinky';
45
56// NOTE: the -> is correct because inter recognizes the pair
67export const ForwardButton = ({ loading, ...props }) => (
7− <Button accessory={loading ? <Blinky /> : '->'} {...props} />
8+ <Button accessory={blinkIf(loading, '->')} {...props} />
89);
910export const DownloadButton = ({ loading, ...props }) => (
10− <Button accessory={loading ? <Blinky /> : '↓'} {...props} />
11+ <Button accessory={blinkIf(loading, '↓')} {...props} />
1112);
1213export const RestartButton = props => <Button accessory="↺" {...props} />;
13−export const GenerateButton = props => (
14− <Button accessory="○" solid {...props} />
14+export const GenerateButton = ({ loading, ...props }) => (
15+ <Button accessory={blinkIf(loading, '○')} solid {...props} />
1516);
1617export const OutButton = props => (
1718 <Button as="a" target="_blank" accessory="↗" {...props} />
src/components/DownloadKeyfileButton.js+4−3
@@ -21,15 +21,16 @@ export default function DownloadKeyfileButton({
2121 networkSeed
2222 );
2323
24+ const showHelp = !generating && !available;
25+
2426 return (
2527 <DownloadButton
2628 as="span"
2729 className={className}
2830 disabled={downloaded || !available}
2931 disabledDetail={
30− !generating &&
31− !available && (
32− // TODO: make this a toggle-able 'help' or something
32+ // TODO: make this a toggle-able 'help' or something — too much space
33+ showHelp && (
3334 <Flex col>
3435 <Flex.Item as={B} className="wrap ws-normal">
3536 · You are using nondeterministic networking keys. To download your
src/components/InlineEthereumTransaction.js+13−21
@@ -10,12 +10,13 @@ import {
1010 Text,
1111 HelpText,
1212} from 'indigo-react';
13−import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
13+
1414import { useCheckboxInput } from 'lib/useInputs';
15−import Blinky from './Blinky';
1615import { hexify } from 'lib/txn';
1716import { useExploreTxUrl } from 'lib/explorer';
1817
18+import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
19+
1920export default function InlineEthereumTransaction({
2021 // from useEthereumTransaction.bind
2122 initializing,
@@ -42,10 +43,10 @@ export default function InlineEthereumTransaction({
4243 const showReceipt = broadcasted || confirmed;
4344 // show configure controls pre-broadcast
4445 const showConfigureInput = !(signed || broadcasted || confirmed);
45− // show signed tx after signing
46+ // show signed tx only when signing (for offline usage)
4647 const showSignedTx = signed;
4748
48− const exploreHashUrl = useExploreTxUrl(txHash);
49+ const exploreTxUrl = useExploreTxUrl(txHash);
4950 const [advancedInput, { data: advancedOpen }] = useCheckboxInput({
5051 name: 'advanced',
5152 label: 'Advanced Configuration',
@@ -63,7 +64,7 @@ export default function InlineEthereumTransaction({
6364 disabled: !showSignedTx,
6465 });
6566
66− const renderButton = () => {
67+ const renderPrimaryButton = () => {
6768 if (error) {
6869 return (
6970 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
@@ -79,25 +80,15 @@ export default function InlineEthereumTransaction({
7980 </Grid.Item>
8081 </>
8182 );
82− } else if (broadcasted) {
83− return (
84− <Grid.Item
85− full
86− as={ForwardButton}
87− solid
88− success
89− disabled
90− accessory={<Blinky />}>
91− Sending Transaction...
92− </Grid.Item>
93− );
94− } else if (signed) {
83+ } else if (signed || broadcasted) {
9584 return (
9685 <Grid.Item
9786 full
9887 as={ForwardButton}
9988 solid
10089 success
90+ disable={broadcasted}
91+ loading={broadcasted}
10192 onClick={() => broadcast()}>
10293 Send Transaction
10394 </Grid.Item>
@@ -109,7 +100,7 @@ export default function InlineEthereumTransaction({
109100 as={GenerateButton}
110101 onClick={generateAndSign}
111102 disabled={!canSign}
112− accessory={!canSign && initializing ? <Blinky /> : undefined}>
103+ loading={!canSign && initializing}>
113104 Generate & Sign Transaction
114105 </Grid.Item>
115106 );
@@ -118,7 +109,7 @@ export default function InlineEthereumTransaction({
118109
119110 return (
120111 <Grid className={cn(className, 'mt1')}>
121− {renderButton()}
112+ {renderPrimaryButton()}
122113
123114 {error && (
124115 <Grid.Item full as={ErrorText} className="mt1">
@@ -136,6 +127,7 @@ export default function InlineEthereumTransaction({
136127 <Flex.Item as={H5}>Gas Price</Flex.Item>
137128 <Flex.Item as={H5}>{gasPrice} Gwei</Flex.Item>
138129 </Grid.Item>
130+ {/* TODO(shrugs): move to indigo/RangeInput */}
139131 <Grid.Item
140132 full
141133 as="input"
@@ -182,7 +174,7 @@ export default function InlineEthereumTransaction({
182174 <Grid.Item full as={Flex} col className="pv4">
183175 <Flex.Item as={Flex} row justify="between">
184176 <Flex.Item as={H5}>Transaction Hash</Flex.Item>
185− <Flex.Item as={LinkButton} href={exploreHashUrl}>
177+ <Flex.Item as={LinkButton} href={exploreTxUrl}>
186178 Etherscan↗
187179 </Flex.Item>
188180 </Flex.Item>
src/views/Activate/ActivateCode.js+2−2
@@ -14,7 +14,7 @@ import * as need from 'lib/need';
1414import { ROUTE_NAMES } from 'lib/routeNames';
1515import { useSyncKnownPoints } from 'lib/useSyncPoints';
1616import FooterButton from 'components/FooterButton';
17−import Blinky from 'components/Blinky';
17+import { blinkIf } from 'components/Blinky';
1818import { DEFAULT_HD_PATH, walletFromMnemonic } from 'lib/wallet';
1919import { useNetwork } from 'store/network';
2020import { generateWallet } from 'lib/invite';
@@ -138,7 +138,7 @@ export default function ActivateCode() {
138138 as={ForwardButton}
139139 className="mt4"
140140 disabled={!pass || deriving}
141− accessory={deriving ? <Blinky /> : undefined}
141+ accessory={blinkIf(deriving)}
142142 onClick={goToPassport}
143143 solid
144144 full>
src/views/Admin/Reticket/ReticketConfirm.js+2−2
@@ -13,7 +13,7 @@ import { isDevelopment } from 'lib/flags';
1313import { ForwardButton } from 'components/Buttons';
1414import PaperRenderer from 'components/PaperRenderer';
1515import WarningBox from 'components/WarningBox';
16−import Blinky from 'components/Blinky';
16+import { blinkIf } from 'components/Blinky';
1717import useCurrentPointName from 'lib/useCurrentPointName';
1818
1919export default function ReticketConfirm({ newWallet, setNewWallet }) {
@@ -79,7 +79,7 @@ export default function ReticketConfirm({ newWallet, setNewWallet }) {
7979 full
8080 as={ForwardButton}
8181 solid
82− accessory={Nothing.hasInstance(newWallet) ? <Blinky /> : undefined}
82+ accessory={blinkIf(Nothing.hasInstance(newWallet))}
8383 disabled={Nothing.hasInstance(newWallet)}
8484 onClick={goDownload}>
8585 I understand, continue