Skip to content

Commit 18c3009

Browse files
bomsyjasonLaster
authored andcommitted
[breakpoints] log points updates (firefox-devtools#7632)
1 parent 180f7b3 commit 18c3009

16 files changed

Lines changed: 77 additions & 27 deletions

File tree

src/actions/breakpoints/addBreakpoint.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ async function addBreakpointPromise(getState, client, sourceMaps, breakpoint) {
8484
hidden: breakpoint.hidden,
8585
loading: false,
8686
condition: breakpoint.condition,
87+
log: breakpoint.log,
8788
location: newLocation,
8889
astLocation,
8990
generatedLocation: newGeneratedLocation,
@@ -156,7 +157,7 @@ export function enableBreakpoint(location: SourceLocation) {
156157

157158
export function addBreakpoint(
158159
location: SourceLocation,
159-
{ condition, hidden }: addBreakpointOptions = {}
160+
{ condition, hidden, log = false }: addBreakpointOptions = {}
160161
) {
161162
return async ({ dispatch, getState, sourceMaps, client }: ThunkArgs) => {
162163
recordEvent("add_breakpoint");
@@ -165,7 +166,7 @@ export function addBreakpoint(
165166
location = getFirstPausePointLocation(getState(), location);
166167
}
167168

168-
const breakpoint = createBreakpoint(location, { condition, hidden });
169+
const breakpoint = createBreakpoint(location, { condition, hidden, log });
169170

170171
return dispatch({
171172
type: "ADD_BREAKPOINT",

src/actions/breakpoints/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ import { recordEvent } from "../../utils/telemetry";
4444

4545
export type addBreakpointOptions = {
4646
condition?: string,
47-
hidden?: boolean
47+
hidden?: boolean,
48+
log?: boolean
4849
};
4950

5051
/**
@@ -196,11 +197,10 @@ export function toggleBreakpoints(
196197
breakpoints: Breakpoint[]
197198
) {
198199
return async ({ dispatch }: ThunkArgs) => {
199-
const promises = breakpoints.map(
200-
breakpoint =>
201-
shouldDisableBreakpoints
202-
? dispatch(disableBreakpoint(breakpoint.location))
203-
: dispatch(enableBreakpoint(breakpoint.location))
200+
const promises = breakpoints.map(breakpoint =>
201+
shouldDisableBreakpoints
202+
? dispatch(disableBreakpoint(breakpoint.location))
203+
: dispatch(enableBreakpoint(breakpoint.location))
204204
);
205205

206206
await Promise.all(promises);
@@ -283,12 +283,12 @@ export function remapBreakpoints(sourceId: string) {
283283
*/
284284
export function setBreakpointCondition(
285285
location: SourceLocation,
286-
{ condition }: addBreakpointOptions = {}
286+
{ condition, log = false }: addBreakpointOptions = {}
287287
) {
288288
return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
289289
const bp = getBreakpoint(getState(), location);
290290
if (!bp) {
291-
return dispatch(addBreakpoint(location, { condition }));
291+
return dispatch(addBreakpoint(location, { condition, log }));
292292
}
293293

294294
if (bp.loading) {
@@ -306,7 +306,7 @@ export function setBreakpointCondition(
306306
isOriginalId(bp.location.sourceId)
307307
);
308308

309-
const newBreakpoint = { ...bp, disabled: false, condition };
309+
const newBreakpoint = { ...bp, disabled: false, condition, log };
310310

311311
assertBreakpoint(newBreakpoint);
312312

src/actions/breakpoints/tests/__snapshots__/breakpoints.spec.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Object {
2626
"sourceId": "a",
2727
"sourceUrl": "http://localhost:8000/examples/a",
2828
},
29+
"log": false,
2930
"originalText": "",
3031
"text": "",
3132
}
@@ -39,6 +40,7 @@ Array [
3940
"condition": null,
4041
"disabled": false,
4142
"id": "hi",
43+
"log": false,
4244
"selectedLocation": Object {
4345
"line": 2,
4446
"sourceId": "a",
@@ -94,6 +96,7 @@ Object {
9496
"sourceId": "a.js/originalSource-d6d70368d5c252598541e693a7ad6c27",
9597
"sourceUrl": "http://localhost:8000/examples/a.js:formatted",
9698
},
99+
"log": false,
97100
"originalText": "function a() {",
98101
"text": "function a() {",
99102
}
@@ -107,6 +110,7 @@ Array [
107110
"condition": null,
108111
"disabled": true,
109112
"id": "hi",
113+
"log": false,
110114
"selectedLocation": Object {
111115
"line": 5,
112116
"sourceId": "a",

src/actions/breakpoints/tests/__snapshots__/syncing.spec.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Object {
2626
"sourceId": "magic.js",
2727
"sourceUrl": "http://localhost:8000/examples/magic.js",
2828
},
29+
"log": false,
2930
"originalText": "",
3031
"text": "",
3132
},
@@ -64,6 +65,7 @@ Object {
6465
"sourceId": "magic.js",
6566
"sourceUrl": "http://localhost:8000/examples/magic.js",
6667
},
68+
"log": false,
6769
"originalText": "",
6870
"text": "",
6971
},
@@ -97,6 +99,7 @@ Object {
9799
"line": 3,
98100
"sourceUrl": "http://localhost:8000/examples/magic.js",
99101
},
102+
"log": false,
100103
},
101104
}
102105
`;
@@ -127,6 +130,7 @@ Object {
127130
"sourceId": "magic.js",
128131
"sourceUrl": "http://localhost:8000/examples/magic.js",
129132
},
133+
"log": false,
130134
"originalText": "",
131135
"text": "",
132136
},
@@ -165,6 +169,7 @@ Object {
165169
"sourceId": "magic.js",
166170
"sourceUrl": "http://localhost:8000/magic.js",
167171
},
172+
"log": false,
168173
"originalText": "",
169174
"text": "",
170175
},

src/actions/tests/__snapshots__/pending-breakpoints.spec.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Object {
5050
"line": 7,
5151
"sourceUrl": "http://localhost:8000/examples/foo.js",
5252
},
53+
"log": false,
5354
}
5455
`;
5556

@@ -76,6 +77,7 @@ Object {
7677
"line": 5,
7778
"sourceUrl": "http://localhost:8000/examples/foo.js",
7879
},
80+
"log": false,
7981
}
8082
`;
8183

@@ -102,6 +104,7 @@ Object {
102104
"line": 5,
103105
"sourceUrl": "http://localhost:8000/examples/foo",
104106
},
107+
"log": false,
105108
}
106109
`;
107110

@@ -128,5 +131,6 @@ Object {
128131
"line": 5,
129132
"sourceUrl": "http://localhost:8000/examples/foo2",
130133
},
134+
"log": false,
131135
}
132136
`;

src/components/Editor/Breakpoint.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ class Breakpoint extends PureComponent<Props> {
6161

6262
editor.codeMirror.addLineClass(line, "line", "new-breakpoint");
6363
if (breakpoint.condition) {
64-
editor.codeMirror.addLineClass(line, "line", "has-condition");
64+
if (breakpoint.log) {
65+
editor.codeMirror.addLineClass(line, "line", "has-condition log");
66+
} else {
67+
editor.codeMirror.addLineClass(line, "line", "has-condition");
68+
}
6569
} else {
6670
editor.codeMirror.removeLineClass(line, "line", "has-condition");
6771
}

src/components/Editor/ColumnBreakpoints.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
stroke: var(--theme-graphs-orange);
3131
}
3232

33+
.column-breakpoint.has-condition.log svg {
34+
fill: var(--theme-graphs-orange);
35+
stroke: var(--theme-graphs-yellow);
36+
}
37+
3338
.theme-dark .column-breakpoint.active svg {
3439
fill: var(--blue-55);
3540
stroke: var(--blue-40);

src/components/Editor/ConditionalPanel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export class ConditionalPanel extends PureComponent<Props> {
6767
if (log) {
6868
condition = `console.log(${condition})`;
6969
}
70-
return this.props.setBreakpointCondition(location, { condition });
70+
return this.props.setBreakpointCondition(location, { condition, log });
7171
}
7272

7373
clearConditionalPanel() {

src/components/Editor/Editor.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ html[dir="rtl"] .editor-mount {
159159
stroke: var(--theme-graphs-orange);
160160
}
161161

162+
.new-breakpoint.has-condition.log .CodeMirror-gutter-wrapper svg {
163+
fill: var(--theme-graphs-orange);
164+
stroke: var(--theme-graphs-yellow);
165+
}
166+
162167
.editor.new-breakpoint.breakpoint-disabled svg {
163168
fill: var(--breakpoint-fill-disabled);
164169
stroke: var(--breakpoint-stroke-disabled);

src/components/Editor/GutterMenu.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,12 @@ export function gutterMenu({
120120
: gutterItems.addConditional)
121121
};
122122

123-
const items = [toggleBreakpointItem, conditionalBreakpoint, logPoint];
123+
let items = [toggleBreakpointItem, conditionalBreakpoint, logPoint];
124+
125+
if (breakpoint && breakpoint.condition) {
126+
const remove = breakpoint.log ? conditionalBreakpoint : logPoint;
127+
items = items.filter(item => item !== remove);
128+
}
124129

125130
if (isPaused) {
126131
const continueToHereItem = {

0 commit comments

Comments
 (0)