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

UI configurator enhancements #829

Merged
merged 34 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b924e72
feat: Remove right panel and flatter style
ptbrowne Nov 7, 2022
116ee91
fix: Do not show user id in Login Menu
ptbrowne Nov 7, 2022
7d854fb
feat: Move annotator config to configuring step
ptbrowne Nov 8, 2022
92cd06f
refactor: Extract TitleAndDescription
ptbrowne Nov 8, 2022
9f9dd11
feat: Show interactive filters in the left panel
ptbrowne Nov 8, 2022
ea84a81
feat: Add collapse to ControlSection
ptbrowne Nov 8, 2022
8e978c3
feat: Add warn icon when no title or description
ptbrowne Nov 8, 2022
4ec82a7
feat: Remove shadows according to new design
ptbrowne Nov 8, 2022
b210c11
refactor: Extract Title and Description options
ptbrowne Nov 8, 2022
96976af
fix: Control sections show their border top, to have a separation wit…
ptbrowne Nov 8, 2022
c72abb1
feat: Clicking on title & description brings title/description
ptbrowne Nov 8, 2022
1228afc
feat: Improve gutterBottom for section titles and rename collapse pro…
ptbrowne Nov 8, 2022
06cfd04
fix: Can change description/title in configuring step
ptbrowne Nov 8, 2022
bb84b2f
fix: Ability to click on page while configurator drawer is opened
ptbrowne Nov 8, 2022
a97319c
fix: Styling for drawer
ptbrowne Nov 8, 2022
2a2fd6e
feat: Add correct gutterBottom + collapse to table chart configurator
ptbrowne Nov 8, 2022
9ac95f5
feat: Use control section skeleton for interactive filters
ptbrowne Nov 8, 2022
a8bc8d8
feat: Use correct icon for chart annotator
ptbrowne Nov 8, 2022
8791afa
feat: Use translated string for Back to preview and Checkout to publi…
ptbrowne Nov 8, 2022
1413cf0
feat: Remove unused stepper
ptbrowne Nov 8, 2022
65968b0
feat: Add chevron right to publish chart
ptbrowne Nov 8, 2022
2788e66
feat: Remove describing chart step
ptbrowne Nov 8, 2022
ea34643
feat: Publish button send STEP_NEXT
ptbrowne Nov 8, 2022
97af247
fix: Keep a singleton Prisma across hot reloads
ptbrowne Nov 8, 2022
174a618
feat: Update messages
ptbrowne Nov 8, 2022
916dcb7
feat: Put login links below language menu
ptbrowne Nov 8, 2022
038ef2b
refactor: Remove unused
ptbrowne Nov 8, 2022
3143284
feat: Add right icon to field controls
ptbrowne Nov 8, 2022
b0fef1a
feat: Add warning on annotator fields
ptbrowne Nov 8, 2022
0962364
refactor: Remove unused EmptyRightPanel
ptbrowne Nov 8, 2022
71f5271
test: Use new data-testid for panel-drawer
ptbrowne Nov 8, 2022
82d3f9e
fix: Handle case where meta.title.<lang> is not defined
ptbrowne Nov 8, 2022
caf2822
fix: Remove unused
ptbrowne Nov 8, 2022
9892c3e
test: Close drawer before trying to change chart type
ptbrowne Nov 8, 2022
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
5 changes: 1 addition & 4 deletions app/components/chart-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Flex from "@/components/flex";
import {
ChartType,
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
ConfiguratorStatePublishing,
} from "@/configurator";
import { useConfiguratorState } from "@/src";
Expand All @@ -18,9 +17,7 @@ type ChartPanelProps = { children: ReactNode } & BoxProps;
export const ChartPanelConfigurator = (props: ChartPanelProps) => {
// This type of chart panel can only appear for below steps.
const [state] = useConfiguratorState() as unknown as [
| ConfiguratorStateConfiguringChart
| ConfiguratorStateDescribingChart
| ConfiguratorStatePublishing
ConfiguratorStateConfiguringChart | ConfiguratorStatePublishing
];

return (
Expand Down
1 change: 0 additions & 1 deletion app/components/chart-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export const ChartPreviewInner = ({
</Box>
)}
{(state.state === "CONFIGURING_CHART" ||
state.state === "DESCRIBING_CHART" ||
state.state === "PUBLISHING") && (
<>
<>
Expand Down
5 changes: 1 addition & 4 deletions app/components/chart-selection-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import React, {
import {
ChartType,
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
ConfiguratorStatePublishing,
useConfiguratorState,
} from "@/configurator";
Expand Down Expand Up @@ -97,9 +96,7 @@ const useStyles = makeStyles<Theme, { editable: boolean }>((theme) => ({

const TabsEditable = ({ chartType }: { chartType: ChartType }) => {
const [configuratorState] = useConfiguratorState() as unknown as [
| ConfiguratorStateConfiguringChart
| ConfiguratorStateDescribingChart
| ConfiguratorStatePublishing
ConfiguratorStateConfiguringChart | ConfiguratorStatePublishing
];
const [tabsState, setTabsState] = useTabsState();
const [popoverAnchorEl, setPopoverAnchorEl] = useState<HTMLElement | null>(
Expand Down
6 changes: 1 addition & 5 deletions app/configurator/components/chart-configurator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { chartConfigOptionsUISpec } from "@/charts/chart-config-ui-options";
import {
ChartConfig,
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
ConfiguratorStatePublishing,
isMapConfig,
OptionGroup,
Expand Down Expand Up @@ -189,10 +188,7 @@ const orderedIsEqual = (
const useEnsurePossibleFilters = ({
state,
}: {
state:
| ConfiguratorStateConfiguringChart
| ConfiguratorStateDescribingChart
| ConfiguratorStatePublishing;
state: ConfiguratorStateConfiguringChart | ConfiguratorStatePublishing;
}) => {
const [, dispatch] = useConfiguratorState();
const [fetching, setFetching] = useState(false);
Expand Down
6 changes: 1 addition & 5 deletions app/configurator/components/chart-type-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import { useLocale } from "@/locales/use-locale";
import {
ChartType,
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
ConfiguratorStatePublishing,
} from "../config-types";

Expand Down Expand Up @@ -104,10 +103,7 @@ export const ChartTypeSelector = ({
sx,
...props
}: {
state:
| ConfiguratorStateConfiguringChart
| ConfiguratorStateDescribingChart
| ConfiguratorStatePublishing;
state: ConfiguratorStateConfiguringChart | ConfiguratorStatePublishing;
showHelp?: boolean;
sx?: BoxProps["sx"];
} & BoxProps) => {
Expand Down
13 changes: 2 additions & 11 deletions app/configurator/components/empty-right-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ import { Trans } from "@lingui/macro";
import { Typography } from "@mui/material";
ptbrowne marked this conversation as resolved.
Show resolved Hide resolved
import { ReactNode } from "react";

import {
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
} from "@/configurator";
import { ConfiguratorStateConfiguringChart } from "@/configurator";

export const EmptyRightPanel = ({
state,
}: {
state: ConfiguratorStateConfiguringChart | ConfiguratorStateDescribingChart;
state: ConfiguratorStateConfiguringChart;
}) => (
<Typography component="div" variant="body2" sx={{ m: 4 }}>
{getRightPanelHint(state.state)}
Expand All @@ -26,12 +23,6 @@ const getRightPanelHint = (state: string): ReactNode => {
its options.
</Trans>
);
case "DESCRIBING_CHART":
return (
<Trans id="controls.hint.describing.chart">
Select an annotation field in the left panel.
</Trans>
);
default:
return "blabla";
}
Expand Down
2 changes: 1 addition & 1 deletion app/configurator/config-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export const useChartType = (): {
});

const value =
state.state === "CONFIGURING_CHART" || state.state === "DESCRIBING_CHART"
state.state === "CONFIGURING_CHART"
? get(state, "chartConfig.chartType")
: "";

Expand Down
10 changes: 0 additions & 10 deletions app/configurator/config-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -832,12 +832,6 @@ const ConfiguratorStateConfiguringChart = t.intersection([
}),
Config,
]);
const ConfiguratorStateDescribingChart = t.intersection([
t.type({
state: t.literal("DESCRIBING_CHART"),
}),
Config,
]);
const ConfiguratorStatePublishing = t.intersection([
t.type({
state: t.literal("PUBLISHING"),
Expand All @@ -851,17 +845,13 @@ export type ConfiguratorStateSelectingDataSet = t.TypeOf<
export type ConfiguratorStateConfiguringChart = t.TypeOf<
typeof ConfiguratorStateConfiguringChart
>;
export type ConfiguratorStateDescribingChart = t.TypeOf<
typeof ConfiguratorStateDescribingChart
>;
export type ConfiguratorStatePublishing = t.TypeOf<
typeof ConfiguratorStatePublishing
>;
const ConfiguratorState = t.union([
ConfiguratorStateInitial,
ConfiguratorStateSelectingDataSet,
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
ConfiguratorStatePublishing,
]);

Expand Down
50 changes: 8 additions & 42 deletions app/configurator/configurator-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import { DEFAULT_FIXED_COLOR_FIELD } from "@/charts/map/constants";
import { mapValueIrisToColor } from "@/configurator/components/ui-helpers";
import {
ConfiguratorStateConfiguringChart,
ConfiguratorStateDescribingChart,
DataSource,
GenericField,
ImputationType,
Expand Down Expand Up @@ -295,7 +294,7 @@ const emptyState: ConfiguratorStateSelectingDataSet = {
};

const getCachedCubeMetadataWithComponentValues = (
draft: ConfiguratorStateConfiguringChart | ConfiguratorStateDescribingChart,
draft: ConfiguratorStateConfiguringChart,
locale: Locale
) => {
const query = client.readQuery<
Expand Down Expand Up @@ -576,17 +575,12 @@ const transitionStepNext = (
}
break;
case "CONFIGURING_CHART":
return {
...draft,
activeField: undefined,
state: "DESCRIBING_CHART",
};
case "DESCRIBING_CHART":
return {
...draft,
activeField: undefined,
state: "PUBLISHING",
};

case "INITIAL":
case "PUBLISHING":
break;
Expand All @@ -612,8 +606,6 @@ export const canTransitionToNextStep = (
case "SELECTING_DATASET":
return state.dataSet !== undefined;
case "CONFIGURING_CHART":
case "DESCRIBING_CHART":
// These are all interchangeable in terms of validity
return true;
}

Expand All @@ -628,10 +620,8 @@ const getPreviousState = (
return state;
case "CONFIGURING_CHART":
return "SELECTING_DATASET";
case "DESCRIBING_CHART":
return "CONFIGURING_CHART";
case "PUBLISHING":
return "DESCRIBING_CHART";
return "CONFIGURING_CHART";
default:
return "SELECTING_DATASET";
}
Expand Down Expand Up @@ -662,12 +652,6 @@ const transitionStepPrevious = (
activeField: undefined,
state: stepTo,
};
case "DESCRIBING_CHART":
return {
...draft,
activeField: undefined,
state: stepTo,
};
default:
return draft;
}
Expand Down Expand Up @@ -1066,10 +1050,7 @@ export const handleInteractiveFilterChanged = (
{ type: "INTERACTIVE_FILTER_CHANGED" }
>
) => {
if (
draft.state === "CONFIGURING_CHART" ||
draft.state === "DESCRIBING_CHART"
) {
if (draft.state === "CONFIGURING_CHART") {
setWith(
draft,
"chartConfig.interactiveFiltersConfig",
Expand All @@ -1084,10 +1065,7 @@ export const handleInteractiveFilterChanged = (
export const handleInteractiveFilterTimeSliderReset = (
draft: ConfiguratorState
) => {
if (
draft.state === "CONFIGURING_CHART" ||
draft.state === "DESCRIBING_CHART"
) {
if (draft.state === "CONFIGURING_CHART") {
if (draft.chartConfig.interactiveFiltersConfig) {
draft.chartConfig.interactiveFiltersConfig.timeSlider.componentIri = "";
}
Expand Down Expand Up @@ -1115,10 +1093,7 @@ const reducer: Reducer<ConfiguratorState, ConfiguratorStateAction> = (
draft.dataSource = action.value;
return draft;
case "CHART_TYPE_CHANGED":
if (
draft.state === "CONFIGURING_CHART" ||
draft.state === "DESCRIBING_CHART"
) {
if (draft.state === "CONFIGURING_CHART") {
const { locale, chartType } = action.value;
const metadata = getCachedCubeMetadataWithComponentValues(
draft,
Expand All @@ -1145,11 +1120,9 @@ const reducer: Reducer<ConfiguratorState, ConfiguratorStateAction> = (
return draft;

case "ACTIVE_FIELD_CHANGED":
if (
draft.state === "CONFIGURING_CHART" ||
draft.state === "DESCRIBING_CHART"
)
if (draft.state === "CONFIGURING_CHART") {
draft.activeField = action.value;
}
return draft;

case "CHART_FIELD_CHANGED":
Expand Down Expand Up @@ -1568,7 +1541,6 @@ const ConfiguratorStateProviderInternal = ({
try {
switch (state.state) {
case "CONFIGURING_CHART":
case "DESCRIBING_CHART":
if (chartId === "new") {
const newChartId = createChartId();
window.localStorage.setItem(
Expand Down Expand Up @@ -1724,9 +1696,3 @@ export const isConfiguring = (
): s is ConfiguratorStateConfiguringChart => {
return s.state === "CONFIGURING_CHART";
};

export const isDescribing = (
s: ConfiguratorState
): s is ConfiguratorStateDescribingChart => {
return s.state === "DESCRIBING_CHART";
};
10 changes: 6 additions & 4 deletions app/configurator/interactive-filters/editor-time-brush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import React, { useCallback, useEffect, useRef } from "react";
import Flex from "@/components/flex";
import { Label } from "@/components/form";
import { parseDate } from "@/configurator/components/ui-helpers";
import { ConfiguratorStateDescribingChart } from "@/configurator/config-types";
import { useConfiguratorState } from "@/configurator/configurator-state";
import {
isConfiguring,
useConfiguratorState,
} from "@/configurator/configurator-state";
import { updateInteractiveTimeRangeFilter } from "@/configurator/interactive-filters/interactive-filters-config-state";
import { useFormatFullDateAuto } from "@/formatters";
import { useTheme } from "@/themes";
Expand Down Expand Up @@ -42,8 +44,8 @@ export const EditorBrush = ({
// FIXME: make component responsive (currently triggers infinite loop)
const brushWidth = 267; //width - MARGINS.left - MARGINS.right;

const [state, dispatch] = useConfiguratorState();
const { chartConfig } = state as ConfiguratorStateDescribingChart;
const [state, dispatch] = useConfiguratorState(isConfiguring);
const { chartConfig } = state;

const timeScale = scaleTime().domain(timeExtent).range([0, brushWidth]);

Expand Down