Skip to content

Commit

Permalink
#108 reverting show filters
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastiankruk committed Sep 9, 2023
1 parent f28a745 commit b0666f7
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 17 deletions.
4 changes: 2 additions & 2 deletions superset-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion superset-frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superset",
"version": "3.0.0+paiku",
"version": "3.0.1+paiku",
"description": "Superset is a data exploration platform designed to be visual, intuitive, and interactive.",
"keywords": [
"big",
Expand Down
4 changes: 4 additions & 0 deletions superset-frontend/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const URL_PARAMS = {
name: 'filter_set',
type: 'string',
},
showFilters: {
name: 'show_filters',
type: 'boolean',
},
expandFilters: {
name: 'expand_filters',
type: 'boolean',
Expand Down
5 changes: 4 additions & 1 deletion superset-frontend/src/dashboard/actions/hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ 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)) {
const { chartConfiguration, globalChartConfiguration } =
getCrossFiltersConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ 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,
);
Expand All @@ -42,7 +48,8 @@ export const useNativeFilters = () => {
);

const nativeFiltersEnabled =
isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) &&
showNativeFilters &&
isFeatureEnabled(FeatureFlag.DASHBOARD_NATIVE_FILTERS) &&
(canEdit || (!canEdit && filterValues.length !== 0));

const requiredFirstFilter = filterValues.filter(
Expand Down
1 change: 1 addition & 0 deletions superset-frontend/src/dashboard/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export type DashboardInfo = {
json_metadata: string;
metadata: {
native_filter_configuration: JsonObject;
show_native_filters: boolean;
chart_configuration: ChartConfiguration;
global_chart_configuration: GlobalChartCrossFilterConfig;
color_scheme: string;
Expand Down
1 change: 1 addition & 0 deletions superset/dashboards/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,22 @@ class Dashboard(Base):


def upgrade():
bind = op.get_bind()
session = db.Session(bind=bind)
# bind = op.get_bind()
# session = db.Session(bind=bind)

for dashboard in session.query(Dashboard).all():
try:
json_metadata = json.loads(dashboard.json_metadata)
# 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)
except Exception: # pylint: disable=broad-except
pass
# if "show_native_filters" in json_metadata:
# del json_metadata["show_native_filters"]
# dashboard.json_metadata = json.dumps(json_metadata)
# except Exception: # pylint: disable=broad-except
# pass

session.commit()
session.close()
# session.commit()
# session.close()
pass


def downgrade():
Expand Down

0 comments on commit b0666f7

Please sign in to comment.