Skip to content

Commit

Permalink
EES-5542 removed feature flag hasDataSetBoundaryLevels
Browse files Browse the repository at this point in the history
  • Loading branch information
bennettstuart committed Dec 20, 2024
1 parent ad96d61 commit 8255bad
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import React, { ReactNode, useCallback, useMemo } from 'react';

interface Props {
buttons?: ReactNode;
// TODO: EES-5402 - Remove when all boundary level changes are done
hasDataSetBoundaryLevels?: boolean;
map: MapConfig;
meta: FullTableMeta;
options: ChartOptions;
Expand All @@ -21,8 +19,6 @@ interface Props {

export default function ChartBoundaryLevelsConfiguration({
buttons,
// TODO: EES-5402 - Remove when all boundary level changes are done
hasDataSetBoundaryLevels = true,
map,
meta,
options,
Expand Down Expand Up @@ -77,7 +73,6 @@ export default function ChartBoundaryLevelsConfiguration({
<ChartBoundaryLevelsForm
buttons={buttons}
dataSetConfigs={map.dataSetConfigs}
hasDataSetBoundaryLevels={hasDataSetBoundaryLevels}
initialValues={initialValues}
meta={meta}
onChange={handleChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ interface Props {
buttons?: ReactNode;
initialValues: ChartBoundaryLevelsFormValues;
dataSetConfigs: MapDataSetConfig[];
// TODO: EES-5402 - Remove when all boundary level changes are done
hasDataSetBoundaryLevels?: boolean;
meta: FullTableMeta;
onChange: (values: Partial<ChartBoundaryLevelsFormValues>) => void;
onSubmit: (values: ChartBoundaryLevelsFormValues) => void;
Expand All @@ -37,8 +35,6 @@ interface Props {
export default function ChartBoundaryLevelsForm({
buttons,
dataSetConfigs,
// TODO: EES-5402 - Remove when all boundary level changes are done
hasDataSetBoundaryLevels,
initialValues,
meta,
onChange,
Expand Down Expand Up @@ -120,16 +116,8 @@ export default function ChartBoundaryLevelsForm({
onMount={updateForm}
/>
<FormFieldSelect<ChartBoundaryLevelsFormValues>
label={
hasDataSetBoundaryLevels
? 'Default boundary level'
: 'Boundary level'
}
hint={`Select a version of geographical data to use${
hasDataSetBoundaryLevels
? " across any data sets that don't have a specific one set"
: ''
}`}
label="Default boundary level"
hint="Select a version of geographical data to use across any data sets that don't have a specific one set"
name="boundaryLevel"
order={[]}
options={[
Expand All @@ -140,7 +128,7 @@ export default function ChartBoundaryLevelsForm({
...boundaryLevelOptions,
]}
/>
{hasDataSetBoundaryLevels && dataSetRows.length > 1 && (
{dataSetRows.length > 1 && (
<>
<h4>Set boundary levels per data set</h4>
<table data-testid="data-set-boundary-levels">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
options={testDefaultChartOptions}
onChange={noop}
onSubmit={noop}
hasDataSetBoundaryLevels
/>,
);
expect(screen.getByLabelText('Default boundary level')).toBeInTheDocument();
Expand All @@ -116,7 +115,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
options={testDefaultChartOptions}
onChange={noop}
onSubmit={noop}
hasDataSetBoundaryLevels
/>,
);

Expand Down Expand Up @@ -201,7 +199,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
}}
onChange={noop}
onSubmit={noop}
hasDataSetBoundaryLevels
/>,
);

Expand Down Expand Up @@ -229,7 +226,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
options={testDefaultChartOptions}
onChange={handleChange}
onSubmit={noop}
hasDataSetBoundaryLevels
/>,
);

Expand Down Expand Up @@ -264,7 +260,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
options={testDefaultChartOptions}
onChange={noop}
onSubmit={noop}
hasDataSetBoundaryLevels
/>,
);

Expand Down Expand Up @@ -294,7 +289,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
options={testDefaultChartOptions}
onChange={noop}
onSubmit={handleSubmit}
hasDataSetBoundaryLevels
/>,
);

Expand Down Expand Up @@ -329,7 +323,6 @@ describe('ChartBoundaryLevelsConfiguration', () => {
}}
onChange={noop}
onSubmit={handleSubmit}
hasDataSetBoundaryLevels
/>,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('ChartBuilder', () => {

test('calls `onTableQueryUpdate` when change boundary level', async () => {
const testInitialChart: Chart = {
onBoundaryLevelChange: () => {},
onBoundaryLevelChange: jest.fn(),
type: 'map',
boundaryLevel: 2,
map: {
Expand Down Expand Up @@ -444,15 +444,16 @@ describe('ChartBuilder', () => {

await user.click(screen.getByRole('tab', { name: 'Boundary levels' }));

await user.selectOptions(screen.getByLabelText('Boundary level'), ['1']);
await user.selectOptions(screen.getByLabelText('Default boundary level'), [
'1',
]);

expect(handleUpdate).toHaveBeenCalledWith({ boundaryLevel: 1 });
});

describe('data groupings tab', () => {
const testInitialChart: Chart = {
type: 'map',
onBoundaryLevelChange: () => {},
boundaryLevel: 2,
map: {
dataSetConfigs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@ describe('ChartBuilderTabSection', () => {

await user.click(screen.getByRole('tab', { name: 'Boundary levels' }));

await user.selectOptions(screen.getByLabelText('Boundary level'), ['1']);
await user.selectOptions(screen.getByLabelText('Default boundary level'), [
'1',
]);

expect(tableBuilderService.getTableData).toHaveBeenCalledWith(
{ ...testQuery, boundaryLevel: 1 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface MapBlockProps extends ChartProps {
map?: MapConfig;
position?: { lat: number; lng: number };
boundaryLevel: number;
onBoundaryLevelChange: (boundaryLevel: number) => void;
onBoundaryLevelChange?: (boundaryLevel: number) => void;
}

export const mapBlockDefinition: ChartDefinition = {
Expand Down Expand Up @@ -225,16 +225,18 @@ export default function MapBlock({
);

const handleDataSetChange = useCallback(
async (value: string) => {
(value: string) => {
setSelectedDataSetKey(value);
if (!onBoundaryLevelChange) return;

const previouslyRenderredBoundaryLevel =
selectedDataSetConfig?.boundaryLevel ?? boundaryLevel;
const newBoundaryLevelToRender =
dataSetCategoryConfigs[value].boundaryLevel ?? boundaryLevel;

if (newBoundaryLevelToRender !== previouslyRenderredBoundaryLevel) {
setIsBoundaryLevelChanging.on();
await onBoundaryLevelChange(
onBoundaryLevelChange(
dataSetCategoryConfigs[value].boundaryLevel ?? boundaryLevel,
);
}
Expand Down

0 comments on commit 8255bad

Please sign in to comment.