Skip to content

Commit

Permalink
Display useful upload errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbroman committed Oct 2, 2023
1 parent 4194e39 commit 66ba57d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
19 changes: 17 additions & 2 deletions hosting-holium-com/src/pages/upload-pier.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { useEffect, useState } from 'react';

import { OnboardingStorage, UploadPierDialog } from '@holium/shared';
import {
OnboardingStorage,
uploadErrors,
UploadPierDialog,
} from '@holium/shared';

import { Page } from '../components/Page';
import { thirdEarthApi } from '../util/thirdEarthApi';
Expand Down Expand Up @@ -68,7 +72,18 @@ export default function UploadPierPage() {
const ship = await getUnbootedByopShip();
if (!ship) return false;

return ship.ship_type.includes('pierReceived');
// If ship_type includes any of the keys in uploadErrors,
// then the upload failed, and we should show the error.
const shipType = ship.ship_type;
const defaultAdvice = 'Please refresh this page and try again.';

if (Object.keys(uploadErrors).includes(shipType)) {
setError(`${uploadErrors[shipType]} ${defaultAdvice}`);
} else if (shipType === 'hardError') {
setError(`Something went wrong with your upload. ${defaultAdvice}`);
}

return shipType.includes('pierReceived');
};

const prepareSftpServer = async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { GrayButton } from '../../components/ChangeButton';
import { OnboardDialogDescription } from '../../onboarding';

// These errors are stored as the ship_type of the associated ship row in the database.
const uploadErrors: Record<string, string> = {
export const uploadErrors: Record<string, string> = {
invalidFileError:
'The uploaded .tar.gz or .zip file failed to be decompressed.',
invalidFileFormatError:
Expand Down
1 change: 1 addition & 0 deletions shared/src/onboarding/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export {
SUPPORT_EMAIL_ADDRESS,
} from './dialogs/AccountSupport/helpers';
export { AccountUnfinishedUploadDialog } from './dialogs/AccountUnfinishedUpload/AccountUnfinishedUploadDialog';
export { uploadErrors } from './dialogs/AccountUnfinishedUpload/AccountUnfinishedUploadDialogBody';
export { AddIdentityDialog } from './dialogs/AddIdentity/AddIdentityDialog';
export { BootingDialog } from './dialogs/Booting/BootingDialog';
export { ChooseIdentityDialog } from './dialogs/ChooseIdentity/ChooseIdentityDialog';
Expand Down

0 comments on commit 66ba57d

Please sign in to comment.