Add share action to listed objects (#1052)

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
Lenin Alevski
2021-09-20 08:42:50 -07:00
committed by GitHub
parent 00752d2bb1
commit d85b693751
3 changed files with 32 additions and 8 deletions

View File

@@ -96,6 +96,7 @@ import {
FileXlsIcon, FileXlsIcon,
FileZipIcon, FileZipIcon,
} from "../../../../../../icons"; } from "../../../../../../icons";
import ShareFile from "../ObjectDetails/ShareFile";
const commonIcon = { const commonIcon = {
backgroundRepeat: "no-repeat", backgroundRepeat: "no-repeat",
@@ -263,6 +264,7 @@ const ListObjects = ({
const [selectedPreview, setSelectedPreview] = useState<BucketObject | null>( const [selectedPreview, setSelectedPreview] = useState<BucketObject | null>(
null null
); );
const [shareFileModalOpen, setShareFileModalOpen] = useState<boolean>(false);
const internalPaths = get(match.params, "subpaths", ""); const internalPaths = get(match.params, "subpaths", "");
const bucketName = match.params["bucketName"]; const bucketName = match.params["bucketName"];
@@ -628,10 +630,19 @@ const ListObjects = ({
const openPreview = (fileObject: BucketObject) => { const openPreview = (fileObject: BucketObject) => {
setSelectedPreview(fileObject); setSelectedPreview(fileObject);
setPreviewOpen(true); setPreviewOpen(true);
}; };
const openShare = (fileObject: BucketObject) => {
setSelectedPreview(fileObject);
setShareFileModalOpen(true);
};
const closeShareModal = () => {
setShareFileModalOpen(false);
setSelectedPreview(null);
};
const tableActions = [ const tableActions = [
{ type: "view", onClick: openPath, sendOnlyId: true }, { type: "view", onClick: openPath, sendOnlyId: true },
{ {
@@ -640,6 +651,11 @@ const ListObjects = ({
disableButtonFunction: (item: string) => disableButtonFunction: (item: string) =>
extensionPreview(item) === "none", extensionPreview(item) === "none",
}, },
{
type: "share",
onClick: openShare,
disableButtonFunction: (item: string) => item.endsWith("/"),
},
{ {
type: "download", type: "download",
onClick: downloadObject, onClick: downloadObject,
@@ -788,13 +804,11 @@ const ListObjects = ({
const rewindCloseModal = (refresh: boolean) => { const rewindCloseModal = (refresh: boolean) => {
setRewindSelect(false); setRewindSelect(false);
if (refresh) {
}
}; };
const closePreviewWindow = () => { const closePreviewWindow = () => {
setPreviewOpen(false); setPreviewOpen(false);
setSelectedPreview(null);
}; };
const selectListObjects = (e: React.ChangeEvent<HTMLInputElement>) => { const selectListObjects = (e: React.ChangeEvent<HTMLInputElement>) => {
@@ -873,6 +887,18 @@ const ListObjects = ({
return ( return (
<React.Fragment> <React.Fragment>
{shareFileModalOpen && selectedPreview && (
<ShareFile
open={shareFileModalOpen}
closeModalAndRefresh={closeShareModal}
bucketName={bucketName}
dataObject={{
name: selectedPreview.name,
last_modified: "",
version_id: selectedPreview.version_id,
}}
/>
)}
{deleteOpen && ( {deleteOpen && (
<DeleteObject <DeleteObject
deleteOpen={deleteOpen} deleteOpen={deleteOpen}

View File

@@ -24,8 +24,6 @@ import { CircleIcon, VersionIcon } from "../../../../icons";
import get from "lodash/get"; import get from "lodash/get";
import { commonDashboardInfocard } from "../../Common/FormComponents/common/styleLibrary"; import { commonDashboardInfocard } from "../../Common/FormComponents/common/styleLibrary";
const styles = (theme: Theme) => const styles = (theme: Theme) =>
createStyles({ createStyles({
...commonDashboardInfocard, ...commonDashboardInfocard,

View File

@@ -43,8 +43,8 @@ const styles = (theme: Theme) =>
marginRight: 10, marginRight: 10,
}, },
widgetValue: { widgetValue: {
marginRight: 25, marginRight: 25,
} },
}); });
const SimpleWidget = ({ classes, iconWidget, label, value }: ISimpleWidget) => { const SimpleWidget = ({ classes, iconWidget, label, value }: ISimpleWidget) => {