on master help sign in
Only enable admin page when usable
a9887cfFang
src/views/Point.js+17−2
@@ -16,6 +16,7 @@ import { matchBlinky } from 'components/Blinky';
16import useInvites from 'lib/useInvites';
16import useInvites from 'lib/useInvites';
17import { useSyncOwnedPoints } from 'lib/useSyncPoints';
17import { useSyncOwnedPoints } from 'lib/useSyncPoints';
18import { ROUTE_NAMES } from 'lib/routeNames';
18import { ROUTE_NAMES } from 'lib/routeNames';
19+import { eqAddr } from 'lib/wallet';
19
20
20import Actions from './Point/Actions';
21import Actions from './Point/Actions';
21import { useWallet } from 'store/wallet';
22import { useWallet } from 'store/wallet';
@@ -27,7 +28,21 @@ export default function Point() {
27 const { wallet } = useWallet();
28 const { wallet } = useWallet();
28
29
29 const point = need.point(pointCursor);
30 const point = need.point(pointCursor);
31+
32+ let canAdmin = false;
30− const hasInCache = point in pointCache;
33+ if (point in pointCache) {
34+ canAdmin = wallet.matchWith({
35+ Nothing: () => false,
36+ Just: wal => {
37+ const pointDetails = need.fromPointCache(pointCache, point);
38+ const address = need.addressFromWallet(wallet);
39+ return (
40+ eqAddr(address, pointDetails.owner) ||
41+ eqAddr(address, pointDetails.managementProxy)
42+ );
43+ },
44+ });
45+ }
31
46
32 // fetch the invites for the current cursor
47 // fetch the invites for the current cursor
33 const { availableInvites } = useInvites(point);
48 const { availableInvites } = useInvites(point);
@@ -51,7 +66,7 @@ export default function Point() {
51 <Grid.Item
66 <Grid.Item
52 full
67 full
53 as={ForwardButton}
68 as={ForwardButton}
54− disabled={!hasInCache}
69+ disabled={!canAdmin}
55 onClick={goAdmin}>
70 onClick={goAdmin}>
56 Admin
71 Admin
57 </Grid.Item>
72 </Grid.Item>