Bug 1416104 - Part 0: Combine action files and reducer files into one. r=gl
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 19 Jan 2018 15:16:16 +0900
changeset 400035 c897609672e6cd4953aa9c7856b9e46ad6af62e5
parent 400034 332f7a69835390b8918f2de7d0e2c5e799ad24fa
child 400036 f9ef5865484a02eb21e944f01e6370ecb3a37dd4
push id99079
push userrgurzau@mozilla.com
push dateSat, 20 Jan 2018 09:46:52 +0000
treeherdermozilla-inbound@85824602b479 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1416104
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1416104 - Part 0: Combine action files and reducer files into one. r=gl MozReview-Commit-ID: 7PTPdt7pT8o
devtools/client/inspector/animation/actions/animations.js
devtools/client/inspector/animation/actions/element-picker.js
devtools/client/inspector/animation/actions/moz.build
devtools/client/inspector/animation/actions/sidebar.js
devtools/client/inspector/animation/animation.js
devtools/client/inspector/animation/components/AnimationTimelineTickList.js
devtools/client/inspector/animation/components/App.js
devtools/client/inspector/animation/components/NoAnimationPanel.js
devtools/client/inspector/animation/reducers/animations.js
devtools/client/inspector/animation/reducers/element-picker.js
devtools/client/inspector/animation/reducers/moz.build
devtools/client/inspector/animation/reducers/sidebar.js
devtools/client/inspector/reducers.js
--- a/devtools/client/inspector/animation/actions/animations.js
+++ b/devtools/client/inspector/animation/actions/animations.js
@@ -1,19 +1,43 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const { UPDATE_ANIMATIONS } = require("./index");
+const {
+  UPDATE_ANIMATIONS,
+  UPDATE_ELEMENT_PICKER_ENABLED,
+  UPDATE_SIDEBAR_SIZE
+} = require("./index");
 
 module.exports = {
   /**
    * Update the list of animation in the animation inspector.
    */
   updateAnimations(animations) {
     return {
       type: UPDATE_ANIMATIONS,
       animations,
     };
+  },
+
+  /**
+   * Update the state of element picker in animation inspector.
+   */
+  updateElementPickerEnabled(elementPickerEnabled) {
+    return {
+      type: UPDATE_ELEMENT_PICKER_ENABLED,
+      elementPickerEnabled,
+    };
+  },
+
+  /**
+   * Update the sidebar size.
+   */
+  updateSidebarSize(sidebarSize) {
+    return {
+      type: UPDATE_SIDEBAR_SIZE,
+      sidebarSize,
+    };
   }
 };
deleted file mode 100644
--- a/devtools/client/inspector/animation/actions/element-picker.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { UPDATE_ELEMENT_PICKER_ENABLED } = require("./index");
-
-module.exports = {
-  /**
-   * Update the state of element picker in animation inspector.
-   */
-  updateElementPickerEnabled(isEnabled) {
-    return {
-      type: UPDATE_ELEMENT_PICKER_ENABLED,
-      isEnabled,
-    };
-  }
-};
--- a/devtools/client/inspector/animation/actions/moz.build
+++ b/devtools/client/inspector/animation/actions/moz.build
@@ -1,10 +1,8 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DevToolsModules(
     'animations.js',
-    'element-picker.js',
     'index.js',
-    'sidebar.js',
 )
deleted file mode 100644
--- a/devtools/client/inspector/animation/actions/sidebar.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { UPDATE_SIDEBAR_SIZE } = require("./index");
-
-module.exports = {
-  /**
-   * Update the sidebar size.
-   */
-  updateSidebarSize(size) {
-    return {
-      type: UPDATE_SIDEBAR_SIZE,
-      size,
-    };
-  }
-};
--- a/devtools/client/inspector/animation/animation.js
+++ b/devtools/client/inspector/animation/animation.js
@@ -7,19 +7,21 @@
 const { AnimationsFront } = require("devtools/shared/fronts/animation");
 const { createElement, createFactory } = require("devtools/client/shared/vendor/react");
 const { Provider } = require("devtools/client/shared/vendor/react-redux");
 
 const EventEmitter = require("devtools/shared/event-emitter");
 
 const App = createFactory(require("./components/App"));
 
-const { updateAnimations } = require("./actions/animations");
-const { updateElementPickerEnabled } = require("./actions/element-picker");
-const { updateSidebarSize } = require("./actions/sidebar");
+const {
+  updateAnimations,
+  updateElementPickerEnabled,
+  updateSidebarSize
+} = require("./actions/animations");
 const { isAllAnimationEqual } = require("./utils/utils");
 
 class AnimationInspector {
   constructor(inspector, win) {
     this.inspector = inspector;
     this.win = win;
 
     this.getAnimatedPropertyMap = this.getAnimatedPropertyMap.bind(this);
--- a/devtools/client/inspector/animation/components/AnimationTimelineTickList.js
+++ b/devtools/client/inspector/animation/components/AnimationTimelineTickList.js
@@ -90,13 +90,13 @@ class AnimationTimelineTickList extends 
       },
       tickList.map(tickItem => AnimationTimelineTickItem(tickItem))
     );
   }
 }
 
 const mapStateToProps = state => {
   return {
-    sidebarWidth: state.animationSidebar.width
+    sidebarWidth: state.animations.sidebarSize.width
   };
 };
 
 module.exports = connect(mapStateToProps)(AnimationTimelineTickList);
--- a/devtools/client/inspector/animation/components/App.js
+++ b/devtools/client/inspector/animation/components/App.js
@@ -66,9 +66,15 @@ class App extends PureComponent {
         {
           toggleElementPicker
         }
       )
     );
   }
 }
 
-module.exports = connect(state => state)(App);
+const mapStateToProps = state => {
+  return {
+    animations: state.animations.animations
+  };
+};
+
+module.exports = connect(mapStateToProps)(App);
--- a/devtools/client/inspector/animation/components/NoAnimationPanel.js
+++ b/devtools/client/inspector/animation/components/NoAnimationPanel.js
@@ -11,47 +11,47 @@ const { connect } = require("devtools/cl
 const { LocalizationHelper } = require("devtools/shared/l10n");
 
 const L10N =
   new LocalizationHelper("devtools/client/locales/animationinspector.properties");
 
 class NoAnimationPanel extends PureComponent {
   static get propTypes() {
     return {
-      elementPicker: PropTypes.object.isRequired,
+      elementPickerEnabled: PropTypes.bool.isRequired,
       toggleElementPicker: PropTypes.func.isRequired,
     };
   }
 
   shouldComponentUpdate(nextProps, nextState) {
-    return this.props.elementPicker.isEnabled != nextProps.elementPicker.isEnabled;
+    return this.props.elementPickerEnabled != nextProps.elementPickerEnabled;
   }
 
   render() {
-    const { elementPicker, toggleElementPicker } = this.props;
+    const { elementPickerEnabled, toggleElementPicker } = this.props;
 
     return dom.div(
       {
         className: "animation-error-message devtools-sidepanel-no-result"
       },
       dom.p(
         null,
         L10N.getStr("panel.noAnimation")
       ),
       dom.button(
         {
-          className: "animation-element-picker devtools-button"
-                     + (elementPicker.isEnabled ? " checked" : ""),
+          className: "animation-element-picker devtools-button" +
+                     (elementPickerEnabled ? " checked" : ""),
           "data-standalone": true,
           onClick: toggleElementPicker
         }
       )
     );
   }
 }
 
 const mapStateToProps = state => {
   return {
-    elementPicker: state.animationElementPicker
+    elementPickerEnabled: state.animations.elementPickerEnabled
   };
 };
 
 module.exports = connect(mapStateToProps)(NoAnimationPanel);
--- a/devtools/client/inspector/animation/reducers/animations.js
+++ b/devtools/client/inspector/animation/reducers/animations.js
@@ -1,20 +1,45 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const { UPDATE_ANIMATIONS } = require("../actions/index");
+const {
+  UPDATE_ANIMATIONS,
+  UPDATE_ELEMENT_PICKER_ENABLED,
+  UPDATE_SIDEBAR_SIZE,
+} = require("../actions/index");
 
-const INITIAL_ANIMATIONS = [];
+const INITIAL_STATE = {
+  animations: [],
+  elementPickerEnabled: false,
+  sidebarSize: {
+    height: 0,
+    width: 0,
+  },
+};
 
 const reducers = {
-  [UPDATE_ANIMATIONS](_, { animations }) {
-    return animations;
-  }
+  [UPDATE_ANIMATIONS](state, { animations }) {
+    return Object.assign({}, state, {
+      animations
+    });
+  },
+
+  [UPDATE_ELEMENT_PICKER_ENABLED](state, { elementPickerEnabled }) {
+    return Object.assign({}, state, {
+      elementPickerEnabled
+    });
+  },
+
+  [UPDATE_SIDEBAR_SIZE](state, { sidebarSize }) {
+    return Object.assign({}, state, {
+      sidebarSize
+    });
+  },
 };
 
-module.exports = function (animations = INITIAL_ANIMATIONS, action) {
+module.exports = function (state = INITIAL_STATE, action) {
   const reducer = reducers[action.type];
-  return reducer ? reducer(animations, action) : animations;
+  return reducer ? reducer(state, action) : state;
 };
deleted file mode 100644
--- a/devtools/client/inspector/animation/reducers/element-picker.js
+++ /dev/null
@@ -1,22 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { UPDATE_ELEMENT_PICKER_ENABLED } = require("../actions/index");
-
-const INITIAL_STATE = { isEnabled: false };
-
-const reducers = {
-  [UPDATE_ELEMENT_PICKER_ENABLED](state, { isEnabled }) {
-    return Object.assign({}, state, {
-      isEnabled
-    });
-  }
-};
-
-module.exports = function (state = INITIAL_STATE, action) {
-  const reducer = reducers[action.type];
-  return reducer ? reducer(state, action) : state;
-};
--- a/devtools/client/inspector/animation/reducers/moz.build
+++ b/devtools/client/inspector/animation/reducers/moz.build
@@ -1,9 +1,7 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 DevToolsModules(
     'animations.js',
-    'element-picker.js',
-    'sidebar.js',
 )
deleted file mode 100644
--- a/devtools/client/inspector/animation/reducers/sidebar.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-"use strict";
-
-const { UPDATE_SIDEBAR_SIZE } = require("../actions/index");
-
-const INITIAL_SIZE = {
-  width: 0,
-  height: 0
-};
-
-const reducers = {
-  [UPDATE_SIDEBAR_SIZE](_, { size }) {
-    return size;
-  }
-};
-
-module.exports = function (size = INITIAL_SIZE, action) {
-  const reducer = reducers[action.type];
-  return reducer ? reducer(size, action) : size;
-};
--- a/devtools/client/inspector/reducers.js
+++ b/devtools/client/inspector/reducers.js
@@ -3,20 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 // This file exposes the Redux reducers of the box model, grid and grid highlighter
 // settings.
 
 exports.animations = require("devtools/client/inspector/animation/reducers/animations");
-exports.animationElementPicker =
-  require("devtools/client/inspector/animation/reducers/element-picker");
-exports.animationSidebar =
-  require("devtools/client/inspector/animation/reducers/sidebar");
 exports.boxModel = require("devtools/client/inspector/boxmodel/reducers/box-model");
 exports.changes = require("devtools/client/inspector/changes/reducers/changes");
 exports.events = require("devtools/client/inspector/events/reducers/events");
 exports.extensionsSidebar = require("devtools/client/inspector/extensions/reducers/sidebar");
 exports.flexboxes = require("devtools/client/inspector/flexbox/reducers/flexboxes");
 exports.fontOptions = require("devtools/client/inspector/fonts/reducers/font-options");
 exports.fonts = require("devtools/client/inspector/fonts/reducers/fonts");
 exports.grids = require("devtools/client/inspector/grids/reducers/grids");