From 492ff82a0dc240ac2e10ae6f383e0bca9e07f4b4 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Mon, 18 Apr 2022 12:12:45 +0100 Subject: [PATCH 1/3] feat: deprecate old API on core superset fave_dashboards --- .../src/profile/components/Favorites.tsx | 27 +++++++++++++------ superset/views/core.py | 10 +++++++ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/superset-frontend/src/profile/components/Favorites.tsx b/superset-frontend/src/profile/components/Favorites.tsx index ab17d625e75b6..3ab20e76a5d73 100644 --- a/superset-frontend/src/profile/components/Favorites.tsx +++ b/superset-frontend/src/profile/components/Favorites.tsx @@ -17,12 +17,13 @@ * under the License. */ import React from 'react'; +import rison from 'rison'; import moment from 'moment'; import { t } from '@superset-ui/core'; import TableLoader from '../../components/TableLoader'; import { Slice } from '../types'; -import { User, Dashboard } from '../../types/bootstrapTypes'; +import { User, DashboardResponse } from '../../types/bootstrapTypes'; interface FavoritesProps { user: User; @@ -50,19 +51,29 @@ export default class Favorites extends React.PureComponent { } renderDashboardTable() { - const mutator = (data: Dashboard[]) => - data.map(dash => ({ - dashboard: {dash.title}, - creator: {dash.creator}, - favorited: moment.utc(dash.dttm).fromNow(), + const search = [{ col: 'id', opr: 'dashboard_is_favorite', value: true }]; + const query = rison.encode({ + keys: ['none'], + columns: ['created_on_delta_humanized', 'dashboard_title', 'url'], + filters: search, + order_column: 'changed_on', + order_direction: 'desc', + page: 0, + page_size: 100, + }); + const mutator = (data: DashboardResponse[]) => + data.result.map(dash => ({ + dashboard: {dash.dashboard_title}, + created: dash.created_on_delta_humanized, + _created: dash.created_on_delta_humanized, })); return ( ); diff --git a/superset/views/core.py b/superset/views/core.py index 27a9a039b2d7b..378c62bb2a410 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -1543,6 +1543,11 @@ def available_domains(self) -> FlaskResponse: # pylint: disable=no-self-use @expose("/fave_dashboards_by_username//", methods=["GET"]) def fave_dashboards_by_username(self, username: str) -> FlaskResponse: """This lets us use a user's username to pull favourite dashboards""" + logger.warning( + "%s.fave_dashboards_by_username " + "This API endpoint is deprecated and will be removed in version 3.0.0", + self.__class__.__name__, + ) user = security_manager.find_user(username=username) return self.fave_dashboards(user.id) @@ -1551,6 +1556,11 @@ def fave_dashboards_by_username(self, username: str) -> FlaskResponse: @event_logger.log_this @expose("/fave_dashboards//", methods=["GET"]) def fave_dashboards(self, user_id: int) -> FlaskResponse: + logger.warning( + "%s.fave_dashboards " + "This API endpoint is deprecated and will be removed in version 3.0.0", + self.__class__.__name__, + ) error_obj = self.get_user_activity_access_error(user_id) if error_obj: return error_obj From 82685b88d2195db75375833c3fe1234db674b597 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Mon, 18 Apr 2022 12:31:28 +0100 Subject: [PATCH 2/3] fix js lint --- superset-frontend/src/profile/components/Favorites.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/superset-frontend/src/profile/components/Favorites.tsx b/superset-frontend/src/profile/components/Favorites.tsx index 3ab20e76a5d73..1a7daa750f063 100644 --- a/superset-frontend/src/profile/components/Favorites.tsx +++ b/superset-frontend/src/profile/components/Favorites.tsx @@ -61,7 +61,7 @@ export default class Favorites extends React.PureComponent { page: 0, page_size: 100, }); - const mutator = (data: DashboardResponse[]) => + const mutator = (data: DashboardResponse) => data.result.map(dash => ({ dashboard: {dash.dashboard_title}, created: dash.created_on_delta_humanized, From 994739ce7db5a60acffa0bb724f20dd26f2a6004 Mon Sep 17 00:00:00 2001 From: Daniel Gaspar Date: Wed, 20 Apr 2022 18:50:00 +0100 Subject: [PATCH 3/3] remove unused type --- superset-frontend/src/types/bootstrapTypes.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/superset-frontend/src/types/bootstrapTypes.ts b/superset-frontend/src/types/bootstrapTypes.ts index 8918ea8489046..3feb32f7a0b2a 100644 --- a/superset-frontend/src/types/bootstrapTypes.ts +++ b/superset-frontend/src/types/bootstrapTypes.ts @@ -40,15 +40,6 @@ export interface UserWithPermissionsAndRoles extends User { export type UndefinedUser = {}; -export type Dashboard = { - dttm: number; - id: number; - url: string; - title: string; - creator?: string; - creator_url?: string; -}; - export type DashboardData = { dashboard_title?: string; created_on_delta_humanized?: string;