1import React, { useCallback, useState, useEffect } from 'react';
2import cn from 'classnames';
3import { Grid, Button, SelectInput, Flex } from 'indigo-react';
4import * as ob from 'urbit-ob';
5import { azimuth } from 'azimuth-js';
7import { usePointCursor } from 'store/pointCursor';
8import { usePointCache } from 'store/pointCache';
10import useCurrentPointName from 'lib/useCurrentPointName';
11import useKeyfileGenerator from 'lib/useKeyfileGenerator';
12import * as need from 'lib/need';
14import { OutButton, ForwardButton } from 'components/Buttons';
15import CopyButton from 'components/CopyButton';
16import NetworkingKeys from 'components/NetworkingKeys';
17import ProgressButton from 'components/ProgressButton';
19import BridgeForm from 'form/BridgeForm';
20import { useLocalRouter } from 'lib/LocalRouter';
21import { useHosting } from 'store/hosting';
22import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
24export default function UrbitOSHome() {
25 const { pointCursor } = usePointCursor();
26 const { getDetails } = usePointCache();
28 const { push, names } = useLocalRouter();
30 const point = need.point(pointCursor);
31 const details = need.details(getDetails(point));
33 const sponsor = ob.patp(details.sponsor);
35 const [showKeys, setShowKeys] = useState(false);
37 const showSponsor = azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy;
38 const toggleShowKeys = useCallback(() => setShowKeys(!showKeys), [
43 const goNetworkingKeys = useCallback(() => push(names.NETWORKING_KEYS), [
48 const goChangeSponsor = useCallback(() => push(names.CHANGE_SPONSOR), [
57 <Grid.Item full className="mv7 f5">
66 detail="A sponsor finds new peers in your network"
67 accessory={<u>Change</u>}
68 onClick={goChangeSponsor}>
69 <span className="mono">{sponsor}</span>
70 <span className="f7 bg-black white p1 ml2 r4">SPONSOR</span>
76 <Grid.Item full as={ForwardButton} onClick={goNetworkingKeys}>
83 accessory={showKeys ? '▲' : '▼'}
84 onClick={toggleShowKeys}>
87 {showKeys && <Grid.Item full as={NetworkingKeys} point={point} />}
93// eslint-disable-next-line
95 const bind = useKeyfileGenerator();
96 const { keyfile, code, notice } = bind;
97 const ship = useHosting();
111 const [synced, setSynced] = useState(false);
113 if (unknown && !synced) {
117 }, [syncStatus, unknown, setSynced, synced]);
119 const createShip = useCallback(() => ship.create(keyfile), [keyfile, ship]);
121 const name = useCurrentPointName();
122 const options = [{ text: 'Tlon', value: 'tlon' }];
124 const props = { name, options, ship };
126 const renderMain = useCallback(() => {
130 <Grid.Item cols={[1, 9]} as={OutButton} solid success href={url}>
133 <Grid.Item cols={[9, 13]} as={Button} className="b-black b1" center>
146 onClick={createShip}>
158 progress={bootProgress}>
159 {bootMessage || 'Connecting'}
174 const renderDetails = useCallback(() => {
178 <Grid.Item cols={[1, 9]} className="gray4">
179 <span className="mono">{name}</span> is connected to Tlon
187 <Grid.Item full className="gray4">
188 <span className="gray3">Status:</span> Disconnected
190 <span className="f6">Last connected: 4m ago</span>
200 <Grid.Item full className="f5" as={Flex}>
201 <Flex.Item>Urbit OS </Flex.Item>
204 { green3: ship.running, grey4: !ship.running },
207 {ship.running ? 'Connected' : 'Disconnected'}
210 <BridgeForm initialValues={{ provider: 'tlon' }}>
219 label="Host Provider"
230 as={DownloadKeyfileButton}
233 detail="A keyfile authenticates your Urbit ID to Urbit OS"
240 accessory={code && <CopyButton text={code} />}
241 detail={code || notice}
243 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