/* 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 . */ import React, { Component } from "react"; import PropTypes from "prop-types"; import { connect } from "../../../utils/connect"; import ExceptionOption from "./ExceptionOption"; import Breakpoint from "./Breakpoint"; import BreakpointHeading from "./BreakpointHeading"; import actions from "../../../actions"; import { getSelectedLocation } from "../../../utils/selected-location"; import { createHeadlessEditor } from "../../../utils/editor/create-editor"; import { makeBreakpointId } from "../../../utils/breakpoint"; import { getSelectedSource, getBreakpointSources, getBlackBoxRanges, } from "../../../selectors"; const classnames = require("devtools/client/shared/classnames.js"); import "./Breakpoints.css"; class Breakpoints extends Component { static get propTypes() { return { breakpointSources: PropTypes.array.isRequired, pauseOnExceptions: PropTypes.func.isRequired, selectedSource: PropTypes.object, shouldPauseOnCaughtExceptions: PropTypes.bool.isRequired, shouldPauseOnExceptions: PropTypes.bool.isRequired, blackboxedRanges: PropTypes.array.isRequired, }; } componentWillUnmount() { this.removeEditor(); } getEditor() { if (!this.headlessEditor) { this.headlessEditor = createHeadlessEditor(); } return this.headlessEditor; } removeEditor() { if (!this.headlessEditor) { return; } this.headlessEditor.destroy(); this.headlessEditor = null; } renderExceptionsOptions() { const { breakpointSources, shouldPauseOnExceptions, shouldPauseOnCaughtExceptions, pauseOnExceptions, } = this.props; const isEmpty = !breakpointSources.length; return (
pauseOnExceptions(!shouldPauseOnExceptions, false)} /> {shouldPauseOnExceptions && ( pauseOnExceptions(true, !shouldPauseOnCaughtExceptions) } /> )}
); } renderBreakpoints() { const { breakpointSources, selectedSource, blackboxedRanges } = this.props; if (!breakpointSources.length) { return null; } const editor = this.getEditor(); const sources = breakpointSources.map(({ source }) => source); return (
{breakpointSources.map(({ source, breakpoints }) => { return [ , breakpoints.map(breakpoint => ( )), ]; })}
); } render() { return (
{this.renderExceptionsOptions()} {this.renderBreakpoints()}
); } } const mapStateToProps = state => ({ breakpointSources: getBreakpointSources(state), selectedSource: getSelectedSource(state), blackboxedRanges: getBlackBoxRanges(state), }); export default connect(mapStateToProps, { pauseOnExceptions: actions.pauseOnExceptions, })(Breakpoints);