Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Adding "Add condition" to breakpoints context menu #4157

Merged
merged 5 commits into from
Sep 27, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions assets/panel/debugger.properties
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ breakpointMenuItem.deleteAll2.label=Remove all
breakpointMenuItem.deleteAll2.accesskey=a
breakpointMenuItem.removeCondition2.label=Remove condition
breakpointMenuItem.removeCondition2.accesskey=c
breakpointMenuItem.addCondition2.label=Add condition
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why addCondition2 and not just addCondition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know why the others got renamed I I just wanted to ensure consistency. Should I remove the "2" from my new entries @flodolo

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd keep the 2 to be consistent. We recently changed the labels to drop "breakpoint" e.g. Remove breakpoint condition to Remove condition...

breakpointMenuItem.addCondition2.accesskey=A
breakpointMenuItem.editCondition2.label=Edit condition
breakpointMenuItem.editCondition2.accesskey=n

Expand Down
16 changes: 11 additions & 5 deletions src/actions/ui.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// @flow
import { getSource, getActiveSearch } from "../selectors";
import { getSource, getActiveSearch, getSelectedSource } from "../selectors";
import type { ThunkArgs } from "./types";
import type { ActiveSearchType, SymbolSearchType } from "../reducers/ui";
import { clearSourceSearchQuery } from "./source-search";
import { selectSource } from "./sources";

export function closeActiveSearch() {
return ({ getState, dispatch }: ThunkArgs) => {
Expand Down Expand Up @@ -118,9 +119,14 @@ export function clearHighlightLineRange() {
};
}

export function toggleConditionalBreakpointPanel(line: null | number) {
return {
type: "TOGGLE_CONDITIONAL_BREAKPOINT_PANEL",
line
export function toggleConditionalBreakpointPanel(line?: number) {
return ({ dispatch, getState }: ThunkArgs) => {
const selectedSource = getSelectedSource(getState());
const sourceId = selectedSource.get("id");
dispatch(selectSource(sourceId, { line }));
dispatch({
type: "TOGGLE_CONDITIONAL_BREAKPOINT_PANEL",
line
});
};
}
17 changes: 17 additions & 0 deletions src/components/SecondaryPanes/Breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ class Breakpoints extends PureComponent {
const removeConditionLabel = L10N.getStr(
"breakpointMenuItem.removeCondition2.label"
);
const addConditionLabel = L10N.getStr(
"breakpointMenuItem.addCondition2.label"
);
const editConditionLabel = L10N.getStr(
"breakpointMenuItem.editCondition2.label"
);
Expand Down Expand Up @@ -165,6 +168,9 @@ class Breakpoints extends PureComponent {
const editConditionKey = L10N.getStr(
"breakpointMenuItem.editCondition2.accesskey"
);
const addConditionKey = L10N.getStr(
"breakpointMenuItem.addCondition2.accesskey"
);

const otherBreakpoints = breakpoints.filter(b => b !== breakpoint);
const enabledBreakpoints = breakpoints.filter(b => !b.disabled);
Expand Down Expand Up @@ -255,6 +261,13 @@ class Breakpoints extends PureComponent {
click: () => setBreakpointCondition(breakpoint.location)
};

const addCondition = {
id: "node-menu-add-condition",
label: addConditionLabel,
accesskey: addConditionKey,
click: () => toggleConditionalBreakpointPanel(breakpoint.location.line)
};

const editCondition = {
id: "node-menu-edit-condition",
label: editConditionLabel,
Expand Down Expand Up @@ -291,6 +304,10 @@ class Breakpoints extends PureComponent {
{
item: { type: "separator" }
},
{
item: addCondition,
hidden: () => breakpoint.condition
},
{
item: editCondition,
hidden: () => !breakpoint.condition
Expand Down