on master help sign in
feat: fully implement admin/redownload
commitf660f7bc1fd12fc8ce9ba2135cf7fe209c424c19 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateTue 9 Jul 2019, 22:48 (7 years ago) parenta3d5a70
5 files changed+52−34
src/components/Buttons.js+1−6 src/indigo-react/index.js+1 src/views/Activate/PassportTransfer.js+3−2 src/views/Admin/AdminRedownload.js+44−24 src/views/Admin/Reticket/ReticketExecute.js+3−2
src/components/Buttons.js+1−6
@@ -4,6 +4,7 @@ import { Button } from 'indigo-react';
44// NOTE: the -> is correct because inter recognizes the pair
55export const ForwardButton = props => <Button accessory="->" {...props} />;
66export const DownloadButton = props => <Button accessory="↓" {...props} />;
7+export const RestartButton = props => <Button accessory="↺" solid {...props} />;
78export const OutButton = props => (
89 <Button as="a" target="_blank" accessory="↗" {...props} />
910);
@@ -13,9 +14,3 @@ export const OfflineButton = props => (
1314 Offline
1415 </OutButton>
1516);
16−
17−export const RestartButton = props => (
18− <Button accessory="↺" solid {...props}>
19− Restart
20− </Button>
21−);
src/indigo-react/index.js+1
@@ -2,6 +2,7 @@ export { default as IndigoApp } from './components/IndigoApp';
22export { default as Grid } from './components/Grid';
33export { default as Flex } from './components/Flex';
44export { default as Input } from './components/Input';
5+export { default as SelectInput } from './components/SelectInput';
56export { default as CheckboxInput } from './components/CheckboxInput';
67export { default as AccessoryIcon } from './components/AccessoryIcon';
78export { default as Button } from './components/Button';
src/views/Activate/PassportTransfer.js+3−2
@@ -139,8 +139,9 @@ export default function PassportTransfer({ className, resetActivateRouter }) {
139139 full
140140 className="mt3"
141141 as={RestartButton}
142− onClick={goToRestart}
143− />
142+ onClick={goToRestart}>
143+ Restart
144+ </Grid.Item>
144145 </>
145146 );
146147 }
src/views/Admin/AdminRedownload.js+44−24
@@ -1,52 +1,72 @@
1−import React, { useState } from 'react';
1+import React, { useCallback, useState } from 'react';
22import { Just, Nothing } from 'folktale/maybe';
33import * as need from 'lib/need';
44
55import { usePointCursor } from 'store/pointCursor';
66
7−import View from 'components/View';
8−import { DownloadButton } from 'components/Buttons';
7+import { DownloadButton, RestartButton } from 'components/Buttons';
98import PaperRenderer from 'components/PaperRenderer';
109
1110import { downloadWallet } from 'lib/invite';
1211
1312import { useWallet } from 'store/wallet';
13+import { Grid, Text } from 'indigo-react';
14+import ViewHeader from 'components/ViewHeader';
15+import { useLocalRouter } from 'lib/LocalRouter';
1416
1517export default function AdminRedownload() {
1618 const { urbitWallet } = useWallet();
1719 const { pointCursor } = usePointCursor();
20+ const { pop } = useLocalRouter();
21+
22+ const _urbitWallet = need.wallet(urbitWallet);
1823 const point = need.point(pointCursor);
1924
2025 const [paper, setPaper] = useState(Nothing());
26+ const [downloaded, setDownloaded] = useState(false);
2127
22− const doDownload = () => {
28+ const doDownload = useCallback(() => {
2329 downloadWallet(paper.value);
24− };
30+ setDownloaded(true);
31+ }, [paper, setDownloaded]);
32+
33+ const goBack = useCallback(() => pop(), [pop]);
2534
26− const paperRenderer = paper.matchWith({
27− Nothing: () => null,
28− Just: p => (
35+ return (
36+ <>
37+ <Grid gap={4}>
38+ <Grid.Item full as={ViewHeader}>
39+ Download Passport
40+ </Grid.Item>
41+ <Grid.Item full as={Text}>
42+ After you’ve downloaded your passport, back up the ticket manually or
43+ store on a trusted device.
44+ </Grid.Item>
45+ {downloaded ? (
46+ <Grid.Item full as={RestartButton} solid onClick={goBack}>
47+ Done
48+ </Grid.Item>
49+ ) : (
50+ <Grid.Item
51+ full
52+ as={DownloadButton}
53+ solid
54+ disabled={Nothing.hasInstance(paper)}
55+ onClick={doDownload}>
56+ {paper.matchWith({
57+ Nothing: () => 'Printing and folding...',
58+ Just: _ => 'Download paper wallet',
59+ })}
60+ </Grid.Item>
61+ )}
62+ </Grid>
2963 <PaperRenderer
3064 point={point}
31− wallet={urbitWallet.value}
65+ wallet={_urbitWallet}
3266 callback={paper => {
3367 setPaper(Just(paper));
3468 }}
3569 />
36− ),
37− });
38−
39− return (
40− <View>
41− <DownloadButton
42− disabled={Nothing.hasInstance(paper)}
43− onClick={doDownload}>
44− {paper.matchWith({
45− Nothing: () => 'Printing and folding...',
46− Just: _ => 'Download paper wallet',
47− })}
48− </DownloadButton>
49− {paperRenderer}
50− </View>
70+ </>
5171 );
5272}
src/views/Admin/Reticket/ReticketExecute.js+3−2
@@ -93,8 +93,9 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
9393 full
9494 className="mt3"
9595 as={RestartButton}
96− onClick={goToRestart}
97− />
96+ onClick={goToRestart}>
97+ Restart
98+ </Grid.Item>
9899 </>
99100 );
100101 }