on master help sign in
ux: new user network keys flow enhancements

More changes based on feedback collected and synthesized by ~fallyn. - Alerts the user when viewing a Point without set networking keys - Conditionally shows different Network Key actions based on state - Adds type for azimuth#getPoint query

commit495e4fe24d22dbdcaaf682c66c7144635870be35 authortomholford <tomholford@users.noreply.github.com> dateSun 4 Jul 2021, 23:46 (5 years ago) parentf899a56
2 files changed+54−11
src/types/PointDetailsType.ts+28 src/views/UrbitOS/Home.js → src/views/UrbitOS/Home.tsx+26−11
src/types/PointDetailsType.tsnew file+28
@@ -0,0 +1,28 @@
1+// Response returned by azimuth#getPoint
2+export type PointDetails = {
3+ 0: string;
4+ 1: string;
5+ 2: string;
6+ 3: string;
7+ 4: string;
8+ 5: string;
9+ 6: string;
10+ 7: string;
11+ 8: string;
12+ 9: string;
13+ active: boolean;
14+ authenticationKey: string;
15+ continuityNumber: string;
16+ cryptoSuiteVersion: string;
17+ encryptionKey: string;
18+ escapeRequested: boolean;
19+ escapeRequestedTo: string;
20+ hasSponsor: boolean;
21+ keyRevisionNumber: string;
22+ managementProxy: string;
23+ owner: string;
24+ spawnProxy: string;
25+ sponsor: string;
26+ transferProxy: string;
27+ votingProxy: string;
28+};
src/views/UrbitOS/Home.js → src/views/UrbitOS/Home.tsxrenamed+26−11
@@ -12,6 +12,8 @@ import { ForwardButton } from 'components/Buttons';
1212import NetworkingKeys from 'components/NetworkingKeys';
1313
1414import { useLocalRouter } from 'lib/LocalRouter';
15+import { PointDetails } from 'types/pointDetailsType';
16+import WarningBox from 'components/WarningBox';
1517
1618export default function UrbitOSHome({ manualNetworkSeed }) {
1719 const { pointCursor } = usePointCursor();
@@ -20,7 +22,7 @@ export default function UrbitOSHome({ manualNetworkSeed }) {
2022 const { push, names } = useLocalRouter();
2123
2224 const point = need.point(pointCursor);
23− const details = need.details(getDetails(point));
25+ const details: PointDetails = need.details(getDetails(point));
2426
2527 const sponsor = ob.patp(details.sponsor);
2628
@@ -29,6 +31,10 @@ export default function UrbitOSHome({ manualNetworkSeed }) {
2931 const showSponsor = azimuth.getPointSize(point) !== azimuth.PointSize.Galaxy;
3032 const toggleShowKeys = useCallback(() => setShowKeys(s => !s), [setShowKeys]);
3133
34+ // The initial key revision number is 0, and increments when set
35+ const hasSetNetworkingKeys = details.keyRevisionNumber !== '0';
36+ const networkKeysAction = hasSetNetworkingKeys ? 'Reset' : 'Initiate';
37+
3238 const goNetworkingKeys = useCallback(() => push(names.NETWORKING_KEYS), [
3339 names,
3440 push,
@@ -61,17 +67,26 @@ export default function UrbitOSHome({ manualNetworkSeed }) {
6167
6268 <Grid.Divider />
6369 <Grid.Item full as={ForwardButton} onClick={goNetworkingKeys}>
64− Reset Networking Keys
65− </Grid.Item>
66− <Grid.Divider />
67− <Grid.Item
68− full
69− as={ForwardButton}
70− accessory={showKeys ? '▼' : '▲'}
71− onClick={toggleShowKeys}>
72− View Networking Keys
70+ {networkKeysAction} Networking Keys
7371 </Grid.Item>
74− {showKeys && <Grid.Item full as={NetworkingKeys} point={point} />}
72+ {hasSetNetworkingKeys && (
73+ <>
74+ <Grid.Divider />
75+ <Grid.Item
76+ full
77+ as={ForwardButton}
78+ accessory={showKeys ? '▼' : '▲'}
79+ onClick={toggleShowKeys}>
80+ View Networking Keys
81+ </Grid.Item>
82+ {showKeys && <Grid.Item full as={NetworkingKeys} point={point} />}
83+ </>
84+ )}
85+ {!hasSetNetworkingKeys && (
86+ <Grid.Item full as={WarningBox} className="mt4">
87+ Networking Keys are required to generate a keyfile
88+ </Grid.Item>
89+ )}
7590 </Grid>
7691 </>
7792 );