Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Display Uploader error in console, as promised #635

Merged
merged 5 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion eslint.packages.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: ['./node_modules/hd-scripts/eslint/ts.js'],
parserOptions: {
project: ['./tsconfig.json', 'packages/*/tsconfig.json'],
project: ['./tsconfig.json', 'packages/*/tsconfig.json', 'examples/*/*/tsconfig.json'],
ecmaFeatures: {
jsx: true,
},
Expand Down
11 changes: 9 additions & 2 deletions examples/react/components/src/Uploader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { ReactNode } from 'react'
import React, { ReactNode, useEffect } from 'react'
import { Uploader, useUploader, UploadStatus, CARMetadata, UploadProgress, AnyLink } from '@w3ui/react'
import { UploadLoader } from './Loader'

Expand Down Expand Up @@ -30,6 +30,13 @@ function Uploading ({ file, files, storedDAGShards, uploadProgress }: UploadingP
}

function Errored ({ error }: { error?: Error }): ReactNode {
useEffect(() => {
if (error != null) {
// eslint-disable-next-line no-console
console.error('Uploader Error:', error)
}
}, [error])

return (
<div className='flex flex-col items-center'>
<h1>
Expand Down Expand Up @@ -136,7 +143,7 @@ export function UploaderForm ({ multiple, allowDirectory }: UploaderFormProps):
return (
<Uploader.Form className="m-12">
<div className='relative shadow h-52 p-8 rounded-md bg-white/5 hover:bg-white/20 border-2 border-dotted border-zinc-950 flex flex-col justify-center items-center text-center'>
<label className={`${hasFile ? 'hidden' : 'block h-px w-px overflow-hidden absolute whitespace-nowrap'}`}>File:</label>
<label className={`${hasFile ? 'hidden' : 'block h-px w-px overflow-hidden absolute whitespace-nowrap'}`}>File:</label>
<Uploader.Input multiple={multiple} allowDirectory={allowDirectory} className={`${hasFile ? 'hidden' : 'block absolute inset-0 cursor-pointer w-full opacity-0'}`} />
<UploaderContents />
{hasFile ? '' : <span>Drag files or Click to Browse</span>}
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
},
{
"path": "packages/react"
},
{
"path": "examples/react/components"
}
]
}
Loading