summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js')
-rw-r--r--devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js152
1 files changed, 152 insertions, 0 deletions
diff --git a/devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js b/devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js
new file mode 100644
index 0000000000..3a3cc19afa
--- /dev/null
+++ b/devtools/client/debugger/src/components/SecondaryPanes/Breakpoints/index.js
@@ -0,0 +1,152 @@
+/* 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 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 (
+ <div
+ className={classnames("breakpoints-exceptions-options", {
+ empty: isEmpty,
+ })}
+ >
+ <ExceptionOption
+ className="breakpoints-exceptions"
+ label={L10N.getStr("pauseOnExceptionsItem2")}
+ isChecked={shouldPauseOnExceptions}
+ onChange={() => pauseOnExceptions(!shouldPauseOnExceptions, false)}
+ />
+
+ {shouldPauseOnExceptions && (
+ <ExceptionOption
+ className="breakpoints-exceptions-caught"
+ label={L10N.getStr("pauseOnCaughtExceptionsItem")}
+ isChecked={shouldPauseOnCaughtExceptions}
+ onChange={() =>
+ pauseOnExceptions(true, !shouldPauseOnCaughtExceptions)
+ }
+ />
+ )}
+ </div>
+ );
+ }
+
+ renderBreakpoints() {
+ const { breakpointSources, selectedSource, blackboxedRanges } = this.props;
+ if (!breakpointSources.length) {
+ return null;
+ }
+
+ const editor = this.getEditor();
+ const sources = breakpointSources.map(({ source }) => source);
+
+ return (
+ <div className="pane breakpoints-list">
+ {breakpointSources.map(({ source, breakpoints }) => {
+ return [
+ <BreakpointHeading
+ key={source.id}
+ source={source}
+ sources={sources}
+ />,
+ breakpoints.map(breakpoint => (
+ <Breakpoint
+ breakpoint={breakpoint}
+ source={source}
+ blackboxedRangesForSource={blackboxedRanges[source.url]}
+ selectedSource={selectedSource}
+ editor={editor}
+ key={makeBreakpointId(
+ getSelectedLocation(breakpoint, selectedSource)
+ )}
+ />
+ )),
+ ];
+ })}
+ </div>
+ );
+ }
+
+ render() {
+ return (
+ <div className="pane">
+ {this.renderExceptionsOptions()}
+ {this.renderBreakpoints()}
+ </div>
+ );
+ }
+}
+
+const mapStateToProps = state => ({
+ breakpointSources: getBreakpointSources(state),
+ selectedSource: getSelectedSource(state),
+ blackboxedRanges: getBlackBoxRanges(state),
+});
+
+export default connect(mapStateToProps, {
+ pauseOnExceptions: actions.pauseOnExceptions,
+})(Breakpoints);