1import React from 'react';
2import { azimuth } from 'azimuth-js';
3import * as need from '../../lib/need';
5import { ETH_ZERO_ADDR, CURVE_ZERO_ADDR, eqAddr } from '../../lib/wallet';
6import { Row, Col, H2, P } from '../../components/old/Base';
7import { Button } from '../../components/old/Base';
8import { ROUTE_NAMES } from '../../lib/routeNames';
9import { useHistory } from '../../store/history';
10import { useWallet } from '../../store/wallet';
12const isPlanet = point =>
13 azimuth.getPointSize(point) === azimuth.PointSize.Planet;
14const isStar = point => azimuth.getPointSize(point) === azimuth.PointSize.Star;
16function Actions(props) {
17 const history = useHistory();
18 const { wallet } = useWallet();
19 const { online, point, pointDetails, invites } = props;
21 const addr = need.address({ wallet });
23 const planet = isPlanet(point);
24 const star = isStar(point);
26 const isOwner = pointDetails.matchWith({
28 Just: details => eqAddr(details.value.owner, addr),
30 const isActive = pointDetails.matchWith({
32 Just: details => details.value.active,
34 const isActiveOwner = isOwner && isActive;
35 const canSetSpawnProxy = isActiveOwner && !planet;
36 const canSetManagementProxy = isActiveOwner;
40 pointDetails.matchWith({
42 Just: details => eqAddr(details.value.managementProxy, addr),
44 const canConfigureKeys = canManage && isActive;
46 const canIssueChild = pointDetails.matchWith({
49 const hasPermission = isOwner || eqAddr(details.value.spawnProxy, addr);
51 const isBooted = details.value.keyRevisionNumber > 0;
53 const isNotPlanet = !isPlanet(point);
55 return hasPermission && isBooted && isNotPlanet;
59 const hasInvites = invites.matchWith({
61 Just: count => count.value > 0,
64 const canTransfer = pointDetails.matchWith({
67 eqAddr(deets.value.transferProxy, addr) ||
68 eqAddr(deets.value.owner, addr),
71 const canGenKeyfile = pointDetails.matchWith({
75 eqAddr(deets.value.owner, addr) ||
76 eqAddr(deets.value.managementProxy, addr);
78 const isBooted = deets.value.keyRevisionNumber > 0;
80 return hasPermission && isBooted;
84 const canAcceptTransfer = pointDetails.matchWith({
86 Just: deets => eqAddr(deets.value.transferProxy, addr),
89 const canCancelTransfer = pointDetails.matchWith({
92 eqAddr(deets.value.owner, addr) &&
93 !eqAddr(deets.value.transferProxy, ETH_ZERO_ADDR),
96 const displayReminder = pointDetails.matchWith({
100 deets.value.encryptionKey === CURVE_ZERO_ADDR &&
101 deets.value.authenticationKey === CURVE_ZERO_ADDR
106 let inviteAction = null;
110 disabled={!isActiveOwner || !online || !hasInvites}
113 onClick={() => history.push(ROUTE_NAMES.INVITES_SEND)}>
117 Just: count => count.value,
126 disabled={!(isActiveOwner && canIssueChild) || !online}
130 history.push(ROUTE_NAMES.INVITES_MANAGE);
141 <P>{`Before you can issue child points or generate your Arvo
142 keyfile, you need to set your public keys.`}</P>
147 <Col className={'flex flex-column items-start col-md-4'}>
151 disabled={(online || planet) && !canIssueChild}
153 history.push(ROUTE_NAMES.ISSUE_CHILD);
161 disabled={online && !canAcceptTransfer}
163 history.push(ROUTE_NAMES.ACCEPT_TRANSFER);
165 {'Accept incoming transfer'}
171 disabled={online && !canCancelTransfer}
173 history.push(ROUTE_NAMES.CANCEL_TRANSFER);
175 {'Cancel outgoing transfer'}
181 disabled={online && !canGenKeyfile}
183 history.push(ROUTE_NAMES.GEN_KEYFILE);
185 {'Generate Arvo keyfile'}
188 <Col className={'flex flex-column items-start col-md-4'}>
190 disabled={online && !canSetSpawnProxy}
194 history.push(ROUTE_NAMES.SET_SPAWN_PROXY);
196 {'Change spawn proxy'}
200 disabled={online && !canSetManagementProxy}
204 history.push(ROUTE_NAMES.SET_MANAGEMENT_PROXY);
206 {'Change management proxy'}
210 disabled={online && !canConfigureKeys}
214 history.push(ROUTE_NAMES.SET_KEYS);
220 disabled={online && !canTransfer}
224 history.push(ROUTE_NAMES.TRANSFER);
229 <Col className={'flex flex-column items-start col-md-4'}>
237export default Actions;
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list