rusackas commented on a change in pull request #11820:
URL:
https://github.com/apache/incubator-superset/pull/11820#discussion_r532879054
##########
File path: superset-frontend/src/views/CRUD/dashboard/DashboardList.tsx
##########
@@ -101,43 +89,37 @@ function DashboardList(props: DashboardListProps) {
setDashboardToEdit(dashboard);
}
- function handleDashboardEdit(edits: Dashboard) {
- return SupersetClient.get({
- endpoint: `/api/v1/dashboard/${edits.id}`,
- }).then(
- ({ json = {} }) => {
- setDashboards(
- dashboards.map(dashboard => {
- if (dashboard.id === json.id) {
- return json.result;
- }
- return dashboard;
- }),
- );
- },
+ async function handleDashboardEdit(edits: Dashboard) {
+ try {
+ const json = await showDashboard(edits.id);
+ setDashboards(
+ dashboards.map(dashboard => {
+ if (dashboard.id === json.id) {
+ return json.result;
+ }
+ return dashboard;
+ }),
+ );
+ } catch (e) {
createErrorHandler(errMsg =>
props.addDangerToast(
t('An error occurred while fetching dashboards: %s', errMsg),
),
- ),
- );
+ );
+ }
}
- function handleBulkDashboardDelete(dashboardsToDelete: Dashboard[]) {
- return SupersetClient.delete({
- endpoint: `/api/v1/dashboard/?q=${rison.encode(
- dashboardsToDelete.map(({ id }) => id),
- )}`,
- }).then(
- ({ json = {} }) => {
- props.addSuccessToast(json.message);
- },
+ async function handleBulkDashboardDelete(dashboardsToDelete: Dashboard[]) {
+ try {
+ const message = await bulkDeleteDashboard(dashboardsToDelete);
+ props.addSuccessToast(message);
Review comment:
I'm curious if _most_ of these API calls will result in toast messages.
If so, it might be worth considering:
• Adding the default toast messages into the API layer (for consistency)
• Allowing optional parameter(s) to override/disable the default toast
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]