@@ -9,11 +9,10 @@ import { connect } from "react-redux";
99import * as I from "immutable" ;
1010import classnames from "classnames" ;
1111import { createSelector } from "reselect" ;
12- import { sortBy } from "lodash" ;
12+ import { groupBy , sortBy } from "lodash" ;
1313
1414import actions from "../../actions" ;
1515import CloseButton from "../shared/Button/Close" ;
16- import { endTruncateStr } from "../../utils/utils" ;
1716import { features } from "../../utils/prefs" ;
1817import { getFilename } from "../../utils/source" ;
1918import {
@@ -68,23 +67,14 @@ function getBreakpointFilename(source) {
6867 return source && source . toJS ? getFilename ( source . toJS ( ) ) : "" ;
6968}
7069
71- function renderSourceLocation ( source , line , column ) {
72- const filename = getBreakpointFilename ( source ) ;
70+ function getBreakpointLocation ( source , line , column ) {
7371 const isWasm = source && source . isWasm ;
7472 const columnVal = features . columnBreakpoints && column ? `:${ column } ` : "" ;
7573 const bpLocation = isWasm
7674 ? `0x${ line . toString ( 16 ) . toUpperCase ( ) } `
7775 : `${ line } ${ columnVal } ` ;
7876
79- if ( ! filename ) {
80- return null ;
81- }
82-
83- return (
84- < div className = "location" >
85- { `${ endTruncateStr ( filename , 30 ) } : ${ bpLocation } ` }
86- </ div >
87- ) ;
77+ return bpLocation ;
8878}
8979
9080class Breakpoints extends Component < Props > {
@@ -149,32 +139,53 @@ class Breakpoints extends Component<Props> {
149139 onClick = { ev => ev . stopPropagation ( ) }
150140 />
151141 < label className = "breakpoint-label" title = { breakpoint . text } >
152- { renderSourceLocation ( breakpoint . location . source , line , column ) }
142+ { breakpoint . text }
153143 </ label >
154- < CloseButton
155- handleClick = { ev => this . removeBreakpoint ( ev , breakpoint ) }
156- tooltip = { L10N . getStr ( "breakpoints.removeBreakpointTooltip" ) }
157- />
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 >
158153 </ div >
159154 ) ;
160155 }
161156
157+ renderEmpty ( ) {
158+ return < div className = "pane-info" > { L10N . getStr ( "breakpoints.none" ) } </ div > ;
159+ }
160+
161+ renderBreakpoints ( ) {
162+ const { breakpoints } = this . props ;
163+
164+ const groupedBreakpoints = groupBy (
165+ sortBy ( [ ...breakpoints . valueSeq ( ) ] , bp => bp . location . line ) ,
166+ bp => getBreakpointFilename ( bp . location . source )
167+ ) ;
168+
169+ return [
170+ ...Object . keys ( groupedBreakpoints ) . map ( filename => {
171+ return [
172+ < div className = "breakpoint-heading" title = { filename } key = { filename } >
173+ { filename }
174+ </ div > ,
175+ ...groupedBreakpoints [ filename ] . map ( bp => this . renderBreakpoint ( bp ) )
176+ ] ;
177+ } )
178+ ] ;
179+ }
180+
162181 render ( ) {
163182 const { breakpoints } = this . props ;
164- const children =
165- breakpoints . size === 0 ? (
166- < div className = "pane-info" > { L10N . getStr ( "breakpoints.none" ) } </ div >
167- ) : (
168- sortBy (
169- [ ...breakpoints . valueSeq ( ) ] ,
170- [
171- bp => getBreakpointFilename ( bp . location . source ) ,
172- bp => bp . location . line
173- ]
174- ) . map ( bp => this . renderBreakpoint ( bp ) )
175- ) ;
176-
177- return < div className = "pane breakpoints-list" > { children} < / d i v > ;
183+
184+ return (
185+ < div className = "pane breakpoints-list" >
186+ { breakpoints . size ? this . renderBreakpoints ( ) : this . renderEmpty ( ) }
187+ </ div >
188+ ) ;
178189 }
179190}
180191
0 commit comments