on master help sign in
bridge: handle activation links for expired planets
commit154ca108f69e9710db6d847bc30d4ca70bb6f55b authorPatrick O'Sullivan <patrick@osullivan.io> dateSun 6 Mar 2022, 15:31 (5 years ago) parent3fe131d
6 files changed+162−50
src/lib/expiredPlanetsByStar.json+27 src/lib/useCheckExpired.ts+24 src/views/Activate/ActivateCode.tsx+58−50 src/views/Activate/CodeExpired.scss+3 src/views/Activate/CodeExpired.tsx+49 tool-versions+1
src/lib/expiredPlanetsByStar.jsonnew file+27
@@ -0,0 +1,27 @@
1+{
2+ "~tomwet": {
3+ "ownership": "0x7915e2909455658cc868af49a4cd77f926320e68",
4+ "planets": [
5+ {
6+ "patp": "~podtug-davtyl",
7+ "oldTicket": "~lachus-bartep-navsum-rinten"
8+ },
9+ {
10+ "patp": "~hocdec-hosdev",
11+ "oldTicket": "~rapdur-ponteg-nopweg-pardyt"
12+ },
13+ {
14+ "patp": "~taswyn-montex",
15+ "oldTicket": "~ponryc-firfur-livdyn-boslyt"
16+ },
17+ {
18+ "patp": "~rosrus-tollyr",
19+ "oldTicket": "~hilpet-tabryc-novnet-nilmur"
20+ },
21+ {
22+ "patp": "~picrys-tardet",
23+ "oldTicket": "~bidfyr-satlyn-pictec-walsug"
24+ }
25+ ]
26+ }
27+}
src/lib/useCheckExpired.tsnew file+24
@@ -0,0 +1,24 @@
1+import expiredPlanetsByStar from './expiredPlanetsByStar.json';
2+
3+export default function useIsExpired(patp: string | null) {
4+ let isExpired = false;
5+ let expiredPatps: string[] = [];
6+
7+ for (const [_, value] of Object.entries(expiredPlanetsByStar)) {
8+ const { planets } = value;
9+
10+ planets.forEach(planet => expiredPatps.push(planet.patp));
11+ }
12+
13+ function patpInExpiredList(patp: string): boolean {
14+ return expiredPatps.includes(patp);
15+ }
16+
17+ if (patp !== null) {
18+ isExpired = patpInExpiredList(patp);
19+ }
20+
21+ return {
22+ isExpired,
23+ };
24+}
src/views/Activate/ActivateCode.tsx+58−50
@@ -2,10 +2,12 @@ import { useCallback, useMemo } from 'react';
22
33import View from 'components/View';
44import ActivateView from './ActivateView';
5+import CodeExpired from './CodeExpired';
56
67import { useLocalRouter } from 'lib/LocalRouter';
78import useImpliedTicket from 'lib/useImpliedTicket';
89import useHasDisclaimed from 'lib/useHasDisclaimed';
10+import useIsExpired from 'lib/useCheckExpired';
911
1012import { ReactComponent as PlaceholderSigil } from 'assets/blank-planet-sigil.svg';
1113import { FadeablePointPresenter as PointPresenter } from './PointPresenter';
@@ -35,58 +37,64 @@ export default function ActivateCode() {
3537 [impliedTicket, impliedPatp]
3638 );
3739
40+ const { isExpired } = useIsExpired(impliedPatp);
41+
3842 return (
3943 <View inset hideBack>
40− <ActivateView
41− hideBack={hasInitialValues}
42− header={
43− <ActivateHeader
44− content={
45− hasInitialValues
46− ? 'Welcome. This is your Urbit ID.'
47− : 'Activate a Planet'
48− }
49− />
50− }
51− footer={<ActivateCodeForm afterSubmit={goToMasterKey} />}>
52− <Box className="flex-col align-center justify-center w-full h-full">
53− {hasInitialValues ? (
54− <Box>
55− <p
56− className="mb2 sans gray5"
57− style={{
58− fontSize: 14,
59− textAlign: 'center',
60− maxWidth: '38ch',
61− marginLeft: 'auto',
62− }}>
63− An Urbit ID is your unique identity that you use to communicate
64− on Urbit. You own it forever.
65− </p>
66− <p
67− className="mb2 sans gray5"
68− style={{
69− fontSize: 14,
70− textAlign: 'center',
71− maxWidth: '38ch',
72− marginLeft: 'auto',
73− }}>
74− To activate your Urbit ID, begin by claiming it via the link
75− below.
76− </p>
77− </Box>
78− ) : (
79− <Box className="mb2 sans gray5" fontSize={14}>
80− Enter your planet activation code below.
81− </Box>
82− )}
83− {impliedPatp ? (
84− <PointPresenter patp={impliedPatp} className="mb6 mt7" />
85− ) : (
86− <PlaceholderSigil className="mv9" style={{ marginTop: 78 }} />
87− )}
88− </Box>
89− </ActivateView>
44+ {isExpired ? (
45+ <CodeExpired />
46+ ) : (
47+ <ActivateView
48+ hideBack={hasInitialValues}
49+ header={
50+ <ActivateHeader
51+ content={
52+ hasInitialValues
53+ ? 'Welcome. This is your Urbit ID.'
54+ : 'Activate a Planet'
55+ }
56+ />
57+ }
58+ footer={<ActivateCodeForm afterSubmit={goToMasterKey} />}>
59+ <Box className="flex-col align-center justify-center w-full h-full">
60+ {hasInitialValues ? (
61+ <Box>
62+ <p
63+ className="mb2 sans gray5"
64+ style={{
65+ fontSize: 14,
66+ textAlign: 'center',
67+ maxWidth: '38ch',
68+ marginLeft: 'auto',
69+ }}>
70+ An Urbit ID is your unique identity that you use to
71+ communicate on Urbit. You own it forever.
72+ </p>
73+ <p
74+ className="mb2 sans gray5"
75+ style={{
76+ fontSize: 14,
77+ textAlign: 'center',
78+ maxWidth: '38ch',
79+ marginLeft: 'auto',
80+ }}>
81+ To activate your Urbit ID, begin by claiming it via the link
82+ below.
83+ </p>
84+ </Box>
85+ ) : (
86+ <Box className="mb2 sans gray5" fontSize={14}>
87+ Enter your planet activation code below.
88+ </Box>
89+ )}
90+ {impliedPatp ? (
91+ <PointPresenter patp={impliedPatp} className="mb6 mt7" />
92+ ) : (
93+ <PlaceholderSigil className="mv9" style={{ marginTop: 78 }} />
94+ )}
95+ </Box>
96+ </ActivateView>
97+ )}
9098 </View>
9199 );
92100}
src/views/Activate/CodeExpired.scssnew file+3
@@ -0,0 +1,3 @@
1+.expired-view {
2+ min-height: 200px;
3+}
src/views/Activate/CodeExpired.tsxnew file+49
@@ -0,0 +1,49 @@
1+import View from 'components/View';
2+
3+import { Box, Button } from '@tlon/indigo-react';
4+import { FadeableActivateHeader as ActivateHeader } from './ActivateHeader';
5+import useFadeIn from './useFadeIn';
6+import Window from 'components/L2/Window/Window';
7+
8+import './CodeExpired.scss';
9+
10+export default function CodeExpired() {
11+ // Fade in on load
12+ useFadeIn();
13+
14+ return (
15+ <Window className="expired-view mt10">
16+ <Box className="w-full">
17+ <ActivateHeader content="This invite link has expired." />
18+ </Box>
19+ <Box className="flex-col align-center justify-center w-full h-full">
20+ <Box>
21+ <p
22+ className="mb2 sans gray5"
23+ style={{
24+ fontSize: 14,
25+ textAlign: 'center',
26+ maxWidth: '38ch',
27+ marginLeft: 'auto',
28+ }}>
29+ Please contact the entity you received it from.
30+ </p>
31+ </Box>
32+ <a className="flex-col m4 w-full" href="https://urbit.org/">
33+ <Button
34+ className="m2"
35+ backgroundColor={'black'}
36+ color={'white'}
37+ padding={'16px'}
38+ fontFamily="Inter"
39+ height={'40px'}
40+ fontWeight={'400'}
41+ fontSize={'14px'}
42+ borderRadius={'4px'}>
43+ Learn more
44+ </Button>
45+ </a>
46+ </Box>
47+ </Window>
48+ );
49+}
tool-versionsnew file+1
@@ -0,0 +1 @@
1+nodejs 14.17.0