33 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
44
55// @flow
6+
67import React , { Component } from "react" ;
78import { bindActionCreators } from "redux" ;
89import { connect } from "react-redux" ;
910import * as I from "immutable" ;
10- import classnames from "classnames" ;
1111import { createSelector } from "reselect" ;
1212import { groupBy , sortBy } from "lodash" ;
1313
14+ import BreakpointItem from "./BreakpointItem" ;
15+
1416import actions from "../../actions" ;
15- import CloseButton from "../shared/Button/Close" ;
16- import { features } from "../../utils/prefs" ;
1717import { getFilename } from "../../utils/source" ;
1818import {
1919 getSources ,
@@ -26,14 +26,15 @@ import { isInterrupted } from "../../utils/pause";
2626import { makeLocationId } from "../../utils/breakpoint" ;
2727import showContextMenu from "./BreakpointsContextMenu" ;
2828
29- import type { Breakpoint , Location } from "../../types" ;
29+ import type { Breakpoint , Location , Source , Frame , Why } from "../../types" ;
3030
3131import "./Breakpoints.css" ;
3232
33- type LocalBreakpoint = Breakpoint & {
34- location : any ,
33+ export type LocalBreakpoint = Breakpoint & {
34+ location : Location ,
3535 isCurrentlyPaused : boolean ,
36- locationId : string
36+ locationId : string ,
37+ source : Source
3738} ;
3839
3940type BreakpointsMap = I . Map < string , LocalBreakpoint > ;
@@ -53,7 +54,11 @@ type Props = {
5354 openConditionalPanel : number => void
5455} ;
5556
56- function isCurrentlyPausedAtBreakpoint ( frame , why , breakpoint ) {
57+ function isCurrentlyPausedAtBreakpoint (
58+ frame : Frame ,
59+ why : Why ,
60+ breakpoint : LocalBreakpoint
61+ ) {
5762 if ( ! frame || ! isInterrupted ( why ) ) {
5863 return false ;
5964 }
@@ -63,18 +68,8 @@ function isCurrentlyPausedAtBreakpoint(frame, why, breakpoint) {
6368 return bpId === pausedId ;
6469}
6570
66- function getBreakpointFilename ( source ) {
67- return source && source . toJS ? getFilename ( source . toJS ( ) ) : "" ;
68- }
69-
70- function getBreakpointLocation ( source , line , column ) {
71- const isWasm = source && source . isWasm ;
72- const columnVal = features . columnBreakpoints && column ? `:${ column } ` : "" ;
73- const bpLocation = isWasm
74- ? `0x${ line . toString ( 16 ) . toUpperCase ( ) } `
75- : `${ line } ${ columnVal } ` ;
76-
77- return bpLocation ;
71+ function getBreakpointFilename ( source : Source ) {
72+ return source ? getFilename ( source ) : "" ;
7873}
7974
8075class Breakpoints extends Component < Props > {
@@ -104,53 +99,18 @@ class Breakpoints extends Component<Props> {
10499 this . props . removeBreakpoint ( breakpoint . location ) ;
105100 }
106101
107- renderBreakpoint ( breakpoint ) {
108- const locationId = breakpoint . locationId ;
109- const line = breakpoint . location . line ;
110- const column = breakpoint . location . column ;
111- const isCurrentlyPaused = breakpoint . isCurrentlyPaused ;
112- const isDisabled = breakpoint . disabled ;
113- const isConditional = ! ! breakpoint . condition ;
114- const isHidden = breakpoint . hidden ;
115-
116- if ( isHidden ) {
117- return ;
118- }
119-
102+ renderBreakpoint ( breakpoint , key ) {
120103 return (
121- < div
122- className = { classnames ( {
123- breakpoint,
124- paused : isCurrentlyPaused ,
125- disabled : isDisabled ,
126- "is-conditional" : isConditional
127- } ) }
128- key = { locationId }
104+ < BreakpointItem
105+ key = { key }
106+ breakpoint = { breakpoint }
129107 onClick = { ( ) => this . selectBreakpoint ( breakpoint ) }
130108 onContextMenu = { e =>
131109 showContextMenu ( { ...this . props , breakpoint, contextMenuEvent : e } )
132110 }
133- >
134- < input
135- type = "checkbox"
136- className = "breakpoint-checkbox"
137- checked = { ! isDisabled }
138- onChange = { ( ) => this . handleCheckbox ( breakpoint ) }
139- onClick = { ev => ev . stopPropagation ( ) }
140- />
141- < label className = "breakpoint-label" title = { breakpoint . text } >
142- { breakpoint . text }
143- </ label >
144- < div className = "breakpoint-line-close" >
145- < div className = "breakpoint-line" >
146- { getBreakpointLocation ( breakpoint . location . source , line , column ) }
147- </ div >
148- < CloseButton
149- handleClick = { ev => this . removeBreakpoint ( ev , breakpoint ) }
150- tooltip = { L10N . getStr ( "breakpoints.removeBreakpointTooltip" ) }
151- />
152- </ div >
153- </ div >
111+ onChange = { ( ) => this . handleCheckbox ( breakpoint ) }
112+ onCloseClick = { ev => this . removeBreakpoint ( ev , breakpoint ) }
113+ />
154114 ) ;
155115 }
156116
@@ -163,20 +123,20 @@ class Breakpoints extends Component<Props> {
163123
164124 const groupedBreakpoints = groupBy (
165125 sortBy ( [ ...breakpoints . valueSeq ( ) ] , bp => bp . location . line ) ,
166- bp => getBreakpointFilename ( bp . location . source )
126+ bp => getBreakpointFilename ( bp . source )
167127 ) ;
168128
169129 return [
170- ...Object . keys ( groupedBreakpoints )
171- . sort ( )
172- . map ( filename => {
173- return [
174- < div className = "breakpoint-heading" title = { filename } key = { filename } >
175- { filename }
176- </ div > ,
177- ... groupedBreakpoints [ filename ] . map ( bp => this . renderBreakpoint ( bp ) )
178- ] ;
179- } )
130+ ...Object . keys ( groupedBreakpoints ) . map ( filename => {
131+ return [
132+ < div className = "breakpoint-heading" title = { filename } key = { filename } >
133+ { filename }
134+ </ div > ,
135+ ... groupedBreakpoints [ filename ]
136+ . filter ( bp => ! bp . hidden )
137+ . map ( ( bp , i ) => this . renderBreakpoint ( bp , ` ${ filename } - ${ i } ` ) )
138+ ] ;
139+ } )
180140 ] ;
181141 }
182142
@@ -195,9 +155,7 @@ function updateLocation(sources, frame, why, bp): LocalBreakpoint {
195155 const source = getSourceInSources ( sources , bp . location . sourceId ) ;
196156 const isCurrentlyPaused = isCurrentlyPausedAtBreakpoint ( frame , why , bp ) ;
197157 const locationId = makeLocationId ( bp . location ) ;
198-
199- const location = { ...bp . location , source } ;
200- const localBP = { ...bp , location, locationId, isCurrentlyPaused } ;
158+ const localBP = { ...bp , locationId, isCurrentlyPaused, source } ;
201159
202160 return localBP ;
203161}
@@ -210,7 +168,7 @@ const _getBreakpoints = createSelector(
210168 ( breakpoints , sources , frame , why ) =>
211169 breakpoints
212170 . map ( bp => updateLocation ( sources , frame , why , bp ) )
213- . filter ( bp => bp . location . source && ! bp . location . source . isBlackBoxed )
171+ . filter ( bp => bp . source && ! bp . source . isBlackBoxed )
214172) ;
215173
216174export default connect (
0 commit comments