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 Blinky from 'components/Blinky';
14import BarGraph from 'components/BarGraph';
15import Chip from 'components/Chip';
16import InviteSigilList from 'components/InviteSigilList';
17import { ForwardButton, HostingButton } from 'components/Buttons';
18import CopyButton from 'components/CopyButton';
19import { matchBlinky } from 'components/Blinky';
20import DownloadSigilButton from 'components/DownloadSigilButton';
22import * as need from 'lib/need';
23import useInvites from 'lib/useInvites';
24import { useSyncOwnedPoints } from 'lib/useSyncPoints';
25import useCurrentPermissions from 'lib/useCurrentPermissions';
26import { useLocalRouter } from 'lib/LocalRouter';
28import Inviter from 'views/Invite/Inviter';
30export default function Point() {
31 const { pop, push, names } = useLocalRouter();
32 const { pointCursor } = usePointCursor();
34 const { wallet } = useWallet();
35 const point = need.point(pointCursor);
43 } = useCurrentPermissions();
45 // fetch the invites for the current cursor
46 const invites = useInvites(point);
55 const showInvites = !(
56 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
59 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
62 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
63 const _pendingInvites = pendingPoints.getOrElse([]).length;
65 const loadedInvites = Just.hasInstance(availableInvites);
67 // availableInvites.getOrElse(0) === 0
69 const goAdmin = useCallback(() => push(names.ADMIN), [push, names]);
71 const goSenate = useCallback(() => push(names.SENATE), [push, names]);
73 const goSigil = useCallback(() => push(names.SIGIL_GENERATOR), [push, names]);
75 const goCohort = useCallback(() => push(names.INVITE_COHORT), [push, names]);
77 const goUrbitOS = useCallback(() => push(names.URBIT_OS), [push, names]);
79 const goPartiesSetPoolSize = useCallback(
80 () => push(names.PARTY_SET_POOL_SIZE),
84 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
89 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
91 const [showInviteForm, setShowInviteForm] = useState(false);
93 const goBoot = useCallback(() => push(names.BOOT), [push, names]);
94 const goHosting = useCallback(() => push(names.HOSTING), [push, names]);
96 const inviteButton = (() => {
97 if (azimuth.getPointSize(point) === azimuth.PointSize.Star) {
103 disabled={!isActiveOwner}
104 onClick={goPartiesSetPoolSize}>
115 const senateButton = (() => {
116 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
133 // sync the current cursor
134 useSyncOwnedPoints([point]);
136 const address = need.addressFromWallet(wallet);
139 <View pop={pop} inset>
140 <Greeting point={point} />
143 address={Just(address)}
144 animationMode={'slide'}
147 {isPlanet && hasInvites && (
149 <Grid.Item cols={[1, 11]}>
155 className={cn('t-right underline pointer-hover', {
156 gray4: sentInvites.getOrElse(0) === 0,
163 <Flex align="center">
165 {acceptedInvites.getOrElse(0)} / {_totalInvites}
167 {_pendingInvites > 0 && (
168 <Flex.Item as={Chip} className="bg-yellow1 yellow4">
169 {_pendingInvites} pending
180 available={availableInvites}
182 accepted={acceptedInvites}
187 pendingPoints={pendingPoints}
188 acceptedPoints={acceptedPoints}
194 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
195 <div className="p4 pv8 t-center gray4">
196 Start your invite group by adding members
201 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
207 onClick={() => setShowInviteForm(true)}>
211 {showInviteForm && <Inviter />}
212 <Grid.Item full className="mb2" />
215 {!loadedInvites && isPlanet && (
216 <Grid.Item className="mv2" full>
217 Invite Group <Blinky />
221 <Grid className="pt2">
223 <Grid.Item full as={ForwardButton} onClick={goSigil}>
230 disabled={!canManage}
238 disabled={!canManage}
250 onClick={goIssuePoint}>
260 detail="Boot your computer"
265 <Grid.Item full as={HostingButton} onClick={goHosting} />
271 accessory={code && <CopyButton text={code} />}
272 detail={code || notice}
274 detailClassName="mono">
278 <Grid.Item full as={DownloadSigilButton} point={point} />
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