diff --git a/docs/docs/configuration/alerts-reports.mdx b/docs/docs/configuration/alerts-reports.mdx index 55349e33c6288..9e3474a5dad67 100644 --- a/docs/docs/configuration/alerts-reports.mdx +++ b/docs/docs/configuration/alerts-reports.mdx @@ -411,6 +411,6 @@ This configuration is based on menu item called “Schedule” to SQL Lab. When the menu item is clicked, a modal will show up where the user can add the metadata required for scheduling the query. -This information can then be retrieved from the endpoint `/savedqueryviewapi/api/read` and used to -schedule the queries that have `scheduled_queries` in their JSON metadata. For schedulers other than +This information can then be retrieved from the endpoint `/api/v1/saved_query/` and used to +schedule the queries that have `schedule_info` in their JSON metadata. For schedulers other than Airflow, additional fields can be easily added to the configuration file above. diff --git a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/controlPanel.ts b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/controlPanel.ts index bfabd2a0e8af9..f56b4eb9ec050 100644 --- a/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/controlPanel.ts +++ b/superset-frontend/plugins/legacy-preset-chart-deckgl/src/Multi/controlPanel.ts @@ -40,7 +40,7 @@ export default { 'Pick a set of deck.gl charts to layer on top of one another', ), dataEndpoint: - '/sliceasync/api/read?_flt_0_viz_type=deck_&_flt_7_viz_type=deck_multi', + 'api/v1/chart/?q=(filters:!((col:viz_type,opr:sw,value:deck)))', placeholder: t('Select charts'), onAsyncErrorMessage: t('Error while fetching charts'), mutator: (data: { diff --git a/superset-frontend/src/SqlLab/actions/sqlLab.js b/superset-frontend/src/SqlLab/actions/sqlLab.js index 7a73f9b9c86f9..03c1855503c5d 100644 --- a/superset-frontend/src/SqlLab/actions/sqlLab.js +++ b/superset-frontend/src/SqlLab/actions/sqlLab.js @@ -171,8 +171,8 @@ export function setEditorTabLastUpdate(timestamp) { export function scheduleQuery(query) { return dispatch => SupersetClient.post({ - endpoint: '/savedqueryviewapi/api/create', - postPayload: query, + endpoint: '/api/v1/saved_query/', + jsonPayload: query, stringify: false, }) .then(() => @@ -1214,7 +1214,7 @@ export function popStoredQuery(urlId) { export function popSavedQuery(saveQueryId) { return function (dispatch) { return SupersetClient.get({ - endpoint: `/savedqueryviewapi/api/get/${saveQueryId}`, + endpoint: `/api/v1/saved_query/${saveQueryId}`, }) .then(({ json }) => { const queryEditorProps = { @@ -1222,7 +1222,15 @@ export function popSavedQuery(saveQueryId) { loaded: true, autorun: false, }; - return dispatch(addQueryEditor(queryEditorProps)); + const tmpAdaptedProps = { + name: queryEditorProps.name, + dbId: queryEditorProps.database.id, + catalog: queryEditorProps.catalog, + schema: queryEditorProps.schema, + sql: queryEditorProps.sql, + templateParams: queryEditorProps.templateParams, + }; + return dispatch(addQueryEditor(tmpAdaptedProps)); }) .catch(() => dispatch(addDangerToast(ERR_MSG_CANT_LOAD_QUERY))); }; diff --git a/superset/initialization/__init__.py b/superset/initialization/__init__.py index 83d3afb3d1721..65e518b7c9b15 100644 --- a/superset/initialization/__init__.py +++ b/superset/initialization/__init__.py @@ -156,7 +156,7 @@ def init_views(self) -> None: from superset.sqllab.api import SqlLabRestApi from superset.tags.api import TagRestApi from superset.views.alerts import AlertView, ReportView - from superset.views.all_entities import TaggedObjectsModelView, TaggedObjectView + from superset.views.all_entities import TaggedObjectsModelView from superset.views.annotations import AnnotationLayerView from superset.views.api import Api from superset.views.chart.views import SliceAsync, SliceModelView @@ -309,7 +309,6 @@ def init_views(self) -> None: appbuilder.add_view_no_menu(TableModelView) appbuilder.add_view_no_menu(TableSchemaView) appbuilder.add_view_no_menu(TabStateView) - appbuilder.add_view_no_menu(TaggedObjectView) appbuilder.add_view_no_menu(TaggedObjectsModelView) appbuilder.add_view_no_menu(TagView) appbuilder.add_view_no_menu(ReportView) diff --git a/superset/queries/saved_queries/api.py b/superset/queries/saved_queries/api.py index d772483d9c4d8..57ef2dab14c88 100644 --- a/superset/queries/saved_queries/api.py +++ b/superset/queries/saved_queries/api.py @@ -136,6 +136,7 @@ class SavedQueryRestApi(BaseSupersetModelRestApi): "schema", "sql", "template_parameters", + "extra_json", ] edit_columns = add_columns order_columns = [ diff --git a/superset/views/all_entities.py b/superset/views/all_entities.py index 3de53be461971..5ca7e41e1d75a 100644 --- a/superset/views/all_entities.py +++ b/superset/views/all_entities.py @@ -18,37 +18,22 @@ import logging from flask_appbuilder import expose -from flask_appbuilder.hooks import before_request from flask_appbuilder.models.sqla.interface import SQLAInterface from flask_appbuilder.security.decorators import has_access -from jinja2.sandbox import SandboxedEnvironment -from werkzeug.exceptions import NotFound from superset import is_feature_enabled -from superset.jinja_context import ExtraCache from superset.superset_typing import FlaskResponse from superset.tags.models import Tag from superset.views.base import SupersetModelView -from .base import BaseSupersetView - logger = logging.getLogger(__name__) -def process_template(content: str) -> str: - env = SandboxedEnvironment() - template = env.from_string(content) - context = { - "current_user_id": ExtraCache.current_user_id, - "current_username": ExtraCache.current_username, - } - return template.render(context) - - class TaggedObjectsModelView(SupersetModelView): route_base = "/superset/all_entities" datamodel = SQLAInterface(Tag) class_permission_name = "Tags" + include_route_methods = {"list"} @has_access @expose("/") @@ -57,14 +42,3 @@ def list(self) -> FlaskResponse: return super().list() return super().render_app_template() - - -class TaggedObjectView(BaseSupersetView): - @staticmethod - def is_enabled() -> bool: - return is_feature_enabled("TAGGING_SYSTEM") - - @before_request - def ensure_enabled(self) -> None: - if not self.is_enabled(): - raise NotFound() diff --git a/superset/views/base.py b/superset/views/base.py index 8171140e80ea5..06e330ab64853 100644 --- a/superset/views/base.py +++ b/superset/views/base.py @@ -562,6 +562,7 @@ class DeprecateModelViewMixin: def add(self) -> FlaskResponse: return super().add() # type: ignore + @expose("/show/", methods=["GET"]) @has_access @deprecated(eol_version="5.0.0") def show(self, pk: int) -> FlaskResponse: diff --git a/superset/views/chart/views.py b/superset/views/chart/views.py index 209f7582e0016..00d591587207f 100644 --- a/superset/views/chart/views.py +++ b/superset/views/chart/views.py @@ -23,11 +23,13 @@ from superset.models.slice import Slice from superset.superset_typing import FlaskResponse from superset.utils import core as utils -from superset.views.base import DeleteMixin, SupersetModelView +from superset.views.base import DeleteMixin, DeprecateModelViewMixin, SupersetModelView from superset.views.chart.mixin import SliceMixin -class SliceModelView(SliceMixin, SupersetModelView, DeleteMixin): # pylint: disable=too-many-ancestors +class SliceModelView( + DeprecateModelViewMixin, SliceMixin, SupersetModelView, DeleteMixin +): # pylint: disable=too-many-ancestors route_base = "/chart" datamodel = SQLAInterface(Slice) include_route_methods = RouteMethod.CRUD_SET | { diff --git a/superset/views/database/views.py b/superset/views/database/views.py index c475e4ba2b27d..019dc1138bd11 100644 --- a/superset/views/database/views.py +++ b/superset/views/database/views.py @@ -31,7 +31,7 @@ from superset.utils import core as utils from superset.views.base import ( DeleteMixin, - deprecated, + DeprecateModelViewMixin, SupersetModelView, YamlExportMixin, ) @@ -75,7 +75,13 @@ def upload_stream_write(form_file_field: "FileStorage", path: str) -> None: file_description.write(chunk) -class DatabaseView(DatabaseMixin, SupersetModelView, DeleteMixin, YamlExportMixin): # pylint: disable=too-many-ancestors +class DatabaseView( + DeprecateModelViewMixin, + DatabaseMixin, + SupersetModelView, + DeleteMixin, + YamlExportMixin, +): # pylint: disable=too-many-ancestors datamodel = SQLAInterface(models.Database) class_permission_name = "Database" @@ -92,34 +98,6 @@ class DatabaseView(DatabaseMixin, SupersetModelView, DeleteMixin, YamlExportMixi yaml_dict_key = "databases" - @expose("/show/", methods=["GET"]) - @has_access - @deprecated(eol_version="5.0.0") - def show(self, pk: int) -> FlaskResponse: - """Show database""" - return super().show(pk) - - @expose("/add", methods=["GET", "POST"]) - @has_access - @deprecated(eol_version="5.0.0") - def add(self) -> FlaskResponse: - return super().add() - - @expose("/edit/", methods=["GET", "POST"]) - @has_access - @deprecated(eol_version="5.0.0") - def edit(self, pk: int) -> FlaskResponse: - return super().edit(pk) - - @expose("/delete/", methods=["GET", "POST"]) - @has_access - @deprecated(eol_version="5.0.0") - def delete(self, pk: int) -> FlaskResponse: - return super().delete(pk) - - def _delete(self, pk: int) -> None: - DeleteMixin._delete(self, pk) - @expose("/list/") @has_access def list(self) -> FlaskResponse: diff --git a/superset/views/sql_lab/views.py b/superset/views/sql_lab/views.py index 6e2738ea2e764..b481f191b8227 100644 --- a/superset/views/sql_lab/views.py +++ b/superset/views/sql_lab/views.py @@ -33,6 +33,7 @@ from superset.views.base import ( BaseSupersetView, DeleteMixin, + DeprecateModelViewMixin, json_success, SupersetModelView, ) @@ -40,7 +41,7 @@ logger = logging.getLogger(__name__) -class SavedQueryView(BaseSupersetView): +class SavedQueryView(DeprecateModelViewMixin, BaseSupersetView): route_base = "/savedqueryview" class_permission_name = "SavedQuery" @@ -50,7 +51,7 @@ def list(self) -> FlaskResponse: return super().render_app_template() -class SavedQueryViewApi(SupersetModelView, DeleteMixin): # pylint: disable=too-many-ancestors +class SavedQueryViewApi(DeprecateModelViewMixin, SupersetModelView, DeleteMixin): # pylint: disable=too-many-ancestors datamodel = SQLAInterface(SavedQuery) include_route_methods = RouteMethod.CRUD_SET route_base = "/savedqueryviewapi" diff --git a/superset/views/tags.py b/superset/views/tags.py index 17d814ebb2778..3b27510ff3ee6 100644 --- a/superset/views/tags.py +++ b/superset/views/tags.py @@ -22,11 +22,9 @@ from flask_appbuilder.hooks import before_request from flask_appbuilder.models.sqla.interface import SQLAInterface from flask_appbuilder.security.decorators import has_access, has_access_api -from jinja2.sandbox import SandboxedEnvironment from werkzeug.exceptions import NotFound from superset import db, is_feature_enabled, utils -from superset.jinja_context import ExtraCache from superset.superset_typing import FlaskResponse from superset.tags.models import Tag from superset.views.base import SupersetModelView @@ -36,20 +34,11 @@ logger = logging.getLogger(__name__) -def process_template(content: str) -> str: - env = SandboxedEnvironment() - template = env.from_string(content) - context = { - "current_user_id": ExtraCache.current_user_id, - "current_username": ExtraCache.current_username, - } - return template.render(context) - - class TagModelView(SupersetModelView): route_base = "/superset/tags" datamodel = SQLAInterface(Tag) class_permission_name = "Tags" + include_route_methods = {"list"} @has_access @expose("/")