williaster commented on a change in pull request #3581: Dashboard refactory
URL: 
https://github.com/apache/incubator-superset/pull/3581#discussion_r147903383
 
 

 ##########
 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(
+        {},
+        state,
+        {
+          chartStatus: 'success',
+          queryResponse: action.queryResponse,
+          chartUpdateEndTime: now(),
+        },
+      );
+    },
+    [actions.CHART_UPDATE_STARTED](state) {
+      return Object.assign({}, state,
+        {
+          chartStatus: 'loading',
+          chartUpdateEndTime: null,
+          chartUpdateStartTime: now(),
+          queryRequest: action.queryRequest,
+        });
+    },
+    [actions.CHART_UPDATE_STOPPED](state) {
+      return Object.assign({}, state,
+        {
+          chartStatus: 'stopped',
+          chartAlert: t('Updating chart was stopped'),
+        });
+    },
+    [actions.CHART_RENDERING_FAILED](state) {
+      return Object.assign({}, state, {
 
 Review comment:
   ditto object spread `{ ... }`

----------------------------------------------------------------
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

Reply via email to