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';
51 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
52 const _pendingInvites = pendingPoints.getOrElse([]).length;
56 <Grid.Item cols={[1, 11]}>
62 className={cn('t-right underline pointer-hover', {
63 gray4: sentInvites.getOrElse(0) === 0,
72 {acceptedInvites.getOrElse(0)} / {_totalInvites}
74 {_pendingInvites > 0 && (
75 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
76 {_pendingInvites} pending
87 available={availableInvites}
89 accepted={acceptedInvites}
94 pendingPoints={pendingPoints}
95 acceptedPoints={acceptedPoints}
101 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
102 <div className="p4 pv8 t-center gray4">
103 Start your invite group by adding members
108 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
114 onClick={() => setShowInviteForm(true)}>
118 {showInviteForm && <Inviter />}
119 <Grid.Item full className="mb2" />
124export default function Point() {
125 const { pop, push, names } = useLocalRouter();
126 const { wallet, authToken } = useWallet();
127 const { pointCursor } = usePointCursor();
128 const point = need.point(pointCursor);
129 const { getDetails } = usePointCache();
131 const { api, getInvites } = useRoller();
137 setPendingTransactions,
139 } = useRollerStore();
141 const pointSize = azimuth.getPointSize(point);
142 const details = need.details(getDetails(point));
143 const isStarOrGalaxy = pointSize !== azimuth.PointSize.Planet;
144 const networkRevision = convertToInt(details.keyRevisionNumber, 10);
145 const networkKeysNotSet =
146 !currentL2 && isStarOrGalaxy && networkRevision === 0;
148 const [showModal, setShowModal] = useState(networkKeysNotSet);
151 if (networkKeysNotSet) {
154 }, [networkKeysNotSet]);
157 const loadL2Info = async () => {
158 const getTransactions = async () => {
159 const pointInfo = await api.getPoint(Number(point));
161 console.log('POINT INFO', pointInfo);
163 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 isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
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.length;
247 hideTimer={!!numPending}
248 numInvites={invites.length}
249 hideInvites={networkKeysNotSet}
252 <Greeting point={point} />
254 <div className="transaction">
255 <Row className="title-row">
256 <div className="title">
257 {numPending} Planet{numPending > 1 ? 's' : ''} Spawned
259 <div className="rollup-timer">
260 <Icon icon="Clock" />
264 <Row className="info-row">
265 <LayerIndicator layer={2} size="sm" />
266 <div className="date"></div>
272 address={Just(address)}
273 animationMode={'slide'}
277 <Grid.Item full as={Flex} justify="between">
280 subtitle="Manage peers that you service"
281 onClick={goResidents}
285 {isPlanet && hasInvites && (
287 showInviteForm={showInviteForm}
288 setShowInviteForm={setShowInviteForm}
289 acceptedInvites={acceptedInvites}
290 acceptedPoints={acceptedPoints}
291 availableInvites={availableInvites}
293 pendingPoints={pendingPoints}
294 sentInvites={sentInvites}
295 showInvites={showInvites}
298 {!loadedInvites && isPlanet && (
299 <Grid.Item className="mv2" full>
300 Invite Group <Blinky />
303 {/* {inviteButton} */}
304 <Grid.Item full as={Flex} justify="between">
307 subtitle="Identity and security settings"
308 icon={<Icon icon="User" />}
310 disabled={!canManage}
313 <Grid.Item full as={Flex} justify="between">
316 subtitle="Urbit OS Settings"
317 icon={<Icon icon="Server" />}
319 disabled={!canManage}
328 onClick={goIssuePoint}>
336 <Modal show={showModal} hide={() => setShowModal(false)}>
337 <Box className="network-keys-modal">
338 <Box className="close" onClick={() => setShowModal(false)}>
341 <Box className="title">Network Keys Not Set</Box>
342 <Box className="message">
343 This point's network keys are not set. The network keys must be set
344 to spawn points or migrate to Layer 2. Please set them in Urbit OS
347 <Row className="buttons">
348 <Button className="cancel" onClick={() => setShowModal(false)}>
351 <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