on master help sign in
feat: fully implement admin/redownload
f660f7bMatt Condon (shrugs)
src/components/Buttons.js+1−6
@@ -4,6 +4,7 @@ import { Button } from 'indigo-react';
4// NOTE: the -> is correct because inter recognizes the pair
4// NOTE: the -> is correct because inter recognizes the pair
5export const ForwardButton = props => <Button accessory="->" {...props} />;
5export const ForwardButton = props => <Button accessory="->" {...props} />;
6export const DownloadButton = props => <Button accessory="↓" {...props} />;
6export const DownloadButton = props => <Button accessory="↓" {...props} />;
7+export const RestartButton = props => <Button accessory="↺" solid {...props} />;
7export const OutButton = props => (
8export const OutButton = props => (
8 <Button as="a" target="_blank" accessory="↗" {...props} />
9 <Button as="a" target="_blank" accessory="↗" {...props} />
9);
10);
@@ -13,9 +14,3 @@ export const OfflineButton = props => (
13 Offline
14 Offline
14 </OutButton>
15 </OutButton>
15);
16);
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';
2export { default as Grid } from './components/Grid';
2export { default as Grid } from './components/Grid';
3export { default as Flex } from './components/Flex';
3export { default as Flex } from './components/Flex';
4export { default as Input } from './components/Input';
4export { default as Input } from './components/Input';
5+export { default as SelectInput } from './components/SelectInput';
5export { default as CheckboxInput } from './components/CheckboxInput';
6export { default as CheckboxInput } from './components/CheckboxInput';
6export { default as AccessoryIcon } from './components/AccessoryIcon';
7export { default as AccessoryIcon } from './components/AccessoryIcon';
7export { default as Button } from './components/Button';
8export { default as Button } from './components/Button';
src/views/Activate/PassportTransfer.js+3−2
@@ -139,8 +139,9 @@ export default function PassportTransfer({ className, resetActivateRouter }) {
139 full
139 full
140 className="mt3"
140 className="mt3"
141 as={RestartButton}
141 as={RestartButton}
142− onClick={goToRestart}
142+ onClick={goToRestart}>
143− />
143+ Restart
144+ </Grid.Item>
144 </>
145 </>
145 );
146 );
146 }
147 }
src/views/Admin/AdminRedownload.js+44−24
@@ -1,52 +1,72 @@
1−import React, { useState } from 'react';
1+import React, { useCallback, useState } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
2import { Just, Nothing } from 'folktale/maybe';
3import * as need from 'lib/need';
3import * as need from 'lib/need';
4
4
5import { usePointCursor } from 'store/pointCursor';
5import { usePointCursor } from 'store/pointCursor';
6
6
7−import View from 'components/View';
8−import { DownloadButton } from 'components/Buttons';
7+import { DownloadButton, RestartButton } from 'components/Buttons';
9import PaperRenderer from 'components/PaperRenderer';
8import PaperRenderer from 'components/PaperRenderer';
10
9
11import { downloadWallet } from 'lib/invite';
10import { downloadWallet } from 'lib/invite';
12
11
13import { useWallet } from 'store/wallet';
12import { useWallet } from 'store/wallet';
13+import { Grid, Text } from 'indigo-react';
14+import ViewHeader from 'components/ViewHeader';
15+import { useLocalRouter } from 'lib/LocalRouter';
14
16
15export default function AdminRedownload() {
17export default function AdminRedownload() {
16 const { urbitWallet } = useWallet();
18 const { urbitWallet } = useWallet();
17 const { pointCursor } = usePointCursor();
19 const { pointCursor } = usePointCursor();
20+ const { pop } = useLocalRouter();
21+
22+ const _urbitWallet = need.wallet(urbitWallet);
18 const point = need.point(pointCursor);
23 const point = need.point(pointCursor);
19
24
20 const [paper, setPaper] = useState(Nothing());
25 const [paper, setPaper] = useState(Nothing());
26+ const [downloaded, setDownloaded] = useState(false);
21
27
22− const doDownload = () => {
28+ const doDownload = useCallback(() => {
23 downloadWallet(paper.value);
29 downloadWallet(paper.value);
24− };
30+ setDownloaded(true);
31+ }, [paper, setDownloaded]);
32+
33+ const goBack = useCallback(() => pop(), [pop]);
25
34
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}>
26− const paperRenderer = paper.matchWith({
56+ {paper.matchWith({
27− Nothing: () => null,
57+ Nothing: () => 'Printing and folding...',
28− Just: p => (
58+ Just: _ => 'Download paper wallet',
59+ })}
60+ </Grid.Item>
61+ )}
62+ </Grid>
29 <PaperRenderer
63 <PaperRenderer
30 point={point}
64 point={point}
31− wallet={urbitWallet.value}
65+ wallet={_urbitWallet}
32 callback={paper => {
66 callback={paper => {
33 setPaper(Just(paper));
67 setPaper(Just(paper));
34 }}
68 }}
35 />
69 />
36− ),
70+ </>
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>
51 );
71 );
52}
72}
src/views/Admin/Reticket/ReticketExecute.js+3−2
@@ -93,8 +93,9 @@ export default function ReticketExecute({ newWallet, setNewWallet }) {
93 full
93 full
94 className="mt3"
94 className="mt3"
95 as={RestartButton}
95 as={RestartButton}
96− onClick={goToRestart}
96+ onClick={goToRestart}>
97− />
97+ Restart
98+ </Grid.Item>
98 </>
99 </>
99 );
100 );
100 }
101 }