mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-19 08:15:31 +00:00
Bug 1494170: Show proper runtime's name and version. r=jdescottes
Depends on D6881 Differential Revision: https://phabricator.services.mozilla.com/D7036 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
a6f095ce5b
commit
f83a54699b
@ -66,18 +66,31 @@ async function createClientForRuntime(runtime) {
|
||||
return null;
|
||||
}
|
||||
|
||||
async function getRuntimeInfo(client) {
|
||||
const deviceFront = await client.mainRoot.getFront("device");
|
||||
const { brandName: name, version } = await deviceFront.getDescription();
|
||||
|
||||
return {
|
||||
icon: "chrome://branding/content/icon64.png",
|
||||
name,
|
||||
version,
|
||||
};
|
||||
}
|
||||
|
||||
function connectRuntime(id) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({ type: CONNECT_RUNTIME_START });
|
||||
try {
|
||||
const runtime = findRuntimeById(id, getState().runtimes);
|
||||
const client = await createClientForRuntime(runtime);
|
||||
const info = await getRuntimeInfo(client);
|
||||
|
||||
dispatch({
|
||||
type: CONNECT_RUNTIME_SUCCESS,
|
||||
runtime: {
|
||||
id,
|
||||
client,
|
||||
info,
|
||||
type: runtime.type,
|
||||
}
|
||||
});
|
||||
|
@ -23,8 +23,8 @@ const TemporaryExtensionInstaller =
|
||||
createFactory(require("./debugtarget/TemporaryExtensionInstaller"));
|
||||
const WorkerDetail = createFactory(require("./debugtarget/WorkerDetail"));
|
||||
|
||||
const Services = require("Services");
|
||||
const { DEBUG_TARGET_PANE } = require("../constants");
|
||||
const { getCurrentRuntimeInfo } = require("../modules/runtimes-state-helper");
|
||||
|
||||
class RuntimePage extends PureComponent {
|
||||
static get propTypes() {
|
||||
@ -33,6 +33,7 @@ class RuntimePage extends PureComponent {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
installedExtensions: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
otherWorkers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
runtimeInfo: PropTypes.object,
|
||||
serviceWorkers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
sharedWorkers: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
tabs: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||
@ -46,21 +47,24 @@ class RuntimePage extends PureComponent {
|
||||
dispatch,
|
||||
installedExtensions,
|
||||
otherWorkers,
|
||||
runtimeInfo,
|
||||
serviceWorkers,
|
||||
sharedWorkers,
|
||||
tabs,
|
||||
temporaryExtensions,
|
||||
} = this.props;
|
||||
|
||||
if (!runtimeInfo) {
|
||||
// runtimeInfo can be null when the selectPage action navigates from a runtime A
|
||||
// to a runtime B (between unwatchRuntime and watchRuntime).
|
||||
return null;
|
||||
}
|
||||
|
||||
return dom.article(
|
||||
{
|
||||
className: "page js-runtime-page",
|
||||
},
|
||||
RuntimeInfo({
|
||||
icon: "chrome://branding/content/icon64.png",
|
||||
name: Services.appinfo.name,
|
||||
version: Services.appinfo.version,
|
||||
}),
|
||||
RuntimeInfo(runtimeInfo),
|
||||
TemporaryExtensionInstaller({ dispatch }),
|
||||
Localized(
|
||||
{
|
||||
@ -161,6 +165,7 @@ const mapStateToProps = state => {
|
||||
collapsibilities: state.ui.debugTargetCollapsibilities,
|
||||
installedExtensions: state.debugTargets.installedExtensions,
|
||||
otherWorkers: state.debugTargets.otherWorkers,
|
||||
runtimeInfo: getCurrentRuntimeInfo(state.runtimes),
|
||||
serviceWorkers: state.debugTargets.serviceWorkers,
|
||||
sharedWorkers: state.debugTargets.sharedWorkers,
|
||||
tabs: state.debugTargets.tabs,
|
||||
|
@ -15,6 +15,12 @@ function getCurrentClient(runtimesState) {
|
||||
}
|
||||
exports.getCurrentClient = getCurrentClient;
|
||||
|
||||
function getCurrentRuntimeInfo(runtimesState) {
|
||||
const runtime = getCurrentRuntime(runtimesState);
|
||||
return runtime ? runtime.info : null;
|
||||
}
|
||||
exports.getCurrentRuntimeInfo = getCurrentRuntimeInfo;
|
||||
|
||||
function findRuntimeById(id, runtimesState) {
|
||||
const allRuntimes = [
|
||||
...runtimesState.networkRuntimes,
|
||||
|
@ -40,7 +40,7 @@ function RuntimesState(networkRuntimes = []) {
|
||||
function runtimesReducer(state = RuntimesState(), action) {
|
||||
switch (action.type) {
|
||||
case CONNECT_RUNTIME_SUCCESS: {
|
||||
const { id, client } = action.runtime;
|
||||
const { id, client, info } = action.runtime;
|
||||
|
||||
// Find the array of runtimes that contains the updated runtime.
|
||||
const runtime = findRuntimeById(id, state);
|
||||
@ -50,7 +50,7 @@ function runtimesReducer(state = RuntimesState(), action) {
|
||||
// Add the new client to the runtime.
|
||||
const updatedRuntimes = runtimesToUpdate.map(r => {
|
||||
if (r.id === id) {
|
||||
return Object.assign({}, r, { client });
|
||||
return Object.assign({}, r, { client, info });
|
||||
}
|
||||
return r;
|
||||
});
|
||||
@ -68,7 +68,7 @@ function runtimesReducer(state = RuntimesState(), action) {
|
||||
// Remove the client from the updated runtime.
|
||||
const updatedRuntimes = runtimesToUpdate.map(r => {
|
||||
if (r.id === id) {
|
||||
return Object.assign({}, r, { client: null });
|
||||
return Object.assign({}, r, { client: null, info: null });
|
||||
}
|
||||
return r;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user