@databiosphere/findable-ui 16.0.0 → 17.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.release-please-manifest.json +1 -1
- package/CHANGELOG.md +18 -0
- package/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand.d.ts +3 -2
- package/lib/components/Export/components/DownloadCurlCommand/downloadCurlCommand.js +6 -4
- package/lib/components/Export/components/ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm.d.ts +3 -2
- package/lib/components/Export/components/ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm.js +2 -12
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraForm/exportToTerraForm.d.ts +5 -2
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraForm/exportToTerraForm.js +2 -2
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraNotStarted/exportToTerraNotStarted.d.ts +3 -1
- package/lib/components/Export/components/ExportToTerra/components/ExportToTerraNotStarted/exportToTerraNotStarted.js +2 -2
- package/lib/components/Export/components/ExportToTerra/exportToTerra.d.ts +1 -1
- package/lib/components/Export/components/ExportToTerra/exportToTerra.js +9 -6
- package/lib/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.d.ts +3 -1
- package/lib/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.js +3 -4
- package/lib/components/Export/components/ManifestDownload/manifestDownload.d.ts +3 -2
- package/lib/components/Export/components/ManifestDownload/manifestDownload.js +6 -4
- package/lib/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.js +4 -3
- package/lib/hooks/types.d.ts +4 -0
- package/lib/hooks/types.js +5 -0
- package/lib/hooks/useFileManifest/common/entities.d.ts +0 -5
- package/lib/hooks/useFileManifest/common/entities.js +0 -6
- package/lib/hooks/useFileManifest/useFileManifest.d.ts +8 -5
- package/lib/hooks/useFileManifest/useFileManifest.js +29 -8
- package/lib/hooks/useFileManifest/useFileManifestDownload.js +10 -9
- package/lib/hooks/useFileManifest/useFileManifestFormat.d.ts +12 -0
- package/lib/hooks/useFileManifest/useFileManifestFormat.js +10 -0
- package/lib/hooks/useRequestFileLocation.d.ts +1 -4
- package/lib/hooks/useRequestFileLocation.js +1 -5
- package/lib/hooks/useRequestManifest/constants.d.ts +2 -0
- package/lib/hooks/useRequestManifest/constants.js +4 -0
- package/lib/hooks/useRequestManifest/types.d.ts +6 -0
- package/lib/hooks/useRequestManifest/types.js +1 -0
- package/lib/hooks/useRequestManifest/useRequestManifest.d.ts +10 -0
- package/lib/hooks/useRequestManifest/useRequestManifest.js +30 -0
- package/lib/hooks/useRequestManifest/utils.d.ts +65 -0
- package/lib/hooks/useRequestManifest/utils.js +118 -0
- package/lib/mocks/useRequestFileManifest.mocks.d.ts +11 -0
- package/lib/mocks/useRequestFileManifest.mocks.js +100 -0
- package/lib/providers/fileManifestState/constants.d.ts +0 -2
- package/lib/providers/fileManifestState/constants.js +0 -11
- package/lib/providers/fileManifestState.d.ts +3 -25
- package/lib/providers/fileManifestState.js +3 -36
- package/lib/views/ExportView/exportView.js +2 -2
- package/package.json +1 -1
- package/src/components/Export/components/DownloadCurlCommand/downloadCurlCommand.tsx +17 -10
- package/src/components/Export/components/ExportForm/components/ExportManifestDownloadFormatForm/exportManifestDownloadFormatForm.tsx +7 -16
- package/src/components/Export/components/ExportToTerra/components/ExportToTerraForm/exportToTerraForm.tsx +8 -4
- package/src/components/Export/components/ExportToTerra/components/ExportToTerraNotStarted/exportToTerraNotStarted.tsx +4 -1
- package/src/components/Export/components/ExportToTerra/exportToTerra.tsx +13 -9
- package/src/components/Export/components/ManifestDownload/components/ManifestDownloadEntity/manifestDownloadEntity.tsx +4 -9
- package/src/components/Export/components/ManifestDownload/manifestDownload.tsx +17 -11
- package/src/components/Links/components/Link/components/ExploreViewLink/exploreViewLink.tsx +6 -3
- package/src/hooks/types.ts +4 -0
- package/src/hooks/useFileManifest/common/entities.ts +0 -6
- package/src/hooks/useFileManifest/useFileManifest.ts +34 -13
- package/src/hooks/useFileManifest/useFileManifestDownload.ts +21 -16
- package/src/hooks/useFileManifest/useFileManifestFormat.ts +23 -0
- package/src/hooks/useRequestFileLocation.ts +1 -5
- package/src/hooks/useRequestManifest/constants.ts +6 -0
- package/src/hooks/useRequestManifest/types.ts +7 -0
- package/src/hooks/useRequestManifest/useRequestManifest.ts +49 -0
- package/src/hooks/useRequestManifest/utils.ts +153 -0
- package/src/mocks/useRequestFileManifest.mocks.ts +121 -0
- package/src/providers/fileManifestState/constants.ts +0 -15
- package/src/providers/fileManifestState.tsx +5 -77
- package/src/views/ExportView/exportView.tsx +2 -2
- package/tests/buildRequestFilters.test.ts +68 -0
- package/tests/buildRequestManifest.test.ts +103 -0
- package/tests/useRequestManifest.test.ts +193 -0
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.d.ts +0 -15
- package/lib/hooks/useFileManifest/common/buildFileManifestRequestURL.js +0 -28
- package/lib/hooks/useFileManifest/useFileManifestURL.d.ts +0 -5
- package/lib/hooks/useFileManifest/useFileManifestURL.js +0 -11
- package/lib/hooks/useFileManifest/useRequestFileManifest.d.ts +0 -11
- package/lib/hooks/useFileManifest/useRequestFileManifest.js +0 -40
- package/lib/providers/fileManifestState/actions.d.ts +0 -9
- package/lib/providers/fileManifestState/actions.js +0 -19
- package/lib/providers/fileManifestState/utils.d.ts +0 -34
- package/lib/providers/fileManifestState/utils.js +0 -80
- package/src/hooks/useFileManifest/common/buildFileManifestRequestURL.ts +0 -44
- package/src/hooks/useFileManifest/useFileManifestURL.ts +0 -12
- package/src/hooks/useFileManifest/useRequestFileManifest.ts +0 -51
- package/src/providers/fileManifestState/actions.ts +0 -34
- package/src/providers/fileManifestState/utils.ts +0 -108
- package/tests/fileManifestRequestFilters.test.ts +0 -160
- package/tests/updateFilesFacetsStatus.test.ts +0 -84
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ManifestDownloadFormat } from "../../apis/azul/common/entities";
|
|
2
|
+
import { Filters } from "../../common/entities";
|
|
3
|
+
import { FormFacet } from "../../components/Export/common/entities";
|
|
4
|
+
import { FileManifestState } from "../../providers/fileManifestState";
|
|
5
|
+
import { UseRequestManifest } from "./types";
|
|
6
|
+
/**
|
|
7
|
+
* Returns true if all form facets have all their terms selected.
|
|
8
|
+
* @param formFacet - Form related file facets.
|
|
9
|
+
* @returns true if all form facets have all their terms selected.
|
|
10
|
+
*/
|
|
11
|
+
export declare function areAllFormFilterTermsSelected(formFacet: FormFacet): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Generates the filters for a request URL based on the file manifest state.
|
|
14
|
+
* - **all form facets have all their terms selected** - returns filters from state without form filters.
|
|
15
|
+
* - **at least one form facet has an unselected term** - returns filters from state.
|
|
16
|
+
* @param state - File manifest state.
|
|
17
|
+
* @param formFacet - Form related file facets.
|
|
18
|
+
* @returns filters for the request URL.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildRequestFilters(state: FileManifestState, formFacet: FormFacet): Filters;
|
|
21
|
+
/**
|
|
22
|
+
* Build up file manifest request params and URL query string for the given search results, catalog and format.
|
|
23
|
+
* @param endpointUrl - Data URL.
|
|
24
|
+
* @param catalog - Configured catalog.
|
|
25
|
+
* @param filters - Selected filters.
|
|
26
|
+
* @param manifestFormat - Manifest format.
|
|
27
|
+
* @returns file manifest request params and URL query string.
|
|
28
|
+
*/
|
|
29
|
+
export declare function buildRequestManifest(endpointUrl: string, catalog: string, filters: Filters, manifestFormat: ManifestDownloadFormat): Required<UseRequestManifest>;
|
|
30
|
+
/**
|
|
31
|
+
* Returns filters, without form related filters.
|
|
32
|
+
* @param state - File manifest state.
|
|
33
|
+
* @param formFacet - Form related file facets.
|
|
34
|
+
* @returns filters.
|
|
35
|
+
*/
|
|
36
|
+
export declare function excludeFullySelectedFormFilters(state: FileManifestState, formFacet: FormFacet): Filters;
|
|
37
|
+
/**
|
|
38
|
+
* Returns true if the catalog is defined.
|
|
39
|
+
* The catalog is defined via the configuration and is required for the file manifest request.
|
|
40
|
+
* @param catalog - Catalog.
|
|
41
|
+
* @returns true if the catalog is defined.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isCatalogReady(catalog: string | undefined): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Returns true if the file manifest state is ready for a request.
|
|
46
|
+
* A file manifest state is considered ready if it is both enabled (`isEnabled` is `true`)
|
|
47
|
+
* and not currently loading (`isLoading` is `false`).
|
|
48
|
+
* @param fileManifestState - File manifest state.
|
|
49
|
+
* @returns true if the file manifest state is ready for a request.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isFileManifestStateReady(fileManifestState: FileManifestState): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Checks if the file manifest format is ready for use.
|
|
54
|
+
* The file manifest format is considered ready if `fileManifestFormat` is defined.
|
|
55
|
+
* @param fileManifestFormat - File manifest format.
|
|
56
|
+
* @returns `true` if the `fileManifestFormat` is defined.
|
|
57
|
+
*/
|
|
58
|
+
export declare function isFileManifestFormatReady(fileManifestFormat: ManifestDownloadFormat | undefined): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Checks if the form is ready to request a manifest.
|
|
61
|
+
* A form is considered ready if all facets have the `selected` term set to `true`.
|
|
62
|
+
* @param formFacet - Form related file facets.
|
|
63
|
+
* @returns `true` if all facets in the form are selected.
|
|
64
|
+
*/
|
|
65
|
+
export declare function isFormSelectionReady(formFacet: FormFacet): boolean;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { AZUL_PARAM, MANIFEST_DOWNLOAD_FORMAT, } from "../../apis/azul/common/entities";
|
|
2
|
+
import { transformFilters } from "../../apis/azul/common/filterTransformer";
|
|
3
|
+
import { REQUEST_MANIFEST } from "./constants";
|
|
4
|
+
/**
|
|
5
|
+
* Returns true if all form facets have all their terms selected.
|
|
6
|
+
* @param formFacet - Form related file facets.
|
|
7
|
+
* @returns true if all form facets have all their terms selected.
|
|
8
|
+
*/
|
|
9
|
+
export function areAllFormFilterTermsSelected(formFacet) {
|
|
10
|
+
return Object.values(formFacet)
|
|
11
|
+
.filter(Boolean)
|
|
12
|
+
.every(({ selectedTermCount, termCount }) => selectedTermCount === termCount);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Generates the filters for a request URL based on the file manifest state.
|
|
16
|
+
* - **all form facets have all their terms selected** - returns filters from state without form filters.
|
|
17
|
+
* - **at least one form facet has an unselected term** - returns filters from state.
|
|
18
|
+
* @param state - File manifest state.
|
|
19
|
+
* @param formFacet - Form related file facets.
|
|
20
|
+
* @returns filters for the request URL.
|
|
21
|
+
*/
|
|
22
|
+
export function buildRequestFilters(state, formFacet) {
|
|
23
|
+
// Form terms are fully selected; return filters excluding form filters.
|
|
24
|
+
if (areAllFormFilterTermsSelected(formFacet)) {
|
|
25
|
+
return excludeFullySelectedFormFilters(state, formFacet);
|
|
26
|
+
}
|
|
27
|
+
// Form terms are partially selected; return filters.
|
|
28
|
+
return state.filters;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build up file manifest request params and URL query string for the given search results, catalog and format.
|
|
32
|
+
* @param endpointUrl - Data URL.
|
|
33
|
+
* @param catalog - Configured catalog.
|
|
34
|
+
* @param filters - Selected filters.
|
|
35
|
+
* @param manifestFormat - Manifest format.
|
|
36
|
+
* @returns file manifest request params and URL query string.
|
|
37
|
+
*/
|
|
38
|
+
export function buildRequestManifest(endpointUrl, catalog, filters, manifestFormat) {
|
|
39
|
+
const requestParams = new URLSearchParams({
|
|
40
|
+
[AZUL_PARAM.CATALOG]: catalog,
|
|
41
|
+
[AZUL_PARAM.FILTERS]: transformFilters(filters),
|
|
42
|
+
format: manifestFormat,
|
|
43
|
+
});
|
|
44
|
+
const requestUrl = `${endpointUrl}fetch/manifest/files?${requestParams.toString()}`;
|
|
45
|
+
return {
|
|
46
|
+
...REQUEST_MANIFEST,
|
|
47
|
+
requestParams,
|
|
48
|
+
requestUrl,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Returns filters, without form related filters.
|
|
53
|
+
* @param state - File manifest state.
|
|
54
|
+
* @param formFacet - Form related file facets.
|
|
55
|
+
* @returns filters.
|
|
56
|
+
*/
|
|
57
|
+
export function excludeFullySelectedFormFilters(state, formFacet) {
|
|
58
|
+
const filters = [];
|
|
59
|
+
const formFacetNames = getFormFacetNamesSet(formFacet);
|
|
60
|
+
for (const filter of state.filters) {
|
|
61
|
+
if (formFacetNames.has(filter.categoryKey))
|
|
62
|
+
continue;
|
|
63
|
+
filters.push(filter);
|
|
64
|
+
}
|
|
65
|
+
return filters;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Returns a set of form facet names.
|
|
69
|
+
* @param formFacet - Form related file facets.
|
|
70
|
+
* @returns set of form facet names.
|
|
71
|
+
*/
|
|
72
|
+
function getFormFacetNamesSet(formFacet) {
|
|
73
|
+
return new Set(Object.values(formFacet)
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.map(({ name }) => name));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if the catalog is defined.
|
|
79
|
+
* The catalog is defined via the configuration and is required for the file manifest request.
|
|
80
|
+
* @param catalog - Catalog.
|
|
81
|
+
* @returns true if the catalog is defined.
|
|
82
|
+
*/
|
|
83
|
+
export function isCatalogReady(catalog) {
|
|
84
|
+
return typeof catalog === "string";
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Returns true if the file manifest state is ready for a request.
|
|
88
|
+
* A file manifest state is considered ready if it is both enabled (`isEnabled` is `true`)
|
|
89
|
+
* and not currently loading (`isLoading` is `false`).
|
|
90
|
+
* @param fileManifestState - File manifest state.
|
|
91
|
+
* @returns true if the file manifest state is ready for a request.
|
|
92
|
+
*/
|
|
93
|
+
export function isFileManifestStateReady(fileManifestState) {
|
|
94
|
+
return fileManifestState.isEnabled && !fileManifestState.isLoading;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Checks if the file manifest format is ready for use.
|
|
98
|
+
* The file manifest format is considered ready if `fileManifestFormat` is defined.
|
|
99
|
+
* @param fileManifestFormat - File manifest format.
|
|
100
|
+
* @returns `true` if the `fileManifestFormat` is defined.
|
|
101
|
+
*/
|
|
102
|
+
export function isFileManifestFormatReady(fileManifestFormat) {
|
|
103
|
+
if (!fileManifestFormat)
|
|
104
|
+
return false;
|
|
105
|
+
return Object.values(MANIFEST_DOWNLOAD_FORMAT).includes(fileManifestFormat);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Checks if the form is ready to request a manifest.
|
|
109
|
+
* A form is considered ready if all facets have the `selected` term set to `true`.
|
|
110
|
+
* @param formFacet - Form related file facets.
|
|
111
|
+
* @returns `true` if all facets in the form are selected.
|
|
112
|
+
*/
|
|
113
|
+
export function isFormSelectionReady(formFacet) {
|
|
114
|
+
const facets = Object.values(formFacet).filter(Boolean);
|
|
115
|
+
if (facets.length === 0)
|
|
116
|
+
return false;
|
|
117
|
+
return facets.every(({ selected }) => selected);
|
|
118
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Filters } from "../common/entities";
|
|
2
|
+
import { FormFacet } from "../components/Export/common/entities";
|
|
3
|
+
import { FileFacet } from "../hooks/useFileManifest/common/entities";
|
|
4
|
+
import { ConfigContextProps } from "../providers/config";
|
|
5
|
+
import { FileManifestState } from "../providers/fileManifestState";
|
|
6
|
+
export declare const CATALOG: string | undefined;
|
|
7
|
+
export declare const CONFIG: ConfigContextProps;
|
|
8
|
+
export declare const FILE_FACET: Record<string, FileFacet>;
|
|
9
|
+
export declare const FILTERS: Record<string, Filters>;
|
|
10
|
+
export declare const FILE_MANIFEST_STATE: FileManifestState;
|
|
11
|
+
export declare const FORM_FACET: Record<string, FormFacet>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export const CATALOG = "catalog";
|
|
2
|
+
const CATEGORY_KEY_NAME = {
|
|
3
|
+
CATEGORY_FILES: "files",
|
|
4
|
+
CATEGORY_OTHER: "other",
|
|
5
|
+
CATEGORY_SPECIES: "species",
|
|
6
|
+
};
|
|
7
|
+
export const CONFIG = {
|
|
8
|
+
config: { dataSource: { url: "https://mock-endpoint.com" } },
|
|
9
|
+
};
|
|
10
|
+
const FACET_PARTIAL = {
|
|
11
|
+
selectedTerms: [],
|
|
12
|
+
terms: [],
|
|
13
|
+
termsByName: new Map(),
|
|
14
|
+
total: 0,
|
|
15
|
+
}; // `name`, `selected`, `selectedTermCount`, and `termCount` properties are not used in this test.
|
|
16
|
+
export const FILE_FACET = {
|
|
17
|
+
FACET_FILES: {
|
|
18
|
+
...FACET_PARTIAL,
|
|
19
|
+
name: CATEGORY_KEY_NAME.CATEGORY_FILES,
|
|
20
|
+
selected: false,
|
|
21
|
+
selectedTermCount: 0,
|
|
22
|
+
termCount: 2,
|
|
23
|
+
},
|
|
24
|
+
FACET_OTHER: {
|
|
25
|
+
...FACET_PARTIAL,
|
|
26
|
+
name: CATEGORY_KEY_NAME.CATEGORY_OTHER,
|
|
27
|
+
selected: false,
|
|
28
|
+
selectedTermCount: 0,
|
|
29
|
+
termCount: 1,
|
|
30
|
+
},
|
|
31
|
+
FACET_SPECIES: {
|
|
32
|
+
...FACET_PARTIAL,
|
|
33
|
+
name: CATEGORY_KEY_NAME.CATEGORY_SPECIES,
|
|
34
|
+
selected: false,
|
|
35
|
+
selectedTermCount: 0,
|
|
36
|
+
termCount: 3,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
const FILTER_FILES = {
|
|
40
|
+
categoryKey: CATEGORY_KEY_NAME.CATEGORY_FILES,
|
|
41
|
+
value: ["file01", "file02"],
|
|
42
|
+
};
|
|
43
|
+
const FILTER_FILES_SUBSET = {
|
|
44
|
+
categoryKey: CATEGORY_KEY_NAME.CATEGORY_FILES,
|
|
45
|
+
value: ["file01"],
|
|
46
|
+
};
|
|
47
|
+
const FILTER_OTHER = {
|
|
48
|
+
categoryKey: CATEGORY_KEY_NAME.CATEGORY_OTHER,
|
|
49
|
+
value: ["other"],
|
|
50
|
+
};
|
|
51
|
+
const FILTER_SPECIES = {
|
|
52
|
+
categoryKey: CATEGORY_KEY_NAME.CATEGORY_SPECIES,
|
|
53
|
+
value: ["species01", "species02", "species03"],
|
|
54
|
+
};
|
|
55
|
+
export const FILTERS = {
|
|
56
|
+
FORM_COMPLETE_SET: [FILTER_FILES, FILTER_OTHER, FILTER_SPECIES],
|
|
57
|
+
FORM_INCOMPLETE_SET: [FILTER_FILES, FILTER_OTHER],
|
|
58
|
+
FORM_INITIAL_SET: [FILTER_OTHER],
|
|
59
|
+
FORM_SUBSET: [FILTER_FILES_SUBSET, FILTER_OTHER, FILTER_SPECIES],
|
|
60
|
+
};
|
|
61
|
+
export const FILE_MANIFEST_STATE = {
|
|
62
|
+
filters: FILTERS.FORM_INITIAL_SET,
|
|
63
|
+
isEnabled: true,
|
|
64
|
+
isLoading: false,
|
|
65
|
+
};
|
|
66
|
+
export const FORM_FACET = {
|
|
67
|
+
COMPLETE_SET: {
|
|
68
|
+
fileSummaryFacet: {
|
|
69
|
+
...FILE_FACET.FACET_FILES,
|
|
70
|
+
selected: true,
|
|
71
|
+
selectedTermCount: FILE_FACET.FACET_FILES.termCount, // All terms selected.
|
|
72
|
+
},
|
|
73
|
+
speciesFacet: {
|
|
74
|
+
...FILE_FACET.FACET_SPECIES,
|
|
75
|
+
selected: true,
|
|
76
|
+
selectedTermCount: FILE_FACET.FACET_SPECIES.termCount, // All terms selected.
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
INCOMPLETE_SET: {
|
|
80
|
+
fileSummaryFacet: {
|
|
81
|
+
...FILE_FACET.FACET_FILES,
|
|
82
|
+
selected: true,
|
|
83
|
+
selectedTermCount: FILE_FACET.FACET_FILES.termCount, // All terms selected.
|
|
84
|
+
},
|
|
85
|
+
speciesFacet: FILE_FACET.FACET_SPECIES, // Species facet is unselected.
|
|
86
|
+
},
|
|
87
|
+
INITIAL_SET: { fileSummaryFacet: undefined, speciesFacet: undefined },
|
|
88
|
+
SUBSET: {
|
|
89
|
+
fileSummaryFacet: {
|
|
90
|
+
...FILE_FACET.FACET_FILES,
|
|
91
|
+
selected: true,
|
|
92
|
+
selectedTermCount: 1, // One of a possible two terms selected.
|
|
93
|
+
},
|
|
94
|
+
speciesFacet: {
|
|
95
|
+
...FILE_FACET.FACET_SPECIES,
|
|
96
|
+
selected: true,
|
|
97
|
+
selectedTermCount: 1, // One of a possible three terms selected.
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
};
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
import { FILE_MANIFEST_TYPE } from "../../hooks/useFileManifest/common/entities";
|
|
2
1
|
import { FileManifestState } from "../fileManifestState";
|
|
3
|
-
export declare const ENTITIES_FILE_MANIFEST_TYPES: FILE_MANIFEST_TYPE[];
|
|
4
2
|
export declare const FILE_MANIFEST_STATE: FileManifestState;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { FILE_MANIFEST_TYPE, FILES_FACETS_STATUS, } from "../../hooks/useFileManifest/common/entities";
|
|
2
|
-
export const ENTITIES_FILE_MANIFEST_TYPES = [
|
|
3
|
-
FILE_MANIFEST_TYPE.BULK_DOWNLOAD,
|
|
4
|
-
FILE_MANIFEST_TYPE.DOWNLOAD_MANIFEST,
|
|
5
|
-
FILE_MANIFEST_TYPE.EXPORT_TO_TERRA,
|
|
6
|
-
];
|
|
7
1
|
export const FILE_MANIFEST_STATE = {
|
|
8
|
-
fileManifestFormat: undefined,
|
|
9
|
-
fileManifestType: undefined,
|
|
10
2
|
fileSummary: undefined,
|
|
11
3
|
fileSummaryFacetName: undefined,
|
|
12
4
|
fileSummaryFilters: [],
|
|
13
5
|
filesFacets: [],
|
|
14
|
-
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED,
|
|
15
6
|
filters: [],
|
|
16
7
|
isEnabled: false,
|
|
17
8
|
isFacetsLoading: false,
|
|
@@ -19,7 +10,5 @@ export const FILE_MANIFEST_STATE = {
|
|
|
19
10
|
isFileSummaryLoading: false,
|
|
20
11
|
isLoading: false,
|
|
21
12
|
isSummaryLoading: false,
|
|
22
|
-
requestParams: undefined,
|
|
23
|
-
requestURL: undefined,
|
|
24
13
|
summary: undefined,
|
|
25
14
|
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import React, { Dispatch, ReactNode } from "react";
|
|
2
|
-
import { AzulSummaryResponse
|
|
2
|
+
import { AzulSummaryResponse } from "../apis/azul/common/entities";
|
|
3
3
|
import { CategoryKey, CategoryValueKey, Filters } from "../common/entities";
|
|
4
|
-
import { FileFacet
|
|
4
|
+
import { FileFacet } from "../hooks/useFileManifest/common/entities";
|
|
5
5
|
/**
|
|
6
6
|
* File manifest state.
|
|
7
7
|
*/
|
|
8
8
|
export type FileManifestState = {
|
|
9
|
-
fileManifestFormat?: ManifestDownloadFormat;
|
|
10
|
-
fileManifestType?: FileManifestType;
|
|
11
9
|
filesFacets: FileFacet[];
|
|
12
|
-
filesFacetsStatus: FILES_FACETS_STATUS;
|
|
13
10
|
fileSummary?: AzulSummaryResponse;
|
|
14
11
|
fileSummaryFacetName?: string;
|
|
15
12
|
fileSummaryFilters: Filters;
|
|
@@ -20,8 +17,6 @@ export type FileManifestState = {
|
|
|
20
17
|
isFileSummaryLoading: boolean;
|
|
21
18
|
isLoading: boolean;
|
|
22
19
|
isSummaryLoading: boolean;
|
|
23
|
-
requestParams?: URLSearchParams;
|
|
24
|
-
requestURL?: string;
|
|
25
20
|
summary?: AzulSummaryResponse;
|
|
26
21
|
};
|
|
27
22
|
/**
|
|
@@ -43,14 +38,13 @@ export declare enum FileManifestActionKind {
|
|
|
43
38
|
ClearFileManifest = "CLEAR_FILE_MANIFEST",
|
|
44
39
|
FetchFileManifest = "FETCH_FILE_MANIFEST",
|
|
45
40
|
UpdateFileManifest = "UPDATE_FILE_MANIFEST",
|
|
46
|
-
UpdateFileManifestFormat = "UPDATE_FILE_MANIFEST_FORMAT",
|
|
47
41
|
UpdateFilter = "UPDATE_FILTER",
|
|
48
42
|
UpdateFiltersCategory = "UPDATE_FILTERS_CATEGORY"
|
|
49
43
|
}
|
|
50
44
|
/**
|
|
51
45
|
* File manifest action.
|
|
52
46
|
*/
|
|
53
|
-
export type FileManifestAction = ClearFileManifestAction | FetchFileManifestAction | UpdateFileManifestAction |
|
|
47
|
+
export type FileManifestAction = ClearFileManifestAction | FetchFileManifestAction | UpdateFileManifestAction | UpdateFilterAction | UpdateFiltersCategoryAction;
|
|
54
48
|
/**
|
|
55
49
|
* Resets file manifest state.
|
|
56
50
|
*/
|
|
@@ -72,13 +66,6 @@ type UpdateFileManifestAction = {
|
|
|
72
66
|
payload: UpdateFileManifestPayload;
|
|
73
67
|
type: FileManifestActionKind.UpdateFileManifest;
|
|
74
68
|
};
|
|
75
|
-
/**
|
|
76
|
-
* Update file manifest format action.
|
|
77
|
-
*/
|
|
78
|
-
type UpdateFileManifestFormatAction = {
|
|
79
|
-
payload: ManifestDownloadFormat | undefined;
|
|
80
|
-
type: FileManifestActionKind.UpdateFileManifestFormat;
|
|
81
|
-
};
|
|
82
69
|
/**
|
|
83
70
|
* Update filter action.
|
|
84
71
|
*/
|
|
@@ -97,8 +84,6 @@ type UpdateFiltersCategoryAction = {
|
|
|
97
84
|
* Initialize file manifest payload.
|
|
98
85
|
*/
|
|
99
86
|
type FetchFileManifestPayload = {
|
|
100
|
-
fileManifestFormat?: ManifestDownloadFormat;
|
|
101
|
-
fileManifestType?: FileManifestType;
|
|
102
87
|
fileSummaryFacetName?: string;
|
|
103
88
|
filters: Filters;
|
|
104
89
|
};
|
|
@@ -123,11 +108,4 @@ export type UpdateFilterPayload = {
|
|
|
123
108
|
selected: boolean;
|
|
124
109
|
selectedValue: CategoryValueKey;
|
|
125
110
|
};
|
|
126
|
-
/**
|
|
127
|
-
* File manifest context.
|
|
128
|
-
*/
|
|
129
|
-
export interface FileManifestContext {
|
|
130
|
-
catalog: string;
|
|
131
|
-
URL: string;
|
|
132
|
-
}
|
|
133
111
|
export {};
|
|
@@ -2,14 +2,9 @@ import React, { createContext, useEffect, useReducer, } from "react";
|
|
|
2
2
|
import { getFilterParameterValue } from "../apis/azul/common/utils";
|
|
3
3
|
import { useCatalog } from "../hooks/useCatalog";
|
|
4
4
|
import { buildNextFilterState } from "../hooks/useCategoryFilter";
|
|
5
|
-
import { buildFileManifestRequestURL } from "../hooks/useFileManifest/common/buildFileManifestRequestURL";
|
|
6
|
-
import { FILES_FACETS_STATUS, } from "../hooks/useFileManifest/common/entities";
|
|
7
5
|
import { useFetchFilesFacets } from "../hooks/useFileManifest/useFetchFilesFacets";
|
|
8
6
|
import { useFetchSummary } from "../hooks/useFileManifest/useFetchSummary";
|
|
9
|
-
import { useFileManifestURL } from "../hooks/useFileManifest/useFileManifestURL";
|
|
10
|
-
import { updateFileManifestAction } from "./fileManifestState/actions";
|
|
11
7
|
import { FILE_MANIFEST_STATE } from "./fileManifestState/constants";
|
|
12
|
-
import { getRequestFilters } from "./fileManifestState/utils";
|
|
13
8
|
export const FileManifestStateContext = createContext({
|
|
14
9
|
// eslint-disable-next-line @typescript-eslint/no-empty-function -- allow dummy function for default state.
|
|
15
10
|
fileManifestDispatch: () => { },
|
|
@@ -18,10 +13,8 @@ export const FileManifestStateContext = createContext({
|
|
|
18
13
|
export function FileManifestStateProvider({ children, }) {
|
|
19
14
|
// Determine catalog.
|
|
20
15
|
const catalog = useCatalog(); // catalog should be defined.
|
|
21
|
-
// Determine file manifest request data URL.
|
|
22
|
-
const URL = useFileManifestURL();
|
|
23
16
|
// File manifest state.
|
|
24
|
-
const [fileManifestState, fileManifestDispatch] = useReducer((s, a) => fileManifestReducer(s, a
|
|
17
|
+
const [fileManifestState, fileManifestDispatch] = useReducer((s, a) => fileManifestReducer(s, a), FILE_MANIFEST_STATE);
|
|
25
18
|
const { fileSummaryFacetName, fileSummaryFilters, filters, isEnabled } = fileManifestState;
|
|
26
19
|
// Fetch files facets.
|
|
27
20
|
const { filesFacets, isLoading: isFacetsLoading, isSuccess: isFacetsSuccess, } = useFetchFilesFacets(filters, catalog, { size: "25" }, isEnabled);
|
|
@@ -66,7 +59,6 @@ export var FileManifestActionKind;
|
|
|
66
59
|
FileManifestActionKind["ClearFileManifest"] = "CLEAR_FILE_MANIFEST";
|
|
67
60
|
FileManifestActionKind["FetchFileManifest"] = "FETCH_FILE_MANIFEST";
|
|
68
61
|
FileManifestActionKind["UpdateFileManifest"] = "UPDATE_FILE_MANIFEST";
|
|
69
|
-
FileManifestActionKind["UpdateFileManifestFormat"] = "UPDATE_FILE_MANIFEST_FORMAT";
|
|
70
62
|
FileManifestActionKind["UpdateFilter"] = "UPDATE_FILTER";
|
|
71
63
|
FileManifestActionKind["UpdateFiltersCategory"] = "UPDATE_FILTERS_CATEGORY";
|
|
72
64
|
})(FileManifestActionKind || (FileManifestActionKind = {}));
|
|
@@ -74,22 +66,16 @@ export var FileManifestActionKind;
|
|
|
74
66
|
* File manifest reducer.
|
|
75
67
|
* @param state - File manifest state.
|
|
76
68
|
* @param action - File manifest action.
|
|
77
|
-
* @param fileManifestContext - File manifest context.
|
|
78
69
|
* @returns file manifest state.
|
|
79
70
|
*/
|
|
80
|
-
function fileManifestReducer(state, action
|
|
71
|
+
function fileManifestReducer(state, action) {
|
|
81
72
|
const { payload, type } = action;
|
|
82
|
-
const { catalog, URL } = fileManifestContext;
|
|
83
73
|
switch (type) {
|
|
84
74
|
// Resets file manifest.
|
|
85
75
|
case FileManifestActionKind.ClearFileManifest: {
|
|
86
76
|
return {
|
|
87
77
|
...state,
|
|
88
|
-
fileManifestFormat: undefined,
|
|
89
|
-
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED,
|
|
90
78
|
isEnabled: false,
|
|
91
|
-
requestParams: undefined,
|
|
92
|
-
requestURL: undefined,
|
|
93
79
|
};
|
|
94
80
|
}
|
|
95
81
|
// Fetches file manifest.
|
|
@@ -101,24 +87,11 @@ function fileManifestReducer(state, action, fileManifestContext) {
|
|
|
101
87
|
...payload,
|
|
102
88
|
fileSummaryFilters,
|
|
103
89
|
isEnabled: true,
|
|
104
|
-
requestParams: undefined,
|
|
105
|
-
requestURL: undefined,
|
|
106
90
|
};
|
|
107
91
|
}
|
|
108
92
|
// Updates file manifest.
|
|
109
93
|
case FileManifestActionKind.UpdateFileManifest: {
|
|
110
|
-
return
|
|
111
|
-
}
|
|
112
|
-
// Updates file manifest format.
|
|
113
|
-
case FileManifestActionKind.UpdateFileManifestFormat: {
|
|
114
|
-
// Build request params and request URL.
|
|
115
|
-
const { requestParams, requestURL } = buildFileManifestRequestURL(URL, getRequestFilters(state), catalog, payload) || {};
|
|
116
|
-
return {
|
|
117
|
-
...state,
|
|
118
|
-
fileManifestFormat: payload,
|
|
119
|
-
requestParams,
|
|
120
|
-
requestURL,
|
|
121
|
-
};
|
|
94
|
+
return { ...state, ...payload };
|
|
122
95
|
}
|
|
123
96
|
// Updates selected file manifest filters with given selected category value.
|
|
124
97
|
case FileManifestActionKind.UpdateFilter: {
|
|
@@ -130,10 +103,7 @@ function fileManifestReducer(state, action, fileManifestContext) {
|
|
|
130
103
|
return {
|
|
131
104
|
...state,
|
|
132
105
|
fileSummaryFilters,
|
|
133
|
-
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED,
|
|
134
106
|
filters,
|
|
135
|
-
requestParams: undefined,
|
|
136
|
-
requestURL: undefined,
|
|
137
107
|
};
|
|
138
108
|
}
|
|
139
109
|
// Updates selected file manifest filters by category.
|
|
@@ -145,10 +115,7 @@ function fileManifestReducer(state, action, fileManifestContext) {
|
|
|
145
115
|
return {
|
|
146
116
|
...state,
|
|
147
117
|
fileSummaryFilters,
|
|
148
|
-
filesFacetsStatus: FILES_FACETS_STATUS.NOT_STARTED,
|
|
149
118
|
filters,
|
|
150
|
-
requestParams: undefined,
|
|
151
|
-
requestURL: undefined,
|
|
152
119
|
};
|
|
153
120
|
}
|
|
154
121
|
default:
|
|
@@ -3,12 +3,12 @@ import { ComponentCreator } from "../../components/ComponentCreator/ComponentCre
|
|
|
3
3
|
import { BackPageView } from "../../components/Layout/components/BackPage/backPageView";
|
|
4
4
|
import { useExploreState } from "../../hooks/useExploreState";
|
|
5
5
|
import { useExportConfig } from "../../hooks/useExportConfig";
|
|
6
|
-
import {
|
|
6
|
+
import { useFileManifest } from "../../hooks/useFileManifest/useFileManifest";
|
|
7
7
|
import { useUpdateURLSearchParams } from "../../hooks/useUpdateURLSearchParams";
|
|
8
8
|
export const ExportView = (props) => {
|
|
9
9
|
const { exploreState: { filterState }, } = useExploreState();
|
|
10
10
|
useUpdateURLSearchParams();
|
|
11
|
-
|
|
11
|
+
useFileManifest(filterState, undefined);
|
|
12
12
|
const { tabs, top } = useExportConfig();
|
|
13
13
|
const currentTab = tabs[0];
|
|
14
14
|
const { mainColumn, sideColumn } = currentTab;
|
package/package.json
CHANGED
|
@@ -4,13 +4,17 @@ import { Filters } from "../../../../common/entities";
|
|
|
4
4
|
import { useExploreState } from "../../../../hooks/useExploreState";
|
|
5
5
|
import { FileManifestType } from "../../../../hooks/useFileManifest/common/entities";
|
|
6
6
|
import { useFileManifest } from "../../../../hooks/useFileManifest/useFileManifest";
|
|
7
|
-
import {
|
|
8
|
-
|
|
7
|
+
import {
|
|
8
|
+
FileLocation,
|
|
9
|
+
useRequestFileLocation,
|
|
10
|
+
} from "../../../../hooks/useRequestFileLocation";
|
|
11
|
+
import { useRequestManifest } from "../../../../hooks/useRequestManifest/useRequestManifest";
|
|
9
12
|
import { FileManifestState } from "../../../../providers/fileManifestState";
|
|
10
13
|
import {
|
|
11
14
|
BULK_DOWNLOAD_EXECUTION_ENVIRONMENT,
|
|
12
15
|
ExecutionEnvironment,
|
|
13
16
|
FormFacet,
|
|
17
|
+
ManifestDownloadFormat,
|
|
14
18
|
} from "../../common/entities";
|
|
15
19
|
import { trackBulkDownloadRequested } from "../../common/tracking";
|
|
16
20
|
import { DownloadCurlCommandNotStarted } from "./components/DownloadCurlCommandNotStarted/downloadCurlCommandNotStarted";
|
|
@@ -25,6 +29,7 @@ interface DownloadCurlCommandProps {
|
|
|
25
29
|
fileSummaryFacetName: string;
|
|
26
30
|
filters: Filters; // Initializes bulk download filters.
|
|
27
31
|
formFacet: FormFacet;
|
|
32
|
+
manifestDownloadFormat?: ManifestDownloadFormat;
|
|
28
33
|
}
|
|
29
34
|
|
|
30
35
|
export const DownloadCurlCommand = ({
|
|
@@ -32,23 +37,25 @@ export const DownloadCurlCommand = ({
|
|
|
32
37
|
DownloadCurlStart,
|
|
33
38
|
DownloadCurlSuccess,
|
|
34
39
|
fileManifestState,
|
|
35
|
-
fileManifestType,
|
|
36
40
|
fileSummaryFacetName,
|
|
37
41
|
filters,
|
|
38
42
|
formFacet,
|
|
43
|
+
manifestDownloadFormat = MANIFEST_DOWNLOAD_FORMAT.CURL,
|
|
39
44
|
}: DownloadCurlCommandProps): JSX.Element => {
|
|
40
|
-
|
|
41
|
-
fileManifestType,
|
|
42
|
-
MANIFEST_DOWNLOAD_FORMAT.CURL,
|
|
43
|
-
filters,
|
|
44
|
-
fileSummaryFacetName
|
|
45
|
-
);
|
|
45
|
+
useFileManifest(filters, fileSummaryFacetName);
|
|
46
46
|
const [executionEnvironment, setExecutionEnvironment] =
|
|
47
47
|
useState<ExecutionEnvironment>(BULK_DOWNLOAD_EXECUTION_ENVIRONMENT.BASH);
|
|
48
48
|
const {
|
|
49
49
|
exploreState: { tabValue: entityList },
|
|
50
50
|
} = useExploreState();
|
|
51
|
-
const {
|
|
51
|
+
const { requestMethod, requestUrl } = useRequestManifest(
|
|
52
|
+
manifestDownloadFormat,
|
|
53
|
+
formFacet
|
|
54
|
+
);
|
|
55
|
+
const { data, isLoading, run } = useRequestFileLocation(
|
|
56
|
+
requestUrl,
|
|
57
|
+
requestMethod
|
|
58
|
+
);
|
|
52
59
|
const curlCommand = getBulkDownloadCurlCommand(data, executionEnvironment);
|
|
53
60
|
return curlCommand ? (
|
|
54
61
|
<DownloadCurlCommandReady
|
|
@@ -1,42 +1,33 @@
|
|
|
1
1
|
import { FormControlLabel, FormLabel, Radio, RadioGroup } from "@mui/material";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { FileManifestActionKind } from "../../../../../../providers/fileManifestState";
|
|
3
|
+
import { FileManifestFormatState } from "../../../../../../hooks/useFileManifest/useFileManifestFormat";
|
|
5
4
|
import { RadioCheckedIcon } from "../../../../../common/CustomIcon/components/RadioCheckedIcon/radioCheckedIcon";
|
|
6
5
|
import { RadioUncheckedIcon } from "../../../../../common/CustomIcon/components/RadioUncheckedIcon/radioUncheckedIcon";
|
|
7
6
|
import { ManifestDownloadFormat } from "../../../../common/entities";
|
|
8
7
|
import { FormControl } from "../../exportForm.styles";
|
|
9
8
|
|
|
10
9
|
export interface ExportManifestDownloadFormatFormProps {
|
|
11
|
-
|
|
10
|
+
fileManifestFormatState: FileManifestFormatState;
|
|
12
11
|
manifestDownloadFormats: ManifestDownloadFormat[];
|
|
13
12
|
}
|
|
14
13
|
|
|
15
14
|
export const ExportManifestDownloadFormatForm = ({
|
|
16
|
-
|
|
15
|
+
fileManifestFormatState,
|
|
17
16
|
manifestDownloadFormats,
|
|
18
17
|
}: ExportManifestDownloadFormatFormProps): JSX.Element => {
|
|
19
|
-
const { fileManifestDispatch } = useFileManifestState();
|
|
20
|
-
|
|
21
|
-
// Updates file manifest format state.
|
|
22
|
-
const onUpdateManifestFormat = (format: ManifestDownloadFormat): void => {
|
|
23
|
-
fileManifestDispatch({
|
|
24
|
-
payload: format,
|
|
25
|
-
type: FileManifestActionKind.UpdateFileManifestFormat,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
|
|
29
18
|
return (
|
|
30
19
|
<FormControl>
|
|
31
20
|
<FormLabel>Download Format</FormLabel>
|
|
32
|
-
<RadioGroup value={
|
|
21
|
+
<RadioGroup value={fileManifestFormatState.fileManifestFormat ?? ""}>
|
|
33
22
|
{manifestDownloadFormats.map((manifestFormat) => (
|
|
34
23
|
<FormControlLabel
|
|
35
24
|
control={
|
|
36
25
|
<Radio
|
|
37
26
|
checkedIcon={<RadioCheckedIcon />}
|
|
38
27
|
icon={<RadioUncheckedIcon />}
|
|
39
|
-
onChange={(): void =>
|
|
28
|
+
onChange={(): void =>
|
|
29
|
+
fileManifestFormatState.setFileManifestFormat(manifestFormat)
|
|
30
|
+
}
|
|
40
31
|
size="small"
|
|
41
32
|
value={manifestFormat}
|
|
42
33
|
/>
|