diff --git a/app/browser/dataset-preview.tsx b/app/browser/dataset-preview.tsx index fee2f7a9a..0b4b22231 100644 --- a/app/browser/dataset-preview.tsx +++ b/app/browser/dataset-preview.tsx @@ -202,7 +202,7 @@ export const DataSetPreview = ({ diff --git a/app/components/chart-footnotes.tsx b/app/components/chart-footnotes.tsx index 3d95cd4f6..4b0a58b06 100644 --- a/app/components/chart-footnotes.tsx +++ b/app/components/chart-footnotes.tsx @@ -19,6 +19,7 @@ import { } from "@/graphql/hooks"; import { Icon, getChartIcon } from "@/icons"; import { useLocale } from "@/locales/use-locale"; +import { assert } from "@/utils/assert"; import { useEmbedOptions } from "@/utils/embed"; import { makeOpenDataLink } from "@/utils/opendata"; @@ -121,6 +122,10 @@ export const ChartFootnotes = ({ const sparqlEditorUrl = sparqlEditorUrls?.find( (d) => d.cubeIri === dataCubeMetadata.iri )?.url; + const cubeQueryFilters = queryFilters.find( + (f) => f.iri === dataCubeMetadata.iri + ); + assert(cubeQueryFilters, "Cube query filters not found"); return ( @@ -206,7 +211,7 @@ export const ChartFootnotes = ({ ) : null} {showTableSwitch !== false ? ( diff --git a/app/components/data-download.spec.ts b/app/components/data-download.spec.ts index 1641d4e9e..14a85c257 100644 --- a/app/components/data-download.spec.ts +++ b/app/components/data-download.spec.ts @@ -5,16 +5,11 @@ import { DataCubeObservationFilter } from "@/graphql/query-hooks"; describe("getFullDataDownloadFilters", () => { it("should not have componentIris", () => { - const rawFilters: DataCubeObservationFilter[] = [ - { - iri: "ABC", - componentIris: ["DEF"], - }, - { - iri: "GHI", - }, - ]; + const rawFilters: DataCubeObservationFilter = { + iri: "ABC", + componentIris: ["DEF"], + }; const filters = getFullDataDownloadFilters(rawFilters); - expect(filters.some((f) => get(f, "componentIris"))).toBeFalsy(); + expect(get(filters, "componentIris")).toBeFalsy(); }); }); diff --git a/app/components/data-download.tsx b/app/components/data-download.tsx index 704c7db04..20e5805bc 100644 --- a/app/components/data-download.tsx +++ b/app/components/data-download.tsx @@ -179,7 +179,7 @@ export const DataDownloadMenu = memo( title, }: { dataSource: DataSource; - filters: DataCubeObservationFilter[]; + filters: DataCubeObservationFilter; title: string; }) => { return ( @@ -201,7 +201,7 @@ const DataDownloadInnerMenu = ({ }: { dataSource: DataSource; fileName: string; - filters: DataCubeObservationFilter[]; + filters: DataCubeObservationFilter; }) => { const [state] = useDataDownloadState(); const popupState = usePopupState({ @@ -239,7 +239,7 @@ const DataDownloadInnerMenu = ({ sx: { width: 200, pt: 1, pb: 2 }, }} > - {filters.some((f) => f.filters) && ( + {filters.filters && ( { - return filters.map((d) => ({ iri: d.iri })); + return { iri: filters.iri }; }; const DataDownloadMenuSection = ({ @@ -285,7 +285,7 @@ const DataDownloadMenuSection = ({ dataSource: DataSource; subheader: ReactNode; fileName: string; - filters?: DataCubeObservationFilter[]; + filters?: DataCubeObservationFilter; }) => { return ( <> @@ -318,7 +318,7 @@ const DownloadMenuItem = ({ dataSource: DataSource; fileName: string; fileFormat: FileFormat; - filters?: DataCubeObservationFilter[]; + filters?: DataCubeObservationFilter; }) => { const locale = useLocale(); const i18n = useI18n(); @@ -398,13 +398,13 @@ const DownloadMenuItem = ({ sourceType: dataSource.type, sourceUrl: dataSource.url, locale, - cubeFilters: filters, + cubeFilters: [filters], }), executeDataCubesObservationsQuery(client, { sourceType: dataSource.type, sourceUrl: dataSource.url, locale, - cubeFilters: filters, + cubeFilters: [filters], }), ]);