Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Austenem/CAT-1052 Add bulk download dialog to detail pages #3622

Merged
merged 6 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions CHANGELOG-add-bulk-download-to-detail-pages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add bulk file download option to the Bulk Download section of dataset detail pages.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import BulkDownloadButton from 'js/components/bulkDownload/BulkDownloadButton/BulkDownloadButton';
import BulkDownloadButton from 'js/components/bulkDownload/buttons/BulkDownloadButton/BulkDownloadButton';
import { useSelectableTableStore } from 'js/shared-styles/tables/SelectableTableProvider';

const tooltip = 'Bulk download files for selected datasets.';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react';
import Box from '@mui/material/Box';
import { ButtonProps } from '@mui/material/Button';
import { useBulkDownloadDialog } from 'js/components/bulkDownload/hooks';
import BulkDownloadDialog from 'js/components/bulkDownload/BulkDownloadDialog';
import OutlinedButton from 'js/shared-styles/buttons/OutlinedButton';

interface BulkDownloadTextButtonProps extends ButtonProps {
uuids: Set<string>;
}
function BulkDownloadTextButton({ uuids, ...rest }: BulkDownloadTextButtonProps) {
const { openDialog, isOpen } = useBulkDownloadDialog();

return (
<Box>
<OutlinedButton color="primary" onClick={() => openDialog(uuids)} {...rest}>
Download Files with HuBMAP CLT
</OutlinedButton>
{isOpen && <BulkDownloadDialog />}
</Box>
);
}

export default BulkDownloadTextButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import BulkDownloadTextButton from './BulkDownloadTextButton';

export default BulkDownloadTextButton;
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
import React, { useState } from 'react';
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';

import { CollapsibleDetailPageSection } from 'js/components/detailPage/DetailPageSection';
import { FilesContextProvider } from 'js/components/detailPage/files/FilesContext';
import { Tabs, Tab, TabPanel } from 'js/shared-styles/tables/TableTabs';
import { DetailSectionPaper } from 'js/shared-styles/surfaces';
import { OutboundLink } from 'js/shared-styles/Links';
import withShouldDisplay from 'js/helpers/withShouldDisplay';
import { sectionIconMap } from 'js/shared-styles/icons/sectionIconMap';
import { SectionDescription } from 'js/shared-styles/sections/SectionDescription';
import BulkDownloadTextButton from 'js/components/bulkDownload/buttons/BulkDownloadTextButton';
import { LINKS } from 'js/components/bulkDownload/constants';
import BulkDataTransferPanels from './BulkDataTransferPanels';
import { useProcessedDatasetTabs } from '../ProcessedData/ProcessedDataset/hooks';
import { BULK_DATA_DESCRIPTION_TEXT } from './const';

const description = (
<Typography>
This section explains how to bulk download the raw and processed data for this dataset. Files for individual raw or
processed data can be downloaded via Globus or dbGaP from the respective tabs. To download files from multiple
Globus directories simultaneously, use the
<OutboundLink href={LINKS.documentation}> HuBMAP Command Line Transfer (CLT) Tool</OutboundLink>. Note that
processed data has separate download directories in Globus or dbGaP, distinct from the raw data directory.
</Typography>
);

function BulkDataTransfer() {
const tabs = useProcessedDatasetTabs();
const uuids = new Set(tabs.map((tab) => tab.uuid));

const [openTabIndex, setOpenTabIndex] = useState(0);

Expand All @@ -24,7 +39,12 @@ function BulkDataTransfer() {
icon={sectionIconMap['bulk-data-transfer']}
>
<FilesContextProvider>
<SectionDescription>{BULK_DATA_DESCRIPTION_TEXT}</SectionDescription>
<SectionDescription>
<Stack spacing={1}>
{description}
<BulkDownloadTextButton uuids={uuids} />
</Stack>
</SectionDescription>
<Tabs
value={openTabIndex}
onChange={(_, newValue) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,3 @@ export const SRA_EXPERIMENT_TEXT = {
description: 'Select the "Run" link on the page to download the dataset information.',
outboundLink: 'https://www.ncbi.nlm.nih.gov/sra/docs/',
};

export const BULK_DATA_DESCRIPTION_TEXT =
'This section explains how to download data in bulk from raw and processed datasets. Processed datasets have separate download directories in Globus or dbGaP, distinct from the raw dataset.';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Typography from '@mui/material/Typography';
import type { Entity } from 'js/components/types';
import { CollapsibleDetailPageSection } from 'js/components/detailPage/DetailPageSection';
import RelatedEntitiesTable from 'js/components/detailPage/related-entities/RelatedEntitiesTable';
import BulkDownloadButton from 'js/components/bulkDownload/BulkDownloadButton';
import BulkDownloadButton from 'js/components/bulkDownload/buttons/BulkDownloadButton';
import { SpacedSectionButtonRow } from 'js/shared-styles/sections/SectionButtonRow';
import { sectionIconMap } from 'js/shared-styles/icons/sectionIconMap';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Stack from '@mui/material/Stack';

import { useFlaskDataContext } from 'js/components/Contexts';
import { useTrackEntityPageEvent } from 'js/components/detailPage/useTrackEntityPageEvent';
import BulkDownloadButton from 'js/components/bulkDownload/BulkDownloadButton';
import BulkDownloadButton from 'js/components/bulkDownload/buttons/BulkDownloadButton';

interface RelatedEntitiesSectionHeaderProps {
searchPageHref: string;
Expand Down
2 changes: 1 addition & 1 deletion context/app/static/js/components/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import history from 'history/browser';
import { useAppContext } from 'js/components/Contexts';
import SelectableTableProvider from 'js/shared-styles/tables/SelectableTableProvider';
import WorkspacesDropdownMenu, { WorkspaceSearchDialogs } from 'js/components/workspaces/WorkspacesDropdownMenu';
import BulkDownloadButtonFromSearch from 'js/components/bulkDownload/BulkDownloadButtonFromSearch';
import BulkDownloadButtonFromSearch from 'js/components/bulkDownload/buttons/BulkDownloadButtonFromSearch';
import { entityIconMap } from 'js/shared-styles/icons/entityIconMap';
import {
SearchStoreProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { SearchBox, SelectedFilters, SortingSelector, ViewSwitcherToggle, SimpleQueryString } from 'searchkit';
import Stack from '@mui/material/Stack';

import BulkDownloadButtonFromSearch from 'js/components/bulkDownload/BulkDownloadButtonFromSearch';
import BulkDownloadButtonFromSearch from 'js/components/bulkDownload/buttons/BulkDownloadButtonFromSearch';
import { withAnalyticsCategory } from 'js/components/searchPage/hooks';
import WorkspacesDropdownMenu from 'js/components/workspaces/WorkspacesDropdownMenu';
import SearchViewSwitch, { DevSearchViewSwitch } from './SearchViewSwitch';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react';
import { StyledButton } from 'js/shared-styles/buttons/OutlinedButton/style';
import { ButtonProps } from '@mui/material/Button';

interface OutlinedButtonProps extends ButtonProps {
children: React.ReactNode;
}

function OutlinedButton({ children, ...rest }: OutlinedButtonProps) {
return (
<StyledButton variant="outlined" {...rest}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to introduce a new shared component to pass a single prop. @NickAkhmetov thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like the purpose of this is to decouple the styles from the OutlinedLinkButton's link logic so that those styles are usable in non-link scenarios, but it seems like just applying the outlined variant to StyledButton would accomplish the same thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point - this was created because I believed the variant styling could only be applied inline, and the outline is always necessary for this component. I just wrapped the Button component into the styled function so that the variant styling can be applied there, which eliminates the need for this component.

{children}
</StyledButton>
);
}

export default OutlinedButton;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import OutlinedButton from './OutlinedButton';

export default OutlinedButton;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { PropsWithChildren } from 'react';
import LinkIcon from '@mui/icons-material/Link';
import LaunchRounded from '@mui/icons-material/LaunchRounded';
import { StyledButton } from 'js/shared-styles/buttons/OutlinedLinkButton/style';
import OutlinedButton from 'js/shared-styles/buttons/OutlinedButton';

interface OutlinedLinkButtonProps extends PropsWithChildren {
link: string;
Expand All @@ -13,15 +13,14 @@ function OutlinedLinkButton({ link, onClick, external, children }: OutlinedLinkB
const EndIcon = external ? LaunchRounded : LinkIcon;

return (
<StyledButton
variant="outlined"
<OutlinedButton
color="info"
href={link}
onClick={onClick}
endIcon={<EndIcon color="info" sx={{ width: '1rem' }} />}
>
{children}
</StyledButton>
</OutlinedButton>
);
}

Expand Down
Loading