[dashboard] Deprecate superset published API (#8914)

This commit is contained in:
Daniel Vaz Gaspar 2020-01-10 08:48:17 +00:00 committed by GitHub
parent 5bc3d24b2f
commit 5b2499984d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -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';

View File

@ -1857,6 +1857,9 @@ class Superset(BaseSupersetView):
@expose("/dashboard/<dashboard_id>/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,
)