-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1635 from bipuladh/file-upload
Add support for file uploads in S3 browser
- Loading branch information
Showing
27 changed files
with
1,271 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
packages/odf/components/s3-browser/objects-list/ObjectListWithSidebar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import * as React from 'react'; | ||
import { LoadingBox } from '@odf/shared/generic/status-box'; | ||
import { useParams } from 'react-router-dom-v5-compat'; | ||
import { NoobaaS3Context } from '../noobaa-context'; | ||
import UploadSidebar from '../upload-objects'; | ||
import { UploadProgress } from '../upload-objects'; | ||
import { FileUploadComponent } from '../upload-objects'; | ||
import { ObjectsList } from './ObjectsList'; | ||
|
||
type ObjectListWithSidebarProps = { | ||
obj: { refresh: boolean; triggerRefresh: () => void }; | ||
}; | ||
|
||
export const ObjectListWithSidebar: React.FC<ObjectListWithSidebarProps> = ({ | ||
obj: { refresh, triggerRefresh }, | ||
}) => { | ||
const [isExpanded, setExpanded] = React.useState(false); | ||
const [uploadProgress, setUploadProgress] = React.useState<UploadProgress>( | ||
{} | ||
); | ||
const [completionTime, setCompletionTime] = React.useState<number>(); | ||
|
||
const abortAll = React.useCallback(() => { | ||
Object.values(uploadProgress).forEach((upload) => upload?.abort?.()); | ||
}, [uploadProgress]); | ||
|
||
const { bucketName } = useParams(); | ||
|
||
const { noobaaS3 } = React.useContext(NoobaaS3Context); | ||
|
||
const closeSidebar = () => setExpanded(false); | ||
const showSidebar = () => setExpanded(true); | ||
|
||
return ( | ||
<UploadSidebar | ||
isExpanded={isExpanded} | ||
closeSidebar={closeSidebar} | ||
uploadProgress={uploadProgress} | ||
completionTime={completionTime} | ||
mainContent={ | ||
<> | ||
<FileUploadComponent | ||
client={noobaaS3} | ||
bucketName={bucketName} | ||
uploadProgress={uploadProgress} | ||
setUploadProgress={setUploadProgress} | ||
showSidebar={showSidebar} | ||
abortAll={abortAll} | ||
setCompletionTime={setCompletionTime} | ||
triggerRefresh={triggerRefresh} | ||
/> | ||
{refresh ? <ObjectsList /> : <LoadingBox />} | ||
</> | ||
} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.