From 5b2499984dd2d65d8a89b67ad216322a044f1979 Mon Sep 17 00:00:00 2001 From: Daniel Vaz Gaspar Date: Fri, 10 Jan 2020 08:48:17 +0000 Subject: [PATCH] [dashboard] Deprecate superset published API (#8914) --- superset/assets/src/dashboard/actions/dashboardState.js | 9 ++++++--- superset/views/core.py | 9 +++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/superset/assets/src/dashboard/actions/dashboardState.js b/superset/assets/src/dashboard/actions/dashboardState.js index cea6e2556..2b506d84e 100644 --- a/superset/assets/src/dashboard/actions/dashboardState.js +++ b/superset/assets/src/dashboard/actions/dashboardState.js @@ -110,9 +110,12 @@ export function togglePublished(isPublished) { export function savePublished(id, isPublished) { return function savePublishedThunk(dispatch) { - return SupersetClient.post({ - endpoint: `/superset/dashboard/${id}/published/`, - postPayload: { published: isPublished }, + return SupersetClient.put({ + endpoint: `/api/v1/dashboard/${id}`, + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + published: isPublished, + }), }) .then(() => { const nowPublished = isPublished ? 'published' : 'hidden'; diff --git a/superset/views/core.py b/superset/views/core.py index 2742c6c21..e1369d7eb 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1857,6 +1857,9 @@ class Superset(BaseSupersetView): @expose("/dashboard//published/", methods=("GET", "POST")) def publish(self, dashboard_id): """Gets and toggles published status on dashboards""" + logging.warning( + "This API endpoint is deprecated and will be removed in version 1.0.0" + ) session = db.session() Role = ab_models.Role dash = ( @@ -1869,16 +1872,14 @@ class Superset(BaseSupersetView): return json_success(json.dumps({"published": dash.published})) else: return json_error_response( - "ERROR: cannot find dashboard {0}".format(dashboard_id), status=404 + f"ERROR: cannot find dashboard {dashboard_id}", status=404 ) else: edit_perm = is_owner(dash, g.user) or admin_role in get_user_roles() if not edit_perm: return json_error_response( - 'ERROR: "{0}" cannot alter dashboard "{1}"'.format( - g.user.username, dash.dashboard_title - ), + f'ERROR: "{g.user.username}" cannot alter dashboard "{dash.dashboard_title}"', status=403, )