Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion frontend/src/components/datasets/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export const Dataset = (): JSX.Element => {
);
const adminMode = useSelector((state: RootState) => state.user.adminMode);
const license = useSelector((state: RootState) => state.dataset.license);
const newFiles = useSelector((state: RootState) => state.dataset.newFiles);
const deletedFile = useSelector(
(state: RootState) => state.dataset.deletedFile
);
Expand Down Expand Up @@ -170,7 +171,7 @@ export const Dataset = (): JSX.Element => {
listDatasetLicense(about.license_id);
getFolderPath(folderId);
getMetadatDefinitions(null, 0, 100);
}, [searchParams, adminMode, about.license_id]);
}, [searchParams, adminMode, about.license_id, newFiles]);

useEffect(() => {
fetchFoldersFilesInDataset(
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/components/datasets/NewMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import { CreateFolder } from "../folders/CreateFolder";
import React from "react";
import { useSelector } from "react-redux";
import { RootState } from "../../types/data";
import { UploadFile } from "../files/UploadFile";
import { UploadFileMultiple } from "../files/UploadFileMultiple";
import { UploadFileDragAndDrop } from "../files/UploadFileDragAndDrop";
import UploadIcon from "@mui/icons-material/Upload";
import { Folder } from "@material-ui/icons";
Expand Down Expand Up @@ -57,6 +55,7 @@ export const NewMenu = (props: ActionsMenuProps): JSX.Element => {
<UploadFileDragAndDrop
selectedDatasetId={datasetId}
folderId={folderId}
setDragDropFiles={setDragDropFiles}
/>
</Dialog>

Expand Down
224 changes: 0 additions & 224 deletions frontend/src/components/files/UploadFile.tsx

This file was deleted.

14 changes: 8 additions & 6 deletions frontend/src/components/files/UploadFileDragAndDrop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ import FileUploadDrop from "./FileUploadDrop";
type UploadFileDragAndDropProps = {
selectedDatasetId: string | undefined;
folderId: string | undefined;
setDragDropFiles: any;
};

export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (
props: UploadFileDragAndDropProps
) => {
const { selectedDatasetId, folderId } = props;
const { selectedDatasetId, folderId, setDragDropFiles } = props;
const [selectedFiles, setSelectedFiles] = useState<File[]>([]);
const [metadataRequestForms, setMetadataRequestForms] = useState({});
const [allFilled, setAllFilled] = React.useState<boolean>(false);
Expand All @@ -53,7 +54,9 @@ export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (
const createFileMetadata = (
fileId: string | undefined,
metadata: MetadataIn
) => dispatch(postFileMetadata(fileId, metadata));
) => {
dispatch(postFileMetadata(fileId, metadata));
};

const uploadFiles = (
selectedDatasetId: string | undefined,
Expand Down Expand Up @@ -157,9 +160,9 @@ export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (

useEffect(() => {
if (newFiles.length > 0) {
newFiles.map((file) => {
newFiles.forEach((file) => {
// post new metadata
Object.keys(metadataRequestForms).map((key) => {
Object.keys(metadataRequestForms).forEach((key) => {
createFileMetadata(file.id, metadataRequestForms[key]);
});
});
Expand All @@ -171,8 +174,7 @@ export const UploadFileDragAndDrop: React.FC<UploadFileDragAndDropProps> = (
// Stop spinner
setLoading(false);

// go back to the dataset
location.reload();
setDragDropFiles(false);
}
}, [newFiles]);

Expand Down
Loading