refactor: Removes the deprecated ENABLE_EXPLORE_DRAG_AND_DROP feature flag (#26343)

This commit is contained in:
Michael S. Molina 2024-01-16 10:47:52 -03:00 committed by GitHub
parent b2ad74f94f
commit 6063f4ff04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 41 additions and 232 deletions

View File

@ -91,7 +91,6 @@ These features flags currently default to True and **will be removed in a future
- DASHBOARD_FILTERS_EXPERIMENTAL
- DASHBOARD_NATIVE_FILTERS
- DASHBOARD_NATIVE_FILTERS_SET
- ENABLE_EXPLORE_DRAG_AND_DROP
- ENABLE_EXPLORE_JSON_CSRF_PROTECTION
- ENABLE_TEMPLATE_REMOVE_FILTERS
- GENERIC_CHART_AXES

View File

@ -29,6 +29,7 @@ assists people when migrating to a new version.
### Breaking Changes
- [26343](https://github.com/apache/superset/issues/26343): Removes the deprecated `ENABLE_EXPLORE_DRAG_AND_DROP` feature flag. The previous value of the feature flag was `True` and now the feature is permanently enabled.
- [26331](https://github.com/apache/superset/issues/26331): Removes the deprecated `DISABLE_DATASET_SOURCE_EDIT` feature flag. The previous value of the feature flag was `False` and now the feature is permanently removed.
### Potential Downtime

View File

@ -17,14 +17,8 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { useMemo } from 'react';
import {
FeatureFlag,
isFeatureEnabled,
QueryColumn,
t,
validateNonEmpty,
} from '@superset-ui/core';
import React from 'react';
import { QueryColumn, t, validateNonEmpty } from '@superset-ui/core';
import {
ExtraControlProps,
SharedControlConfig,
@ -266,21 +260,3 @@ export const dndXAxisControl: typeof dndGroupByControl = {
...dndGroupByControl,
...xAxisMixin,
};
export function withDndFallback(
DndComponent: React.ComponentType<any>,
FallbackComponent: React.ComponentType<any>,
) {
return function DndControl(props: any) {
const enableExploreDnd = useMemo(
() => isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP),
[],
);
return enableExploreDnd ? (
<DndComponent {...props} />
) : (
<FallbackComponent {...props} />
);
};
}

View File

@ -17,7 +17,6 @@
* under the License.
*/
export { default as sharedControls } from './sharedControls';
export { withDndFallback } from './dndControls';
// React control components
export { default as sharedControlComponents } from './components';
export * from './components';

View File

@ -86,8 +86,6 @@ import {
dndXAxisControl,
} from './dndControls';
export { withDndFallback } from './dndControls';
const categoricalSchemeRegistry = getCategoricalSchemeRegistry();
const sequentialSchemeRegistry = getSequentialSchemeRegistry();

View File

@ -41,7 +41,6 @@ export enum FeatureFlag {
EMBEDDABLE_CHARTS = 'EMBEDDABLE_CHARTS',
EMBEDDED_SUPERSET = 'EMBEDDED_SUPERSET',
ENABLE_ADVANCED_DATA_TYPES = 'ENABLE_ADVANCED_DATA_TYPES',
ENABLE_EXPLORE_DRAG_AND_DROP = 'ENABLE_EXPLORE_DRAG_AND_DROP',
ENABLE_JAVASCRIPT_CONTROLS = 'ENABLE_JAVASCRIPT_CONTROLS',
ENABLE_TEMPLATE_PROCESSING = 'ENABLE_TEMPLATE_PROCESSING',
ENABLE_TEMPLATE_REMOVE_FILTERS = 'ENABLE_TEMPLATE_REMOVE_FILTERS',

View File

@ -17,16 +17,9 @@
* under the License.
*/
import React from 'react';
import { t } from '@superset-ui/core';
import {
FeatureFlag,
isFeatureEnabled,
t,
validateNonEmpty,
} from '@superset-ui/core';
import {
columnChoices,
ControlPanelConfig,
ControlPanelState,
formatSelectOptionsForRange,
sections,
sharedControls,
@ -41,25 +34,11 @@ const sortAxisChoices = [
['value_desc', t('Metric descending')],
];
const allColumns = {
type: 'SelectControl',
default: null,
description: t('Columns to display'),
mapStateToProps: (state: ControlPanelState) => ({
choices: columnChoices(state.datasource),
}),
validators: [validateNonEmpty],
};
const dndAllColumns = {
...sharedControls.entity,
description: t('Columns to display'),
};
const columnsConfig = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndAllColumns
: allColumns;
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
@ -71,7 +50,7 @@ const config: ControlPanelConfig = {
{
name: 'all_columns_x',
config: {
...columnsConfig,
...dndAllColumns,
label: t('X Axis'),
},
},
@ -80,7 +59,7 @@ const config: ControlPanelConfig = {
{
name: 'all_columns_y',
config: {
...columnsConfig,
...dndAllColumns,
label: t('Y Axis'),
},
},

View File

@ -16,33 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
import {
FeatureFlag,
isFeatureEnabled,
t,
validateMapboxStylesUrl,
} from '@superset-ui/core';
import { t, validateMapboxStylesUrl } from '@superset-ui/core';
import {
columnChoices,
ControlPanelConfig,
ControlPanelState,
formatSelectOptions,
sections,
sharedControls,
getStandardizedControls,
} from '@superset-ui/chart-controls';
const allColumns = {
type: 'SelectControl',
default: null,
mapStateToProps: (state: ControlPanelState) => ({
choices: columnChoices(state.datasource),
}),
};
const columnsConfig = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? sharedControls.entity
: allColumns;
const columnsConfig = sharedControls.entity;
const colorChoices = [
['rgb(0, 139, 139)', t('Dark Cyan')],

View File

@ -17,12 +17,7 @@
* under the License.
*/
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
import {
t,
legacyValidateInteger,
isFeatureEnabled,
FeatureFlag,
} from '@superset-ui/core';
import { t, legacyValidateInteger } from '@superset-ui/core';
import { formatSelectOptions } from '../../utilities/utils';
import {
filterNulls,
@ -37,16 +32,11 @@ import {
extruded,
viewport,
mapboxStyle,
geojsonColumn,
autozoom,
lineWidth,
} from '../../utilities/Shared_DeckGL';
import { dndGeojsonColumn } from '../../utilities/sharedDndControls';
const geojson = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndGeojsonColumn
: geojsonColumn;
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
@ -54,7 +44,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
[geojson],
[dndGeojsonColumn],
['row_limit'],
[filterNulls],
['adhoc_filters'],

View File

@ -17,7 +17,7 @@
* under the License.
*/
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
filterNulls,
autozoom,
@ -25,7 +25,6 @@ import {
jsDataMutator,
jsTooltip,
jsOnclickHref,
lineColumn,
viewport,
lineWidth,
lineType,
@ -41,11 +40,7 @@ const config: ControlPanelConfig = {
label: t('Query'),
expanded: true,
controlSetRows: [
[
isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndLineColumn
: lineColumn,
],
[dndLineColumn],
[
{
...lineType,

View File

@ -21,7 +21,7 @@ import {
getStandardizedControls,
sections,
} from '@superset-ui/chart-controls';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import timeGrainSqlaAnimationOverrides from '../../utilities/controls';
import { formatSelectOptions } from '../../utilities/utils';
import {
@ -33,7 +33,6 @@ import {
jsOnclickHref,
legendFormat,
legendPosition,
lineColumn,
fillColorPicker,
strokeColorPicker,
filled,
@ -49,10 +48,6 @@ import {
} from '../../utilities/Shared_DeckGL';
import { dndLineColumn } from '../../utilities/sharedDndControls';
const lines = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndLineColumn
: lineColumn;
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
@ -62,9 +57,9 @@ const config: ControlPanelConfig = {
controlSetRows: [
[
{
...lines,
...dndLineColumn,
config: {
...lines.config,
...dndLineColumn.config,
label: t('Polygon Column'),
},
},

View File

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
ControlSubSectionHeader,
@ -93,9 +93,7 @@ const controlPanel: ControlPanelConfig = {
name: 'metric',
config: {
...optionalEntity,
type: isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? 'DndMetricSelect'
: 'MetricsControl',
type: 'DndMetricSelect',
label: t('Metric'),
description: t('Metric for node values'),
},

View File

@ -17,46 +17,15 @@
* under the License.
*/
import {
ColumnOption,
ControlSetItem,
ExtraControlProps,
sharedControls,
Dataset,
ColumnMeta,
} from '@superset-ui/chart-controls';
import {
ensureIsArray,
FeatureFlag,
isFeatureEnabled,
t,
} from '@superset-ui/core';
import React from 'react';
import { ensureIsArray, t } from '@superset-ui/core';
import { getQueryMode, isRawMode } from './shared';
const allColumns: typeof sharedControls.groupby = {
type: 'SelectControl',
label: t('Columns'),
description: t('Columns to display'),
multi: true,
freeForm: true,
allowAll: true,
commaChoosesOption: false,
default: [],
optionRenderer: c => <ColumnOption showType column={c} />,
valueRenderer: c => <ColumnOption column={c} />,
valueKey: 'column_name',
mapStateToProps: ({ datasource, controls }, controlState) => ({
options: datasource?.columns || [],
queryMode: getQueryMode(controls),
externalValidationErrors:
isRawMode({ controls }) && ensureIsArray(controlState?.value).length === 0
? [t('must have a value')]
: [],
}),
visibility: isRawMode,
resetOnHide: false,
};
const dndAllColumns: typeof sharedControls.groupby = {
type: 'DndColumnSelect',
label: t('Columns'),
@ -84,7 +53,5 @@ const dndAllColumns: typeof sharedControls.groupby = {
export const allColumnsControlSetItem: ControlSetItem = {
name: 'all_columns',
config: isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndAllColumns
: allColumns,
config: dndAllColumns,
};

View File

@ -25,7 +25,7 @@ import {
ColumnMeta,
defineSavedMetrics,
} from '@superset-ui/chart-controls';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import { t } from '@superset-ui/core';
import { getQueryMode, isAggMode, validateAggControlValues } from './shared';
const percentMetrics: typeof sharedControls.metrics = {
@ -64,9 +64,7 @@ const dndPercentMetrics = {
export const percentMetricsControlSetItem: ControlSetItem = {
name: 'percent_metrics',
config: {
...(isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndPercentMetrics
: percentMetrics),
...dndPercentMetrics,
},
};

View File

@ -20,15 +20,13 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
import {
css,
DatasourceType,
isFeatureEnabled,
FeatureFlag,
Metric,
QueryFormData,
styled,
t,
} from '@superset-ui/core';
import { ControlConfig, ColumnMeta } from '@superset-ui/chart-controls';
import { ControlConfig } from '@superset-ui/chart-controls';
import { debounce, isArray } from 'lodash';
import { matchSorter, rankings } from 'match-sorter';
@ -42,7 +40,6 @@ import { ExploreActions } from 'src/explore/actions/exploreActions';
import Control from 'src/explore/components/Control';
import DatasourcePanelDragOption from './DatasourcePanelDragOption';
import { DndItemType } from '../DndItemType';
import { StyledColumnOption, StyledMetricOption } from '../optionRenderers';
import { DndItemValue } from './types';
interface DatasourceControl extends ControlConfig {
@ -83,10 +80,6 @@ export interface Props {
formData?: QueryFormData;
}
const enableExploreDnd = isFeatureEnabled(
FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP,
);
const Button = styled.button`
background: none;
border: none;
@ -151,14 +144,11 @@ const LabelWrapper = styled.div`
margin-bottom: 0;
}
${enableExploreDnd &&
css`
padding: 0;
cursor: pointer;
&:hover {
background-color: ${theme.colors.grayscale.light3};
}
`}
padding: 0;
cursor: pointer;
&:hover {
background-color: ${theme.colors.grayscale.light3};
}
& > span {
white-space: nowrap;
@ -417,14 +407,10 @@ export default function DataSourcePanel({
key={m.metric_name + String(shouldForceUpdate)}
className="column"
>
{enableExploreDnd ? (
<DatasourcePanelDragOption
value={m}
type={DndItemType.Metric}
/>
) : (
<StyledMetricOption metric={m} showType />
)}
<DatasourcePanelDragOption
value={m}
type={DndItemType.Metric}
/>
</LabelContainer>
))}
{lists?.metrics?.length > DEFAULT_MAX_METRICS_LENGTH ? (
@ -454,14 +440,10 @@ export default function DataSourcePanel({
key={col.column_name + String(shouldForceUpdate)}
className="column"
>
{enableExploreDnd ? (
<DatasourcePanelDragOption
value={col as DndItemValue}
type={DndItemType.Column}
/>
) : (
<StyledColumnOption column={col as ColumnMeta} showType />
)}
<DatasourcePanelDragOption
value={col as DndItemValue}
type={DndItemType.Column}
/>
</LabelContainer>
))}
{lists.columns.length > DEFAULT_MAX_COLUMNS_LENGTH ? (

View File

@ -123,7 +123,7 @@ const renderWithRouter = ({
<ExploreViewContainer />
</Route>
</MemoryRouter>,
{ useRedux: true, initialState },
{ useRedux: true, useDnd: true, initialState },
);
};

View File

@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { FeatureFlag } from '@superset-ui/core';
import React from 'react';
import { render, screen } from 'spec/helpers/testing-library';
import {
@ -32,14 +31,6 @@ const defaultProps: DndColumnSelectProps = {
actions: { setControlValue: jest.fn() },
};
beforeAll(() => {
window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true };
});
afterAll(() => {
window.featureFlags = {};
});
test('renders with default props', async () => {
render(<DndColumnSelect {...defaultProps} />, {
useDnd: true,

View File

@ -24,11 +24,7 @@ import {
t,
isAdhocColumn,
} from '@superset-ui/core';
import {
ColumnMeta,
isColumnMeta,
withDndFallback,
} from '@superset-ui/chart-controls';
import { ColumnMeta, isColumnMeta } from '@superset-ui/chart-controls';
import { isEmpty } from 'lodash';
import DndSelectLabel from 'src/explore/components/controls/DndColumnSelectControl/DndSelectLabel';
import OptionWrapper from 'src/explore/components/controls/DndColumnSelectControl/OptionWrapper';
@ -37,7 +33,6 @@ import { DatasourcePanelDndItem } from 'src/explore/components/DatasourcePanel/t
import { DndItemType } from 'src/explore/components/DndItemType';
import ColumnSelectPopoverTrigger from './ColumnSelectPopoverTrigger';
import { DndControlProps } from './types';
import SelectControl from '../SelectControl';
export type DndColumnSelectProps = DndControlProps<QueryFormColumn> & {
options: ColumnMeta[];
@ -216,9 +211,4 @@ function DndColumnSelect(props: DndColumnSelectProps) {
);
}
const DndColumnSelectWithFallback = withDndFallback(
DndColumnSelect,
SelectControl,
);
export { DndColumnSelectWithFallback as DndColumnSelect };
export { DndColumnSelect };

View File

@ -23,7 +23,6 @@ import configureStore from 'redux-mock-store';
import {
ensureIsArray,
FeatureFlag,
GenericDataType,
QueryFormData,
} from '@superset-ui/core';
@ -58,14 +57,6 @@ const baseFormData = {
datasource: 'table__1',
};
beforeAll(() => {
window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true };
});
afterAll(() => {
window.featureFlags = {};
});
const mockStore = configureStore([thunk]);
const store = mockStore({});

View File

@ -30,7 +30,6 @@ import {
ColumnMeta,
isColumnMeta,
isTemporalColumn,
withDndFallback,
} from '@superset-ui/chart-controls';
import Modal from 'src/components/Modal';
import {
@ -50,7 +49,6 @@ import {
} from 'src/explore/components/DatasourcePanel/types';
import { DndItemType } from 'src/explore/components/DndItemType';
import { ControlComponentProps } from 'src/explore/components/Control';
import AdhocFilterControl from '../FilterControl/AdhocFilterControl';
import DndAdhocFilterOption from './DndAdhocFilterOption';
import { useDefaultTimeFilter } from '../DateFilterControl/utils';
import { CLAUSES, EXPRESSION_TYPES } from '../FilterControl/types';
@ -422,9 +420,4 @@ const DndFilterSelect = (props: DndFilterSelectProps) => {
);
};
const DndFilterSelectWithFallback = withDndFallback(
DndFilterSelect,
AdhocFilterControl,
);
export { DndFilterSelectWithFallback as DndFilterSelect };
export { DndFilterSelect };

View File

@ -18,7 +18,6 @@
*/
import React from 'react';
import userEvent from '@testing-library/user-event';
import { FeatureFlag } from '@superset-ui/core';
import {
render,
screen,
@ -68,14 +67,6 @@ const adhocMetricB = {
optionName: 'def',
};
beforeAll(() => {
window.featureFlags = { [FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP]: true };
});
afterAll(() => {
window.featureFlags = {};
});
test('renders with default props', () => {
render(<DndMetricSelect {...defaultProps} />, { useDnd: true });
expect(

View File

@ -28,7 +28,7 @@ import {
t,
tn,
} from '@superset-ui/core';
import { ColumnMeta, withDndFallback } from '@superset-ui/chart-controls';
import { ColumnMeta } from '@superset-ui/chart-controls';
import AdhocMetric from 'src/explore/components/controls/MetricControl/AdhocMetric';
import AdhocMetricPopoverTrigger from 'src/explore/components/controls/MetricControl/AdhocMetricPopoverTrigger';
import MetricDefinitionValue from 'src/explore/components/controls/MetricControl/MetricDefinitionValue';
@ -40,7 +40,6 @@ import { DndItemType } from 'src/explore/components/DndItemType';
import DndSelectLabel from 'src/explore/components/controls/DndColumnSelectControl/DndSelectLabel';
import { savedMetricType } from 'src/explore/components/controls/MetricControl/types';
import { AGGREGATES } from 'src/explore/constants';
import MetricsControl from '../MetricControl/MetricsControl';
const EMPTY_OBJECT = {};
const DND_ACCEPTED_TYPES = [DndItemType.Column, DndItemType.Metric];
@ -364,9 +363,4 @@ const DndMetricSelect = (props: any) => {
);
};
const DndMetricSelectWithFallback = withDndFallback(
DndMetricSelect,
MetricsControl,
);
export { DndMetricSelectWithFallback as DndMetricSelect };
export { DndMetricSelect };

View File

@ -453,7 +453,6 @@ DEFAULT_FEATURE_FLAGS: dict[str, bool] = {
# Enables Alerts and reports new implementation
"ALERT_REPORTS": False,
"DASHBOARD_RBAC": False,
"ENABLE_EXPLORE_DRAG_AND_DROP": True, # deprecated
"ENABLE_ADVANCED_DATA_TYPES": False,
# Enabling ALERTS_ATTACH_REPORTS, the system sends email and slack message
# with screenshot and link