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 { CopyButtonWide } 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';
23import useLifecycle from 'lib/useLifecycle';
25export default function UrbitOSHome({ manualNetworkSeed }) {
26 const { pointCursor } = usePointCursor();
27 const { getDetails } = usePointCache();
29 const { push, names } = useLocalRouter();
31 const point = need.point(pointCursor);
32 const details = need.details(getDetails(point));
34 const sponsor = ob.patp(details.sponsor);
36 const [showKeys, setShowKeys] = useState(false);
38 const showSponsor = azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy;
39 const toggleShowKeys = useCallback(() => setShowKeys(s => !s), [setShowKeys]);
41 const goNetworkingKeys = useCallback(() => push(names.NETWORKING_KEYS), [
46 const goChangeSponsor = useCallback(() => push(names.CHANGE_SPONSOR), [
52 <Hosting manualNetworkSeed={manualNetworkSeed} />
55 <Grid.Item full className="mv7 f5">
64 detail="A sponsor finds new peers in your network"
65 accessory={<u>Change</u>}
66 onClick={goChangeSponsor}>
67 <span className="mono">{sponsor}</span>
68 <span className="f7 bg-black white p1 ml2 r4">SPONSOR</span>
74 <Grid.Item full as={ForwardButton} onClick={goNetworkingKeys}>
81 accessory={showKeys ? '▼' : '▲'}
82 onClick={toggleShowKeys}>
85 {showKeys && <Grid.Item full as={NetworkingKeys} point={point} />}
91// eslint-disable-next-line
92function Hosting({ manualNetworkSeed }) {
93 const bind = useKeyfileGenerator(manualNetworkSeed);
94 const { keyfile, code } = bind;
95 const ship = useHosting();
110 const createShip = useCallback(() => ship.create(keyfile), [keyfile, ship]);
112 const name = useCurrentPointName();
113 const options = [{ text: 'Tlon', value: 'tlon' }];
115 const renderMain = useCallback(() => {
119 <Grid.Item cols={[1, 9]} as={OutButton} solid success href={url}>
122 {/* Unsupported for now */}
123 {/* <Grid.Item cols={[9, 13]} as={Button} className="b-black b1" center> */}
136 onClick={createShip}>
148 progress={bootProgress}>
149 {bootMessage || 'Connecting'}
164 const renderDetails = useCallback(() => {
168 <Grid.Item cols={[1, 9]} className="gray4">
169 <span className="mono">{name}</span> is connected to Tlon
174 if (!keyfile && ship.missing) {
176 <Grid.Item full className="gray4">
177 Please reset your networking keys in order to use hosting
181 }, [name, ship, keyfile]);
187 <Grid.Item full className="f5">
195 <Grid.Item full className="f5" as={Flex}>
196 <Flex.Item>Urbit OS </Flex.Item>
199 { green3: ship.running, gray4: !ship.running },
202 {ship.running ? 'Connected' : 'Disconnected'}
205 <BridgeForm initialValues={{ provider: 'tlon' }}>
214 label="Host Provider"
226 as={DownloadKeyfileButton}
229 detail="A keyfile authenticates your Urbit ID to Urbit OS"
238 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