on master help sign in
refactor: clean up all of the blinky tests
e7c1371Matt Condon (shrugs)
src/components/Blinky.js+2
@@ -26,6 +26,8 @@ export const matchBlinkyDate = obj =>
26 Just: p => formatDots(p.value),
26 Just: p => formatDots(p.value),
27 });
27 });
28
28
29+export const blinkIf = (test, right) => (test ? <Blinky /> : right);
30+
29export default function Blinky({
31export default function Blinky({
30 a = LOADING_CHARACTER,
32 a = LOADING_CHARACTER,
31 b = INTERSTITIAL_CHARACTER,
33 b = INTERSTITIAL_CHARACTER,
src/components/Buttons.js+6−5
@@ -1,17 +1,18 @@
1import React from 'react';
1import React from 'react';
2import { Button } from 'indigo-react';
2import { Button } from 'indigo-react';
3+
3−import Blinky from './Blinky';
4+import { blinkIf } from './Blinky';
4
5
5// NOTE: the -> is correct because inter recognizes the pair
6// NOTE: the -> is correct because inter recognizes the pair
6export const ForwardButton = ({ loading, ...props }) => (
7export const ForwardButton = ({ loading, ...props }) => (
7− <Button accessory={loading ? <Blinky /> : '->'} {...props} />
8+ <Button accessory={blinkIf(loading, '->')} {...props} />
8);
9);
9export const DownloadButton = ({ loading, ...props }) => (
10export const DownloadButton = ({ loading, ...props }) => (
10− <Button accessory={loading ? <Blinky /> : '↓'} {...props} />
11+ <Button accessory={blinkIf(loading, '↓')} {...props} />
11);
12);
12export const RestartButton = props => <Button accessory="↺" {...props} />;
13export const RestartButton = props => <Button accessory="↺" {...props} />;
13−export const GenerateButton = props => (
14+export const GenerateButton = ({ loading, ...props }) => (
14− <Button accessory="○" solid {...props} />
15+ <Button accessory={blinkIf(loading, '○')} solid {...props} />
15);
16);
16export const OutButton = props => (
17export const OutButton = props => (
17 <Button as="a" target="_blank" accessory="↗" {...props} />
18 <Button as="a" target="_blank" accessory="↗" {...props} />
src/components/DownloadKeyfileButton.js+4−3
@@ -21,15 +21,16 @@ export default function DownloadKeyfileButton({
21 networkSeed
21 networkSeed
22 );
22 );
23
23
24+ const showHelp = !generating && !available;
25+
24 return (
26 return (
25 <DownloadButton
27 <DownloadButton
26 as="span"
28 as="span"
27 className={className}
29 className={className}
28 disabled={downloaded || !available}
30 disabled={downloaded || !available}
29 disabledDetail={
31 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 && (
33 <Flex col>
34 <Flex col>
34 <Flex.Item as={B} className="wrap ws-normal">
35 <Flex.Item as={B} className="wrap ws-normal">
35 · You are using nondeterministic networking keys. To download your
36 · You are using nondeterministic networking keys. To download your
src/components/InlineEthereumTransaction.js+13−21
@@ -10,12 +10,13 @@ import {
10 Text,
10 Text,
11 HelpText,
11 HelpText,
12} from 'indigo-react';
12} from 'indigo-react';
13−import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
13+
14import { useCheckboxInput } from 'lib/useInputs';
14import { useCheckboxInput } from 'lib/useInputs';
15−import Blinky from './Blinky';
16import { hexify } from 'lib/txn';
15import { hexify } from 'lib/txn';
17import { useExploreTxUrl } from 'lib/explorer';
16import { useExploreTxUrl } from 'lib/explorer';
18
17
18+import { GenerateButton, ForwardButton, RestartButton } from './Buttons';
19+
19export default function InlineEthereumTransaction({
20export default function InlineEthereumTransaction({
20 // from useEthereumTransaction.bind
21 // from useEthereumTransaction.bind
21 initializing,
22 initializing,
@@ -42,10 +43,10 @@ export default function InlineEthereumTransaction({
42 const showReceipt = broadcasted || confirmed;
43 const showReceipt = broadcasted || confirmed;
43 // show configure controls pre-broadcast
44 // show configure controls pre-broadcast
44 const showConfigureInput = !(signed || broadcasted || confirmed);
45 const showConfigureInput = !(signed || broadcasted || confirmed);
45− // show signed tx after signing
46+ // show signed tx only when signing (for offline usage)
46 const showSignedTx = signed;
47 const showSignedTx = signed;
47
48
48− const exploreHashUrl = useExploreTxUrl(txHash);
49+ const exploreTxUrl = useExploreTxUrl(txHash);
49 const [advancedInput, { data: advancedOpen }] = useCheckboxInput({
50 const [advancedInput, { data: advancedOpen }] = useCheckboxInput({
50 name: 'advanced',
51 name: 'advanced',
51 label: 'Advanced Configuration',
52 label: 'Advanced Configuration',
@@ -63,7 +64,7 @@ export default function InlineEthereumTransaction({
63 disabled: !showSignedTx,
64 disabled: !showSignedTx,
64 });
65 });
65
66
66− const renderButton = () => {
67+ const renderPrimaryButton = () => {
67 if (error) {
68 if (error) {
68 return (
69 return (
69 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
70 <Grid.Item full as={RestartButton} solid onClick={() => reset()}>
@@ -79,25 +80,15 @@ export default function InlineEthereumTransaction({
79 </Grid.Item>
80 </Grid.Item>
80 </>
81 </>
81 );
82 );
82− } else if (broadcasted) {
83+ } else if (signed || 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) {
95 return (
84 return (
96 <Grid.Item
85 <Grid.Item
97 full
86 full
98 as={ForwardButton}
87 as={ForwardButton}
99 solid
88 solid
100 success
89 success
90+ disable={broadcasted}
91+ loading={broadcasted}
101 onClick={() => broadcast()}>
92 onClick={() => broadcast()}>
102 Send Transaction
93 Send Transaction
103 </Grid.Item>
94 </Grid.Item>
@@ -109,7 +100,7 @@ export default function InlineEthereumTransaction({
109 as={GenerateButton}
100 as={GenerateButton}
110 onClick={generateAndSign}
101 onClick={generateAndSign}
111 disabled={!canSign}
102 disabled={!canSign}
112− accessory={!canSign && initializing ? <Blinky /> : undefined}>
103+ loading={!canSign && initializing}>
113 Generate & Sign Transaction
104 Generate & Sign Transaction
114 </Grid.Item>
105 </Grid.Item>
115 );
106 );
@@ -118,7 +109,7 @@ export default function InlineEthereumTransaction({
118
109
119 return (
110 return (
120 <Grid className={cn(className, 'mt1')}>
111 <Grid className={cn(className, 'mt1')}>
121− {renderButton()}
112+ {renderPrimaryButton()}
122
113
123 {error && (
114 {error && (
124 <Grid.Item full as={ErrorText} className="mt1">
115 <Grid.Item full as={ErrorText} className="mt1">
@@ -136,6 +127,7 @@ export default function InlineEthereumTransaction({
136 <Flex.Item as={H5}>Gas Price</Flex.Item>
127 <Flex.Item as={H5}>Gas Price</Flex.Item>
137 <Flex.Item as={H5}>{gasPrice} Gwei</Flex.Item>
128 <Flex.Item as={H5}>{gasPrice} Gwei</Flex.Item>
138 </Grid.Item>
129 </Grid.Item>
130+ {/* TODO(shrugs): move to indigo/RangeInput */}
139 <Grid.Item
131 <Grid.Item
140 full
132 full
141 as="input"
133 as="input"
@@ -182,7 +174,7 @@ export default function InlineEthereumTransaction({
182 <Grid.Item full as={Flex} col className="pv4">
174 <Grid.Item full as={Flex} col className="pv4">
183 <Flex.Item as={Flex} row justify="between">
175 <Flex.Item as={Flex} row justify="between">
184 <Flex.Item as={H5}>Transaction Hash</Flex.Item>
176 <Flex.Item as={H5}>Transaction Hash</Flex.Item>
185− <Flex.Item as={LinkButton} href={exploreHashUrl}>
177+ <Flex.Item as={LinkButton} href={exploreTxUrl}>
186 Etherscan↗
178 Etherscan↗
187 </Flex.Item>
179 </Flex.Item>
188 </Flex.Item>
180 </Flex.Item>
src/views/Activate/ActivateCode.js+2−2
@@ -14,7 +14,7 @@ import * as need from 'lib/need';
14import { ROUTE_NAMES } from 'lib/routeNames';
14import { ROUTE_NAMES } from 'lib/routeNames';
15import { useSyncKnownPoints } from 'lib/useSyncPoints';
15import { useSyncKnownPoints } from 'lib/useSyncPoints';
16import FooterButton from 'components/FooterButton';
16import FooterButton from 'components/FooterButton';
17−import Blinky from 'components/Blinky';
17+import { blinkIf } from 'components/Blinky';
18import { DEFAULT_HD_PATH, walletFromMnemonic } from 'lib/wallet';
18import { DEFAULT_HD_PATH, walletFromMnemonic } from 'lib/wallet';
19import { useNetwork } from 'store/network';
19import { useNetwork } from 'store/network';
20import { generateWallet } from 'lib/invite';
20import { generateWallet } from 'lib/invite';
@@ -138,7 +138,7 @@ export default function ActivateCode() {
138 as={ForwardButton}
138 as={ForwardButton}
139 className="mt4"
139 className="mt4"
140 disabled={!pass || deriving}
140 disabled={!pass || deriving}
141− accessory={deriving ? <Blinky /> : undefined}
141+ accessory={blinkIf(deriving)}
142 onClick={goToPassport}
142 onClick={goToPassport}
143 solid
143 solid
144 full>
144 full>
src/views/Admin/Reticket/ReticketConfirm.js+2−2
@@ -13,7 +13,7 @@ import { isDevelopment } from 'lib/flags';
13import { ForwardButton } from 'components/Buttons';
13import { ForwardButton } from 'components/Buttons';
14import PaperRenderer from 'components/PaperRenderer';
14import PaperRenderer from 'components/PaperRenderer';
15import WarningBox from 'components/WarningBox';
15import WarningBox from 'components/WarningBox';
16−import Blinky from 'components/Blinky';
16+import { blinkIf } from 'components/Blinky';
17import useCurrentPointName from 'lib/useCurrentPointName';
17import useCurrentPointName from 'lib/useCurrentPointName';
18
18
19export default function ReticketConfirm({ newWallet, setNewWallet }) {
19export default function ReticketConfirm({ newWallet, setNewWallet }) {
@@ -79,7 +79,7 @@ export default function ReticketConfirm({ newWallet, setNewWallet }) {
79 full
79 full
80 as={ForwardButton}
80 as={ForwardButton}
81 solid
81 solid
82− accessory={Nothing.hasInstance(newWallet) ? <Blinky /> : undefined}
82+ accessory={blinkIf(Nothing.hasInstance(newWallet))}
83 disabled={Nothing.hasInstance(newWallet)}
83 disabled={Nothing.hasInstance(newWallet)}
84 onClick={goDownload}>
84 onClick={goDownload}>
85 I understand, continue
85 I understand, continue