on c19b2a8 help sign in
bridge/src/views/Admin/AdminHome.js
106 lines 3.1 kB history raw
1import React, { useCallback } from 'react';
2import { Just } from 'folktale/maybe';
3import { Grid, B } from 'indigo-react';
5import { useWallet } from 'store/wallet';
7import { useLocalRouter } from 'lib/LocalRouter';
8import useCurrentPermissions from 'lib/useCurrentPermissions';
9import useKeyfileGenerator from 'lib/useKeyfileGenerator';
11import { ForwardButton } from 'components/Buttons';
12import ViewHeader from 'components/ViewHeader';
13import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
15export default function AdminHome() {
16 const { push, names } = useLocalRouter();
17 const { urbitWallet } = useWallet();
19 const { bind: keyfileBind } = useKeyfileGenerator();
21 const { isOwner, canTransfer, isTransferProxySet } = useCurrentPermissions();
23 const goRedownload = useCallback(() => push(names.REDOWNLOAD), [push, names]);
24 const goReticket = useCallback(() => push(names.RETICKET), [push, names]);
25 const goEditPermissions = useCallback(() => push(names.EDIT_PERMISSIONS), [
26 push,
27 names,
28 ]);
29 const goCancelTransfer = useCallback(() => push(names.CANCEL_TRANSFER), [
30 names,
31 push,
32 ]);
33 const goTransfer = useCallback(() => push(names.TRANSFER), [names, push]);
35 const canDownloadPassport = Just.hasInstance(urbitWallet);
37 return (
38 <>
39 <Grid>
40 <Grid.Item full as={ViewHeader}>
41 Admin
42 </Grid.Item>
44 <Grid.Item
45 full
46 as={ForwardButton}
47 disabled={!canDownloadPassport}
48 onClick={goRedownload}
49 detail="Re-download your paper wallet"
50 disabledDetail={
51 <B className="wrap ws-normal">
52 · Master Ticket Authentication required.
53 </B>
54 }>
55 Download Passport
56 </Grid.Item>
57 <Grid.Divider />
58 <Grid.Item
59 full
60 as={DownloadKeyfileButton}
61 {...keyfileBind}
62 detail="Download your current Arvo Keyfile">
63 Download Arvo Keyfile
64 </Grid.Item>
65 <Grid.Divider />
66 <Grid.Item
67 full
68 as={ForwardButton}
69 disabled={!isOwner}
70 onClick={goReticket}
71 detail="Move to brand new wallet, resetting all permissions">
72 Reticket
73 </Grid.Item>
74 <Grid.Divider />
75 <Grid.Item
76 full
77 as={ForwardButton}
78 onClick={goEditPermissions}
79 detail="Proxies, networking keys, etc.">
80 Edit Permissions
81 </Grid.Item>
82 <Grid.Divider />
83 {isTransferProxySet ? (
84 <Grid.Item
85 full
86 as={ForwardButton}
87 onClick={goCancelTransfer}
88 detail="Cancel outgoing transfer"
89 disabled={!canTransfer}>
90 Cancel Outgoing Transfer
91 </Grid.Item>
92 ) : (
93 <Grid.Item
94 full
95 as={ForwardButton}
96 onClick={goTransfer}
97 detail="Transfer ownership of this ID"
98 disabled={!canTransfer}>
99 Transfer
100 </Grid.Item>
101 )}
102 <Grid.Divider />
103 </Grid>
104 </>
105 );