Bug 1479411 - Remove all actions and reducers from new about:debugging UI;r=daisuke draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 30 Jul 2018 14:19:59 +0200
changeset 824278 8a67fdaadef21914e101ca4817d1ad75c40eddb4
parent 824277 281d78354ecc39031e772da6095b3820d72e32ad
push id117857
push userjdescottes@mozilla.com
push dateMon, 30 Jul 2018 14:53:30 +0000
reviewersdaisuke
bugs1479411
milestone63.0a1
Bug 1479411 - Remove all actions and reducers from new about:debugging UI;r=daisuke MozReview-Commit-ID: 6OjfdnfvlC5
devtools/client/aboutdebugging-new/aboutdebugging.js
devtools/client/aboutdebugging-new/src/actions/index.js
devtools/client/aboutdebugging-new/src/actions/moz.build
devtools/client/aboutdebugging-new/src/actions/runtimes.js
devtools/client/aboutdebugging-new/src/components/App.js
devtools/client/aboutdebugging-new/src/components/Sidebar.js
devtools/client/aboutdebugging-new/src/constants.js
devtools/client/aboutdebugging-new/src/create-store.js
devtools/client/aboutdebugging-new/src/moz.build
devtools/client/aboutdebugging-new/src/reducers/index.js
devtools/client/aboutdebugging-new/src/reducers/moz.build
devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
devtools/client/aboutdebugging-new/src/runtimes/moz.build
devtools/client/aboutdebugging-new/src/runtimes/runtime.js
devtools/client/aboutdebugging-new/src/runtimes/this-firefox.js
--- a/devtools/client/aboutdebugging-new/aboutdebugging.js
+++ b/devtools/client/aboutdebugging-new/aboutdebugging.js
@@ -7,58 +7,41 @@
 const { BrowserLoader } =
   ChromeUtils.import("resource://devtools/client/shared/browser-loader.js", {});
 const { require } = BrowserLoader({
   baseURI: "resource://devtools/client/aboutdebugging-new/",
   window,
 });
 const Services = require("Services");
 
-const { bindActionCreators } = require("devtools/client/shared/vendor/redux");
 const { createFactory } =
   require("devtools/client/shared/vendor/react");
 const { render, unmountComponentAtNode } =
   require("devtools/client/shared/vendor/react-dom");
-const Provider =
-  createFactory(require("devtools/client/shared/vendor/react-redux").Provider);
-
-const actions = require("./src/actions/index");
-const { configureStore } = require("./src/create-store");
-const ThisFirefox = require("./src/runtimes/this-firefox");
 
 const App = createFactory(require("./src/components/App"));
 
 const AboutDebugging = {
   init() {
     if (!Services.prefs.getBoolPref("devtools.enabled", true)) {
       // If DevTools are disabled, navigate to about:devtools.
       window.location = "about:devtools?reason=AboutDebugging";
       return;
     }
 
-    this.store = configureStore();
-    this.actions = bindActionCreators(actions, this.store.dispatch);
-
-    const thisFirefox = new ThisFirefox();
-    this.updateSelectedRuntime(thisFirefox);
-
-    render(Provider({ store: this.store }, App({ thisFirefox })), this.mount);
+    render(App(), this.mount);
   },
 
   destroy() {
     unmountComponentAtNode(this.mount);
   },
 
   get mount() {
     return document.getElementById("mount");
   },
-
-  updateSelectedRuntime(runtime) {
-    this.actions.updateSelectedRuntime(runtime);
-  },
 };
 
 window.addEventListener("DOMContentLoaded", () => {
   AboutDebugging.init();
 }, { once: true });
 
 window.addEventListener("unload", () => {
   AboutDebugging.destroy();
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/actions/index.js
+++ /dev/null
@@ -1,9 +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 runtimes = require("./runtimes");
-
-Object.assign(exports, runtimes);
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/actions/moz.build
+++ /dev/null
@@ -1,8 +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/.
-
-DevToolsModules(
-    'index.js',
-    'runtimes.js',
-)
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/actions/runtimes.js
+++ /dev/null
@@ -1,20 +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_SELECTED_RUNTIME,
-} = require("../constants");
-
-function updateSelectedRuntime(runtime) {
-  return {
-    type: UPDATE_SELECTED_RUNTIME,
-    runtime,
-  };
-}
-
-module.exports = {
-  updateSelectedRuntime,
-};
--- a/devtools/client/aboutdebugging-new/src/components/App.js
+++ b/devtools/client/aboutdebugging-new/src/components/App.js
@@ -1,43 +1,23 @@
 /* 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 { connect } = require("devtools/client/shared/vendor/react-redux");
 const { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
-
-const Runtime = require("../runtimes/runtime");
-const ThisFirefox = require("../runtimes/this-firefox");
 
 const Sidebar = createFactory(require("./Sidebar"));
 
 class App extends PureComponent {
-  static get propTypes() {
-    return {
-      selectedRuntime: PropTypes.instanceOf(Runtime),
-      thisFirefox: PropTypes.instanceOf(ThisFirefox).isRequired,
-    };
-  }
-
   render() {
-    const { selectedRuntime, thisFirefox } = this.props;
-
     return dom.div(
       {
         className: "app",
       },
-      Sidebar({ selectedRuntime, thisFirefox })
+      Sidebar()
     );
   }
 }
 
-const mapStateToProps = state => {
-  return {
-    selectedRuntime: state.runtimes.selectedRuntime,
-  };
-};
-
-module.exports = connect(mapStateToProps)(App);
+module.exports = App;
--- a/devtools/client/aboutdebugging-new/src/components/Sidebar.js
+++ b/devtools/client/aboutdebugging-new/src/components/Sidebar.js
@@ -1,43 +1,32 @@
 /* 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 { createFactory, PureComponent } = require("devtools/client/shared/vendor/react");
 const dom = require("devtools/client/shared/vendor/react-dom-factories");
-const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
 
-const ThisFirefox = require("../runtimes/this-firefox");
+const SidebarItem = createFactory(require("./SidebarItem"));
 
-const Runtime = require("../runtimes/runtime");
-const SidebarItem = createFactory(require("./SidebarItem"));
+const FIREFOX_ICON = "chrome://devtools/skin/images/firefox-logo-glyph.svg";
 
 class Sidebar extends PureComponent {
-  static get propTypes() {
-    return {
-      selectedRuntime: PropTypes.instanceOf(Runtime),
-      thisFirefox: PropTypes.instanceOf(ThisFirefox).isRequired,
-    };
-  }
-
   render() {
-    const { selectedRuntime, thisFirefox } = this.props;
-
     return dom.section(
       {
         className: "sidebar",
       },
       dom.ul(
         {},
         SidebarItem({
-          icon: thisFirefox.getIcon(),
-          isSelected: thisFirefox === selectedRuntime,
-          name: thisFirefox.getName(),
+          icon: FIREFOX_ICON,
+          isSelected: true,
+          name: "This Firefox",
         })
       )
     );
   }
 }
 
 module.exports = Sidebar;
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/constants.js
+++ /dev/null
@@ -1,11 +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 actionTypes = {
-  UPDATE_SELECTED_RUNTIME: "UPDATE_SELECTED_RUNTIME",
-};
-
-module.exports = Object.assign({}, actionTypes);
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/create-store.js
+++ /dev/null
@@ -1,18 +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 { createStore } = require("devtools/client/shared/vendor/redux");
-
-const rootReducer = require("./reducers/index");
-const { RuntimesState } = require("./reducers/runtimes-state");
-
-exports.configureStore = function() {
-  const initialState = {
-    runtimes: new RuntimesState(),
-  };
-
-  return createStore(rootReducer, initialState);
-};
--- a/devtools/client/aboutdebugging-new/src/moz.build
+++ b/devtools/client/aboutdebugging-new/src/moz.build
@@ -1,15 +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/.
 
 DIRS += [
-    'actions',
     'components',
-    'runtimes',
-    'reducers',
 ]
-
-DevToolsModules(
-    'constants.js',
-    'create-store.js'
-)
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/reducers/index.js
+++ /dev/null
@@ -1,12 +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 { combineReducers } = require("devtools/client/shared/vendor/redux");
-const { runtimesReducer } = require("./runtimes-state");
-
-module.exports = combineReducers({
-  runtimes: runtimesReducer,
-});
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/reducers/moz.build
+++ /dev/null
@@ -1,8 +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/.
-
-DevToolsModules(
-    'index.js',
-    'runtimes-state.js',
-)
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/reducers/runtimes-state.js
+++ /dev/null
@@ -1,33 +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_SELECTED_RUNTIME,
-} = require("../constants");
-
-function RuntimesState() {
-  return {
-    selectedRuntime: null,
-  };
-}
-
-function runtimesReducer(state = RuntimesState(), action) {
-  switch (action.type) {
-    case UPDATE_SELECTED_RUNTIME: {
-      return Object.assign({}, state, {
-        selectedRuntime: action.runtime,
-      });
-    }
-
-    default:
-      return state;
-  }
-}
-
-module.exports = {
-  RuntimesState,
-  runtimesReducer,
-};
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/runtimes/moz.build
+++ /dev/null
@@ -1,8 +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/.
-
-DevToolsModules(
-    'runtime.js',
-    'this-firefox.js',
-)
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/runtimes/runtime.js
+++ /dev/null
@@ -1,30 +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";
-
-/**
- * This class represents a runtime, such as a remote Firefox.
- */
-class Runtime {
-  /**
-   * Return icon of this runtime on sidebar.
-   * Subclass should override this method.
-   * @return {String}
-   */
-  getIcon() {
-    throw new Error("Subclass of Runtime should override getIcon()");
-  }
-
-  /**
-   * Return name of this runtime on sidebar.
-   * Subclass should override this method.
-   * @return {String}
-   */
-  getName() {
-    throw new Error("Subclass of Runtime should override getName()");
-  }
-}
-
-module.exports = Runtime;
deleted file mode 100644
--- a/devtools/client/aboutdebugging-new/src/runtimes/this-firefox.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 Runtime = require("./runtime");
-
-/**
- * This class represents the Firefox instance which runs in the same environment that
- * opened about:debugging.
- */
-class ThisFirefox extends Runtime {
-  getIcon() {
-    return "chrome://devtools/skin/images/firefox-logo-glyph.svg";
-  }
-
-  getName() {
-    return "This Firefox";
-  }
-}
-
-module.exports = ThisFirefox;