diff --git a/src/components/Transfer/Drawer.tsx b/src/components/Transfer/Drawer.tsx index dc55dd9..30c4724 100644 --- a/src/components/Transfer/Drawer.tsx +++ b/src/components/Transfer/Drawer.tsx @@ -27,7 +27,6 @@ import { AlertIcon, AlertTitle, AlertDescription, - Code, } from "@chakra-ui/react"; import { usePathname } from "next/navigation"; @@ -35,8 +34,10 @@ import { Item, useGlobusTransferStore } from "@/store/globus-transfer"; import NextLink from "next/link"; import { MinusCircleIcon } from "@heroicons/react/24/outline"; import { CollectionName } from "@/globus/Collection"; -import { isTransferEnabled } from "../../../static"; import { useStat } from "@/hooks/useGlobusAPI"; +import { readableBytes } from "@globus/sdk/services/transfer/utils"; + +import { isTransferEnabled } from "../../../static"; export const TransferListItem = ({ item, @@ -61,16 +62,16 @@ export const TransferListItem = ({ > {item.label} - {stat.data?.size && ( - - {stat.data?.size} Bytes - - )} - - - {item.path} - - + + {stat.data?.type === "file" && stat.data?.size && ( + {readableBytes(stat.data?.size)} + )} + + + {item.path} + + + ; export function CollectionSearch({ - defaultValue = null, + value = null, onSelect = () => {}, }: { - defaultValue?: Endpoint | null; + value?: Endpoint | null; onSelect: (endpoint: Endpoint) => void; }) { const auth = useGlobusAuth(); const [results, setResults] = useState([]); - const [selection, setSelection] = useState(defaultValue); + const [selection, setSelection] = useState(value); + + useEffect(() => { + setSelection(value); + if (value === null) { + setResults([]); + } + }, [value]); async function handleSearch(e: React.FormEvent) { const query = e.currentTarget.value; diff --git a/src/pages/transfer.tsx b/src/pages/transfer.tsx index d5389ef..b7b6a87 100644 --- a/src/pages/transfer.tsx +++ b/src/pages/transfer.tsx @@ -10,9 +10,7 @@ import { CardHeader, CardBody, Box, - HStack, Icon, - IconButton, Spacer, Stack, Button, @@ -22,18 +20,13 @@ import { Input, useToast, SimpleGrid, - Tooltip, Alert, AlertIcon, AlertTitle, FormHelperText, AlertDescription, } from "@chakra-ui/react"; -import { - XCircleIcon, - ArrowTopRightOnSquareIcon, -} from "@heroicons/react/24/outline"; -import NextLink from "next/link"; +import { ArrowTopRightOnSquareIcon } from "@heroicons/react/24/outline"; import { transfer, webapp } from "@globus/sdk"; import { useGlobusAuth } from "@globus/react-auth-context"; @@ -48,9 +41,6 @@ export default function ResultPage() { const auth = useGlobusAuth(); const toast = useToast(); const transferStore = useGlobusTransferStore(); - const removeItemBySubject = useGlobusTransferStore( - (state) => state.removeItemBySubject, - ); if (isTransferEnabled === false) { return ( @@ -92,6 +82,7 @@ export default function ResultPage() { ) ).json(); + const basePath = path.endsWith("/") ? path : `${path}/`; const response = await transfer.taskSubmission.submitTransfer( { payload: { @@ -106,7 +97,7 @@ export default function ResultPage() { /** * @todo Should we allow (or require) configuration of `item.name` and `item.type`? */ - destination_path: `${path}${item.path}`, + destination_path: `${basePath}${item.path}`, recursive: item.type === "directory", }; }), @@ -216,9 +207,7 @@ export default function ResultPage() { Destination { transferStore.setDestination(destination); }} @@ -227,7 +216,7 @@ export default function ResultPage() { Path { @@ -237,7 +226,7 @@ export default function ResultPage() { {transferStore.transfer?.path && ( Label { transferStore.setLabel(e.currentTarget.value);