@@ -43,8 +43,12 @@ import formatBytes from '../../../utils/formatBytes';
4343import './StorageDirectoryPage.scss' ;
4444import { formatTimestamp } from '../../../utils/dateTimeUtils' ;
4545import useLoadData from '../../../utils/hooks/useLoadData' ;
46- import { DEFAULT_PAGE_SIZE } from '../../../utils/constants/storageBrowser' ;
46+ import { DEFAULT_PAGE_SIZE , FileUploadStatus } from '../../../utils/constants/storageBrowser' ;
4747import CreateAndUploadAction from './CreateAndUploadAction/CreateAndUploadAction' ;
48+ import DragAndDrop from '../../../reactComponents/DragAndDrop/DragAndDrop' ;
49+ import UUID from '../../../utils/string/UUID' ;
50+ import { UploadItem } from '../../../utils/hooks/useFileUpload/util' ;
51+ import FileUploadQueue from '../../../reactComponents/FileUploadQueue/FileUploadQueue' ;
4852
4953interface StorageDirectoryPageProps {
5054 fileStats : FileStats ;
@@ -71,6 +75,7 @@ const StorageDirectoryPage = ({
7175 const [ loadingFiles , setLoadingFiles ] = useState < boolean > ( false ) ;
7276 const [ tableHeight , setTableHeight ] = useState < number > ( 100 ) ;
7377 const [ selectedFiles , setSelectedFiles ] = useState < StorageDirectoryTableData [ ] > ( [ ] ) ;
78+ const [ filesToUpload , setFilesToUpload ] = useState < UploadItem [ ] > ( [ ] ) ;
7479
7580 const [ pageSize , setPageSize ] = useState < number > ( DEFAULT_PAGE_SIZE ) ;
7681 const [ pageNumber , setPageNumber ] = useState < number > ( 1 ) ;
@@ -213,6 +218,18 @@ const StorageDirectoryPage = ({
213218 [ setSearchTerm ]
214219 ) ;
215220
221+ const onFilesDrop = ( newFiles : File [ ] ) => {
222+ const newUploadItems = newFiles . map ( file => {
223+ return {
224+ file,
225+ filePath : fileStats . path ,
226+ uuid : UUID ( ) ,
227+ status : FileUploadStatus . Pending
228+ } ;
229+ } ) ;
230+ setFilesToUpload ( prevFiles => [ ...prevFiles , ...newUploadItems ] ) ;
231+ } ;
232+
216233 useEffect ( ( ) => {
217234 //TODO: handle table resize
218235 const calculateTableHeight = ( ) => {
@@ -262,40 +279,50 @@ const StorageDirectoryPage = ({
262279 currentPath = { fileStats . path }
263280 setLoadingFiles = { setLoadingFiles }
264281 onSuccessfulAction = { reloadData }
282+ onFilesUpload = { onFilesDrop }
265283 />
266284 </ div >
267285 </ div >
268286
269- < Spin spinning = { loadingFiles || listDirectoryLoading } >
270- < Table
271- className = { className }
272- columns = { getColumns ( tableData [ 0 ] ?? { } ) }
273- dataSource = { tableData }
274- onRow = { onRowClicked }
275- pagination = { false }
276- rowClassName = { rowClassName }
277- rowKey = { r => `${ r . path } _${ r . type } _${ r . mtime } ` }
278- rowSelection = { {
279- type : 'checkbox' ,
280- ...rowSelection
281- } }
282- scroll = { { y : tableHeight } }
283- data-testid = { `${ testId } ` }
284- locale = { locale }
285- { ...restProps }
286- />
287-
288- { filesData ?. page && filesData ?. page ?. total_count > 0 && (
289- < Pagination
290- onNextPageButtonClicked = { onNextPageButtonClicked }
291- onPageNumberChange = { setPageNumber }
292- onPageSizeChange = { setPageSize }
293- onPreviousPageButtonClicked = { onPreviousPageButtonClicked }
294- pageSize = { pageSize }
295- pageStats = { filesData ?. page }
287+ < DragAndDrop onDrop = { onFilesDrop } >
288+ < Spin spinning = { loadingFiles || listDirectoryLoading } >
289+ < Table
290+ className = { className }
291+ columns = { getColumns ( tableData [ 0 ] ?? { } ) }
292+ dataSource = { tableData }
293+ onRow = { onRowClicked }
294+ pagination = { false }
295+ rowClassName = { rowClassName }
296+ rowKey = { r => `${ r . path } _${ r . type } _${ r . mtime } ` }
297+ rowSelection = { {
298+ type : 'checkbox' ,
299+ ...rowSelection
300+ } }
301+ scroll = { { y : tableHeight } }
302+ data-testid = { `${ testId } ` }
303+ locale = { locale }
304+ { ...restProps }
296305 />
297- ) }
298- </ Spin >
306+
307+ { filesData ?. page && filesData ?. page ?. total_count > 0 && (
308+ < Pagination
309+ onNextPageButtonClicked = { onNextPageButtonClicked }
310+ onPageNumberChange = { setPageNumber }
311+ onPageSizeChange = { setPageSize }
312+ onPreviousPageButtonClicked = { onPreviousPageButtonClicked }
313+ pageSize = { pageSize }
314+ pageStats = { filesData ?. page }
315+ />
316+ ) }
317+ </ Spin >
318+ </ DragAndDrop >
319+ { filesToUpload . length > 0 && (
320+ < FileUploadQueue
321+ filesQueue = { filesToUpload }
322+ onClose = { ( ) => setFilesToUpload ( [ ] ) }
323+ onComplete = { reloadData }
324+ />
325+ ) }
299326 </ >
300327 ) ;
301328} ;
0 commit comments