mirror of https://github.com/apache/superset.git
chore: Deprecate show_native_filters (#23228)
This commit is contained in:
parent
022df93422
commit
5f0c320415
|
@ -119,7 +119,6 @@ function prepareDashboardFilters(
|
|||
});
|
||||
if (dashboardId) {
|
||||
const jsonMetadata = {
|
||||
show_native_filters: true,
|
||||
native_filter_configuration: allFilters,
|
||||
timed_refresh_immune_slices: [],
|
||||
expanded_slices: {},
|
||||
|
|
|
@ -113,6 +113,6 @@ export const overwriteConfirmMetadata = {
|
|||
slug: null,
|
||||
owners: [],
|
||||
json_metadata:
|
||||
'{"timed_refresh_immune_slices":[],"expanded_slices":{},"refresh_frequency":0,"default_filters":"{}","color_scheme":"supersetColors","label_colors":{"0":"#FCC700","1":"#A868B7","15":"#3CCCCB","30":"#A38F79","45":"#8FD3E4","age":"#1FA8C9","Yes,":"#1FA8C9","Female":"#454E7C","Prefer":"#5AC189","No,":"#FF7F44","Male":"#666666","Prefer not to say":"#E04355","Ph.D.":"#FCC700","associate\'s degree":"#A868B7","bachelor\'s degree":"#3CCCCB","high school diploma or equivalent (GED)":"#A38F79","master\'s degree (non-professional)":"#8FD3E4","no high school (secondary school)":"#A1A6BD","professional degree (MBA, MD, JD, etc.)":"#ACE1C4","some college credit, no degree":"#FEC0A1","some high school":"#B2B2B2","trade, technical, or vocational training":"#EFA1AA","No, not an ethnic minority":"#1FA8C9","Yes, an ethnic minority":"#454E7C","<NULL>":"#5AC189","Yes":"#FF7F44","No":"#666666","last_yr_income":"#E04355","More":"#A1A6BD","Less":"#ACE1C4","I":"#FEC0A1","expected_earn":"#B2B2B2","Yes: Willing To":"#EFA1AA","No: Not Willing to":"#FDE380","No Answer":"#D3B3DA","In an Office (with Other Developers)":"#9EE5E5","No Preference":"#D1C6BC","From Home":"#1FA8C9"},"show_native_filters":true,"color_scheme_domain":["#1FA8C9","#454E7C","#5AC189","#FF7F44","#666666","#E04355","#FCC700","#A868B7","#3CCCCB","#A38F79","#8FD3E4","#A1A6BD","#ACE1C4","#FEC0A1","#B2B2B2","#EFA1AA","#FDE380","#D3B3DA","#9EE5E5","#D1C6BC"],"shared_label_colors":{"Male":"#5ac19e","Female":"#1f86c9","<NULL>":"#5AC189","Prefer not to say":"#47457c","No Answer":"#e05043","Yes, an ethnic minority":"#666666","No, not an ethnic minority":"#ffa444","age":"#1FA8C9"},"cross_filters_enabled":false,"filter_scopes":{},"chart_configuration":{},"positions":{}}',
|
||||
'{"timed_refresh_immune_slices":[],"expanded_slices":{},"refresh_frequency":0,"default_filters":"{}","color_scheme":"supersetColors","label_colors":{"0":"#FCC700","1":"#A868B7","15":"#3CCCCB","30":"#A38F79","45":"#8FD3E4","age":"#1FA8C9","Yes,":"#1FA8C9","Female":"#454E7C","Prefer":"#5AC189","No,":"#FF7F44","Male":"#666666","Prefer not to say":"#E04355","Ph.D.":"#FCC700","associate\'s degree":"#A868B7","bachelor\'s degree":"#3CCCCB","high school diploma or equivalent (GED)":"#A38F79","master\'s degree (non-professional)":"#8FD3E4","no high school (secondary school)":"#A1A6BD","professional degree (MBA, MD, JD, etc.)":"#ACE1C4","some college credit, no degree":"#FEC0A1","some high school":"#B2B2B2","trade, technical, or vocational training":"#EFA1AA","No, not an ethnic minority":"#1FA8C9","Yes, an ethnic minority":"#454E7C","<NULL>":"#5AC189","Yes":"#FF7F44","No":"#666666","last_yr_income":"#E04355","More":"#A1A6BD","Less":"#ACE1C4","I":"#FEC0A1","expected_earn":"#B2B2B2","Yes: Willing To":"#EFA1AA","No: Not Willing to":"#FDE380","No Answer":"#D3B3DA","In an Office (with Other Developers)":"#9EE5E5","No Preference":"#D1C6BC","From Home":"#1FA8C9"},"color_scheme_domain":["#1FA8C9","#454E7C","#5AC189","#FF7F44","#666666","#E04355","#FCC700","#A868B7","#3CCCCB","#A38F79","#8FD3E4","#A1A6BD","#ACE1C4","#FEC0A1","#B2B2B2","#EFA1AA","#FDE380","#D3B3DA","#9EE5E5","#D1C6BC"],"shared_label_colors":{"Male":"#5ac19e","Female":"#1f86c9","<NULL>":"#5AC189","Prefer not to say":"#47457c","No Answer":"#e05043","Yes, an ethnic minority":"#666666","No, not an ethnic minority":"#ffa444","age":"#1FA8C9"},"cross_filters_enabled":false,"filter_scopes":{},"chart_configuration":{},"positions":{}}',
|
||||
},
|
||||
};
|
||||
|
|
|
@ -51,10 +51,6 @@ export const URL_PARAMS = {
|
|||
name: 'filter_set',
|
||||
type: 'string',
|
||||
},
|
||||
showFilters: {
|
||||
name: 'show_filters',
|
||||
type: 'boolean',
|
||||
},
|
||||
expandFilters: {
|
||||
name: 'expand_filters',
|
||||
type: 'boolean',
|
||||
|
|
|
@ -305,9 +305,6 @@ export const hydrateDashboard =
|
|||
const nativeFilters = getInitialNativeFilterState({
|
||||
filterConfig: metadata?.native_filter_configuration || [],
|
||||
});
|
||||
metadata.show_native_filters = isFeatureEnabled(
|
||||
FeatureFlag.DASHBOARD_NATIVE_FILTERS,
|
||||
);
|
||||
|
||||
if (isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS)) {
|
||||
metadata.chart_configuration = getCrossFiltersConfiguration(
|
||||
|
|
|
@ -281,7 +281,6 @@ describe('DashboardBuilder', () => {
|
|||
dashboardInfo: {
|
||||
...mockState.dashboardInfo,
|
||||
dash_edit_perm: true,
|
||||
metadata: { show_native_filters: true },
|
||||
},
|
||||
});
|
||||
const filterbar = getByTestId('dashboard-filters-panel');
|
||||
|
|
|
@ -30,11 +30,6 @@ import {
|
|||
// eslint-disable-next-line import/prefer-default-export
|
||||
export const useNativeFilters = () => {
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
const showNativeFilters = useSelector<RootState, boolean>(
|
||||
state =>
|
||||
(getUrlParam(URL_PARAMS.showFilters) ?? true) &&
|
||||
state.dashboardInfo.metadata?.show_native_filters,
|
||||
);
|
||||
const canEdit = useSelector<RootState, boolean>(
|
||||
({ dashboardInfo }) => dashboardInfo.dash_edit_perm,
|
||||
);
|
||||
|
@ -47,7 +42,6 @@ export const useNativeFilters = () => {
|
|||
);
|
||||
|
||||
const nativeFiltersEnabled =
|
||||
showNativeFilters &&
|
||||
isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) &&
|
||||
(canEdit || (!canEdit && filterValues.length !== 0));
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ const initialState: { dashboardInfo: DashboardInfo } = {
|
|||
userId: '1',
|
||||
metadata: {
|
||||
native_filter_configuration: {},
|
||||
show_native_filters: true,
|
||||
chart_configuration: {},
|
||||
color_scheme: '',
|
||||
color_namespace: '',
|
||||
|
|
|
@ -101,7 +101,6 @@ export type DashboardInfo = {
|
|||
json_metadata: string;
|
||||
metadata: {
|
||||
native_filter_configuration: JsonObject;
|
||||
show_native_filters: boolean;
|
||||
chart_configuration: JsonObject;
|
||||
color_scheme: string;
|
||||
color_namespace: string;
|
||||
|
|
|
@ -108,7 +108,6 @@ def validate_json_metadata(value: Union[bytes, bytearray, str]) -> None:
|
|||
|
||||
|
||||
class DashboardJSONMetadataSchema(Schema):
|
||||
show_native_filters = fields.Boolean()
|
||||
# native_filter_configuration is for dashboard-native filters
|
||||
native_filter_configuration = fields.List(fields.Dict(), allow_none=True)
|
||||
# chart_configuration for now keeps data about cross-filter scoping for charts
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
"""remove_show_native_filters
|
||||
|
||||
Revision ID: c0a3ea245b61
|
||||
Revises: f3c2d8ec8595
|
||||
Create Date: 2023-02-28 14:46:59.597847
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = "c0a3ea245b61"
|
||||
down_revision = "f3c2d8ec8595"
|
||||
|
||||
import json
|
||||
|
||||
from alembic import op
|
||||
|
||||
from superset import db
|
||||
from superset.models.dashboard import Dashboard
|
||||
|
||||
|
||||
def upgrade():
|
||||
bind = op.get_bind()
|
||||
session = db.Session(bind=bind)
|
||||
|
||||
for dashboard in session.query(Dashboard).all():
|
||||
try:
|
||||
json_metadata = json.loads(dashboard.json_metadata)
|
||||
|
||||
if "show_native_filters" in json_metadata:
|
||||
del json_metadata["show_native_filters"]
|
||||
dashboard.json_metadata = json.dumps(json_metadata)
|
||||
session.merge(dashboard)
|
||||
except Exception: # pylint: disable=broad-except
|
||||
pass
|
||||
|
||||
session.commit()
|
||||
session.close()
|
||||
|
||||
|
||||
def downgrade():
|
||||
pass
|
|
@ -174,7 +174,6 @@ dashboards_config_1: Dict[str, Any] = {
|
|||
"default_filters": "{}",
|
||||
"color_scheme": "supersetColors",
|
||||
"label_colors": {},
|
||||
"show_native_filters": True,
|
||||
"color_scheme_domain": [],
|
||||
"shared_label_colors": {},
|
||||
"cross_filters_enabled": False,
|
||||
|
@ -251,7 +250,6 @@ dashboards_config_2: Dict[str, Any] = {
|
|||
"default_filters": "{}",
|
||||
"color_scheme": "supersetColors",
|
||||
"label_colors": {},
|
||||
"show_native_filters": True,
|
||||
"color_scheme_domain": [],
|
||||
"shared_label_colors": {},
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue