Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparation dashboard #1516

Merged
merged 18 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 77 additions & 72 deletions app/components/chart-published.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Trans } from "@lingui/macro";
import { Box, Theme } from "@mui/material";
import { makeStyles } from "@mui/styles";
import clsx from "clsx";
import React, { useEffect, useMemo, useRef, useCallback } from "react";
import { useCallback, useEffect, useMemo, useRef } from "react";
import { useStore } from "zustand";

import { DataSetTable } from "@/browse/datatable";
Expand Down Expand Up @@ -50,7 +50,10 @@ import {
} from "@/graphql/hooks";
import { DataCubePublicationStatus } from "@/graphql/resolver-types";
import { useLocale } from "@/locales/use-locale";
import { InteractiveFiltersProvider } from "@/stores/interactive-filters";
import {
InteractiveFiltersChartProvider,
InteractiveFiltersProvider,
} from "@/stores/interactive-filters";
import { useEmbedOptions } from "@/utils/embed";
import useEvent from "@/utils/use-event";

Expand Down Expand Up @@ -80,7 +83,7 @@ export const ChartPublished = (props: ChartPublishedProps) => {
);

return state.layout.type === "dashboard" ? (
<>
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
<Box
sx={{
mb:
Expand Down Expand Up @@ -108,9 +111,9 @@ export const ChartPublished = (props: ChartPublishedProps) => {
renderChart={renderChart}
/>
)}
</>
</InteractiveFiltersProvider>
) : (
<>
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
ptbrowne marked this conversation as resolved.
Show resolved Hide resolved
<Flex
sx={{
flexDirection: "column",
Expand Down Expand Up @@ -138,7 +141,7 @@ export const ChartPublished = (props: ChartPublishedProps) => {
/>
</ChartWrapper>
</ChartTablePreviewProvider>
</>
</InteractiveFiltersProvider>
);
};

Expand Down Expand Up @@ -292,82 +295,84 @@ const ChartPublishedInner = (props: ChartPublishInnerProps) => {
</Box>
)}
<LoadingStateProvider>
<InteractiveFiltersProvider>
<Flex
sx={{
justifyContent: meta.title[locale]
? "space-between"
: "flex-end",
gap: 2,
}}
>
{meta.title[locale] ? (
<Title text={meta.title[locale]} />
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
ptbrowne marked this conversation as resolved.
Show resolved Hide resolved
<InteractiveFiltersChartProvider chartConfigKey={chartConfig.key}>
<Flex
sx={{
justifyContent: meta.title[locale]
? "space-between"
: "flex-end",
gap: 2,
}}
>
{meta.title[locale] ? (
<Title text={meta.title[locale]} />
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
)}
<MetadataPanel
dataSource={dataSource}
chartConfigs={[chartConfig]}
dimensions={allComponents}
container={rootRef.current}
/>
</Flex>
{meta.description[locale] ? (
<Description text={meta.description[locale]} />
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
)}
<MetadataPanel
dataSource={dataSource}
chartConfigs={[chartConfig]}
dimensions={allComponents}
container={rootRef.current}
/>
</Flex>
{meta.description[locale] ? (
<Description text={meta.description[locale]} />
) : (
// We need to have a span here to keep the space between the
// title and the chart (subgrid layout)
<span />
)}
{chartConfig.interactiveFiltersConfig?.dataFilters.active ? (
<ChartDataFilters
dataSource={dataSource}
chartConfig={chartConfig}
/>
) : (
// We need to have a span here to keep the space between the
// description and the chart (subgrid layout)
<span />
)}
<div
ref={containerRef}
style={{
minWidth: 0,
height: containerHeight.current,
marginTop: 16,
}}
>
{isTablePreview ? (
<DataSetTable
sx={{ maxHeight: "100%" }}
{chartConfig.interactiveFiltersConfig?.dataFilters.active ? (
<ChartDataFilters
dataSource={dataSource}
chartConfig={chartConfig}
/>
) : (
<ChartWithFilters
dataSource={dataSource}
componentIris={componentIris}
chartConfig={chartConfig}
/>
// We need to have a span here to keep the space between the
// description and the chart (subgrid layout)
<span />
)}
</div>
<ChartFootnotes
dataSource={dataSource}
chartConfig={chartConfig}
dimensions={dimensions}
configKey={configKey}
onToggleTableView={handleToggleTableView}
visualizeLinkText={
showDownload === false ? (
<Trans id="metadata.link.created.with.visualize.alternate">
visualize.admin.ch
</Trans>
) : undefined
}
/>
<div
ref={containerRef}
style={{
minWidth: 0,
height: containerHeight.current,
marginTop: 16,
}}
>
{isTablePreview ? (
<DataSetTable
sx={{ maxHeight: "100%" }}
dataSource={dataSource}
chartConfig={chartConfig}
/>
) : (
<ChartWithFilters
dataSource={dataSource}
componentIris={componentIris}
chartConfig={chartConfig}
/>
)}
</div>
<ChartFootnotes
dataSource={dataSource}
chartConfig={chartConfig}
dimensions={dimensions}
configKey={configKey}
onToggleTableView={handleToggleTableView}
visualizeLinkText={
showDownload === false ? (
<Trans id="metadata.link.created.with.visualize.alternate">
visualize.admin.ch
</Trans>
) : undefined
}
/>
</InteractiveFiltersChartProvider>
</InteractiveFiltersProvider>
</LoadingStateProvider>
</ChartErrorBoundary>
Expand Down
5 changes: 3 additions & 2 deletions app/configurator/components/chart-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
} from "@/graphql/query-hooks";
import { Icon } from "@/icons";
import { useLocale } from "@/locales/use-locale";
import { InteractiveFiltersChartProvider } from "@/stores/interactive-filters";
import useEvent from "@/utils/use-event";

import { DatasetsControlSection } from "./dataset-control-section";
Expand Down Expand Up @@ -594,7 +595,7 @@ export const ChartConfigurator = ({
}

return (
<>
<InteractiveFiltersChartProvider chartConfigKey={chartConfig.key}>
<ControlSection collapse>
<SubsectionTitle titleId="controls-design" gutterBottom={false}>
<Trans id="controls.select.chart.type">Chart Type</Trans>
Expand Down Expand Up @@ -744,7 +745,7 @@ export const ChartConfigurator = ({
<InteractiveFiltersConfigurator state={state} />
)}
<DatasetsControlSection />
</>
</InteractiveFiltersChartProvider>
);
};

Expand Down
29 changes: 17 additions & 12 deletions app/configurator/components/configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ import { ChartConfiguratorTable } from "@/configurator/table/table-chart-configu
import SvgIcChevronLeft from "@/icons/components/IcChevronLeft";
import { useLocale } from "@/locales/use-locale";
import { useDataSourceStore } from "@/stores/data-source";
import { InteractiveFiltersProvider } from "@/stores/interactive-filters";
import {
InteractiveFiltersChartProvider,
InteractiveFiltersProvider,
} from "@/stores/interactive-filters";
import { getRouterChartId } from "@/utils/router/helpers";
import useEvent from "@/utils/use-event";

Expand Down Expand Up @@ -166,7 +169,7 @@ const ConfigureChartStep = () => {
}

return (
<InteractiveFiltersProvider chartConfigs={state.chartConfigs}>
<InteractiveFiltersChartProvider chartConfigKey={chartConfig.key}>
<PanelLayout type="LM">
<PanelBodyWrapper
type="L"
Expand Down Expand Up @@ -207,7 +210,7 @@ const ConfigureChartStep = () => {
</div>
</ConfiguratorDrawer>
</PanelLayout>
</InteractiveFiltersProvider>
</InteractiveFiltersChartProvider>
);
};

Expand Down Expand Up @@ -438,20 +441,22 @@ export const Configurator = () => {
const { pathname } = useRouter();
// Local state, the dataset preview doesn't need to be persistent.
// FIXME: for a11y, "updateDataSetPreviewIri" should also move focus to "Weiter" button (?)
const [{ state }] = useConfiguratorState();
const [configuratorState] = useConfiguratorState();
const isLoadingConfigureChartStep =
state === "INITIAL" && pathname === "/create/[chartId]";
configuratorState.state === "INITIAL" && pathname === "/create/[chartId]";

return isLoadingConfigureChartStep ? (
<LoadingConfigureChartStep />
) : state === "SELECTING_DATASET" ? (
) : configuratorState.state === "SELECTING_DATASET" ? (
<SelectDatasetStep />
) : (
<>
{state === "CONFIGURING_CHART" && <ConfigureChartStep />}
{state === "LAYOUTING" && <LayoutingStep />}
{state === "PUBLISHING" && <PublishStep />}
</>
) : configuratorState.state === "INITIAL" ? null : (
<InteractiveFiltersProvider chartConfigs={configuratorState.chartConfigs}>
{configuratorState.state === "CONFIGURING_CHART" && (
<ConfigureChartStep />
)}
{configuratorState.state === "LAYOUTING" && <LayoutingStep />}
{configuratorState.state === "PUBLISHING" && <PublishStep />}
</InteractiveFiltersProvider>
);
};

Expand Down
Loading