Skip to content

Commit 98c76b9

Browse files
frano-mFran McDade
andauthored
feat: add download manifest under a feature flag (#4032) (#4033)
Co-authored-by: Fran McDade <[email protected]>
1 parent 6b19e2a commit 98c76b9

File tree

10 files changed

+185
-11
lines changed

10 files changed

+185
-11
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
"use client";
2+
import {
3+
ExportMethod as DXExportMethod,
4+
ExportMethodProps,
5+
} from "@databiosphere/findable-ui/lib/components/Export/components/ExportMethod/exportMethod";
6+
import { useExploreState } from "@databiosphere/findable-ui/lib/hooks/useExploreState";
7+
import React, { Fragment, useEffect, useState } from "react";
8+
import { FEATURE_FLAGS } from "../../../../../viewModelBuilders/common/contants";
9+
10+
export const ExportMethod = ({ ...props }: ExportMethodProps): JSX.Element => {
11+
const {
12+
exploreState: { featureFlagState },
13+
} = useExploreState();
14+
const [showMethod, setShowMethod] = useState<boolean>(false);
15+
16+
useEffect(() => {
17+
if (featureFlagState) {
18+
setShowMethod(featureFlagState === FEATURE_FLAGS.MANIFEST);
19+
}
20+
}, [featureFlagState]);
21+
22+
return showMethod ? <DXExportMethod {...props} /> : <Fragment />;
23+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Alert } from "@databiosphere/findable-ui/lib/components/common/Alert/alert";
2+
import {
3+
ManifestDownload as DXManifestDownload,
4+
ManifestDownloadProps,
5+
} from "@databiosphere/findable-ui/lib/components/Export/components/ManifestDownload/manifestDownload";
6+
import { useExploreState } from "@databiosphere/findable-ui/lib/hooks/useExploreState";
7+
import { useEffect, useState } from "react";
8+
import { FEATURE_FLAGS } from "../../../../../viewModelBuilders/common/contants";
9+
10+
export const ManifestDownload = ({
11+
...props
12+
}: ManifestDownloadProps): JSX.Element => {
13+
const {
14+
exploreState: { featureFlagState },
15+
} = useExploreState();
16+
const [showExport, setShowExport] = useState<boolean>(false);
17+
18+
useEffect(() => {
19+
if (featureFlagState) {
20+
setShowExport(featureFlagState === FEATURE_FLAGS.MANIFEST);
21+
}
22+
}, [featureFlagState]);
23+
24+
return showExport ? (
25+
<DXManifestDownload {...props} />
26+
) : (
27+
<Alert severity="error" title="Not Available" />
28+
);
29+
};

explorer/app/components/common/MDXContent/anvil-cmg/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ export { default as LoginReminder } from "./loginReminder.mdx";
88
export { default as LoginTermsOfService } from "./loginTermsOfService.mdx";
99
export { default as LoginText } from "./loginText.mdx";
1010
export { default as LoginWarning } from "./loginWarning.mdx";
11+
export { default as ManifestDownloadStart } from "./manifestDownloadStart.mdx";
12+
export { default as ManifestDownloadSuccess } from "./manifestDownloadSuccess.mdx";
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Confirm Organism Type and Manifest File Formats
2+
3+
Please explicitly select at least one organism type and file format for inclusion in the manifest.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Your File Manifest is Ready
2+
3+
This link expires in 7 days.

explorer/app/components/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export { FileLocationCopy } from "./Detail/components/GeneratedMatricesTables/co
8989
export { FileLocationDownload } from "./Detail/components/GeneratedMatricesTables/components/FileLocationDownload/fileLocationDownload";
9090
export { FileNameCell } from "./Detail/components/GeneratedMatricesTables/components/FileNameCell/fileNameCell";
9191
export { GeneratedMatricesTables } from "./Detail/components/GeneratedMatricesTables/generatedMatricesTables";
92+
export { ExportMethod as AnVILExportMethod } from "./Export/components/AnVILExplorer/ExportMethod/exportMethod";
93+
export { ManifestDownload as AnVILManifestDownload } from "./Export/components/AnVILExplorer/ManifestDownload/manifestDownload";
9294
export { ConsentCodesCell } from "./Index/components/ConsentCodesCell/consentCodesCell";
9395
export { CopyCell } from "./Index/components/CopyCell/copyCell";
9496
export { ANVILBranding } from "./Layout/components/Footer/components/Branding/components/ANVILBranding/anvilBranding";

explorer/app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders.ts

Lines changed: 91 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ import {
4343
ANVIL_CMG_CATEGORY_KEY,
4444
ANVIL_CMG_CATEGORY_LABEL,
4545
} from "../../../../../site-config/anvil-cmg/category";
46-
import { ROUTE_EXPORT_TO_TERRA } from "../../../../../site-config/anvil-cmg/dev/export/constants";
46+
import {
47+
ROUTE_EXPORT_TO_TERRA,
48+
ROUTE_MANIFEST_DOWNLOAD,
49+
} from "../../../../../site-config/anvil-cmg/dev/export/constants";
4750
import { URL_DATASETS } from "../../../../../site-config/anvil/dev/config";
4851
import {
4952
AggregatedBioSampleResponse,
@@ -482,6 +485,23 @@ export function buildExportHero(
482485
};
483486
}
484487

488+
/**
489+
* Build props for manifest download Hero component.
490+
* @param _ - Unused.
491+
* @param viewContext - View context.
492+
* @returns model to be used as props for the Hero component.
493+
*/
494+
export const buildExportMethodHeroManifestDownload = (
495+
_: Unused,
496+
viewContext: ViewContext
497+
): React.ComponentProps<typeof C.BackPageHero> => {
498+
const title = "Request File Manifest";
499+
const {
500+
exploreState: { tabValue },
501+
} = viewContext;
502+
return getExportMethodHero(tabValue, title);
503+
};
504+
485505
/**
486506
* Build props for export to terra Hero component.
487507
* @param _ - Unused.
@@ -499,6 +519,26 @@ export const buildExportMethodHeroTerra = (
499519
return getExportMethodHero(tabValue, title);
500520
};
501521

522+
/**
523+
* Build props for ExportMethod component for display of the manifest download section.
524+
* @param _ - Unused.
525+
* @param viewContext - View context.
526+
* @returns model to be used as props for the ExportMethod component.
527+
*/
528+
export const buildExportMethodManifestDownload = (
529+
_: Unused,
530+
viewContext: ViewContext
531+
): React.ComponentProps<typeof C.AnVILExportMethod> => {
532+
return {
533+
...getExportMethodAccessibility(viewContext),
534+
buttonLabel: "Request File Manifest",
535+
description:
536+
"Request a file manifest for the current query containing the full list of selected files and the metadata for each file.",
537+
route: ROUTE_MANIFEST_DOWNLOAD,
538+
title: "Download a File Manifest with Metadata for the Selected Data",
539+
};
540+
};
541+
502542
/**
503543
* Build props for ExportMethod component for display of the export to terra metadata section.
504544
* @param _ - Unused.
@@ -509,19 +549,11 @@ export const buildExportMethodTerra = (
509549
_: Unused,
510550
viewContext: ViewContext
511551
): React.ComponentProps<typeof C.ExportMethod> => {
512-
const { fileManifestState } = viewContext;
513-
const { isFacetsSuccess } = fileManifestState;
514-
const isAccessible = isFileManifestAccessible(fileManifestState);
515552
return {
553+
...getExportMethodAccessibility(viewContext),
516554
buttonLabel: "Analyze in Terra",
517555
description:
518556
"Terra is a biomedical research platform to analyze data using workflows, Jupyter Notebooks, RStudio, and Galaxy.",
519-
footnote: isFacetsSuccess
520-
? isAccessible
521-
? null
522-
: "You currently don’t have access to any files matching the query."
523-
: null,
524-
isAccessible: isFacetsSuccess && isAccessible,
525557
route: ROUTE_EXPORT_TO_TERRA,
526558
title: "Export Study Data and Metadata to Terra Workspace",
527559
};
@@ -695,6 +727,34 @@ export const buildListWarning = (
695727
};
696728
};
697729

730+
/**
731+
* Build props for ManifestDownload component.
732+
* @param _ - Unused.
733+
* @param viewContext - View context.
734+
* @returns model to be used as props for the ManifestDownload component.
735+
*/
736+
export const buildManifestDownload = (
737+
_: Unused,
738+
viewContext: ViewContext
739+
): React.ComponentProps<typeof C.AnVILManifestDownload> => {
740+
const {
741+
exploreState: { filterState },
742+
fileManifestState,
743+
} = viewContext;
744+
// Get the form facets.
745+
const formFacet = getFormFacets(fileManifestState);
746+
return {
747+
ManifestDownloadForm: C.ManifestDownloadForm,
748+
ManifestDownloadStart: MDX.ManifestDownloadStart,
749+
ManifestDownloadSuccess: MDX.ManifestDownloadSuccess,
750+
fileManifestState,
751+
fileManifestType: FILE_MANIFEST_TYPE.DOWNLOAD_MANIFEST,
752+
fileSummaryFacetName: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_FORMAT,
753+
filters: filterState,
754+
formFacet,
755+
};
756+
};
757+
698758
/**
699759
* Build props for organism type cell component from the given donors response.
700760
* @param response - Response model return from index/donors API endpoint.
@@ -929,6 +989,27 @@ function getExportEntityFilters(datasetsResponse: DatasetsResponse): Filters {
929989
];
930990
}
931991

992+
/**
993+
* Returns the export method accessibility.
994+
* @param viewContext - View context.
995+
* @returns export method accessibility.
996+
*/
997+
function getExportMethodAccessibility(
998+
viewContext: ViewContext
999+
): Partial<typeof C.ExportMethod> {
1000+
const { fileManifestState } = viewContext;
1001+
const { isFacetsSuccess } = fileManifestState;
1002+
const isAccessible = isFileManifestAccessible(fileManifestState);
1003+
return {
1004+
footnote: isFacetsSuccess
1005+
? isAccessible
1006+
? null
1007+
: "You currently don’t have access to any files matching the query."
1008+
: null,
1009+
isAccessible: isFacetsSuccess && isAccessible,
1010+
};
1011+
}
1012+
9321013
/**
9331014
* Returns breadcrumbs and title for export method Hero component.
9341015
* @param explorePath - Explore path.

explorer/app/viewModelBuilders/common/contants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ export const DATE_TIME_FORMAT_OPTIONS: Intl.DateTimeFormatOptions = {
66
};
77
export const DATE_TIME_LOCALES = "en-US";
88
export const FEATURE_FLAGS = {
9+
MANIFEST: "manifest",
910
VERBATIM: "verbatim",
1011
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const ROUTE_EXPORT_TO_TERRA = "/export/export-to-terra";
2+
export const ROUTE_MANIFEST_DOWNLOAD = "/export/download-manifest";

explorer/site-config/anvil-cmg/dev/export/export.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from "@databiosphere/findable-ui/lib/config/entities";
55
import * as C from "../../../../app/components";
66
import * as V from "../../../../app/viewModelBuilders/azul/anvil-cmg/common/viewModelBuilders";
7-
import { ROUTE_EXPORT_TO_TERRA } from "./constants";
7+
import { ROUTE_EXPORT_TO_TERRA, ROUTE_MANIFEST_DOWNLOAD } from "./constants";
88
import { mainColumn as exportMainColumn } from "./exportMainColumn";
99
import { sideColumn as exportSideColumn } from "./exportSideColumn";
1010

@@ -35,6 +35,31 @@ export const exportConfig: ExportConfig = {
3535
} as ComponentConfig<typeof C.BackPageHero>,
3636
],
3737
},
38+
{
39+
mainColumn: [
40+
/* mainColumn - top section - warning - some datasets are not available */
41+
...exportMainColumn,
42+
/* mainColumn */
43+
{
44+
children: [
45+
{
46+
component: C.AnVILManifestDownload, // TODO update component to ManifestDownload when feature flag is no longer required.
47+
viewBuilder: V.buildManifestDownload,
48+
} as ComponentConfig<typeof C.AnVILManifestDownload>,
49+
],
50+
component: C.BackPageContentMainColumn,
51+
} as ComponentConfig<typeof C.BackPageContentMainColumn>,
52+
/* sideColumn */
53+
...exportSideColumn,
54+
],
55+
route: ROUTE_MANIFEST_DOWNLOAD,
56+
top: [
57+
{
58+
component: C.BackPageHero,
59+
viewBuilder: V.buildExportMethodHeroManifestDownload,
60+
} as ComponentConfig<typeof C.BackPageHero>,
61+
],
62+
},
3863
],
3964
staticLoad: true, //TODO is this correct?
4065
tabs: [
@@ -50,6 +75,10 @@ export const exportConfig: ExportConfig = {
5075
component: C.ExportMethod,
5176
viewBuilder: V.buildExportMethodTerra,
5277
} as ComponentConfig<typeof C.ExportMethod>,
78+
{
79+
component: C.AnVILExportMethod, // TODO update component to ExportMethod when feature flag is no longer required.
80+
viewBuilder: V.buildExportMethodManifestDownload,
81+
} as ComponentConfig<typeof C.AnVILExportMethod>,
5382
],
5483
component: C.BackPageContentMainColumn,
5584
} as ComponentConfig<typeof C.BackPageContentMainColumn>,

0 commit comments

Comments
 (0)