Added option to download selected items in object browser (#1286)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
Alex
2021-12-03 13:10:32 -06:00
committed by GitHub
parent a39e468b96
commit 569d2390b9
2 changed files with 44 additions and 14 deletions

View File

@@ -42,11 +42,11 @@ const UploadFile = (props: SVGProps<SVGSVGElement>) => {
<g transform="translate(-0.036 -24.789)">
<path d="M239.185,72.637A29.456,29.456,0,0,0,209.767,43.6H128.581l-1.119-1.512c-5.078-6.886-12.756-17.3-26.1-17.3H49.394A29.455,29.455,0,0,0,19.972,54.21a19.778,19.778,0,0,0,.236,3.081V70.763A29.818,29.818,0,0,0,.036,98.947c0,.6.023,1.205.076,1.806L9.8,207.577A29.8,29.8,0,0,0,39.545,236.2h175.73A29.8,29.8,0,0,0,245.021,207.6L254.947,100.8q.088-.928.09-1.852A29.792,29.792,0,0,0,239.185,72.637ZM49.394,44.808h51.963c6.586,0,13.645,18.813,20.7,18.813h87.709a9.429,9.429,0,0,1,9.4,9.4v4.7H40.213V54.206h-.229A9.431,9.431,0,0,1,49.394,44.808ZM225.031,206.43a9.781,9.781,0,0,1-9.754,9.748H39.547a9.779,9.779,0,0,1-9.75-9.748L20.051,98.947A9.782,9.782,0,0,1,29.8,89.192H225.268a9.788,9.788,0,0,1,9.758,9.755Z" />
<g transform="translate(-351.512 467)">
<g transform="translate(352 -469)" clip-path="url(#a)">
<g transform="translate(352 -469)" clipPath="url(#a)">
<path d="M118.046,203.4c0,12.123,18.976,12.123,18.976,0V126.379l10.748,10.443c8.823,8.569,22.236-4.465,13.415-13.034L134.3,97.665a9.685,9.685,0,0,0-13.526,0L93.89,123.788c-8.82,8.568,4.592,21.6,13.415,13.034l10.745-10.443V203.4Z" />
</g>
</g>
<g clip-path="url(#b)">
<g clipPath="url(#b)">
<path d="M56.052,158.235c0-12.121,18.978-12.121,18.978,0v66.218H185.056V158.235c0-12.121,18.973-12.121,18.973,0v75.436a9.357,9.357,0,0,1-9.486,9.217h-129a9.357,9.357,0,0,1-9.486-9.217V158.235Zm64.5,45.162c0,12.123,18.976,12.123,18.976,0V126.379l10.748,10.443c8.823,8.569,22.236-4.465,13.415-13.034L136.8,97.665a9.685,9.685,0,0,0-13.526,0L96.394,123.788c-8.82,8.568,4.593,21.6,13.415,13.034l10.745-10.443V203.4Z" />
</g>
</g>

View File

@@ -79,7 +79,7 @@ import SearchBox from "../../../../Common/SearchBox";
import withSuspense from "../../../../Common/Components/withSuspense";
import { displayName } from "./utils";
import UploadFolderIcon from "../../../../../../icons/UploadFolderIcon";
import { UploadFolderIcon, DownloadIcon } from "../../../../../../icons";
const AddFolderIcon = React.lazy(
() => import("../../../../../../icons/AddFolderIcon")
@@ -753,7 +753,7 @@ const ListObjects = ({
return state ? "Yes" : "No";
};
const downloadObject = (object: BucketObject) => {
const downloadObject = (object: BucketObject | RewindObject) => {
const identityDownload = btoa(
`${bucketName}-${object.name}-${new Date().getTime()}-${Math.random()}`
);
@@ -990,6 +990,25 @@ const ListObjects = ({
setSelectedObjects(elements);
};
const downloadSelected = () => {
if (selectedObjects.length !== 0) {
let itemsToDownload: BucketObject[] | RewindObject[] = [];
const filterFunction = (currValue: BucketObject | RewindObject) =>
selectedObjects.includes(currValue.name);
if (rewindEnabled) {
itemsToDownload = rewind.filter(filterFunction);
} else {
itemsToDownload = filteredRecords.filter(filterFunction);
}
itemsToDownload.forEach((filteredItem) => {
downloadObject(filteredItem);
});
}
};
return (
<React.Fragment>
{shareFileModalOpen && selectedPreview && (
@@ -1175,22 +1194,33 @@ const ListObjects = ({
placeholder="Search Objects"
/>
</SecureComponent>
<SecureComponent
scopes={[IAM_SCOPES.S3_DELETE_OBJECT]}
resource={bucketName}
>
<div>
<Button
variant="contained"
color="primary"
endIcon={<DeleteIcon />}
onClick={() => {
setDeleteMultipleOpen(true);
}}
endIcon={<DownloadIcon />}
onClick={downloadSelected}
disabled={selectedObjects.length === 0}
>
Delete Selected
Download Selected
</Button>
</SecureComponent>
<SecureComponent
scopes={[IAM_SCOPES.S3_DELETE_OBJECT]}
resource={bucketName}
>
<Button
variant="contained"
color="primary"
endIcon={<DeleteIcon />}
onClick={() => {
setDeleteMultipleOpen(true);
}}
disabled={selectedObjects.length === 0}
>
Delete Selected
</Button>
</SecureComponent>
</div>
</Grid>
<Grid item xs={12}>
<br />