mirror of
https://github.com/apache/superset.git
synced 2024-09-06 22:07:34 -04:00
fix: remove keys in dashboard export (#12115)
This commit is contained in:
parent
1a5f61b133
commit
4ae21bf30b
@ -20,7 +20,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import random
|
import random
|
||||||
import string
|
import string
|
||||||
from typing import Any, Dict, Iterator, List, Tuple
|
from typing import Any, Dict, Iterator, List, Optional, Tuple
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
@ -108,8 +108,8 @@ class ExportDashboardsCommand(ExportModelsCommand):
|
|||||||
# TODO (betodealmeida): move this logic to export_to_dict once this
|
# TODO (betodealmeida): move this logic to export_to_dict once this
|
||||||
# becomes the default export endpoint
|
# becomes the default export endpoint
|
||||||
for key, new_name in JSON_KEYS.items():
|
for key, new_name in JSON_KEYS.items():
|
||||||
if payload.get(key):
|
value: Optional[str] = payload.pop(key, None)
|
||||||
value = payload.pop(key)
|
if value:
|
||||||
try:
|
try:
|
||||||
payload[new_name] = json.loads(value)
|
payload[new_name] = json.loads(value)
|
||||||
except (TypeError, json.decoder.JSONDecodeError):
|
except (TypeError, json.decoder.JSONDecodeError):
|
||||||
|
@ -54,7 +54,7 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
|
|||||||
id_map = {old_id: chart_ids[uuid] for uuid, old_id in old_ids.items()}
|
id_map = {old_id: chart_ids[uuid] for uuid, old_id in old_ids.items()}
|
||||||
|
|
||||||
# fix metadata
|
# fix metadata
|
||||||
metadata = fixed["metadata"]
|
metadata = fixed.get("metadata", {})
|
||||||
if "timed_refresh_immune_slices" in metadata:
|
if "timed_refresh_immune_slices" in metadata:
|
||||||
metadata["timed_refresh_immune_slices"] = [
|
metadata["timed_refresh_immune_slices"] = [
|
||||||
id_map[old_id] for old_id in metadata["timed_refresh_immune_slices"]
|
id_map[old_id] for old_id in metadata["timed_refresh_immune_slices"]
|
||||||
@ -82,7 +82,7 @@ def update_id_refs(config: Dict[str, Any], chart_ids: Dict[str, int]) -> Dict[st
|
|||||||
}
|
}
|
||||||
|
|
||||||
# fix position
|
# fix position
|
||||||
position = fixed["position"]
|
position = fixed.get("position", {})
|
||||||
for child in position.values():
|
for child in position.values():
|
||||||
if (
|
if (
|
||||||
isinstance(child, dict)
|
isinstance(child, dict)
|
||||||
|
Loading…
Reference in New Issue
Block a user