From 0f44d3edf25b194984255d84f70fce29c8c70ba4 Mon Sep 17 00:00:00 2001 From: auxten Date: Sun, 23 Aug 2020 02:04:18 +0800 Subject: [PATCH] Fix add chart page frontend i18n issue (#9321) --- superset-frontend/src/addSlice/App.tsx | 2 +- superset-frontend/src/addSlice/index.tsx | 2 +- superset/templates/superset/add_slice.html | 2 +- superset/views/chart/views.py | 16 +++++++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/superset-frontend/src/addSlice/App.tsx b/superset-frontend/src/addSlice/App.tsx index 4443fb51f9..7fdb05dbfc 100644 --- a/superset-frontend/src/addSlice/App.tsx +++ b/superset-frontend/src/addSlice/App.tsx @@ -26,7 +26,7 @@ import AddSliceContainer from './AddSliceContainer'; setupApp(); setupPlugins(); -const addSliceContainer = document.getElementById('js-add-slice-container'); +const addSliceContainer = document.getElementById('app'); const bootstrapData = JSON.parse( addSliceContainer?.getAttribute('data-bootstrap') || '{}', ); diff --git a/superset-frontend/src/addSlice/index.tsx b/superset-frontend/src/addSlice/index.tsx index 09b6de2291..c257009e64 100644 --- a/superset-frontend/src/addSlice/index.tsx +++ b/superset-frontend/src/addSlice/index.tsx @@ -20,4 +20,4 @@ import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; -ReactDOM.render(, document.getElementById('js-add-slice-container')); +ReactDOM.render(, document.getElementById('app')); diff --git a/superset/templates/superset/add_slice.html b/superset/templates/superset/add_slice.html index 6d22b1da5d..b287de64e8 100644 --- a/superset/templates/superset/add_slice.html +++ b/superset/templates/superset/add_slice.html @@ -24,7 +24,7 @@ {% block body %}
{% endblock %} diff --git a/superset/views/chart/views.py b/superset/views/chart/views.py index 0523e33aaf..b2ecc5ef6f 100644 --- a/superset/views/chart/views.py +++ b/superset/views/chart/views.py @@ -26,7 +26,12 @@ from superset.constants import RouteMethod from superset.models.slice import Slice from superset.typing import FlaskResponse from superset.utils import core as utils -from superset.views.base import check_ownership, DeleteMixin, SupersetModelView +from superset.views.base import ( + check_ownership, + common_bootstrap_payload, + DeleteMixin, + SupersetModelView, +) from superset.views.chart.mixin import SliceMixin @@ -58,11 +63,12 @@ class SliceModelView( {"value": str(d.id) + "__" + d.type, "label": repr(d)} for d in ConnectorRegistry.get_all_datasources(db.session) ] + payload = { + "datasources": sorted(datasources, key=lambda d: d["label"]), + "common": common_bootstrap_payload(), + } return self.render_template( - "superset/add_slice.html", - bootstrap_data=json.dumps( - {"datasources": sorted(datasources, key=lambda d: d["label"])} - ), + "superset/add_slice.html", bootstrap_data=json.dumps(payload) ) @expose("/list/")