Skip to content

Commit 0b32129

Browse files
committed
feat: Update file upload
1 parent c7b1009 commit 0b32129

File tree

14 files changed

+276
-222
lines changed

14 files changed

+276
-222
lines changed

.env

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
BROWSER="chrome"
33

44
# Set CHRIS_UI_URL to the url of the running CUBE API
5-
VITE_CHRIS_UI_URL="http://localhost:8000/api/v1/"
6-
VITE_CHRIS_UI_USERS_URL="http://localhost:8000/api/v1/users/"
7-
VITE_CHRIS_UI_AUTH_URL="http://localhost:8000/api/v1/auth-token/"
5+
VITE_CHRIS_UI_URL="http://rc-live.tch.harvard.edu:32222/api/v1/"
6+
VITE_CHRIS_UI_USERS_URL="http://rc-live.tch.harvard.edu:32222/api/v1/users/"
7+
VITE_CHRIS_UI_AUTH_URL="http://rc-live.tch.harvard.edu:32222/api/v1/auth-token/"
88
VITE_ALPHA_FEATURES='production'
99

1010
# Set PFDCM_URL to the root url of the running pfdcm instance

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@
8383
"react-bootstrap-typeahead": "^6.2.3",
8484
"react-cookie": "^7.1.4",
8585
"react-dom": "^18.3.1",
86-
"react-dropzone": "^14.2.3",
8786
"react-error-boundary": "^4.0.13",
8887
"react-force-graph-2d": "^1.25.3",
8988
"react-json-view": "^1.21.3",

src/components/CreateFeed/ChooseConfig.tsx

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ import React, { useCallback, useContext, useEffect, useState } from "react";
2424
import { useTypedSelector } from "../../store/hooks";
2525
import GuidedConfig from "../AddNode/GuidedConfig";
2626
import { AddNodeContext } from "../AddNode/context";
27-
import { Types as AddNodeTypes, chooseConfigProps } from "../AddNode/types";
27+
import {
28+
Types as AddNodeTypes,
29+
type chooseConfigProps,
30+
} from "../AddNode/types";
2831
import DragAndUpload from "../DragFileUpload";
2932
import ChrisFileSelect from "./ChrisFileSelect";
3033
import DataPacks from "./DataPacks";
@@ -49,7 +52,6 @@ const ChooseConfig = ({
4952
const [currentStep, setCurrentStep] = useState(0);
5053
const params = useTypedSelector((state) => state.plugin.parameters);
5154
const [selectedCard, setSelectedCard] = useState("");
52-
const [showDragAndDrop, setShowDragAndDrop] = useState(false);
5355

5456
const handleClick = useCallback(
5557
(event: React.MouseEvent, selectedPluginId = "") => {
@@ -58,8 +60,6 @@ const ChooseConfig = ({
5860
setSelectedCard(selectedCard);
5961
if (selectedCard === "swift_storage" || selectedCard === "fs_plugin") {
6062
setRightDrawerExpand(true);
61-
} else if (selectedCard === "local_select") {
62-
setShowDragAndDrop(true);
6363
}
6464
},
6565
[],
@@ -81,7 +81,7 @@ const ChooseConfig = ({
8181
case "ArrowRight":
8282
if (
8383
selectedConfig.includes("fs_plugin") &&
84-
params?.required.length != Object.keys(requiredInput).length
84+
params?.required.length !== Object.keys(requiredInput).length
8585
) {
8686
return;
8787
}
@@ -318,6 +318,7 @@ const ChooseConfig = ({
318318
const fileList =
319319
chrisFiles.length > 0
320320
? chrisFiles.map((file: string, index: number) => (
321+
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
321322
<React.Fragment key={index}>
322323
<FileList file={file} index={index} />
323324
</React.Fragment>
@@ -331,12 +332,6 @@ const ChooseConfig = ({
331332
};
332333
}, [handleKeyDown]);
333334

334-
useEffect(() => {
335-
if (localFiles.length === 0) {
336-
setShowDragAndDrop(false);
337-
}
338-
}, [localFiles.length]);
339-
340335
return (
341336
<Drawer isExpanded={isRightDrawerExpand} position="right">
342337
<DrawerContent panelContent={panelContent}>
@@ -457,35 +452,7 @@ const ChooseConfig = ({
457452
<GridItem>
458453
<Grid>
459454
<GridItem style={{ height: "230px" }}>
460-
{!showDragAndDrop ? (
461-
<Card
462-
id="local_select"
463-
isSelectable={isDataSelected}
464-
style={cardContainerStyle}
465-
onClick={handleClick}
466-
isSelected={selectedConfig.includes("local_select")}
467-
>
468-
<CardHeader style={cardHeaderStyle}>
469-
<Tooltip content="Press the U key to select">
470-
<Chip key="KeyboardShortcut" isReadOnly>
471-
U
472-
</Chip>
473-
</Tooltip>
474-
</CardHeader>
475-
<CardTitle>
476-
<UploadIcon />
477-
<br />
478-
Upload New Data
479-
</CardTitle>
480-
<CardBody>
481-
Upload new files from your local computer
482-
</CardBody>
483-
</Card>
484-
) : (
485-
<DragAndUpload
486-
handleLocalUploadFiles={handleFileUpload}
487-
/>
488-
)}
455+
<DragAndUpload handleLocalUploadFiles={handleFileUpload} />
489456
</GridItem>
490457
<GridItem>
491458
{localFiles.length > 0 ? <LocalFileUpload /> : null}

src/components/CreateFeed/ChrisFileSelect.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React, { useState, useContext, useCallback, useEffect } from "react";
22
import { CreateFeedContext } from "./context";
33
import { useWizardContext } from "@patternfly/react-core";
4-
import { EventDataNode, Key } from "rc-tree/lib/interface";
4+
import type { EventDataNode, Key } from "rc-tree/lib/interface";
55
import { Tree, notification } from "antd";
66

77
import {
88
Types,
9-
Info,
10-
DataBreadcrumb,
11-
ChrisFileSelectProp,
12-
CheckedKeys,
9+
type Info,
10+
type DataBreadcrumb,
11+
type ChrisFileSelectProp,
12+
type CheckedKeys,
1313
} from "./types/feed";
1414
import { generateTreeNodes, getNewTreeData } from "./utils";
1515
import { isEmpty } from "lodash";
@@ -119,7 +119,7 @@ const ChrisFileSelect: React.FC<ChrisFileSelectProp> = ({
119119
if (e.target.closest("INPUT")) return;
120120
if (chrisFiles.length > 0 && e.code == "ArrowRight") {
121121
onNext();
122-
} else if (e.code == "ArrowLeft") {
122+
} else if (e.code === "ArrowLeft") {
123123
onBack();
124124
}
125125
},

src/components/CreateFeed/DataPacks.tsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
import { useEffect, useState, useContext, useRef, useCallback } from "react";
2-
import { PluginMeta } from "@fnndsc/chrisapi";
1+
import type { PluginMeta } from "@fnndsc/chrisapi";
32
import {
4-
Pagination,
5-
ToolbarItem,
6-
Radio,
73
Button,
84
ButtonVariant,
95
InputGroup,
6+
Pagination,
7+
Radio,
108
TextInput,
9+
ToolbarItem,
1110
useWizardContext,
1211
} from "@patternfly/react-core";
13-
import { SearchIcon } from "../Icons";
14-
import { Types as AddNodeTypes } from "../AddNode/types";
15-
import { Types } from "./types/feed";
1612
import { notification } from "antd";
1713
import debounce from "lodash/debounce";
18-
import { getPlugins } from "./utils";
14+
import { useCallback, useContext, useEffect, useRef, useState } from "react";
1915
import { AddNodeContext } from "../AddNode/context";
16+
import { Types as AddNodeTypes } from "../AddNode/types";
17+
import { SearchIcon } from "../Icons";
2018
import { CreateFeedContext } from "./context";
19+
import { Types } from "./types/feed";
20+
import { getPlugins } from "./utils";
2121

2222
interface FilterProps {
2323
perPage: number;
@@ -101,7 +101,7 @@ const DataPacks = ({ next }: { next: () => any }) => {
101101
});
102102

103103
notification.info({
104-
message: `Plugin Selected`,
104+
message: "Plugin Selected",
105105
description: `${plugin.data.name} plugin unselected`,
106106
duration: 1,
107107
});
@@ -127,19 +127,21 @@ const DataPacks = ({ next }: { next: () => any }) => {
127127
(e: any, plugin: any = null) => {
128128
if (e.target.closest("INPUT#filter_plugin")) {
129129
return;
130-
} else if (
130+
}
131+
if (
131132
e.target.closest("BUTTON") &&
132133
!e.target.closest("BUTTON.pf-c-button.pf-m-secondary") &&
133134
!e.target.closest("BUTTON.pf-c-button.pf-m-primary")
134135
) {
135136
return;
136-
} else if (e.code == "Enter" && e.target.closest("DIV.pf-c-radio")) {
137+
}
138+
if (e.code === "Enter" && e.target.closest("DIV.pf-c-radio")) {
137139
e.preventDefault();
138-
if (pluginMeta == undefined) handleOnChange(true, plugin);
140+
if (pluginMeta === undefined) handleOnChange(true, plugin);
139141
onNext();
140-
} else if (pluginMeta && e.code == "ArrowRight") {
142+
} else if (pluginMeta && e.code === "ArrowRight") {
141143
onNext();
142-
} else if (e.code == "ArrowLeft") {
144+
} else if (e.code === "ArrowLeft") {
143145
onBack();
144146
}
145147
},

src/components/CreateFeed/LocalFileUpload.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ const FileUploadComponent = ({
6464
}: FileUploadProps) => {
6565
const handleKeyDown = useCallback(
6666
(e: any) => {
67-
if (e.code == "ArrowLeft") {
67+
if (e.code === "ArrowLeft") {
6868
onBack();
69-
} else if (e.code == "ArrowRight" && localFiles.length > 0) {
69+
} else if (e.code === "ArrowRight" && localFiles.length > 0) {
7070
onNext();
7171
}
7272
},
Lines changed: 29 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,43 @@
11
.drag-and-upload-container {
2-
position: relative;
3-
height: 100%;
4-
cursor: pointer;
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
justify-content: center;
6+
margin: 1rem 0;
57
}
68

9+
/* The label or tag showing the 'U' key hint */
710
.tag {
8-
position: absolute;
9-
top: 10%;
10-
right: 8%;
11-
background-color: #36b37e;
11+
position: relative;
12+
margin-bottom: 0.5rem;
13+
}
14+
.tag .tag-text {
15+
background: #2188ff;
1216
color: white;
13-
padding: 5px 10px;
17+
padding: 0.25rem 0.5rem;
1418
border-radius: 4px;
19+
font-weight: 600;
1520
}
1621

17-
.tag-text {
18-
font-weight: bold;
22+
/* The dashed dropzone area */
23+
.dropzone-area {
24+
width: 350px;
25+
height: 150px;
26+
margin-bottom: 1rem;
27+
text-align: center;
1928
}
2029

21-
.drag-and-upload-container p {
22-
margin-top: 1rem;
30+
/* Additional text styling inside the dropzone */
31+
.dropzone-area p {
32+
margin: 0.5rem;
2333
}
24-
25-
.drag-and-upload-container svg {
26-
color: #6c757d;
27-
}
28-
29-
/* Animation Styles */
30-
@keyframes fadeInUp {
31-
from {
32-
opacity: 0;
33-
transform: translateY(20px);
34-
}
35-
to {
36-
opacity: 1;
37-
transform: translateY(0);
38-
}
39-
}
40-
41-
/* Apply the animation to the drag-and-upload-section */
42-
.drag-and-upload-section {
43-
animation: fadeInUp 0.5s ease-in-out;
44-
}
45-
46-
/* Additional styling for animations/transitions */
47-
.tag {
48-
transition: background-color 0.3s ease-in-out;
34+
.dropzone-area .text-subtle {
35+
font-size: 0.85rem;
36+
color: #666;
4937
}
5038

51-
.drag-and-upload-container p {
52-
transition: color 0.3s ease-in-out;
39+
/* Container for the two upload buttons */
40+
.button-container {
41+
display: flex;
42+
gap: 1rem;
5343
}

0 commit comments

Comments
 (0)