mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
fix: Unable to export multiple Dashboards with the same name (#20383)
This commit is contained in:
@@ -112,7 +112,7 @@ class ExportDashboardsCommand(ExportModelsCommand):
|
||||
model: Dashboard, export_related: bool = True
|
||||
) -> Iterator[Tuple[str, str]]:
|
||||
dashboard_slug = secure_filename(model.dashboard_title)
|
||||
file_name = f"dashboards/{dashboard_slug}.yaml"
|
||||
file_name = f"dashboards/{dashboard_slug}_{model.id}.yaml"
|
||||
|
||||
payload = model.export_to_dict(
|
||||
recursive=False,
|
||||
|
||||
@@ -68,7 +68,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
|
||||
expected_paths = {
|
||||
"metadata.yaml",
|
||||
"dashboards/World_Banks_Data.yaml",
|
||||
f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml",
|
||||
"datasets/examples/wb_health_population.yaml",
|
||||
"databases/examples.yaml",
|
||||
}
|
||||
@@ -77,7 +77,9 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
expected_paths.add(f"charts/{chart_slug}_{chart.id}.yaml")
|
||||
assert expected_paths == set(contents.keys())
|
||||
|
||||
metadata = yaml.safe_load(contents["dashboards/World_Banks_Data.yaml"])
|
||||
metadata = yaml.safe_load(
|
||||
contents[f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml"]
|
||||
)
|
||||
|
||||
# remove chart UUIDs from metadata so we can compare
|
||||
for chart_info in metadata["position"].values():
|
||||
@@ -269,7 +271,9 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
command = ExportDashboardsCommand([example_dashboard.id])
|
||||
contents = dict(command.run())
|
||||
|
||||
metadata = yaml.safe_load(contents["dashboards/World_Banks_Data.yaml"])
|
||||
metadata = yaml.safe_load(
|
||||
contents[f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml"]
|
||||
)
|
||||
assert list(metadata.keys()) == [
|
||||
"dashboard_title",
|
||||
"description",
|
||||
@@ -284,7 +288,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
@pytest.mark.usefixtures("load_world_bank_dashboard_with_slices")
|
||||
@patch("superset.dashboards.commands.export.suffix")
|
||||
def test_append_charts(self, mock_suffix):
|
||||
"""Test that oprhaned charts are added to the dashbaord position"""
|
||||
"""Test that orphaned charts are added to the dashboard position"""
|
||||
# return deterministic IDs
|
||||
mock_suffix.side_effect = (str(i) for i in itertools.count(1))
|
||||
|
||||
@@ -435,7 +439,7 @@ class TestExportDashboardsCommand(SupersetTestCase):
|
||||
|
||||
expected_paths = {
|
||||
"metadata.yaml",
|
||||
"dashboards/World_Banks_Data.yaml",
|
||||
f"dashboards/World_Banks_Data_{example_dashboard.id}.yaml",
|
||||
}
|
||||
assert expected_paths == set(contents.keys())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user