This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new f5fff5eaad refactor: Removes legacy CSS template endpoint (#31942)
f5fff5eaad is described below
commit f5fff5eaadeb19067283e475b78ec87e60b41556
Author: Michael S. Molina <[email protected]>
AuthorDate: Wed Jan 22 15:38:44 2025 -0300
refactor: Removes legacy CSS template endpoint (#31942)
---
.../components/CssEditor/CssEditor.test.tsx | 2 +-
.../src/dashboard/components/CssEditor/index.tsx | 5 +++--
superset/initialization/__init__.py | 6 +----
superset/views/css_templates.py | 26 ++--------------------
4 files changed, 7 insertions(+), 32 deletions(-)
diff --git
a/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx
b/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx
index 9bfe43ece5..f66ca17027 100644
--- a/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx
+++ b/superset-frontend/src/dashboard/components/CssEditor/CssEditor.test.tsx
@@ -38,7 +38,7 @@ const templates = [
{ template_name: 'Template C', css: 'background-color: yellow;' },
];
-fetchMock.get('glob:*/csstemplateasyncmodelview/api/read', {
+fetchMock.get('glob:*/api/v1/css_template*', {
result: templates,
});
diff --git a/superset-frontend/src/dashboard/components/CssEditor/index.tsx
b/superset-frontend/src/dashboard/components/CssEditor/index.tsx
index 996afcca44..e2748c8b0b 100644
--- a/superset-frontend/src/dashboard/components/CssEditor/index.tsx
+++ b/superset-frontend/src/dashboard/components/CssEditor/index.tsx
@@ -17,6 +17,7 @@
* under the License.
*/
import { Key, ReactNode, PureComponent } from 'react';
+import rison from 'rison';
import { AntdDropdown } from 'src/components';
import { Menu } from 'src/components/Menu';
import Button from 'src/components/Button';
@@ -73,8 +74,8 @@ class CssEditor extends PureComponent<CssEditorProps,
CssEditorState> {
componentDidMount() {
AceCssEditor.preload();
-
- SupersetClient.get({ endpoint: '/csstemplateasyncmodelview/api/read' })
+ const query = rison.encode({ columns: ['template_name', 'css'] });
+ SupersetClient.get({ endpoint: `/api/v1/css_template/?q=${query}` })
.then(({ json }) => {
const templates = json.result.map(
(row: { template_name: string; css: string }) => ({
diff --git a/superset/initialization/__init__.py
b/superset/initialization/__init__.py
index a57325c359..2fe2303559 100644
--- a/superset/initialization/__init__.py
+++ b/superset/initialization/__init__.py
@@ -165,10 +165,7 @@ class SupersetAppInitializer: # pylint:
disable=too-many-public-methods
from superset.views.api import Api
from superset.views.chart.views import SliceAsync, SliceModelView
from superset.views.core import Superset
- from superset.views.css_templates import (
- CssTemplateAsyncModelView,
- CssTemplateModelView,
- )
+ from superset.views.css_templates import CssTemplateModelView
from superset.views.dashboard.views import (
Dashboard,
DashboardModelView,
@@ -297,7 +294,6 @@ class SupersetAppInitializer: # pylint:
disable=too-many-public-methods
# Setup views with no menu
#
appbuilder.add_view_no_menu(Api)
- appbuilder.add_view_no_menu(CssTemplateAsyncModelView)
appbuilder.add_view_no_menu(Dashboard)
appbuilder.add_view_no_menu(DashboardModelViewAsync)
appbuilder.add_view_no_menu(Datasource)
diff --git a/superset/views/css_templates.py b/superset/views/css_templates.py
index d629fbfcc5..b0bb5e97f3 100644
--- a/superset/views/css_templates.py
+++ b/superset/views/css_templates.py
@@ -15,18 +15,13 @@
# specific language governing permissions and limitations
# under the License.
from flask_appbuilder.api import expose
-from flask_appbuilder.baseviews import expose_api
from flask_appbuilder.models.sqla.interface import SQLAInterface
-from flask_appbuilder.security.decorators import (
- has_access,
- has_access_api,
- permission_name,
-)
+from flask_appbuilder.security.decorators import has_access
from superset.constants import MODEL_VIEW_RW_METHOD_PERMISSION_MAP, RouteMethod
from superset.models import core as models
from superset.superset_typing import FlaskResponse
-from superset.views.base import DeleteMixin, deprecated, SupersetModelView
+from superset.views.base import DeleteMixin, SupersetModelView
class CssTemplateModelView( # pylint: disable=too-many-ancestors
@@ -43,20 +38,3 @@ class CssTemplateModelView( # pylint:
disable=too-many-ancestors
@has_access
def list(self) -> FlaskResponse:
return super().render_app_template()
-
-
-class CssTemplateAsyncModelView( # pylint: disable=too-many-ancestors
- CssTemplateModelView
-):
- include_route_methods = RouteMethod.API_READ
- class_permission_name = "CssTemplate"
- method_permission_name = MODEL_VIEW_RW_METHOD_PERMISSION_MAP
-
- list_columns = ["template_name", "css"]
-
- @expose_api(name="read", url="/api/read", methods=["GET"])
- @has_access_api
- @permission_name("list")
- @deprecated(eol_version="5.0.0")
- def api_read(self) -> FlaskResponse:
- return super().api_read()