1import React, { useCallback, useState } from 'react';
2import cn from 'classnames';
3import { Just } from 'folktale/maybe';
4import { Grid, Flex } 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 { matchBlinky } from 'components/Blinky';
16import DownloadSigilButton from 'components/DownloadSigilButton';
17import BarGraph from 'components/BarGraph';
18import Chip from 'components/Chip';
19import InviteSigilList from 'components/InviteSigilList';
21import * as need from 'lib/need';
22import useInvites from 'lib/useInvites';
23import { useSyncOwnedPoints } from 'lib/useSyncPoints';
24import useCurrentPermissions from 'lib/useCurrentPermissions';
25import { useLocalRouter } from 'lib/LocalRouter';
26import useKeyfileGenerator from 'lib/useKeyfileGenerator';
28import InviteCohort from 'views/Invite/Cohort';
30export default function Point() {
31 const { pop, push, names } = useLocalRouter();
32 const { pointCursor } = usePointCursor();
34 const { wallet } = useWallet();
35 const point = need.point(pointCursor);
37 const { code, notice } = useKeyfileGenerator();
45 } = useCurrentPermissions();
47 // fetch the invites for the current cursor
48 const invites = useInvites(point);
57 const showInvites = !(
58 acceptedInvites.getOrElse(0) === 0 && sentInvites.getOrElse(0) === 0
61 const hasInvites = showInvites || availableInvites.getOrElse(0) !== 0;
64 sentInvites.getOrElse(0) + availableInvites.getOrElse(0);
65 const _pendingInvites = pendingPoints.getOrElse([]).length;
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 goInvite = useCallback(() => push(names.INVITE), [push, names]);
75 const goParty = useCallback(() => push(names.PARTY), [push, names]);
77 const goPartiesSetPoolSize = useCallback(
78 () => push(names.PARTY_SET_POOL_SIZE),
82 const goIssuePoint = useCallback(() => push(names.ISSUE_CHILD), [
87 const isPlanet = azimuth.getPointSize(point) === azimuth.PointSize.Planet;
89 const [showInviteForm, setShowInviteForm] = useState(false);
91 const inviteButton = (() => {
92 switch (azimuth.getPointSize(point)) {
93 case azimuth.PointSize.Planet:
94 const availableInvitesText = matchBlinky(availableInvites);
100 disabled={!isActiveOwner}
102 Invite <sup>{availableInvitesText}</sup>
108 case azimuth.PointSize.Star:
114 disabled={!isActiveOwner}
115 onClick={goPartiesSetPoolSize}>
127 const senateButton = (() => {
128 if (azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy) {
145 // sync the current cursor
146 useSyncOwnedPoints([point]);
148 const address = need.addressFromWallet(wallet);
151 <View pop={pop} inset>
152 <Greeting point={point} />
155 address={Just(address)}
156 animationMode={'slide'}
159 {isPlanet && hasInvites && (
161 <Grid.Item cols={[1, 11]}>
167 className={cn('t-right underline', {
168 gray4: sentInvites.getOrElse(0) === 0,
175 <Flex align="center">
177 {acceptedInvites.getOrElse(0) + _pendingInvites} /{' '}
180 {_pendingInvites > 0 && (
181 <Flex.Item as={Chip} color="yellow">
182 {_pendingInvites} pending
193 available={availableInvites}
195 accepted={acceptedInvites}
200 pendingPoints={pendingPoints}
201 acceptedPoints={acceptedPoints}
207 <Grid.Item full className="b-gray4 b-dotted b1 self-center">
208 <div className="p4 pv8 t-center gray4">
209 Start your invite group by adding members
214 {!showInviteForm && availableInvites.getOrElse(0) > 0 && (
219 onClick={() => setShowInviteForm(true)}>
223 {showInviteForm && <InviteCohort />}
227 <Grid className="pt2">
232 disabled={!canManage}
244 onClick={goIssuePoint}>
251 <Grid.Item full as={BootUrbitOSButton} />
256 accessory={code && <CopyButton text={code} />}
257 detail={code || notice}
259 detailClassName="mono">
263 <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