|
@@ -1,5 +1,5 @@
|
|
|
import { useTranslation } from 'react-i18next'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
-import { useCallback, useEffect, useState } from 'react'
|
|
|
|
|
|
|
+import { useCallback, useEffect, useRef, useState } from 'react'
|
|
|
import Uppy from '@uppy/core'
|
|
import Uppy from '@uppy/core'
|
|
|
import XHRUpload from '@uppy/xhr-upload'
|
|
import XHRUpload from '@uppy/xhr-upload'
|
|
|
import { Dashboard } from '@uppy/react'
|
|
import { Dashboard } from '@uppy/react'
|
|
@@ -35,6 +35,7 @@ export default function FileTreeUploadDoc() {
|
|
|
const [conflicts, setConflicts] = useState<Conflict[]>([])
|
|
const [conflicts, setConflicts] = useState<Conflict[]>([])
|
|
|
const [folderConflicts, setFolderConflicts] = useState<Conflict[]>([])
|
|
const [folderConflicts, setFolderConflicts] = useState<Conflict[]>([])
|
|
|
const [overwrite, setOverwrite] = useState(false)
|
|
const [overwrite, setOverwrite] = useState(false)
|
|
|
|
|
+ const dashboardRef = useRef<HTMLDivElement>(null)
|
|
|
|
|
|
|
|
const maxNumberOfFiles = 180
|
|
const maxNumberOfFiles = 180
|
|
|
const maxFileSize = getMeta('ol-ExposedSettings').maxUploadSize
|
|
const maxFileSize = getMeta('ol-ExposedSettings').maxUploadSize
|
|
@@ -263,6 +264,22 @@ export default function FileTreeUploadDoc() {
|
|
|
!overwrite && !showFolderUploadConflicts && conflicts.length > 0
|
|
!overwrite && !showFolderUploadConflicts && conflicts.length > 0
|
|
|
const showDashboard = !showFileUploadConfilcts && !showFolderUploadConflicts
|
|
const showDashboard = !showFileUploadConfilcts && !showFolderUploadConflicts
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ if (!showDashboard) {
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ const frameId = window.requestAnimationFrame(() => {
|
|
|
|
|
+ dashboardRef.current
|
|
|
|
|
+ ?.querySelector<HTMLButtonElement>('.uppy-Dashboard-browse')
|
|
|
|
|
+ ?.focus()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ return () => {
|
|
|
|
|
+ window.cancelAnimationFrame(frameId)
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [showDashboard])
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<>
|
|
<>
|
|
|
{error && (
|
|
{error && (
|
|
@@ -284,30 +301,32 @@ export default function FileTreeUploadDoc() {
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
{showDashboard && (
|
|
{showDashboard && (
|
|
|
- <Dashboard
|
|
|
|
|
- uppy={uppy}
|
|
|
|
|
- showProgressDetails
|
|
|
|
|
- // note={`Up to ${maxNumberOfFiles} files, up to ${maxFileSize / (1024 * 1024)}MB`}
|
|
|
|
|
- height={400}
|
|
|
|
|
- width="100%"
|
|
|
|
|
- showLinkToFileUploadResult={false}
|
|
|
|
|
- proudlyDisplayPoweredByUppy={false}
|
|
|
|
|
- // allow files or folders to be selected
|
|
|
|
|
- fileManagerSelectionType="both"
|
|
|
|
|
- locale={{
|
|
|
|
|
- strings: {
|
|
|
|
|
- // Text to show on the droppable area.
|
|
|
|
|
- // `%{browse}` is replaced with a link that opens the system file selection dialog.
|
|
|
|
|
- // TODO: 'drag_here' or 'drop_files_here_to_upload'?
|
|
|
|
|
- // dropHereOr: `${t('drag_here')} ${t('or')} %{browse}`,
|
|
|
|
|
- dropPasteBoth: `Drop or paste your files, folder, or images here. %{browseFiles} or %{browseFolders} from your computer.`,
|
|
|
|
|
- // Used as the label for the link that opens the system file selection dialog.
|
|
|
|
|
- // browseFiles: t('select_from_your_computer')
|
|
|
|
|
- browseFiles: 'Select files',
|
|
|
|
|
- browseFolders: 'select a folder',
|
|
|
|
|
- },
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
|
|
+ <div ref={dashboardRef}>
|
|
|
|
|
+ <Dashboard
|
|
|
|
|
+ uppy={uppy}
|
|
|
|
|
+ showProgressDetails
|
|
|
|
|
+ // note={`Up to ${maxNumberOfFiles} files, up to ${maxFileSize / (1024 * 1024)}MB`}
|
|
|
|
|
+ height={400}
|
|
|
|
|
+ width="100%"
|
|
|
|
|
+ showLinkToFileUploadResult={false}
|
|
|
|
|
+ proudlyDisplayPoweredByUppy={false}
|
|
|
|
|
+ // allow files or folders to be selected
|
|
|
|
|
+ fileManagerSelectionType="both"
|
|
|
|
|
+ locale={{
|
|
|
|
|
+ strings: {
|
|
|
|
|
+ // Text to show on the droppable area.
|
|
|
|
|
+ // `%{browse}` is replaced with a link that opens the system file selection dialog.
|
|
|
|
|
+ // TODO: 'drag_here' or 'drop_files_here_to_upload'?
|
|
|
|
|
+ // dropHereOr: `${t('drag_here')} ${t('or')} %{browse}`,
|
|
|
|
|
+ dropPasteBoth: `Drop or paste your files, folder, or images here. %{browseFiles} or %{browseFolders} from your computer.`,
|
|
|
|
|
+ // Used as the label for the link that opens the system file selection dialog.
|
|
|
|
|
+ // browseFiles: t('select_from_your_computer')
|
|
|
|
|
+ browseFiles: 'Select files',
|
|
|
|
|
+ browseFolders: 'select a folder',
|
|
|
|
|
+ },
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
)}
|
|
)}
|
|
|
</>
|
|
</>
|
|
|
)
|
|
)
|