Bug 1527122 - [release 125] Add context menus for handling breakpoints on a line (#7837). r=dwalsh
authorDavid Walsh <davidwalsh83@gmail.com>
Mon, 11 Feb 2019 16:59:51 -0800
changeset 458680 3bcdb1bf19fc
parent 458679 b953067ffeaf
child 458681 14277097be36
push id35544
push userccoroiu@mozilla.com
push dateTue, 12 Feb 2019 16:29:08 +0000
treeherdermozilla-central@c849fb69e2e7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdwalsh
bugs1527122
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1527122 - [release 125] Add context menus for handling breakpoints on a line (#7837). r=dwalsh
devtools/client/debugger/new/src/actions/breakpoints/index.js
devtools/client/debugger/new/src/components/Editor/menus/breakpoints.js
devtools/client/locales/en-US/debugger.properties
--- a/devtools/client/debugger/new/src/actions/breakpoints/index.js
+++ b/devtools/client/debugger/new/src/actions/breakpoints/index.js
@@ -365,18 +365,44 @@ export function addBreakpointAtLine(line
         line
       })
     );
   };
 }
 
 export function removeBreakpointsAtLine(sourceId: string, line: number) {
   return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
-    const breakpoints = getBreakpointsForSource(getState(), sourceId, line);
-    return dispatch(removeBreakpoints(breakpoints));
+    const breakpointsAtLine = getBreakpointsForSource(
+      getState(),
+      sourceId,
+      line
+    );
+    return dispatch(removeBreakpoints(breakpointsAtLine));
+  };
+}
+
+export function disableBreakpointsAtLine(sourceId: string, line: number) {
+  return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
+    const breakpointsAtLine = getBreakpointsForSource(
+      getState(),
+      sourceId,
+      line
+    );
+    return dispatch(toggleBreakpoints(true, breakpointsAtLine));
+  };
+}
+
+export function enableBreakpointsAtLine(sourceId: string, line: number) {
+  return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
+    const breakpointsAtLine = getBreakpointsForSource(
+      getState(),
+      sourceId,
+      line
+    );
+    return dispatch(toggleBreakpoints(false, breakpointsAtLine));
   };
 }
 
 export function toggleDisabledBreakpoint(breakpoint: Breakpoint) {
   return ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
     if (breakpoint.loading) {
       return;
     }
--- a/devtools/client/debugger/new/src/components/Editor/menus/breakpoints.js
+++ b/devtools/client/debugger/new/src/components/Editor/menus/breakpoints.js
@@ -152,20 +152,32 @@ export const toggleDisabledBreakpointIte
 };
 
 export function breakpointItems(
   breakpoint: Breakpoint,
   breakpointActions: BreakpointItemActions
 ) {
   const items = [
     removeBreakpointItem(breakpoint, breakpointActions),
-    toggleDisabledBreakpointItem(breakpoint, breakpointActions),
-    conditionalBreakpointItem(breakpoint, breakpointActions)
+    toggleDisabledBreakpointItem(breakpoint, breakpointActions)
   ];
 
+  if (features.columnBreakpoints) {
+    items.push(
+      { type: "separator" },
+      removeBreakpointsOnLineItem(breakpoint.location, breakpointActions),
+      breakpoint.disabled
+        ? enableBreakpointsOnLineItem(breakpoint.location, breakpointActions)
+        : disableBreakpointsOnLineItem(breakpoint.location, breakpointActions),
+      { type: "separator" }
+    );
+  }
+
+  items.push(conditionalBreakpointItem(breakpoint, breakpointActions));
+
   if (features.logPoints) {
     items.push(logPointItem(breakpoint, breakpointActions));
   }
   return items;
 }
 
 export function createBreakpointItems(
   location: SourceLocation,
@@ -177,29 +189,70 @@ export function createBreakpointItems(
   ];
 
   if (features.logPoints) {
     items.push(createLogBreakpointItem(location, breakpointActions));
   }
   return items;
 }
 
+// ToDo: Only enable if there are more than one breakpoints on a line?
+export const removeBreakpointsOnLineItem = (
+  location: SourceLocation,
+  breakpointActions: BreakpointItemActions
+) => ({
+  id: "node-menu-remove-breakpoints-on-line",
+  label: L10N.getStr("breakpointMenuItem.removeAllAtLine.label"),
+  accesskey: L10N.getStr("breakpointMenuItem.removeAllAtLine.accesskey"),
+  disabled: false,
+  click: () =>
+    breakpointActions.removeBreakpointsAtLine(location.sourceId, location.line)
+});
+
+export const enableBreakpointsOnLineItem = (
+  location: SourceLocation,
+  breakpointActions: BreakpointItemActions
+) => ({
+  id: "node-menu-remove-breakpoints-on-line",
+  label: L10N.getStr("breakpointMenuItem.enableAllAtLine.label"),
+  accesskey: L10N.getStr("breakpointMenuItem.enableAllAtLine.accesskey"),
+  disabled: false,
+  click: () =>
+    breakpointActions.enableBreakpointsAtLine(location.sourceId, location.line)
+});
+
+export const disableBreakpointsOnLineItem = (
+  location: SourceLocation,
+  breakpointActions: BreakpointItemActions
+) => ({
+  id: "node-menu-remove-breakpoints-on-line",
+  label: L10N.getStr("breakpointMenuItem.disableAllAtLine.label"),
+  accesskey: L10N.getStr("breakpointMenuItem.disableAllAtLine.accesskey"),
+  disabled: false,
+  click: () =>
+    breakpointActions.disableBreakpointsAtLine(location.sourceId, location.line)
+});
+
 export type BreakpointItemActions = {
   addBreakpoint: typeof actions.addBreakpoint,
   removeBreakpoint: typeof actions.removeBreakpoint,
   removeBreakpointsAtLine: typeof actions.removeBreakpointsAtLine,
+  enableBreakpointsAtLine: typeof actions.enableBreakpointsAtLine,
+  disableBreakpointsAtLine: typeof actions.disableBreakpointsAtLine,
   toggleDisabledBreakpoint: typeof actions.toggleDisabledBreakpoint,
   openConditionalPanel: typeof actions.openConditionalPanel
 };
 
 export function breakpointItemActions(dispatch: Function) {
   return bindActionCreators(
     {
       addBreakpoint: actions.addBreakpoint,
       removeBreakpoint: actions.removeBreakpoint,
       removeBreakpointsAtLine: actions.removeBreakpointsAtLine,
+      enableBreakpointsAtLine: actions.enableBreakpointsAtLine,
+      disableBreakpointsAtLine: actions.disableBreakpointsAtLine,
       disableBreakpoint: actions.disableBreakpoint,
       toggleDisabledBreakpoint: actions.toggleDisabledBreakpoint,
       openConditionalPanel: actions.openConditionalPanel
     },
     dispatch
   );
 }
--- a/devtools/client/locales/en-US/debugger.properties
+++ b/devtools/client/locales/en-US/debugger.properties
@@ -400,16 +400,22 @@ breakpointMenuItem.enableAll.accesskey=b
 breakpointMenuItem.disableAll=Disable all breakpoints
 breakpointMenuItem.disableAll.accesskey=k
 breakpointMenuItem.deleteAll=Remove all breakpoints
 breakpointMenuItem.deleteAll.accesskey=a
 breakpointMenuItem.removeCondition.label=Remove breakpoint condition
 breakpointMenuItem.removeCondition.accesskey=c
 breakpointMenuItem.editCondition.label=Edit breakpoint condition
 breakpointMenuItem.editCondition.accesskey=n
+breakpointMenuItem.disableAllAtLine.label=Disable breakpoints on line
+breakpointMenuItem.disableAllAtLine.accesskey=K
+breakpointMenuItem.enableAllAtLine.label=Enable breakpoints on line
+breakpointMenuItem.enableAllAtLine.accesskey=L
+breakpointMenuItem.removeAllAtLine.label=Remove breakpoints on line
+breakpointMenuItem.removeAllAtLine.accesskey=X
 
 # LOCALIZATION NOTE (breakpoints.header): Breakpoints right sidebar pane header.
 breakpoints.header=Breakpoints
 
 # LOCALIZATION NOTE (breakpoints.none): The text that appears when there are
 # no breakpoints present
 breakpoints.none=No breakpoints