diff --git a/web/src/components/CreateResourceDialog.tsx b/web/src/components/CreateResourceDialog.tsx index ddef0130..7c980632 100644 --- a/web/src/components/CreateResourceDialog.tsx +++ b/web/src/components/CreateResourceDialog.tsx @@ -36,6 +36,33 @@ const CreateResourceDialog: React.FC = (props: Props) => { const [fileList, setFileList] = useState([]); const fileInputRef = useRef(null); + const handleReorderFileList = (fileName: string, direction: "up" | "down") => { + const fileIndex = fileList.findIndex((file) => file.name === fileName); + if (fileIndex === -1) { + return; + } + + const newFileList = [...fileList]; + + if (direction === "up") { + if (fileIndex === 0) { + return; + } + const temp = newFileList[fileIndex - 1]; + newFileList[fileIndex - 1] = newFileList[fileIndex]; + newFileList[fileIndex] = temp; + } else if (direction === "down") { + if (fileIndex === fileList.length - 1) { + return; + } + const temp = newFileList[fileIndex + 1]; + newFileList[fileIndex + 1] = newFileList[fileIndex]; + newFileList[fileIndex] = temp; + } + + setFileList(newFileList); + }; + const handleCloseDialog = () => { if (onCancel) { onCancel(); @@ -124,7 +151,12 @@ const CreateResourceDialog: React.FC = (props: Props) => { if (!fileInputRef.current || !fileInputRef.current.files) { return; } - for (const file of fileInputRef.current.files) { + const filesOnInput = Array.from(fileInputRef.current.files); + for (const file of fileList) { + const fileOnInput = filesOnInput.find((fileOnInput) => fileOnInput.name === file.name); + if (!fileOnInput) { + continue; + } const resource = await resourceStore.createResourceWithBlob(file); createdResourceList.push(resource); } @@ -182,10 +214,30 @@ const CreateResourceDialog: React.FC = (props: Props) => { /> - {fileList.map((file) => ( + {fileList.map((file, index) => ( - + {file.name} +
+ + +
))} diff --git a/web/src/pages/ResourcesDashboard.tsx b/web/src/pages/ResourcesDashboard.tsx index dff5cf18..453cdc04 100644 --- a/web/src/pages/ResourcesDashboard.tsx +++ b/web/src/pages/ResourcesDashboard.tsx @@ -224,7 +224,15 @@ const ResourcesDashboard = () => { )} -