1import React, { useCallback, useEffect, useState } from 'react';
2import cn from 'classnames';
3import { azimuth } from 'azimuth-js';
4import { Just } from 'folktale/maybe';
5import { Grid, Flex } from 'indigo-react';
6import { Box, Icon, Row, Button } from '@tlon/indigo-react';
8import { usePointCursor } from 'store/pointCursor';
9import { useWallet } from 'store/wallet';
10import { useRollerStore } from 'store/roller';
12import View from 'components/View';
13import Greeting from 'components/Greeting';
14import Passport from 'components/Passport';
15import Blinky from 'components/Blinky';
16import BarGraph from 'components/BarGraph';
17import Chip from 'components/Chip';
18import InviteSigilList from 'components/InviteSigilList';
19import { ForwardButton } from 'components/Buttons';
20import L2PointHeader from 'components/L2/Headers/L2PointHeader';
21import LayerIndicator from 'components/L2/LayerIndicator';
22import Card from 'components/L2/Card';
24import * as need from 'lib/need';
25import useInvites from 'lib/useInvites';
26import { useSyncExtras } from 'lib/useSyncPoints';
27import useCurrentPermissions from 'lib/useCurrentPermissions';
28import { useLocalRouter } from 'lib/LocalRouter';
29import Inviter from 'views/Invite/Inviter';
30import useRoller from 'lib/useRoller';
33import { isL2 } from 'lib/utils/roller';
34import { isDevelopment } from 'lib/flags';
35import { convertToInt } from 'lib/convertToInt';
36import { usePointCache } from 'store/pointCache';
37import Modal from 'components/L2/Modal';
38import { isPlanet } from 'lib/utils/point';
52 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
53 const _pendingInvites = pendingPoints.getOrElse([]).length;
57 <Grid.Item cols={[1, 11]}>
63 className={cn('t-right underline pointer-hover', {
64 gray4: sentInvites.getOrElse(0) === 0,
73 {acceptedInvites.getOrElse(0)} / {_totalInvites}
75 {_pendingInvites > 0 && (
76 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
77 {_pendingInvites} pending
88 available={availableInvites}
90 accepted={acceptedInvites}
95 pendingPoints={pendingPoints}
96 acceptedPoints={acceptedPoints}
102 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
103 <div className="p4 pv8 t-center gray4">
104 Start your invite group by adding members
109 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
115 onClick={() => setShowInviteForm(true)}>
119 {showInviteForm && <Inviter />}
120 <Grid.Item full className="mb2" />
125export default function Point() {
126 const { pop, push, names } = useLocalRouter();
127 const { wallet, authToken } = useWallet();
128 const { pointCursor } = usePointCursor();
129 const point = need.point(pointCursor);
130 const { getDetails } = usePointCache();
132 const { api, getInvites } = useRoller();
138 setPendingTransactions,
140 } = useRollerStore();
142 const pointSize = azimuth.getPointSize(point);
143 const details = need.details(getDetails(point));
144 const isStarOrGalaxy = pointSize !== azimuth.PointSize.Planet;
145 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
146 const networkKeysNotSet =
147 !currentL2 && isStarOrGalaxy && networkRevision === 0;
149 const [showModal, setShowModal] = useState(networkKeysNotSet);
152 if (networkKeysNotSet) {
155 }, [networkKeysNotSet]);
158 const loadL2Info = async () => {
159 const getTransactions = async () => {
160 const pointInfo = await api.getPoint(Number(point));
162 console.log('POINT INFO', pointInfo);
164 setCurrentPoint(pointInfo);
165 getInvites(isL2(pointInfo.dominion));
172 }, [api, point, authToken, setPendingTransactions]); // eslint-disable-line
174 const { isParent, canManage, canSpawn, canVote } = useCurrentPermissions();
177 const l1Invites = useInvites(point);
186 const showInvites = !(
187 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
190 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
192 const loadedInvites = Just.hasInstance(availableInvites);
194 // availableInvites.getOrElse(0) === 0
196 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
198 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
200 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
202 const goUrbitID = useCallback(() => push(names.URBIT_ID), [push, names]);
204 const goResidents = useCallback(() => push(names.RESIDENTS), [push, names]);
206 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
211 const planet = isPlanet(point);
213 const [showInviteForm, setShowInviteForm] = useState(false);
215 const senateButton = (() => {
216 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
233 // sync the current cursor
234 useSyncExtras([point]);
236 const address = need.addressFromWallet(wallet);
237 const numPending = pendingTransactions.filter(
238 ({ rawTx }) => rawTx?.tx?.type === 'spawn'
249 hideTimer={!!numPending}
250 numInvites={invites.length}
251 hideInvites={networkKeysNotSet}
254 <Greeting point={point} />
256 <div className="transaction">
257 <Row className="title-row">
258 <div className="title">
259 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
261 <div className="rollup-timer">
262 <Icon icon="Clock" />
266 <Row className="info-row">
267 <LayerIndicator layer={2} size="sm" />
268 <div className="date"></div>
274 address={Just(address)}
275 animationMode={'slide'}
279 <Grid.Item full as={Flex} justify="between">
282 subtitle="Manage peers that you service"
283 onClick={goResidents}
287 {planet && hasInvites && (
289 showInviteForm={showInviteForm}
290 setShowInviteForm={setShowInviteForm}
291 acceptedInvites={acceptedInvites}
292 acceptedPoints={acceptedPoints}
293 availableInvites={availableInvites}
295 pendingPoints={pendingPoints}
296 sentInvites={sentInvites}
297 showInvites={showInvites}
300 {!loadedInvites && planet && (
301 <Grid.Item className="mv2" full>
302 Invite Group <Blinky />
305 {/* {inviteButton} */}
306 <Grid.Item full as={Flex} justify="between">
309 subtitle="Identity and security settings"
310 icon={<Icon icon="User" />}
312 disabled={!canManage}
315 <Grid.Item full as={Flex} justify="between">
318 subtitle="Urbit OS Settings"
319 icon={<Icon icon="Server" />}
321 disabled={!canManage}
330 onClick={goIssuePoint}>
338 <Modal show={showModal} hide={() => setShowModal(false)}>
339 <Box className="network-keys-modal">
340 <Box className="close" onClick={() => setShowModal(false)}>
343 <Box className="title">Network Keys Not Set</Box>
344 <Box className="message">
345 This point's network keys are not set. The network keys must be set
346 to spawn points or migrate to Layer 2. Please set them in Urbit OS
349 <Row className="buttons">
350 <Button className="cancel" onClick={() => setShowModal(false)}>
353 <Button className="migrate" onClick={goUrbitOS}>
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