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:
Daisuke Akatsuka 2018-10-05 04:03:04 +00:00
Родитель 077db0ce90
Коммит bbc1c0f059
4 изменённых файлов: 33 добавлений и 9 удалений

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

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

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

@ -68,13 +68,13 @@ function _updateRuntimeById(runtimeId, updatedRuntime, state) {
function runtimesReducer(state = RuntimesState(), action) {
switch (action.type) {
case CONNECT_RUNTIME_SUCCESS: {
const { id, client } = action.runtime;
return _updateRuntimeById(id, { client }, state);
const { id, client, info } = action.runtime;
return _updateRuntimeById(id, { client, info }, state);
}
case DISCONNECT_RUNTIME_SUCCESS: {
const { id } = action.runtime;
return _updateRuntimeById(id, { client: null }, state);
return _updateRuntimeById(id, { client: null, info: null }, state);
}
case NETWORK_LOCATIONS_UPDATED: {