on master help sign in
Make canSpawn and canVote match contracts

Also disables Issue Child action if keys of parent not set.

commiteea7a055f76104a0813bd50c7a661167882e16f6 authorFang <git@fang.io> dateFri 19 Jul 2019, 16:43 (7 years ago) parent0415772
2 files changed+22−6
src/lib/usePermissionsForPoint.js+10−3 src/views/Point.js+12−3
src/lib/usePermissionsForPoint.js+10−3
@@ -47,9 +47,12 @@ export default function usePermissionsForPoint(address, point) {
4747 const isPlanet = pointSize === azimuth.PointSize.Planet;
4848 const isStar = pointSize === azimuth.PointSize.Star;
4949 const isGalaxy = pointSize === azimuth.PointSize.Galaxy;
50+ const isParent = isStar || isGalaxy;
51+
52+ const isActive = details.active;
5053
5154 const isOwner = eqAddr(address, details.owner);
52− const isActiveOwner = isOwner && details.active;
55+ const isActiveOwner = isOwner && isActive;
5356 const isManagementProxy = eqAddr(address, details.managementProxy);
5457 const isSpawnProxy = eqAddr(address, details.spawnProxy);
5558 const isVotingProxy = eqAddr(address, details.votingProxy);
@@ -62,8 +65,9 @@ export default function usePermissionsForPoint(address, point) {
6265
6366 const canManage = isOwner || isManagementProxy;
6467 const canTransfer = isOwner || isTransferProxy;
65− const canSpawn = (isStar || isGalaxy) && (isOwner || isSpawnProxy);
66− const canVote = isGalaxy && (isOwner || isVotingProxy);
68+ const canSpawn =
69+ isParent && (isOwner || isSpawnProxy) && details.keyRevisionNumber > 0;
70+ const canVote = isGalaxy && isActive && (isOwner || isVotingProxy);
6771
6872 const spawnIsDelegatedSending = eqAddr(
6973 _contracts.delegatedSending.address,
@@ -74,6 +78,9 @@ export default function usePermissionsForPoint(address, point) {
7478 isPlanet,
7579 isStar,
7680 isGalaxy,
81+ isParent,
82+ //
83+ isActive,
7784 //
7885 isOwner,
7986 isActiveOwner,
src/views/Point.js+12−3
@@ -23,7 +23,12 @@ export default function Point() {
2323
2424 const point = need.point(pointCursor);
2525
26− const { isActiveOwner, canManage, canSpawn } = useCurrentPermissions();
26+ const {
27+ isParent,
28+ isActiveOwner,
29+ canManage,
30+ canSpawn,
31+ } = useCurrentPermissions();
2732
2833 // fetch the invites for the current cursor
2934 const { availableInvites } = useInvites(point);
@@ -81,9 +86,13 @@ export default function Point() {
8186 Admin
8287 </Grid.Item>
8388 <Grid.Divider />
84− {canSpawn && (
89+ {isParent && (
8590 <>
86− <Grid.Item full as={ForwardButton} onClick={goIssuePoint}>
91+ <Grid.Item
92+ full
93+ as={ForwardButton}
94+ disabled={!canSpawn}
95+ onClick={goIssuePoint}>
8796 Issue Point
8897 </Grid.Item>
8998 <Grid.Divider />