1import React, { useCallback, useState } from 'react';
2import { Nothing } from 'folktale/maybe';
3import { Grid, Text, H5, Flex } from 'indigo-react';
5import { usePointCursor } from 'store/pointCursor';
6import { usePointCache } from 'store/pointCache';
8import { useLocalRouter } from 'lib/LocalRouter';
9import * as need from 'lib/need';
10import { segmentNetworkKey } from 'lib/keys';
11import { formatDotsWithTime } from 'lib/dateFormat';
13import ViewHeader from 'components/ViewHeader';
14import MiniBackButton from 'components/MiniBackButton';
19} from 'components/Buttons';
20import FooterButton from 'components/FooterButton';
21import WarningBox from 'components/WarningBox';
22import DownloadKeyfileButton from 'components/DownloadKeyfileButton';
24const renderNetworkKey = key => {
25 const segments = segmentNetworkKey(key);
31 return segments.join('\n');
34function useSetKeys() {
35 const setting = false;
37 const setKeys = useCallback(async () => {}, []);
46export default function AdminNetworkingKeys() {
47 const { push, names, pop } = useLocalRouter();
48 const { pointCursor } = usePointCursor();
49 const { getDetails, getRekeyDate } = usePointCache();
51 const point = need.point(pointCursor);
52 const details = getDetails(point);
54 const hasKeys = details.matchWith({
56 Just: ({ value: details }) => parseInt(details.keyRevisionNumber, 10) > 0,
58 const [configuring, setConfiguring] = useState(false);
60 const { setKeys, setting, didSet } = useSetKeys();
62 const goRelocate = useCallback(() => push(names.RELOCATE), [push, names]);
63 const configureTransaction = useCallback(() => setConfiguring(true), [
67 const inDefaultState = !configuring && !setting && !didSet;
69 const renderTitle = () => {
71 return 'Networking keys are now set. Download your Keyfile to authenticate Arvo.';
75 return 'Setting Network Keys...';
79 return 'Networking keys have not yet been set.';
85 const renderButton = () => {
87 return <Grid.Item full as={DownloadKeyfileButton} solid />;
90 if (configuring || setting) {
91 return <Grid.Item full as={GenerateButton} solid onClick={setKeys} />;
95 <Grid.Item full as={ForwardButton} solid onClick={configureTransaction}>
96 {hasKeys ? 'Reset' : 'Set'} Networking Keys
101 const renderNetworkKeySection = (title, key) => (
103 <Grid.Item full as={H5} className="mt3 gray4">
108 <Grid.Item full as={Text} className="f5 gray4">
112 Just: ({ value: key }) => (
114 <Grid.Item full as="code" className="f5 wrap">
117 <Grid.Item full as="code" className="f5 wrap">
118 {renderNetworkKey(key)}
126 const renderDetail = (title, value) => (
127 <Flex.Item as={Flex} col>
128 <Flex.Item as={H5} className="gray4">
133 <Flex.Item as={Text} className="f5 gray4">
137 Just: ({ value }) => <Flex.Item as={Text}>{value}</Flex.Item>,
142 const renderDetails = () => {
145 {renderNetworkKeySection(
147 details.map(d => d.authenticationKey)
149 {renderNetworkKeySection(
151 details.map(d => d.encryptionKey)
153 <Grid.Item full as={Flex} row justify="between" className="mt3">
154 {renderDetail('Revision', details.map(d => d.keyRevisionNumber))}
155 {renderDetail('Continuity Era', details.map(d => d.continuityNumber))}
158 details.map(d => d.cryptoSuiteVersion)
162 <Grid.Item full as={Flex} row justify="between" className="mt3">
165 getRekeyDate(point).map(date =>
167 Ok: r => formatDotsWithTime(r.value),
168 Error: () => Nothing(),
181 <Grid.Item full as={MiniBackButton} onClick={() => pop()} />
183 <Grid.Item full as={ViewHeader}>
188 <Grid.Item full as={Text} className="mb3">
190 ? 'Here are your public keys that authenticate your Arvo.'
191 : 'Set your networking keys to authenticate with Arvo.'}
196 <Grid.Item full as={WarningBox} className="mb3">
197 You need this keyfile to authenticate with Arvo.
203 {inDefaultState && renderDetails()}
207 <Grid.Item full as={BootArvoButton} disabled />
214 <FooterButton onClick={goRelocate} disabled>
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