diff options
Diffstat (limited to 'devtools/client/debugger/src/components/Editor/Breakpoints.js')
-rw-r--r-- | devtools/client/debugger/src/components/Editor/Breakpoints.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/components/Editor/Breakpoints.js b/devtools/client/debugger/src/components/Editor/Breakpoints.js new file mode 100644 index 0000000000..1f0adad978 --- /dev/null +++ b/devtools/client/debugger/src/components/Editor/Breakpoints.js @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ + +import PropTypes from "prop-types"; +import React, { Component } from "react"; +import Breakpoint from "./Breakpoint"; + +import { getSelectedSource, getFirstVisibleBreakpoints } from "../../selectors"; +import { makeBreakpointId } from "../../utils/breakpoint"; +import { connect } from "../../utils/connect"; +import { breakpointItemActions } from "./menus/breakpoints"; +import { editorItemActions } from "./menus/editor"; + +class Breakpoints extends Component { + static get propTypes() { + return { + cx: PropTypes.object, + breakpoints: PropTypes.array, + editor: PropTypes.object, + breakpointActions: PropTypes.object, + editorActions: PropTypes.object, + selectedSource: PropTypes.object, + }; + } + render() { + const { + cx, + breakpoints, + selectedSource, + editor, + breakpointActions, + editorActions, + } = this.props; + + if (!selectedSource || !breakpoints) { + return null; + } + + return ( + <div> + {breakpoints.map(bp => { + return ( + <Breakpoint + cx={cx} + key={makeBreakpointId(bp.location)} + breakpoint={bp} + selectedSource={selectedSource} + editor={editor} + breakpointActions={breakpointActions} + editorActions={editorActions} + /> + ); + })} + </div> + ); + } +} + +export default connect( + state => ({ + // Retrieves only the first breakpoint per line so that the + // breakpoint marker represents only the first breakpoint + breakpoints: getFirstVisibleBreakpoints(state), + selectedSource: getSelectedSource(state), + }), + dispatch => ({ + breakpointActions: breakpointItemActions(dispatch), + editorActions: editorItemActions(dispatch), + }) +)(Breakpoints); |