Skip to content

Commit

Permalink
Fix file uploader after merge ...
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Oct 25, 2023
1 parent b3e0605 commit b42c3af
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/dashboard/view/media/FileUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import css from './FileUploader.module.scss'
const styles = fromModule(css)

export interface FileUploaderProps {
destination: UploadDestination
destination?: UploadDestination
max?: number
toggleSelect?: (id: Entry) => void
position?: 'left' | 'right'
Expand All @@ -27,6 +27,7 @@ export function FileUploader({
toggleSelect,
position = 'right'
}: FileUploaderProps) {
const readOnly = !destination
const {upload, uploads} = useUploads(toggleSelect)
const [isOver, setIsOver] = useState(false)
const isUploading = uploads.length > 0
Expand All @@ -37,7 +38,8 @@ export function FileUploader({
const todo = uploads.length - uploadsDone
const [showUploads, setShowUploads] = useState(true)
function uploadFiles(files: FileList) {
return upload(files, destination)
if (readOnly) return
return upload([...files], destination)
}
function handleFileInput(event: ChangeEvent<HTMLInputElement>) {
const {files} = event.target
Expand Down Expand Up @@ -88,12 +90,14 @@ export function FileUploader({
<VStack className={styles.root.content()}>
<HStack as="header" className={styles.root.header()}>
<label className={styles.root.header.label()}>
<input
type="file"
className={styles.root.header.label.input()}
multiple={max !== 1}
onChange={handleFileInput}
/>
{!readOnly && (
<input
type="file"
className={styles.root.header.label.input()}
multiple={max !== 1}
onChange={handleFileInput}
/>
)}
<HStack center gap={8}>
<Icon icon={IcOutlineCloudUpload} size={17} />
<span>{description}</span>
Expand Down

0 comments on commit b42c3af

Please sign in to comment.