fix(dashboard): show_native_filters leftover (#23389)

This commit is contained in:
Beto Dealmeida 2023-03-17 16:50:26 -07:00 committed by GitHub
parent d950eb85d7
commit 022213972b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -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)

View File

@ -18,7 +18,7 @@ import json
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
@ -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()