Skip to content

Commit

Permalink
Merge pull request #1798 from holium/RE-189
Browse files Browse the repository at this point in the history
Upload ID flow
  • Loading branch information
drunkplato authored Jun 19, 2023
2 parents 98893e5 + 0a2cdff commit da67dfe
Show file tree
Hide file tree
Showing 54 changed files with 1,336 additions and 247 deletions.
9 changes: 8 additions & 1 deletion app/src/renderer/onboarding/steps/PaymentStep.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ const PaymentStepView = ({ products, setStep }: PaymentStepViewProps) => {

await thirdEarthApi.updatePaymentStatus(token, invoiceId, 'OK');
await thirdEarthApi.updatePlanetStatus(token, serverId, 'sold');
await thirdEarthApi.ship(token, serverId, productId.toString(), invoiceId);
await thirdEarthApi.provisionalShipEntry({
token,
patp: serverId,
shipType: 'planet',
product: productId.toString(),
invoiceId,
});

setStep('/booting');

Expand All @@ -85,6 +91,7 @@ const PaymentStepView = ({ products, setStep }: PaymentStepViewProps) => {

return (
<PaymentDialog
productType="planet"
products={products}
productId={productId}
patp={serverId}
Expand Down
21 changes: 17 additions & 4 deletions hosting-holium-com/src/pages/account/custom-domain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo, useState } from 'react';
import { useToggle } from '@holium/design-system/util';
import {
AccountCustomDomainDialog,
OnboardingStorage,
UserContextProvider,
useUser,
} from '@holium/shared';
Expand Down Expand Up @@ -63,9 +64,19 @@ const CustomDomainPresenter = () => {
goToPage(accountPageUrl[section]);
};

const onClickBuyIdentity = () => {
goToPage(accountPageUrl['Get Hosting'], {
back_url: accountPageUrl['Custom Domain'],
const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/payment', {
back_url: '/account/custom-domain',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account/custom-domain',
});
};

Expand All @@ -79,10 +90,12 @@ const CustomDomainPresenter = () => {
errorMessage={errorMessage}
successMessage={successMessage}
submitting={submitting.isOn}
isUploadedIdentity={ship?.product_type === 'byop-p'}
setSelectedIdentity={setSelectedIdentity}
onChangeDomain={setDomain}
onSubmit={onSubmit}
onClickBuyIdentity={onClickBuyIdentity}
onClickPurchaseId={onClickPurchaseId}
onClickUploadId={onClickUploadId}
onClickSidebarSection={onClickSidebarSection}
onExit={logout}
/>
Expand Down
27 changes: 22 additions & 5 deletions hosting-holium-com/src/pages/account/download-realm.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AccountDownloadRealmDialog,
OnboardingStorage,
UserContextProvider,
useUser,
} from '@holium/shared';
Expand All @@ -13,6 +14,10 @@ const DownloadRealmPresenter = () => {
const { goToPage, logout } = useNavigation();
const { ships, selectedIdentity, setSelectedIdentity } = useUser();

const identities = ships.map((ship) => ship.patp);
const ship = ships.find((ship) => ship.patp === selectedIdentity);
const isUploadedIdentity = ship?.product_type === 'byop-p';

const onClickSidebarSection = (section: string) => {
if (section === 'Get Hosting') {
goToPage(accountPageUrl[section], {
Expand All @@ -22,9 +27,19 @@ const DownloadRealmPresenter = () => {
goToPage(accountPageUrl[section]);
};

const onClickBuyIdentity = () => {
goToPage(accountPageUrl['Get Hosting'], {
back_url: accountPageUrl['Download Realm'],
const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/payment', {
back_url: '/account/download-realm',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account/download-realm',
});
};

Expand All @@ -40,14 +55,16 @@ const DownloadRealmPresenter = () => {
return (
<Page title="Account / Download Realm" isProtected>
<AccountDownloadRealmDialog
identities={ships.map((ship) => ship.patp)}
identities={identities}
selectedIdentity={selectedIdentity}
isUploadedIdentity={isUploadedIdentity}
setSelectedIdentity={setSelectedIdentity}
onDownloadMacM1={onDownloadMacM1}
onDownloadMacIntel={onDownloadMacIntel}
onDownloadWindows={onDownloadWindows}
onDownloadLinux={onDownloadLinux}
onClickBuyIdentity={onClickBuyIdentity}
onClickPurchaseId={onClickPurchaseId}
onClickUploadId={onClickUploadId}
onClickSidebarSection={onClickSidebarSection}
onExit={logout}
/>
Expand Down
26 changes: 20 additions & 6 deletions hosting-holium-com/src/pages/account/get-realm.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { AccountGetRealmDialog, UserContextProvider } from '@holium/shared';
import {
AccountGetRealmDialog,
OnboardingStorage,
UserContextProvider,
} from '@holium/shared';

import { thirdEarthApi } from 'util/thirdEarthApi';

Expand Down Expand Up @@ -27,15 +31,25 @@ export const joinWaitlist = async (email: string) => {
const GetRealmPresenter = () => {
const { goToPage, logout } = useNavigation();

const goToGetHosting = () => {
goToPage(accountPageUrl['Get Hosting'], {
const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/payment', {
back_url: '/account/get-realm',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account/get-realm',
});
};

const onClickSidebarSection = (section: string) => {
if (section === 'Get Hosting') {
goToGetHosting();
onClickPurchaseId();
} else {
goToPage(accountPageUrl[section]);
}
Expand All @@ -44,10 +58,10 @@ const GetRealmPresenter = () => {
return (
<Page title="Account / Get Realm" isProtected>
<AccountGetRealmDialog
onClickGetHosting={goToGetHosting}
onClickJoinWaitlist={joinWaitlist}
onClickSidebarSection={onClickSidebarSection}
onClickBuyIdentity={() => {}}
onClickPurchaseId={onClickPurchaseId}
onClickUploadId={onClickUploadId}
onExit={logout}
/>
</Page>
Expand Down
27 changes: 22 additions & 5 deletions hosting-holium-com/src/pages/account/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ const HostingPresenter = () => {
const changeMaintenanceWindowModal = useToggle(false);
const ejectIdModal = useToggle(false);

const identities = useMemo(() => ships.map((ship) => ship.patp), [ships]);
const selectedShip = useMemo(
() => ships.find((ship) => ship.patp === selectedIdentity),
[ships, selectedIdentity]
);
const isUploadedIdentity = useMemo(
() => selectedShip?.product_type === 'byop-p',
[selectedShip]
);

const onClickSidebarSection = (section: string) => {
goToPage(accountPageUrl[section]);
Expand Down Expand Up @@ -172,9 +177,19 @@ const HostingPresenter = () => {
return false;
};

const onClickBuyIdentity = () => {
goToPage(accountPageUrl['Get Hosting'], {
back_url: accountPageUrl['Hosting'],
const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/payment', {
back_url: '/account',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage('/choose-id', {
back_url: '/account',
});
};

Expand Down Expand Up @@ -212,13 +227,15 @@ const HostingPresenter = () => {
onSubmit={onSubmitEjectId}
/>
<AccountHostingDialog
identities={ships.map((ship) => ship.patp)}
identities={identities}
selectedIdentity={selectedIdentity}
isUploadedIdentity={isUploadedIdentity}
email={email}
serverUrl={selectedShip?.link}
serverCode={selectedShip?.code}
serverMaintenanceWindow={selectedShip?.maintenance_window}
onClickBuyIdentity={onClickBuyIdentity}
onClickPurchaseId={onClickPurchaseId}
onClickUploadId={onClickUploadId}
setSelectedIdentity={setSelectedIdentity}
onClickChangeEmail={changeEmailModal.toggleOn}
onClickChangePassword={changePasswordModal.toggleOn}
Expand Down
18 changes: 15 additions & 3 deletions hosting-holium-com/src/pages/account/storage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';

import {
AccountStorageDialog,
OnboardingStorage,
UserContextProvider,
useUser,
} from '@holium/shared';
Expand All @@ -26,9 +27,19 @@ const S3StoragePresenter = () => {
goToPage(accountPageUrl[section]);
};

const onClickBuyIdentity = () => {
const onClickUploadId = () => {
OnboardingStorage.set({
productType: 'byop-p',
});
goToPage('/payment', {
back_url: '/account/storage',
});
};

const onClickPurchaseId = () => {
OnboardingStorage.remove('productType');
goToPage(accountPageUrl['Get Hosting'], {
back_url: accountPageUrl['Storage'],
back_url: '/account/storage',
});
};

Expand Down Expand Up @@ -63,7 +74,8 @@ const S3StoragePresenter = () => {
total: Number(s3Info?.storageCapacity),
}}
dataSent={{ networkUsage, minioUsage }}
onClickBuyIdentity={onClickBuyIdentity}
onClickPurchaseId={onClickPurchaseId}
onClickUploadId={onClickUploadId}
onClickSidebarSection={onClickSidebarSection}
onExit={logout}
/>
Expand Down
57 changes: 47 additions & 10 deletions hosting-holium-com/src/pages/booting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,48 @@ export default function Booting() {
const intervalRef = useRef<NodeJS.Timer>();
const [logs, setLogs] = useState<string[]>(['Booting started.']);
const booting = useToggle(true);
const error = useToggle(false);

const isBYOP = useToggle(false);

const pollShipStatus = useCallback(async () => {
const { serverId, token } = OnboardingStorage.get();
const { serverId, token, productType } = OnboardingStorage.get();

if (!serverId || !token) return;
if (!token) return;

const ships = await thirdEarthApi.getUserShips(token);
const ship = Object.values(ships).find((s) => s.patp === serverId);
let ship = Object.values(ships).find((s) => s.patp === serverId);

if (ship?.ship_type === 'hardError') {
booting.toggleOff();
error.toggleOn();
}

if (productType === 'byop-p') {
isBYOP.toggleOn();
ship = Object.values(ships)
.filter((s) => s.product_type === 'byop-p' && s.is_migration)
.sort((a, b) => {
if (a.created_at > b.created_at) return -1;
if (a.created_at < b.created_at) return 1;
return 0;
})[0];
}

if (!ship) return;

if (logs.length === 1) {
setLogs((logs) => [
...logs,
`${serverId} will be ready in a few minutes.`,
]);
if (productType === 'byop-p') {
setLogs((logs) => [
...logs,
`Your uploaded identity will be ready in 5-10 minutes.`,
]);
} else {
setLogs((logs) => [
...logs,
`${serverId} will be ready in a few minutes.`,
]);
}
} else if (logs.length === 2) {
setLogs((logs) => [...logs, 'Go touch some grass.']);
}
Expand Down Expand Up @@ -56,9 +82,15 @@ export default function Booting() {
serverCode,
});
}
}, [booting, logs]);
}, [logs, booting, isBYOP]);

const onNext = () => {
if (isBYOP.isOn) {
return goToPage('/download');
}

const onNext = useCallback(() => goToPage('/credentials'), [goToPage]);
return goToPage('/credentials');
};

useEffect(() => {
if (!booting.isOn) return;
Expand All @@ -71,7 +103,12 @@ export default function Booting() {

return (
<Page title="Booting your identity" isProtected>
<BootingDialog logs={logs} isBooting={booting.isOn} onNext={onNext} />
<BootingDialog
logs={logs}
isBooting={booting.isOn}
isError={error.isOn}
onNext={onNext}
/>
</Page>
);
}
2 changes: 1 addition & 1 deletion hosting-holium-com/src/pages/claim.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function ClaimInvite({
if (full_account) {
goToPage('/login', {
email,
redirect: '/account/download-realm',
redirect_url: '/account/download-realm',
});
}
}, []);
Expand Down
Loading

1 comment on commit da67dfe

@vercel
Copy link

@vercel vercel bot commented on da67dfe Jun 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

hosting-holium-com – ./hosting-holium-com

realm-onboarding.vercel.app
hosting-holium-com-git-master-holium.vercel.app
hosting.holium.com
hosting-holium-com-holium.vercel.app

Please sign in to comment.