Skip to content

Commit

Permalink
feat:add feature flag that displays the data pane closes by default
Browse files Browse the repository at this point in the history
  • Loading branch information
painyjames committed Oct 4, 2022
1 parent 3057e42 commit 3e82f2b
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export enum FeatureFlag {
DASHBOARD_EDIT_CHART_IN_NEW_TAB = 'DASHBOARD_EDIT_CHART_IN_NEW_TAB',
EMBEDDABLE_CHARTS = 'EMBEDDABLE_CHARTS',
DRILL_TO_DETAIL = 'DRILL_TO_DETAIL',
DATAPANEL_CLOSED_BY_DEFAULT = 'DATAPANEL_CLOSED_BY_DEFAULT',
}
export type ScheduleQueriesProps = {
JSONSCHEMA: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import React, {
import { styled, t, useTheme } from '@superset-ui/core';
import Icons from 'src/components/Icons';
import Tabs from 'src/components/Tabs';
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import {
getItem,
setItem,
Expand Down Expand Up @@ -96,11 +97,14 @@ export const DataTablesPane = ({
samples: false,
});
const [panelOpen, setPanelOpen] = useState(
getItem(LocalStorageKeys.is_datapanel_open, false),
isFeatureEnabled(FeatureFlag.DATAPANEL_CLOSED_BY_DEFAULT)
? false
: getItem(LocalStorageKeys.is_datapanel_open, false),
);

useEffect(() => {
setItem(LocalStorageKeys.is_datapanel_open, panelOpen);
if (!isFeatureEnabled(FeatureFlag.DATAPANEL_CLOSED_BY_DEFAULT))
setItem(LocalStorageKeys.is_datapanel_open, panelOpen);
}, [panelOpen]);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import React from 'react';
import userEvent from '@testing-library/user-event';
import fetchMock from 'fetch-mock';
import { FeatureFlag } from 'src/featureFlags';
import * as copyUtils from 'src/utils/copy';
import {
render,
screen,
waitForElementToBeRemoved,
} from 'spec/helpers/testing-library';
import { setItem, LocalStorageKeys } from 'src/utils/localStorageHelpers';
import { DataTablesPane } from '..';
import { createDataTablesPaneProps } from './fixture';

Expand Down Expand Up @@ -143,4 +145,19 @@ describe('DataTablesPane', () => {
expect(screen.queryByText('Action')).not.toBeInTheDocument();
fetchMock.restore();
});

test('Displaying the data pane is under featureflag', () => {
// @ts-ignore
global.featureFlags = {
[FeatureFlag.DATAPANEL_CLOSED_BY_DEFAULT]: true,
};
const props = createDataTablesPaneProps(0);
setItem(LocalStorageKeys.is_datapanel_open, true);
render(<DataTablesPane {...props} />, {
useRedux: true,
});
expect(
screen.queryByLabelText('Collapse data panel'),
).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
import { useResizeDetector } from 'react-resize-detector';
import { chartPropShape } from 'src/dashboard/util/propShapes';
import ChartContainer from 'src/components/Chart/ChartContainer';
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import {
getItem,
setItem,
Expand Down Expand Up @@ -148,10 +149,14 @@ const ExploreChartPanel = ({
refreshRate: 300,
});
const [splitSizes, setSplitSizes] = useState(
getItem(LocalStorageKeys.chart_split_sizes, INITIAL_SIZES),
isFeatureEnabled(FeatureFlag.DATAPANEL_CLOSED_BY_DEFAULT) ?
INITIAL_SIZES
: getItem(LocalStorageKeys.chart_split_sizes, INITIAL_SIZES),
);
const [showSplite, setShowSplit] = useState(
getItem(LocalStorageKeys.is_datapanel_open, false),
isFeatureEnabled(FeatureFlag.DATAPANEL_CLOSED_BY_DEFAULT) ?
false
: getItem(LocalStorageKeys.is_datapanel_open, false),
);

const [showDatasetModal, setShowDatasetModal] = useState(false);
Expand Down
1 change: 1 addition & 0 deletions superset/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def _try_json_readsha(filepath: str, length: int) -> Optional[str]:
# Enable sharing charts with embedding
"EMBEDDABLE_CHARTS": True,
"DRILL_TO_DETAIL": False,
"DATAPANEL_CLOSED_BY_DEFAULT": False,
}

# Feature flags may also be set via 'SUPERSET_FEATURE_' prefixed environment vars.
Expand Down

0 comments on commit 3e82f2b

Please sign in to comment.