зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1497447: Add toggle feature which enables/disables connection prompt. r=jdescottes
Depends on D9066 Differential Revision: https://phabricator.services.mozilla.com/D9067 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
49630e594a
Коммит
b124f68dec
|
@ -11,6 +11,7 @@ const { DebuggerServer } = require("devtools/server/main");
|
|||
const Actions = require("./index");
|
||||
|
||||
const {
|
||||
getCurrentRuntime,
|
||||
findRuntimeById,
|
||||
} = require("../modules/runtimes-state-helper");
|
||||
const { isSupportedDebugTarget } = require("../modules/debug-target-support");
|
||||
|
@ -28,6 +29,9 @@ const {
|
|||
UNWATCH_RUNTIME_FAILURE,
|
||||
UNWATCH_RUNTIME_START,
|
||||
UNWATCH_RUNTIME_SUCCESS,
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_FAILURE,
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_START,
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS,
|
||||
USB_RUNTIMES_UPDATED,
|
||||
WATCH_RUNTIME_FAILURE,
|
||||
WATCH_RUNTIME_START,
|
||||
|
@ -138,6 +142,28 @@ function disconnectRuntime(id) {
|
|||
};
|
||||
}
|
||||
|
||||
function updateConnectionPromptSetting(connectionPromptEnabled) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({ type: UPDATE_CONNECTION_PROMPT_SETTING_START });
|
||||
try {
|
||||
const runtime = getCurrentRuntime(getState().runtimes);
|
||||
const client = runtime.connection.client;
|
||||
const preferenceFront = await client.mainRoot.getFront("preference");
|
||||
await preferenceFront.setBoolPref(RUNTIME_PREFERENCE.CONNECTION_PROMPT,
|
||||
connectionPromptEnabled);
|
||||
// Re-get actual value from the runtime.
|
||||
connectionPromptEnabled =
|
||||
await preferenceFront.getBoolPref(RUNTIME_PREFERENCE.CONNECTION_PROMPT);
|
||||
|
||||
dispatch({ type: UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS,
|
||||
runtime, connectionPromptEnabled });
|
||||
} catch (e) {
|
||||
dispatch({ type: UPDATE_CONNECTION_PROMPT_SETTING_FAILURE,
|
||||
error: e.message });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function watchRuntime(id) {
|
||||
return async (dispatch, getState) => {
|
||||
dispatch({ type: WATCH_RUNTIME_START });
|
||||
|
@ -196,6 +222,7 @@ module.exports = {
|
|||
connectRuntime,
|
||||
disconnectRuntime,
|
||||
unwatchRuntime,
|
||||
updateConnectionPromptSetting,
|
||||
updateUSBRuntimes,
|
||||
watchRuntime,
|
||||
};
|
||||
|
|
|
@ -11,13 +11,21 @@ const PropTypes = require("devtools/client/shared/vendor/react-prop-types");
|
|||
const FluentReact = require("devtools/client/shared/vendor/fluent-react");
|
||||
const Localized = createFactory(FluentReact.Localized);
|
||||
|
||||
const Actions = require("../actions/index");
|
||||
|
||||
class ConnectionPromptSetting extends PureComponent {
|
||||
static get propTypes() {
|
||||
return {
|
||||
dispatch: PropTypes.func.isRequired,
|
||||
connectionPromptEnabled: PropTypes.bool.isRequired,
|
||||
};
|
||||
}
|
||||
|
||||
onToggleClick() {
|
||||
const { connectionPromptEnabled, dispatch } = this.props;
|
||||
dispatch(Actions.updateConnectionPromptSetting(!connectionPromptEnabled));
|
||||
}
|
||||
|
||||
render() {
|
||||
const { connectionPromptEnabled } = this.props;
|
||||
|
||||
|
@ -32,6 +40,7 @@ class ConnectionPromptSetting extends PureComponent {
|
|||
dom.button(
|
||||
{
|
||||
className: "default-button",
|
||||
onClick: () => this.onToggleClick(),
|
||||
},
|
||||
localizedState
|
||||
)
|
||||
|
|
|
@ -48,13 +48,13 @@ class RuntimePage extends PureComponent {
|
|||
}
|
||||
|
||||
renderConnectionPromptSetting() {
|
||||
const { connectionPromptEnabled } = this.props;
|
||||
const { connectionPromptEnabled, dispatch } = this.props;
|
||||
|
||||
return dom.div(
|
||||
{
|
||||
className: "connection-prompt-setting",
|
||||
},
|
||||
ConnectionPromptSetting({ connectionPromptEnabled }),
|
||||
ConnectionPromptSetting({ connectionPromptEnabled, dispatch }),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,9 @@ const actionTypes = {
|
|||
UNWATCH_RUNTIME_FAILURE: "UNWATCH_RUNTIME_FAILURE",
|
||||
UNWATCH_RUNTIME_START: "UNWATCH_RUNTIME_START",
|
||||
UNWATCH_RUNTIME_SUCCESS: "UNWATCH_RUNTIME_SUCCESS",
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_FAILURE: "UPDATE_CONNECTION_PROMPT_SETTING_FAILURE",
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_START: "UPDATE_CONNECTION_PROMPT_SETTING_START",
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS: "UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS",
|
||||
USB_RUNTIMES_UPDATED: "USB_RUNTIMES_UPDATED",
|
||||
WATCH_RUNTIME_FAILURE: "WATCH_RUNTIME_FAILURE",
|
||||
WATCH_RUNTIME_START: "WATCH_RUNTIME_START",
|
||||
|
|
|
@ -10,6 +10,7 @@ const {
|
|||
NETWORK_LOCATIONS_UPDATED,
|
||||
RUNTIMES,
|
||||
UNWATCH_RUNTIME_SUCCESS,
|
||||
UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS,
|
||||
USB_RUNTIMES_UPDATED,
|
||||
WATCH_RUNTIME_SUCCESS,
|
||||
} = require("../constants");
|
||||
|
@ -98,6 +99,15 @@ function runtimesReducer(state = RuntimesState(), action) {
|
|||
return Object.assign({}, state, { selectedRuntimeId: null });
|
||||
}
|
||||
|
||||
case UPDATE_CONNECTION_PROMPT_SETTING_SUCCESS: {
|
||||
const { connectionPromptEnabled } = action;
|
||||
const { id: runtimeId } = action.runtime;
|
||||
const runtime = findRuntimeById(runtimeId, state);
|
||||
const connection =
|
||||
Object.assign({}, runtime.connection, { connectionPromptEnabled });
|
||||
return _updateRuntimeById(runtimeId, { connection }, state);
|
||||
}
|
||||
|
||||
case USB_RUNTIMES_UPDATED: {
|
||||
const { runtimes } = action;
|
||||
const usbRuntimes = runtimes.map(runtime => {
|
||||
|
|
Загрузка…
Ссылка в новой задаче