From a6ce4f827c4a833104c67dcad9435386fb7d0534 Mon Sep 17 00:00:00 2001 From: Martin Schmid Date: Tue, 26 Sep 2017 23:59:32 +0200 Subject: [PATCH 1/4] Preview: Show numbers inside a tooltip (#4164) --- src/components/Editor/Preview/Popup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Editor/Preview/Popup.js b/src/components/Editor/Preview/Popup.js index 5961b298c5..0118db4222 100644 --- a/src/components/Editor/Preview/Popup.js +++ b/src/components/Editor/Preview/Popup.js @@ -185,6 +185,7 @@ export class Popup extends Component { getPreviewType(value: any) { if ( + typeof value == "number" || typeof value == "boolean" || value.type == "null" || value.type == "undefined" || From 468acf85853cebdabc0592222b798abf15c956d3 Mon Sep 17 00:00:00 2001 From: Johnny Khalil Date: Fri, 6 Oct 2017 13:31:57 -0400 Subject: [PATCH 2/4] initial commit --- assets/panel/debugger.properties | 5 ++ assets/panel/prefs.js | 2 + src/actions/tests/ui.spec.js | 10 +++- src/actions/ui.js | 7 +++ src/components/PrimaryPanes/SourcesTree.js | 52 ++++++++++++++++--- src/reducers/ui.js | 10 ++++ .../mochitest/browser_dbg-breakpoints-cond.js | 6 +-- src/utils/prefs.js | 6 ++- src/utils/sources-tree/addToTree.js | 3 +- src/utils/sources-tree/createTree.js | 8 ++- 10 files changed, 93 insertions(+), 16 deletions(-) diff --git a/assets/panel/debugger.properties b/assets/panel/debugger.properties index 5a379a957c..9f31e5df4c 100644 --- a/assets/panel/debugger.properties +++ b/assets/panel/debugger.properties @@ -24,6 +24,11 @@ copySource.accesskey=y copySourceUri2=Copy source URI copySourceUri2.accesskey=u +# LOCALIZATION NOTE (setDirectoryRoot): This is the text that appears in the +# context menu to set a directory as root directory +setDirectoryRoot.label= Set directory root +setDirectoryRoot.accesskey=r + # LOCALIZATION NOTE (copyFunction): This is the text that appears in the # context menu to copy the function the user selected copyFunction.label=Copy function diff --git a/assets/panel/prefs.js b/assets/panel/prefs.js index 8d45b53a3f..f3154aefb9 100644 --- a/assets/panel/prefs.js +++ b/assets/panel/prefs.js @@ -39,3 +39,5 @@ pref("devtools.debugger.file-search-regex-match", false); pref("devtools.debugger.features.async-stepping", true); pref("devtools.debugger.features.project-text-search", true); pref("devtools.debugger.features.wasm", true); +pref("devtools.debugger.project-directory-root", ""); +pref("devtools.debugger.features.root", false); diff --git a/src/actions/tests/ui.spec.js b/src/actions/tests/ui.spec.js index 92ce818994..c8a1495046 100644 --- a/src/actions/tests/ui.spec.js +++ b/src/actions/tests/ui.spec.js @@ -8,7 +8,8 @@ const { getPaneCollapse, getSymbolSearchType, getHighlightedLineRange, - getSearchResults + getSearchResults, + getProjectDirectoryRoot } = selectors; describe("ui", () => { @@ -116,3 +117,10 @@ describe("ui", () => { expect(getHighlightedLineRange(getState())).toEqual({}); }); }); + +it("should set a directory as root directory", () => { + const { dispatch, getState } = createStore(); + const projectRoot = getProjectDirectoryRoot(getState()); + dispatch(actions.setProjectDirectoryRoot(projectRoot)); + expect(getProjectDirectoryRoot(getState())).toBe(projectRoot); +}); diff --git a/src/actions/ui.js b/src/actions/ui.js index 6be512f187..bc904fd1cf 100644 --- a/src/actions/ui.js +++ b/src/actions/ui.js @@ -136,3 +136,10 @@ export function closeConditionalPanel() { type: "CLOSE_CONDITIONAL_PANEL" }; } + +export function setProjectDirectoryRoot(url: Object) { + return { + type: "SET_PROJECT_DIRECTORY_ROOT", + url + }; +} diff --git a/src/components/PrimaryPanes/SourcesTree.js b/src/components/PrimaryPanes/SourcesTree.js index 46be383c96..708a066b7e 100644 --- a/src/components/PrimaryPanes/SourcesTree.js +++ b/src/components/PrimaryPanes/SourcesTree.js @@ -11,7 +11,8 @@ import { getShownSource, getSelectedSource, getDebuggeeUrl, - getExpandedState + getExpandedState, + getProjectDirectoryRoot } from "../../selectors"; import actions from "../../actions"; @@ -37,11 +38,14 @@ import { Set } from "immutable"; import { showMenu } from "devtools-launchpad"; import { copyToTheClipboard } from "../../utils/clipboard"; import { throttle } from "../../utils/utils"; +import { features } from "../../utils/prefs"; +import { sortEntireTree } from "../../utils/sources-tree/sortTree"; type CreateTree = { focusedItem?: any, parentMap: any, sourceTree: any, + projectRoot: string, uncollapsedTree: any, listItems?: any, highlightItems?: any @@ -100,9 +104,18 @@ class SourcesTree extends Component { } componentWillReceiveProps(nextProps) { - if (this.props.debuggeeUrl !== nextProps.debuggeeUrl) { + if ( + this.props.projectRoot !== nextProps.projectRoot || + this.props.debuggeeUrl !== nextProps.debuggeeUrl + ) { // Recreate tree because the sort order changed - this.setState(createTree(nextProps.sources, nextProps.debuggeeUrl)); + this.setState( + createTree( + nextProps.sources, + nextProps.debuggeeUrl, + nextProps.projectRoot + ) + ); return; } const { selectedSource } = this.props; @@ -140,7 +153,13 @@ class SourcesTree extends Component { if (nextProps.sources.size === 0) { // remove all sources - this.setState(createTree(nextProps.sources, this.props.debuggeeUrl)); + this.setState( + createTree( + nextProps.sources, + nextProps.debuggeeUrl, + nextProps.projectRoot + ) + ); return; } @@ -159,9 +178,15 @@ class SourcesTree extends Component { let sourceTree = this.state.sourceTree; if (newSet.size > 0) { for (const source of newSet) { - addToTree(uncollapsedTree, source, this.props.debuggeeUrl); + addToTree( + uncollapsedTree, + source, + this.props.debuggeeUrl, + this.props.projectRoot + ); } - sourceTree = collapseTree(uncollapsedTree); + const unsortedTree = collapseTree(uncollapsedTree); + sourceTree = sortEntireTree(unsortedTree, nextProps.debuggeeUrl); } this.setState({ @@ -198,8 +223,11 @@ class SourcesTree extends Component { } onContextMenu(event, item) { + const { setProjectDirectoryRoot } = this.props; const copySourceUri2Label = L10N.getStr("copySourceUri2"); const copySourceUri2Key = L10N.getStr("copySourceUri2.accesskey"); + const setDirectoryRootLabel = L10N.getStr("setDirectoryRoot.label"); + const setDirectoryRootKey = L10N.getStr("setDirectoryRoot.accesskey"); event.stopPropagation(); event.preventDefault(); @@ -217,8 +245,15 @@ class SourcesTree extends Component { }; menuOptions.push(copySourceUri2); + } else if (features.root) { + menuOptions.push({ + id: "node-set-directory-root", + label: setDirectoryRootLabel, + accesskey: setDirectoryRootKey, + disabled: false, + click: () => setProjectDirectoryRoot(item.path) + }); } - showMenu(event, menuOptions); } @@ -323,7 +358,8 @@ export default connect( shownSource: getShownSource(state), selectedSource: getSelectedSource(state), debuggeeUrl: getDebuggeeUrl(state), - expanded: getExpandedState(state) + expanded: getExpandedState(state), + projectRoot: getProjectDirectoryRoot(state) }; }, dispatch => bindActionCreators(actions, dispatch) diff --git a/src/reducers/ui.js b/src/reducers/ui.js index ca9dfcca8d..91af516cc9 100644 --- a/src/reducers/ui.js +++ b/src/reducers/ui.js @@ -51,6 +51,7 @@ export type UIState = { startPanelCollapsed: boolean, endPanelCollapsed: boolean, frameworkGroupingOn: boolean, + projectDirectoryRoot: string, highlightedLineRange?: { start?: number, end?: number, @@ -77,6 +78,7 @@ export const State = makeRecord( count: 0 }, shownSource: "", + projectDirectoryRoot: "", startPanelCollapsed: prefs.startPanelCollapsed, endPanelCollapsed: prefs.endPanelCollapsed, frameworkGroupingOn: prefs.frameworkGroupingOn, @@ -166,6 +168,10 @@ function update( case "CLOSE_CONDITIONAL_PANEL": return state.set("conditionalPanelLine", null); + case "SET_PROJECT_DIRECTORY_ROOT": + prefs.projectDirectoryRoot = action.url; + return state.set("projectDirectoryRoot", action.url); + default: { return state; } @@ -229,4 +235,8 @@ export function getConditionalPanelLine(state: OuterState): null | number { return state.ui.get("conditionalPanelLine"); } +export function getProjectDirectoryRoot(state: OuterState): boolean { + return state.ui.get("projectDirectoryRoot"); +} + export default update; diff --git a/src/test/mochitest/browser_dbg-breakpoints-cond.js b/src/test/mochitest/browser_dbg-breakpoints-cond.js index 7b124f613c..3153fae5d8 100644 --- a/src/test/mochitest/browser_dbg-breakpoints-cond.js +++ b/src/test/mochitest/browser_dbg-breakpoints-cond.js @@ -39,21 +39,21 @@ add_task(async function() { const dbg = await initDebugger("doc-scripts.html"); await selectSource(dbg, "simple2"); - dump('Adding a conditional Breakpoint\n') + dump("Adding a conditional Breakpoint\n"); await setConditionalBreakpoint(dbg, 5, "1"); await waitForDispatch(dbg, "ADD_BREAKPOINT"); let bp = findBreakpoint(dbg, "simple2", 5); is(bp.condition, "1", "breakpoint is created with the condition"); assertEditorBreakpoint(dbg, 5, true); - dump('Editing a conditional breakpoint\n') + dump("Editing a conditional breakpoint\n"); await setConditionalBreakpoint(dbg, 5, "2"); await waitForDispatch(dbg, "SET_BREAKPOINT_CONDITION"); bp = findBreakpoint(dbg, "simple2", 5); is(bp.condition, "12", "breakpoint is created with the condition"); assertEditorBreakpoint(dbg, 5, true); - dump("Removing a conditional breakpoint\n") + dump("Removing a conditional breakpoint\n"); clickElement(dbg, "gutter", 5); await waitForDispatch(dbg, "REMOVE_BREAKPOINT"); bp = findBreakpoint(dbg, "simple2", 5); diff --git a/src/utils/prefs.js b/src/utils/prefs.js index 917f4354cc..97ae214130 100644 --- a/src/utils/prefs.js +++ b/src/utils/prefs.js @@ -27,6 +27,8 @@ if (isDevelopment()) { pref("devtools.debugger.features.async-stepping", true); pref("devtools.debugger.features.wasm", true); pref("devtools.debugger.features.shortcuts", true); + pref("devtools.debugger.features.root", true); + pref("devtools.debugger.feature.project-directory-root", ""); } export const prefs = new PrefsHelper("devtools", { @@ -51,7 +53,9 @@ export const features = new PrefsHelper("devtools.debugger.features", { asyncStepping: ["Bool", "async-stepping", false], projectTextSearch: ["Bool", "project-text-search", true], wasm: ["Bool", "wasm", true], - shortcuts: ["Bool", "shortcuts", false] + shortcuts: ["Bool", "shortcuts", false], + root: ["Bool", "root", false], + projectDirectoryRoot: ["Bool", "project-directory-root", ""] }); if (prefs.debuggerPrefsSchemaVersion !== prefsSchemaVersion) { diff --git a/src/utils/sources-tree/addToTree.js b/src/utils/sources-tree/addToTree.js index 2d13a9e8e8..01b3b66bfb 100644 --- a/src/utils/sources-tree/addToTree.js +++ b/src/utils/sources-tree/addToTree.js @@ -139,7 +139,8 @@ function addSourceToNode(node: Node, url: Object, source: SourceRecord) { export function addToTree( tree: Node, source: SourceRecord, - debuggeeUrl: string + debuggeeUrl: string, + projectRoot: string ) { const url = getURL(source.get("url"), debuggeeUrl); const debuggeeHost = getDomain(debuggeeUrl); diff --git a/src/utils/sources-tree/createTree.js b/src/utils/sources-tree/createTree.js index 06dcb3dde4..37786947fc 100644 --- a/src/utils/sources-tree/createTree.js +++ b/src/utils/sources-tree/createTree.js @@ -6,10 +6,14 @@ import { addToTree } from "./addToTree"; import type { SourcesMap } from "../../reducers/types"; -export function createTree(sources: SourcesMap, debuggeeUrl: string) { +export function createTree( + sources: SourcesMap, + debuggeeUrl: string, + projectRoot: string +) { const uncollapsedTree = createNode("root", "", []); for (const source of sources.valueSeq()) { - addToTree(uncollapsedTree, source, debuggeeUrl); + addToTree(uncollapsedTree, source, debuggeeUrl, projectRoot); } const sourceTree = collapseTree(uncollapsedTree); From c2af0da9f97d4283d858430b6a752b5ec7eb8854 Mon Sep 17 00:00:00 2001 From: Johnny Khalil Date: Fri, 13 Oct 2017 01:24:05 -0400 Subject: [PATCH 3/4] resolved conflicts in src/actions/ui.js and updated debugger.properties and SourcesTree.js based on flodolo and jasonLaster feedback --- assets/panel/debugger.properties | 4 ++-- src/components/PrimaryPanes/SourcesTree.js | 13 ++++++++----- src/reducers/source-tree.js | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/assets/panel/debugger.properties b/assets/panel/debugger.properties index 9f31e5df4c..0c90da267c 100644 --- a/assets/panel/debugger.properties +++ b/assets/panel/debugger.properties @@ -24,9 +24,9 @@ copySource.accesskey=y copySourceUri2=Copy source URI copySourceUri2.accesskey=u -# LOCALIZATION NOTE (setDirectoryRoot): This is the text that appears in the +# LOCALIZATION NOTE (setDirectoryRoot -> setDirectoryRoot.label): This is the text that appears in the # context menu to set a directory as root directory -setDirectoryRoot.label= Set directory root +setDirectoryRoot.label=Set directory root setDirectoryRoot.accesskey=r # LOCALIZATION NOTE (copyFunction): This is the text that appears in the diff --git a/src/components/PrimaryPanes/SourcesTree.js b/src/components/PrimaryPanes/SourcesTree.js index 708a066b7e..fedeaaa201 100644 --- a/src/components/PrimaryPanes/SourcesTree.js +++ b/src/components/PrimaryPanes/SourcesTree.js @@ -39,7 +39,7 @@ import { showMenu } from "devtools-launchpad"; import { copyToTheClipboard } from "../../utils/clipboard"; import { throttle } from "../../utils/utils"; import { features } from "../../utils/prefs"; -import { sortEntireTree } from "../../utils/sources-tree/sortTree"; +import { setProjectDirectoryRoot } from "../../actions/ui"; type CreateTree = { focusedItem?: any, @@ -57,6 +57,7 @@ type Props = { shownSource?: String, selectedSource?: SourceRecord, debuggeeUrl: String, + projectRoot: String, setExpandedState: any => void, expanded?: any }; @@ -74,7 +75,11 @@ class SourcesTree extends Component { constructor(props) { super(props); - this.state = createTree(this.props.sources, this.props.debuggeeUrl); + this.state = createTree( + this.props.sources, + this.props.debuggeeUrl, + this.props.projectRoot + ); this.focusItem = this.focusItem.bind(this); this.selectItem = this.selectItem.bind(this); this.getIcon = this.getIcon.bind(this); @@ -185,8 +190,7 @@ class SourcesTree extends Component { this.props.projectRoot ); } - const unsortedTree = collapseTree(uncollapsedTree); - sourceTree = sortEntireTree(unsortedTree, nextProps.debuggeeUrl); + sourceTree = collapseTree(uncollapsedTree); } this.setState({ @@ -223,7 +227,6 @@ class SourcesTree extends Component { } onContextMenu(event, item) { - const { setProjectDirectoryRoot } = this.props; const copySourceUri2Label = L10N.getStr("copySourceUri2"); const copySourceUri2Key = L10N.getStr("copySourceUri2.accesskey"); const setDirectoryRootLabel = L10N.getStr("setDirectoryRoot.label"); diff --git a/src/reducers/source-tree.js b/src/reducers/source-tree.js index a54a9d377c..a757290d1d 100644 --- a/src/reducers/source-tree.js +++ b/src/reducers/source-tree.js @@ -7,7 +7,7 @@ * Source tree reducer * @module reducers/source-tree */ - + import makeRecord from "../utils/makeRecord"; import type { SourceTreeAction } from "../actions/types"; From a16befdba8d80e056a654930d4e66e281558d30d Mon Sep 17 00:00:00 2001 From: Jason Laster Date: Fri, 13 Oct 2017 09:24:02 -0400 Subject: [PATCH 4/4] Update debugger.properties --- assets/panel/debugger.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/panel/debugger.properties b/assets/panel/debugger.properties index 0c90da267c..22bcdfe773 100644 --- a/assets/panel/debugger.properties +++ b/assets/panel/debugger.properties @@ -24,7 +24,7 @@ copySource.accesskey=y copySourceUri2=Copy source URI copySourceUri2.accesskey=u -# LOCALIZATION NOTE (setDirectoryRoot -> setDirectoryRoot.label): This is the text that appears in the +# LOCALIZATION NOTE (setDirectoryRoot): This is the text that appears in the # context menu to set a directory as root directory setDirectoryRoot.label=Set directory root setDirectoryRoot.accesskey=r