1import React, { useCallback } from 'react';
2import { Just, Nothing } from 'folktale/maybe';
3import { Grid, LinkButton } from 'indigo-react';
4import { azimuth } from 'azimuth-js';
6import { useNetwork } from 'store/network';
7import { usePointCursor } from 'store/pointCursor';
8import { usePointCache } from 'store/pointCache';
10import * as need from 'lib/need';
11import { isZeroAddress } from 'lib/wallet';
12import { PROXY_TYPE, proxyTypeToHuman } from 'lib/proxy';
13import { useLocalRouter } from 'lib/LocalRouter';
14import capitalize from 'lib/capitalize';
15import { eqAddr } from 'lib/wallet';
16import useCurrentPermissions from 'lib/useCurrentPermissions';
18import ViewHeader from 'components/ViewHeader';
19import { ForwardButton } from 'components/Buttons';
20import { matchBlinkyDate } from 'components/Blinky';
21import CopyButton from 'components/CopyButton';
22import convertToInt from 'lib/convertToInt';
24export default function AdminEditPermissions() {
25 const { push, names } = useLocalRouter();
26 const { contracts } = useNetwork();
27 const { pointCursor } = usePointCursor();
28 const { getDetails, getRekeyDate } = usePointCache();
30 const _contracts = need.contracts(contracts);
32 const point = need.point(pointCursor);
33 const pointSize = azimuth.getPointSize(point);
34 const isParent = pointSize !== azimuth.PointSize.Planet;
35 const isSenate = pointSize === azimuth.PointSize.Galaxy;
37 const details = need.details(getDetails(point));
38 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
39 const { canManage, isOwner } = useCurrentPermissions();
41 const goSetProxy = useCallback(
42 proxyType => push(names.SET_PROXY, { proxyType }),
46 const goNetworkingKeys = useCallback(() => push(names.NETWORKING_KEYS), [
51 const renderProxyAction = (proxyType, address) => {
52 if (isZeroAddress(address)) {
54 } else if (eqAddr(address, _contracts.delegatedSending.address)) {
55 address = `${address} (invites contract)`;
64 onClick={() => goSetProxy(proxyType)}
66 detailClassName="mono"
67 accessory={<LinkButton>Edit</LinkButton>}>
68 {capitalize(proxyTypeToHuman(proxyType))} Proxy Address
75 const renderNetworkKeysDetail = () => {
76 if (networkRevision === 0) {
77 return 'Not yet configured.';
80 const renderRevision = maybeDate => (
82 Revision #{networkRevision}, since {matchBlinkyDate(maybeDate)}
86 return getRekeyDate(point).matchWith({
87 Nothing: () => renderRevision(Nothing()),
90 Ok: r => renderRevision(Just(r.value)),
98 <Grid.Item full as={ViewHeader}>
105 detail={details.owner}
106 detailClassName="mono"
107 accessory={<CopyButton text={details.owner} />}>
112 {renderProxyAction(PROXY_TYPE.MANAGEMENT, details.managementProxy)}
114 {isParent && renderProxyAction(PROXY_TYPE.SPAWN, details.spawnProxy)}
116 {isSenate && renderProxyAction(PROXY_TYPE.VOTING, details.votingProxy)}
121 disabled={!canManage}
122 onClick={goNetworkingKeys}
123 detail={renderNetworkKeysDetail()}
124 accessory={<LinkButton>View</LinkButton>}>
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