1import React, { useCallback, useState } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex, Button } from 'indigo-react';
5import { azimuth } from 'azimuth-js';
7import { usePointCursor } from 'store/pointCursor';
8import { useWallet } from 'store/wallet';
10import View from 'components/View';
11import Greeting from 'components/Greeting';
12import Passport from 'components/Passport';
13import { ForwardButton, BootUrbitOSButton } from 'components/Buttons';
14import CopyButton from 'components/CopyButton';
15import Blinky from 'components/Blinky';
16import BarGraph from 'components/BarGraph';
17import Chip from 'components/Chip';
18import InviteSigilList from 'components/InviteSigilList';
20import * as need from 'lib/need';
21import useInvites from 'lib/useInvites';
22import { useSyncOwnedPoints } from 'lib/useSyncPoints';
23import useCurrentPermissions from 'lib/useCurrentPermissions';
24import { useLocalRouter } from 'lib/LocalRouter';
25import useKeyfileGenerator from 'lib/useKeyfileGenerator';
27import Inviter from 'views/Invite/Inviter';
29export default function Point() {
30 const { pop, push, names } = useLocalRouter();
31 const { pointCursor } = usePointCursor();
33 const { wallet } = useWallet();
34 const point = need.point(pointCursor);
36 const { code, notice } = useKeyfileGenerator();
44 } = useCurrentPermissions();
46 // fetch the invites for the current cursor
47 const invites = useInvites(point);
56 const showInvites = !(
57 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
60 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
63 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
64 const _pendingInvites = pendingPoints.getOrElse([]).length;
66 const loadedInvites = Just.hasInstance(availableInvites);
68 // availableInvites.getOrElse(0) === 0
70 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
72 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
74 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
76 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
78 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
80 const goPartiesSetPoolSize = useCallback(
81 () => push(names.PARTY_SET_POOL_SIZE),
85 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
90 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
92 const [showInviteForm, setShowInviteForm] = useState(false);
94 const inviteButton = (() => {
95 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
101 disabled={!isActiveOwner}
102 onClick={goPartiesSetPoolSize}>
113 const senateButton = (() => {
114 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
131 // sync the current cursor
132 useSyncOwnedPoints([point]);
134 const address = need.addressFromWallet(wallet);
137 <View pop={pop} inset>
138 <Greeting point={point} />
141 address={Just(address)}
142 animationMode={'slide'}
145 {isPlanet && hasInvites && (
147 <Grid.Item cols={[1, 11]}>
153 className={cn('t-right underline pointer-hover', {
154 gray4: sentInvites.getOrElse(0) === 0,
161 <Flex align="center">
163 {acceptedInvites.getOrElse(0)} / {_totalInvites}
165 {_pendingInvites > 0 && (
166 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
167 {_pendingInvites} pending
178 available={availableInvites}
180 accepted={acceptedInvites}
185 pendingPoints={pendingPoints}
186 acceptedPoints={acceptedPoints}
192 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
193 <div className="p4 pv8 t-center gray4">
194 Start your invite group by adding members
199 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
205 onClick={() => setShowInviteForm(true)}>
209 {showInviteForm && <Inviter />}
210 <Grid.Item full className="mb2" />
213 {!loadedInvites && isPlanet && (
214 <Grid.Item className="mv2" full>
215 Invite Group <Blinky />
219 <Grid className="pt2">
221 <Grid.Item full as={ForwardButton} onClick={goSigil}>
228 disabled={!canManage}
235 disabled={!canManage}
247 onClick={goIssuePoint}>
254 <Grid.Item full as={BootUrbitOSButton} />
259 accessory={code && <CopyButton text={code} />}
260 detail={code || notice}
262 detailClassName="mono">
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