Skip to content

Commit

Permalink
fix(dashboard): show_native_filters leftover (#23389)
Browse files Browse the repository at this point in the history
  • Loading branch information
betodealmeida authored and pull[bot] committed Apr 3, 2024
1 parent 1248772 commit 110240f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions superset/dashboards/commands/importers/v1/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ def import_dashboard(

# TODO (betodealmeida): move this logic to import_from_dict
config = config.copy()

# removed in https://github.com/apache/superset/pull/23228
if "metadata" in config and "show_native_filters" in config["metadata"]:
del config["metadata"]["show_native_filters"]

for key, new_name in JSON_KEYS.items():
if config.get(key) is not None:
value = config.pop(key)
Expand Down
19 changes: 18 additions & 1 deletion superset/dashboards/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import re
from typing import Any, Dict, Union

from marshmallow import fields, post_load, Schema
from marshmallow import fields, post_load, pre_load, Schema
from marshmallow.validate import Length, ValidationError

from superset.exceptions import SupersetException
Expand Down Expand Up @@ -135,6 +135,23 @@ class DashboardJSONMetadataSchema(Schema):
remote_id = fields.Integer()
filter_bar_orientation = fields.Str(allow_none=True)

@pre_load
def remove_show_native_filters( # pylint: disable=unused-argument, no-self-use
self,
data: Dict[str, Any],
**kwargs: Any,
) -> Dict[str, Any]:
"""
Remove ``show_native_filters`` from the JSON metadata.
This field was removed in https://github.com/apache/superset/pull/23228, but might
be present in old exports.
"""
if "show_native_filters" in data:
del data["show_native_filters"]

return data


class UserSchema(Schema):
id = fields.Int()
Expand Down

0 comments on commit 110240f

Please sign in to comment.