|
1 | 1 | import { |
2 | 2 | LABEL, |
| 3 | + ManifestDownloadFormat, |
3 | 4 | MANIFEST_DOWNLOAD_FORMAT, |
4 | 5 | } from "@databiosphere/findable-ui/lib/apis/azul/common/entities"; |
5 | 6 | import { |
@@ -100,6 +101,7 @@ import * as C from "../../../../components"; |
100 | 101 | import * as MDX from "../../../../components/common/MDXContent/anvil-cmg"; |
101 | 102 | import { METADATA_KEY } from "../../../../components/Index/common/entities"; |
102 | 103 | import { getPluralizedMetadataLabel } from "../../../../components/Index/common/indexTransformer"; |
| 104 | +import { FEATURE_FLAGS } from "../../../common/contants"; |
103 | 105 | import { Unused } from "../../../common/entities"; |
104 | 106 | import { SUMMARY_DISPLAY_TEXT } from "./summaryMapper/constants"; |
105 | 107 | import { mapExportSummary } from "./summaryMapper/summaryMapper"; |
@@ -430,8 +432,9 @@ export const buildExportEntityToTerra = ( |
430 | 432 | fileSummaryFacetName: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_FORMAT, |
431 | 433 | filters, |
432 | 434 | formFacet, |
433 | | - manifestDownloadFormat: MANIFEST_DOWNLOAD_FORMAT.TERRA_PFB, |
434 | | - manifestDownloadFormats: [MANIFEST_DOWNLOAD_FORMAT.TERRA_PFB], |
| 435 | + manifestDownloadFormat: getExportToTerraManifestDownloadFormat(viewContext), |
| 436 | + manifestDownloadFormats: |
| 437 | + getExportToTerraManifestDownloadFormats(viewContext), |
435 | 438 | }; |
436 | 439 | }; |
437 | 440 |
|
@@ -573,8 +576,9 @@ export const buildExportToTerra = ( |
573 | 576 | fileSummaryFacetName: ANVIL_CMG_CATEGORY_KEY.FILE_FILE_FORMAT, |
574 | 577 | filters: filterState, |
575 | 578 | formFacet, |
576 | | - manifestDownloadFormat: MANIFEST_DOWNLOAD_FORMAT.TERRA_PFB, |
577 | | - manifestDownloadFormats: [MANIFEST_DOWNLOAD_FORMAT.TERRA_PFB], |
| 579 | + manifestDownloadFormat: getExportToTerraManifestDownloadFormat(viewContext), |
| 580 | + manifestDownloadFormats: |
| 581 | + getExportToTerraManifestDownloadFormats(viewContext), |
578 | 582 | }; |
579 | 583 | }; |
580 | 584 |
|
@@ -961,6 +965,38 @@ export function getExportSelectedDataSummary( |
961 | 965 | ]); |
962 | 966 | } |
963 | 967 |
|
| 968 | +/** |
| 969 | + * Returns export to terra manifest download format. |
| 970 | + * @param viewContext - View context. |
| 971 | + * @returns manifest download format. |
| 972 | + */ |
| 973 | +function getExportToTerraManifestDownloadFormat( |
| 974 | + viewContext: ViewContext |
| 975 | +): ManifestDownloadFormat | undefined { |
| 976 | + const { exploreState } = viewContext; |
| 977 | + const { featureFlagState } = exploreState; |
| 978 | + if (featureFlagState?.includes(FEATURE_FLAGS.VERBATIM)) { |
| 979 | + return MANIFEST_DOWNLOAD_FORMAT.VERBATIM_PFB; |
| 980 | + } |
| 981 | + return MANIFEST_DOWNLOAD_FORMAT.TERRA_PFB; |
| 982 | +} |
| 983 | + |
| 984 | +/** |
| 985 | + * Returns export to terra manifest download formats. |
| 986 | + * @param viewContext - View context. |
| 987 | + * @returns manifest download formats. |
| 988 | + */ |
| 989 | +function getExportToTerraManifestDownloadFormats( |
| 990 | + viewContext: ViewContext |
| 991 | +): ManifestDownloadFormat[] { |
| 992 | + const { exploreState } = viewContext; |
| 993 | + const { featureFlagState } = exploreState; |
| 994 | + if (featureFlagState?.includes(FEATURE_FLAGS.VERBATIM)) { |
| 995 | + return [MANIFEST_DOWNLOAD_FORMAT.VERBATIM_PFB]; |
| 996 | + } |
| 997 | + return [MANIFEST_DOWNLOAD_FORMAT.TERRA_PFB]; |
| 998 | +} |
| 999 | + |
964 | 1000 | /** |
965 | 1001 | * Returns the file summary facet, where facet terms are generated from the file summary. |
966 | 1002 | * @param fileFacet - File facet. |
|
0 commit comments