Bug 1479411 - Remove all actions and reducers from new about:debugging UI;r=daisuke

MozReview-Commit-ID: 6OjfdnfvlC5

--HG--
extra : rebase_source : 8a67fdaadef21914e101ca4817d1ad75c40eddb4
This commit is contained in:
Julian Descottes 2018-07-30 14:19:59 +02:00
Родитель 146074f20a
Коммит 4677258505
15 изменённых файлов: 8 добавлений и 244 удалений

Просмотреть файл

@ -12,17 +12,10 @@ const { require } = BrowserLoader({
});
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"));
@ -34,13 +27,7 @@ const 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() {
@ -50,10 +37,6 @@ const AboutDebugging = {
get mount() {
return document.getElementById("mount");
},
updateSelectedRuntime(runtime) {
this.actions.updateSelectedRuntime(runtime);
},
};
window.addEventListener("DOMContentLoaded", () => {

Просмотреть файл

@ -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);

Просмотреть файл

@ -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',
)

Просмотреть файл

@ -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,
};

Просмотреть файл

@ -4,40 +4,20 @@
"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;

Просмотреть файл

@ -6,24 +6,13 @@
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 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",
@ -31,9 +20,9 @@ class Sidebar extends PureComponent {
dom.ul(
{},
SidebarItem({
icon: thisFirefox.getIcon(),
isSelected: thisFirefox === selectedRuntime,
name: thisFirefox.getName(),
icon: FIREFOX_ICON,
isSelected: true,
name: "This Firefox",
})
)
);

Просмотреть файл

@ -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);

Просмотреть файл

@ -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);
};

Просмотреть файл

@ -3,13 +3,5 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += [
'actions',
'components',
'runtimes',
'reducers',
]
DevToolsModules(
'constants.js',
'create-store.js'
)

Просмотреть файл

@ -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,
});

Просмотреть файл

@ -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',
)

Просмотреть файл

@ -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,
};

Просмотреть файл

@ -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',
)

Просмотреть файл

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

Просмотреть файл

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