on master help sign in
Show usable permissions according to context
a574081Fang
src/views/Admin/AdminEditPermissions.js+19−18
@@ -2,6 +2,7 @@ import React, { useState, useCallback } 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';
4import { Grid } from 'indigo-react';
4import { Grid } from 'indigo-react';
5+import { azimuth } from 'azimuth-js';
5
6
6import { ForwardButton } from 'components/Buttons';
7import { ForwardButton } from 'components/Buttons';
7import { matchBlinky, matchBlinkyDate } from 'components/Blinky';
8import { matchBlinky, matchBlinkyDate } from 'components/Blinky';
@@ -46,13 +47,13 @@ export default function AdminEditPermissions() {
46 const [rekeyDate, setRekeyDate] = useState(Nothing());
47 const [rekeyDate, setRekeyDate] = useState(Nothing());
47
48
48 const point = need.point(pointCursor);
49 const point = need.point(pointCursor);
50+ const pointSize = azimuth.getPointSize(point);
51+ const isParent = pointSize !== azimuth.PointSize.Planet;
52+ const isSenate = pointSize === azimuth.PointSize.Galaxy;
49 const userAddress = need.wallet(wallet).address;
53 const userAddress = need.wallet(wallet).address;
50
54
51 const details = need.details(getDetails(point));
55 const details = need.details(getDetails(point));
52− const { canManage, canSpawn, canVote } = usePermissionsForPoint(
56+ const { canManage, isOwner } = usePermissionsForPoint(userAddress, point);
53− userAddress,
54− point
55− );
56
57
57 useLifecycle(() => {
58 useLifecycle(() => {
58 getRekeyDate(need.web3(web3), need.contracts(contracts), point).then(
59 getRekeyDate(need.web3(web3), need.contracts(contracts), point).then(
@@ -82,14 +83,17 @@ export default function AdminEditPermissions() {
82 )} proxy.`;
83 )} proxy.`;
83
84
84 return (
85 return (
86+ <>
85− <Grid.Item full>
87+ <Grid.Item full>
86− <ForwardButton
88+ <ForwardButton
87− disabled={!enabled}
89+ disabled={!enabled}
88− onClick={() => goToProxy(proxyType)}
90+ onClick={() => goToProxy(proxyType)}
89− detail={detail}>
91+ detail={detail}>
90− {capitalize(proxyTypeToHuman(proxyType))} Proxy Address
92+ {capitalize(proxyTypeToHuman(proxyType))} Proxy Address
91− </ForwardButton>
93+ </ForwardButton>
92− </Grid.Item>
94+ </Grid.Item>
95+ <Grid.Divider />
96+ </>
93 );
97 );
94 };
98 };
95
99
@@ -114,14 +118,11 @@ export default function AdminEditPermissions() {
114 </Grid.Item>
118 </Grid.Item>
115 <Grid.Divider />
119 <Grid.Divider />
116
120
117− {proxyAction(PROXY_TYPE.MANAGEMENT, details.managementProxy, canManage)}
121+ {proxyAction(PROXY_TYPE.MANAGEMENT, details.managementProxy, isOwner)}
118− <Grid.Divider />
119
122
120− {proxyAction(PROXY_TYPE.SPAWN, details.spawnProxy, canSpawn)}
123+ {isParent && proxyAction(PROXY_TYPE.SPAWN, details.spawnProxy, isOwner)}
121− <Grid.Divider />
122
124
123− {proxyAction(PROXY_TYPE.VOTING, details.votingProxy, canVote)}
125+ {isSenate && proxyAction(PROXY_TYPE.VOTING, details.votingProxy, isOwner)}
124− <Grid.Divider />
125
126
126 <Grid.Item
127 <Grid.Item
127 full
128 full