зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1497099: Use common runtime PropTypes. r=jdescottes
Differential Revision: https://phabricator.services.mozilla.com/D8795 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
4c897a56af
Коммит
4f3b0292c4
|
@ -13,6 +13,7 @@ const FluentReact = require("devtools/client/shared/vendor/fluent-react");
|
|||
const LocalizationProvider = createFactory(FluentReact.LocalizationProvider);
|
||||
|
||||
const { PAGES } = require("../constants");
|
||||
const Types = require("../types");
|
||||
|
||||
const ConnectPage = createFactory(require("./connect/ConnectPage"));
|
||||
const RuntimePage = createFactory(require("./RuntimePage"));
|
||||
|
@ -28,8 +29,9 @@ class App extends PureComponent {
|
|||
dispatch: PropTypes.func.isRequired,
|
||||
messageContexts: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
networkLocations: PropTypes.arrayOf(PropTypes.string).isRequired,
|
||||
runtimes: PropTypes.object.isRequired,
|
||||
networkRuntimes: PropTypes.arrayOf(Types.runtime).isRequired,
|
||||
selectedPage: PropTypes.string,
|
||||
usbRuntimes: PropTypes.arrayOf(Types.runtime).isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -55,8 +57,9 @@ class App extends PureComponent {
|
|||
adbAddonStatus,
|
||||
dispatch,
|
||||
messageContexts,
|
||||
runtimes,
|
||||
networkRuntimes,
|
||||
selectedPage,
|
||||
usbRuntimes,
|
||||
} = this.props;
|
||||
|
||||
return LocalizationProvider(
|
||||
|
@ -68,8 +71,9 @@ class App extends PureComponent {
|
|||
adbAddonStatus,
|
||||
className: "app__sidebar",
|
||||
dispatch,
|
||||
runtimes,
|
||||
selectedPage
|
||||
networkRuntimes,
|
||||
selectedPage,
|
||||
usbRuntimes,
|
||||
}
|
||||
),
|
||||
dom.main(
|
||||
|
@ -84,9 +88,10 @@ class App extends PureComponent {
|
|||
const mapStateToProps = state => {
|
||||
return {
|
||||
adbAddonStatus: state.ui.adbAddonStatus,
|
||||
runtimes: state.runtimes,
|
||||
networkLocations: state.ui.networkLocations,
|
||||
networkRuntimes: state.runtimes.networkRuntimes,
|
||||
selectedPage: state.ui.selectedPage,
|
||||
usbRuntimes: state.runtimes.usbRuntimes,
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ const FluentReact = require("devtools/client/shared/vendor/fluent-react");
|
|||
const Localized = createFactory(FluentReact.Localized);
|
||||
|
||||
const { PAGES, RUNTIMES } = require("../../constants");
|
||||
const Types = require("../../types");
|
||||
loader.lazyRequireGetter(this, "ADB_ADDON_STATES", "devtools/shared/adb/adb-addon", true);
|
||||
|
||||
const SidebarFixedItem = createFactory(require("./SidebarFixedItem"));
|
||||
|
@ -27,8 +28,9 @@ class Sidebar extends PureComponent {
|
|||
adbAddonStatus: PropTypes.string,
|
||||
className: PropTypes.string,
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
runtimes: PropTypes.object.isRequired,
|
||||
networkRuntimes: PropTypes.arrayOf(Types.runtime).isRequired,
|
||||
selectedPage: PropTypes.string,
|
||||
usbRuntimes: PropTypes.arrayOf(Types.runtime).isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -49,8 +51,8 @@ class Sidebar extends PureComponent {
|
|||
}
|
||||
|
||||
renderDevices() {
|
||||
const { runtimes } = this.props;
|
||||
if (!runtimes.networkRuntimes.length && !runtimes.usbRuntimes.length) {
|
||||
const { networkRuntimes, usbRuntimes } = this.props;
|
||||
if (!networkRuntimes.length && !usbRuntimes.length) {
|
||||
return Localized(
|
||||
{
|
||||
id: "about-debugging-sidebar-no-devices"
|
||||
|
@ -64,8 +66,8 @@ class Sidebar extends PureComponent {
|
|||
}
|
||||
|
||||
return [
|
||||
...this.renderSidebarItems(GLOBE_ICON, runtimes.networkRuntimes),
|
||||
...this.renderSidebarItems(USB_ICON, runtimes.usbRuntimes),
|
||||
...this.renderSidebarItems(GLOBE_ICON, networkRuntimes),
|
||||
...this.renderSidebarItems(USB_ICON, usbRuntimes),
|
||||
];
|
||||
}
|
||||
|
||||
|
|
|
@ -13,4 +13,5 @@ DIRS += [
|
|||
DevToolsModules(
|
||||
'constants.js',
|
||||
'create-store.js',
|
||||
'types.js',
|
||||
)
|
||||
|
|
|
@ -31,6 +31,7 @@ function RuntimesState() {
|
|||
selectedRuntimeId: null,
|
||||
thisFirefoxRuntimes: [{
|
||||
id: RUNTIMES.THIS_FIREFOX,
|
||||
name: "This Firefox",
|
||||
type: RUNTIMES.THIS_FIREFOX,
|
||||
}],
|
||||
usbRuntimes: [],
|
||||
|
@ -84,7 +85,7 @@ function runtimesReducer(state = RuntimesState(), action) {
|
|||
return {
|
||||
id: location,
|
||||
extra: {
|
||||
connectionParameters: { host, port },
|
||||
connectionParameters: { host, port: parseInt(port, 10) },
|
||||
},
|
||||
name: location,
|
||||
type: RUNTIMES.NETWORK,
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/* 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 PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
||||
|
||||
const runtimeInfo = {
|
||||
// device name which is running the runtime,
|
||||
// unavailable on this-firefox runtime
|
||||
deviceName: PropTypes.string,
|
||||
|
||||
// icon which represents the kind of runtime
|
||||
icon: PropTypes.string.isRequired,
|
||||
|
||||
// name of runtime such as "Firefox Nightly"
|
||||
name: PropTypes.string.isRequired,
|
||||
|
||||
// version of runtime
|
||||
version: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
const runtimeTransportDetails = {
|
||||
// host name of tcp connection to debugger server
|
||||
host: PropTypes.string.isRequired,
|
||||
|
||||
// port number of tcp connection to debugger server
|
||||
port: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const runtimeConnection = {
|
||||
// debugger client instance
|
||||
client: PropTypes.object.isRequired,
|
||||
|
||||
// runtime information
|
||||
info: PropTypes.shape(runtimeInfo).isRequired,
|
||||
|
||||
// tcp connection information,
|
||||
// unavailable on this-firefox runtime
|
||||
transportDetails: PropTypes.shape(runtimeTransportDetails),
|
||||
};
|
||||
|
||||
const networkRuntimeConnectionParameter = {
|
||||
// host name of debugger server to connect
|
||||
host: PropTypes.string.isRequired,
|
||||
|
||||
// port number of debugger server to connect
|
||||
port: PropTypes.number.isRequired,
|
||||
};
|
||||
|
||||
const usbRuntimeConnectionParameter = {
|
||||
// socket path to connect debugger server
|
||||
socketPath: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
const runtimeExtra = {
|
||||
// parameter to connect to debugger server
|
||||
connectionParameters: PropTypes.oneOfType([
|
||||
PropTypes.shape(networkRuntimeConnectionParameter),
|
||||
PropTypes.shape(usbRuntimeConnectionParameter)
|
||||
]).isRequired,
|
||||
|
||||
// device name, only available on USB devices
|
||||
deviceName: PropTypes.string,
|
||||
};
|
||||
|
||||
const runtime = {
|
||||
// unique id for the runtime
|
||||
id: PropTypes.string.isRequired,
|
||||
|
||||
// available after the connection to the runtime is established
|
||||
connection: PropTypes.shape(runtimeConnection),
|
||||
|
||||
// object containing non standard properties that depend on the runtime type,
|
||||
// unavailable on this-firefox runtime
|
||||
extra: PropTypes.shape(runtimeExtra),
|
||||
|
||||
// display name of the runtime
|
||||
name: PropTypes.string.isRequired,
|
||||
|
||||
// runtime type, for instance "network", "usb" ...
|
||||
type: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
/**
|
||||
* Export type of runtime
|
||||
*/
|
||||
exports.runtime = PropTypes.shape(runtime);
|
Загрузка…
Ссылка в новой задаче