You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2022/01/12 01:09:14 UTC
[superset] 18/18: Add functionality is now working (#17578)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch refactorReports
in repository https://gitbox.apache.org/repos/asf/superset.git
commit bbc8597612434421836c59e4401c9b5d812a0a3d
Author: Lyndsi Kay Williams <55...@users.noreply.github.com>
AuthorDate: Tue Dec 7 15:17:47 2021 -0600
Add functionality is now working (#17578)
---
superset-frontend/src/reports/reducers/reports.js | 41 ++++++++++-------------
1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/superset-frontend/src/reports/reducers/reports.js b/superset-frontend/src/reports/reducers/reports.js
index a18d72e..fc8f575 100644
--- a/superset-frontend/src/reports/reducers/reports.js
+++ b/superset-frontend/src/reports/reducers/reports.js
@@ -19,7 +19,6 @@
/* eslint-disable camelcase */
// eslint-disable-next-line import/no-extraneous-dependencies
import { report } from 'process';
-// import { allowCrossDomain } from 'src/utils/hostNamesConfig';
import {
SET_REPORT,
ADD_REPORT,
@@ -78,49 +77,43 @@ export default function reportsReducer(state = {}, action) {
},
[ADD_REPORT]() {
- // Grab first matching report by matching dashboard id
- const reportWithDashboard = action.json.result.find(
- report => !!report.dashboard_id,
- );
- // Assign the report's id
- reportWithDashboard.id = action.json.id;
+ const { result, id } = action.json;
+ const report = { ...result, id };
- // Grab first matching report by matching chart id
- const reportWithChart = action.json.result.find(
- report => !!report.chart.id,
- );
- // Assign the report's id
- reportWithChart.id = action.json.id;
-
- // This adds the report by its type, dashboard or chart
- if (reportWithDashboard) {
+ if (result.dashboard) {
return {
...state,
dashboards: {
...state.dashboards,
- [reportWithDashboard.dashboard_id]: report,
+ [report.id]: report,
+ },
+ };
+ }
+ if (result.chart) {
+ return {
+ ...state,
+ charts: {
+ ...state.chart,
+ [report.id]: report,
},
};
}
return {
...state,
- charts: {
- ...state.chart,
- [reportWithChart.chart.id]: report,
- },
};
},
[EDIT_REPORT]() {
// Grab first matching report by matching dashboard id
- const reportWithDashboard = action.json.result.find(
+ // FIX THESE, THEY'RE OBJECTS, NOT ARRAYS, NO FIND
+ const reportWithDashboard = action.json.result?.find(
report => !!report.dashboard_id,
);
// Assign the report's id
reportWithDashboard.id = action.json.id;
// Grab first matching report by matching chart id
- const reportWithChart = action.json.result.find(
+ const reportWithChart = action.json.result?.find(
report => !!report.chart.id,
);
// Assign the report's id
@@ -148,7 +141,7 @@ export default function reportsReducer(state = {}, action) {
[DELETE_REPORT]() {
// Grabs the first report with a dashboard id that
// matches the parameter report's dashboard_id
- const reportWithDashboard = action.report.result.find(
+ const reportWithDashboard = action.report.result?.find(
report => !!report.dashboard_id,
);