Skip to content

Commit

Permalink
feat!: exports via main button don't include orphans (#287) (#288)
Browse files Browse the repository at this point in the history
* feat: exports via main button don't include orphans (#287)

* feat: linting (#287)

* feat: changed file manifest state property name to selectedFormFacetNames (#287)

* feat: jsdoc (#287)

* feat: updated test (#287)

* feat: jsdoc (#287)

* feat: jsdoc (#287)

* feat: updated areAllFormFiltersSelected function (#287)

* feat!: exports via main button exclude orphans (#287)

---------

Co-authored-by: Fran McDade <[email protected]>
Co-authored-by: Fran McDade <[email protected]>
  • Loading branch information
3 people authored Dec 12, 2024
1 parent fad1c42 commit 86e3e40
Show file tree
Hide file tree
Showing 31 changed files with 860 additions and 687 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ import { Filters } from "../../../../common/entities";
import { useExploreState } from "../../../../hooks/useExploreState";
import { FileManifestType } from "../../../../hooks/useFileManifest/common/entities";
import { useFileManifest } from "../../../../hooks/useFileManifest/useFileManifest";
import { useRequestFileManifest } from "../../../../hooks/useFileManifest/useRequestFileManifest";
import { FileLocation } from "../../../../hooks/useRequestFileLocation";
import {
FileLocation,
useRequestFileLocation,
} from "../../../../hooks/useRequestFileLocation";
import { useRequestManifest } from "../../../../hooks/useRequestManifest/useRequestManifest";
import { FileManifestState } from "../../../../providers/fileManifestState";
import {
BULK_DOWNLOAD_EXECUTION_ENVIRONMENT,
ExecutionEnvironment,
FormFacet,
ManifestDownloadFormat,
} from "../../common/entities";
import { trackBulkDownloadRequested } from "../../common/tracking";
import { DownloadCurlCommandNotStarted } from "./components/DownloadCurlCommandNotStarted/downloadCurlCommandNotStarted";
Expand All @@ -25,30 +29,33 @@ interface DownloadCurlCommandProps {
fileSummaryFacetName: string;
filters: Filters; // Initializes bulk download filters.
formFacet: FormFacet;
manifestDownloadFormat?: ManifestDownloadFormat;
}

export const DownloadCurlCommand = ({
DownloadCurlForm,
DownloadCurlStart,
DownloadCurlSuccess,
fileManifestState,
fileManifestType,
fileSummaryFacetName,
filters,
formFacet,
manifestDownloadFormat = MANIFEST_DOWNLOAD_FORMAT.CURL,
}: DownloadCurlCommandProps): JSX.Element => {
useRequestFileManifest(
fileManifestType,
MANIFEST_DOWNLOAD_FORMAT.CURL,
filters,
fileSummaryFacetName
);
useFileManifest(filters, fileSummaryFacetName);
const [executionEnvironment, setExecutionEnvironment] =
useState<ExecutionEnvironment>(BULK_DOWNLOAD_EXECUTION_ENVIRONMENT.BASH);
const {
exploreState: { tabValue: entityList },
} = useExploreState();
const { data, isLoading, run } = useFileManifest();
const { requestMethod, requestUrl } = useRequestManifest(
manifestDownloadFormat,
formFacet
);
const { data, isLoading, run } = useRequestFileLocation(
requestUrl,
requestMethod
);
const curlCommand = getBulkDownloadCurlCommand(data, executionEnvironment);
return curlCommand ? (
<DownloadCurlCommandReady
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
import { FormControlLabel, FormLabel, Radio, RadioGroup } from "@mui/material";
import React from "react";
import { useFileManifestState } from "../../../../../../hooks/useFileManifestState";
import { FileManifestActionKind } from "../../../../../../providers/fileManifestState";
import { FileManifestFormatState } from "../../../../../../hooks/useFileManifest/useFileManifestFormat";
import { RadioCheckedIcon } from "../../../../../common/CustomIcon/components/RadioCheckedIcon/radioCheckedIcon";
import { RadioUncheckedIcon } from "../../../../../common/CustomIcon/components/RadioUncheckedIcon/radioUncheckedIcon";
import { ManifestDownloadFormat } from "../../../../common/entities";
import { FormControl } from "../../exportForm.styles";

export interface ExportManifestDownloadFormatFormProps {
manifestDownloadFormat?: ManifestDownloadFormat;
fileManifestFormatState: FileManifestFormatState;
manifestDownloadFormats: ManifestDownloadFormat[];
}

export const ExportManifestDownloadFormatForm = ({
manifestDownloadFormat,
fileManifestFormatState,
manifestDownloadFormats,
}: ExportManifestDownloadFormatFormProps): JSX.Element => {
const { fileManifestDispatch } = useFileManifestState();

// Updates file manifest format state.
const onUpdateManifestFormat = (format: ManifestDownloadFormat): void => {
fileManifestDispatch({
payload: format,
type: FileManifestActionKind.UpdateFileManifestFormat,
});
};

return (
<FormControl>
<FormLabel>Download Format</FormLabel>
<RadioGroup value={manifestDownloadFormat ?? ""}>
<RadioGroup value={fileManifestFormatState.fileManifestFormat ?? ""}>
{manifestDownloadFormats.map((manifestFormat) => (
<FormControlLabel
control={
<Radio
checkedIcon={<RadioCheckedIcon />}
icon={<RadioUncheckedIcon />}
onChange={(): void => onUpdateManifestFormat(manifestFormat)}
onChange={(): void =>
fileManifestFormatState.setFileManifestFormat(manifestFormat)
}
size="small"
value={manifestFormat}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import React, { Dispatch, SetStateAction } from "react";
import { FileManifestFormatState } from "../../../../../../hooks/useFileManifest/useFileManifestFormat";
import { FormFacet, ManifestDownloadFormat } from "../../../../common/entities";
import { ExportButton } from "../../../ExportForm/components/ExportButton/exportButton";
import { ExportManifestDownloadFormatForm } from "../../../ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm";
Expand All @@ -8,17 +9,20 @@ import {
} from "../../../ExportForm/exportForm";

export interface ExportToTerraFormProps {
fileManifestFormatState: FileManifestFormatState;
formFacet: FormFacet;
isLoading: boolean;
manifestDownloadFormat?: ManifestDownloadFormat;
manifestDownloadFormats: ManifestDownloadFormat[];
onRequestManifest: OnRequestManifestFn;
setFileManifestFormat: Dispatch<
SetStateAction<ManifestDownloadFormat | undefined>
>;
}

export const ExportToTerraForm = ({
fileManifestFormatState,
formFacet,
isLoading,
manifestDownloadFormat,
manifestDownloadFormats,
onRequestManifest,
}: ExportToTerraFormProps): JSX.Element => {
Expand All @@ -30,7 +34,7 @@ export const ExportToTerraForm = ({
onRequestManifest={onRequestManifest}
>
<ExportManifestDownloadFormatForm
manifestDownloadFormat={manifestDownloadFormat}
fileManifestFormatState={fileManifestFormatState}
manifestDownloadFormats={manifestDownloadFormats}
/>
</ExportForm>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { ElementType } from "react";
import { FileManifestFormatState } from "../../../../../../hooks/useFileManifest/useFileManifestFormat";
import { FileManifestState } from "../../../../../../providers/fileManifestState";
import { PAPER_PANEL_STYLE } from "../../../../../common/Paper/paper";
import { FluidPaper } from "../../../../../common/Paper/paper.styles";
Expand All @@ -10,6 +11,7 @@ import { OnRequestManifestFn } from "../../../ExportForm/exportForm";
export interface ExportToTerraNotStartedProps {
ExportTerraForm: ElementType;
ExportToTerraStart: ElementType;
fileManifestFormatState: FileManifestFormatState;
fileManifestState: FileManifestState;
formFacet: FormFacet;
isLoading: boolean;
Expand All @@ -20,6 +22,7 @@ export interface ExportToTerraNotStartedProps {
export const ExportToTerraNotStarted = ({
ExportTerraForm,
ExportToTerraStart,
fileManifestFormatState,
fileManifestState,
formFacet,
isLoading,
Expand All @@ -39,9 +42,9 @@ export const ExportToTerraNotStarted = ({
<ExportToTerraStart />
</SectionContent>
<ExportTerraForm
fileManifestFormatState={fileManifestFormatState}
formFacet={formFacet}
isLoading={fileManifestState.isLoading}
manifestDownloadFormat={fileManifestState.fileManifestFormat}
manifestDownloadFormats={manifestDownloadFormats}
onRequestManifest={onRequestManifest}
/>
Expand Down
22 changes: 13 additions & 9 deletions src/components/Export/components/ExportToTerra/exportToTerra.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { useExploreState } from "../../../../hooks/useExploreState";
import { useExportToTerraResponseURL } from "../../../../hooks/useExportToTerraResponseURL";
import { FileManifestType } from "../../../../hooks/useFileManifest/common/entities";
import { useFileManifest } from "../../../../hooks/useFileManifest/useFileManifest";
import { useRequestFileManifest } from "../../../../hooks/useFileManifest/useRequestFileManifest";
import { useFileManifestFormat } from "../../../../hooks/useFileManifest/useFileManifestFormat";
import { useRequestFileLocation } from "../../../../hooks/useRequestFileLocation";
import { useRequestManifest } from "../../../../hooks/useRequestManifest/useRequestManifest";
import { FileManifestState } from "../../../../providers/fileManifestState";
import { FormFacet, ManifestDownloadFormat } from "../../common/entities";
import { trackExportToTerraRequested } from "../../common/tracking";
Expand All @@ -29,7 +31,6 @@ export const ExportToTerra = ({
ExportToTerraStart,
ExportToTerraSuccess,
fileManifestState,
fileManifestType,
fileSummaryFacetName,
filters,
formFacet,
Expand All @@ -39,14 +40,16 @@ export const ExportToTerra = ({
const {
exploreState: { tabValue: entityList },
} = useExploreState();
useRequestFileManifest(
fileManifestType,
manifestDownloadFormat,
filters,
fileSummaryFacetName
useFileManifest(filters, fileSummaryFacetName);
const fileManifestFormatState = useFileManifestFormat(manifestDownloadFormat);
const { requestMethod, requestParams, requestUrl } = useRequestManifest(
fileManifestFormatState.fileManifestFormat,
formFacet
);
const { data, isLoading, run } = useRequestFileLocation(
requestUrl,
requestMethod
);
const { requestParams } = fileManifestState;
const { data, isLoading, run } = useFileManifest();
const exportURL = useExportToTerraResponseURL(requestParams, data);
return exportURL ? (
<ExportToTerraReady
Expand All @@ -57,6 +60,7 @@ export const ExportToTerra = ({
<ExportToTerraNotStarted
ExportTerraForm={ExportForm}
ExportToTerraStart={ExportToTerraStart}
fileManifestFormatState={fileManifestFormatState}
fileManifestState={fileManifestState}
formFacet={formFacet}
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
import React from "react";
import { MANIFEST_DOWNLOAD_FORMAT } from "../../../../../../apis/azul/common/entities";
import { Filters } from "../../../../../../common/entities";
import { FileManifestType } from "../../../../../../hooks/useFileManifest/common/entities";
import { useRequestFileManifest } from "../../../../../../hooks/useFileManifest/useRequestFileManifest";
import { useFileManifest } from "../../../../../../hooks/useFileManifest/useFileManifest";
import { ManifestDownloadFormat } from "../../../../common/entities";
import { FileManifestDownload } from "./components/FileManifestDownload/fileManifestDownload";
import { FileManifestSpreadsheet } from "./components/FileManifestSpreadsheet/fileManifestSpreadsheet";

export interface ManifestDownloadEntityProps {
fileManifestType: FileManifestType;
filters: Filters; // Initializes manifest download filters.
manifestDownloadFormat?: ManifestDownloadFormat;
metadataFilters: Filters; // Metadata filters filters.
}

export const ManifestDownloadEntity = ({
fileManifestType,
filters,
metadataFilters,
}: ManifestDownloadEntityProps): JSX.Element => {
useRequestFileManifest(
fileManifestType,
MANIFEST_DOWNLOAD_FORMAT.COMPACT,
filters,
undefined
);
useFileManifest(filters, undefined);
return (
<>
<FileManifestSpreadsheet filters={metadataFilters} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { Filters } from "../../../../common/entities";
import { useExploreState } from "../../../../hooks/useExploreState";
import { FileManifestType } from "../../../../hooks/useFileManifest/common/entities";
import { useFileManifest } from "../../../../hooks/useFileManifest/useFileManifest";
import { useRequestFileManifest } from "../../../../hooks/useFileManifest/useRequestFileManifest";
import { FileLocation } from "../../../../hooks/useRequestFileLocation";
import {
FileLocation,
useRequestFileLocation,
} from "../../../../hooks/useRequestFileLocation";
import { useRequestManifest } from "../../../../hooks/useRequestManifest/useRequestManifest";
import { FileManifestState } from "../../../../providers/fileManifestState";
import { FormFacet } from "../../common/entities";
import { FormFacet, ManifestDownloadFormat } from "../../common/entities";
import { trackFileManifestRequested } from "../../common/tracking";
import { ManifestDownloadNotStarted } from "./components/ManifestDownloadNotStarted/manifestDownloadNotStarted";
import { ManifestDownloadReady } from "./components/ManifestDownloadReady/manifestDownloadReady";
Expand All @@ -19,30 +22,33 @@ export interface ManifestDownloadProps {
filters: Filters; // Initializes manifest download filters.
formFacet: FormFacet;
ManifestDownloadForm: ElementType;
manifestDownloadFormat?: ManifestDownloadFormat;
ManifestDownloadStart: ElementType;
ManifestDownloadSuccess: ElementType;
}

export const ManifestDownload = ({
fileManifestState,
fileManifestType,
fileSummaryFacetName,
filters,
formFacet,
ManifestDownloadForm,
manifestDownloadFormat = MANIFEST_DOWNLOAD_FORMAT.COMPACT,
ManifestDownloadStart,
ManifestDownloadSuccess,
}: ManifestDownloadProps): JSX.Element => {
useRequestFileManifest(
fileManifestType,
MANIFEST_DOWNLOAD_FORMAT.COMPACT,
filters,
fileSummaryFacetName
);
useFileManifest(filters, fileSummaryFacetName);
const {
exploreState: { tabValue: entityList },
} = useExploreState();
const { data, isLoading, run } = useFileManifest();
const { requestMethod, requestUrl } = useRequestManifest(
manifestDownloadFormat,
formFacet
);
const { data, isLoading, run } = useRequestFileLocation(
requestUrl,
requestMethod
);
const manifestURL = getManifestDownloadURL(data);
return manifestURL ? (
<ManifestDownloadReady
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum METHOD {
GET = "GET",
PUT = "PUT",
}
44 changes: 0 additions & 44 deletions src/hooks/useFileManifest/common/buildFileManifestRequestURL.ts

This file was deleted.

6 changes: 0 additions & 6 deletions src/hooks/useFileManifest/common/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ export enum FILE_MANIFEST_TYPE {

export type FileManifestType = FILE_MANIFEST_TYPE;

export enum FILES_FACETS_STATUS {
COMPLETED = "COMPLETED",
IN_PROGRESS = "IN_PROGRESS",
NOT_STARTED = "NOT_STARTED",
}

export type SelectedSearchTermsBySearchKey = Map<
CategoryKey,
Set<CategoryValueKey>
Expand Down
Loading

0 comments on commit 86e3e40

Please sign in to comment.