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