williaster commented on a change in pull request #3581: Dashboard refactory
URL:
https://github.com/apache/incubator-superset/pull/3581#discussion_r147903181
##########
File path: superset/assets/javascripts/chart/chartReducer.js
##########
@@ -0,0 +1,108 @@
+/* eslint camelcase: 0 */
+import PropTypes from 'prop-types';
+
+import { now } from '../modules/dates';
+import * as actions from './chartAction';
+import { t } from '../locales';
+
+export const chartPropType = {
+ chartKey: PropTypes.string.isRequired,
+ chartAlert: PropTypes.string,
+ chartStatus: PropTypes.string,
+ chartUpdateEndTime: PropTypes.number,
+ chartUpdateStartTime: PropTypes.number,
+ latestQueryFormData: PropTypes.object,
+ queryResponse: PropTypes.object,
+ triggerQuery: PropTypes.bool,
+ triggerRender: PropTypes.bool,
+};
+
+export const chart = {
+ chartKey: '',
+ chartAlert: null,
+ chartStatus: null,
+ chartUpdateEndTime: null,
+ chartUpdateStartTime: now(),
+ latestQueryFormData: null,
+ queryResponse: null,
+ triggerQuery: true,
+ triggerRender: false,
+};
+
+export default function chartReducer(charts = {}, action) {
+ const actionHandlers = {
+ [actions.CHART_UPDATE_SUCCEEDED](state) {
+ return Object.assign(
Review comment:
why do you not use object rest spread over `Object.assign`? I think
generally this is preferred.
eg `{ ...state, { chartStatus, queryResponse, chartUpdateEndTime } }`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services