Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
#4420 Context Menu "Jump to Original Location" should be disabled whe…
Browse files Browse the repository at this point in the history
…n not pretty-printed (#4497)

* Bug 4420 fix

* tweaks
  • Loading branch information
jainsneha23 authored and jasonLaster committed Nov 9, 2017
1 parent 0a19e39 commit 26e1b1d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/Editor/EditorMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import { PureComponent } from "react";
import { showMenu } from "devtools-launchpad";
import { isOriginalId } from "devtools-source-map";
import { isOriginalId, isGeneratedId } from "devtools-source-map";
import { copyToTheClipboard } from "../../utils/clipboard";
import { isPretty } from "../../utils/source";
import { getSourceLocationFromMouseEvent } from "../../utils/editor";
import { bindActionCreators } from "redux";
import { connect } from "react-redux";
Expand Down Expand Up @@ -83,14 +84,17 @@ function getMenuItems(
event
);

const pairedType = isOriginalId(selectedLocation.sourceId)
? L10N.getStr("generated")
: L10N.getStr("original");
const isOriginal = isOriginalId(selectedLocation.sourceId);
const hasSourceMap = selectedSource.get("sourceMapURL");
const isPrettyPrinted = isPretty(selectedSource.toJS());

const jumpLabel = {
accesskey: L10N.getStr("editor.jumpToMappedLocation1.accesskey"),
disabled: false,
label: L10N.getFormatStr("editor.jumpToMappedLocation1", pairedType),
disabled: isGeneratedId && !hasSourceMap,
label: L10N.getFormatStr(
"editor.jumpToMappedLocation1",
isOriginal ? L10N.getStr("generated") : L10N.getStr("original")
),
click: () => jumpToMappedLocation(sourceLocation)
};

Expand All @@ -104,7 +108,7 @@ function getMenuItems(
id: "node-menu-blackbox",
label: toggleBlackBoxLabel,
accesskey: blackboxKey,
disabled: false,
disabled: isOriginal || isPrettyPrinted || hasSourceMap,
click: () => toggleBlackBox(selectedSource.toJS())
};

Expand All @@ -115,7 +119,7 @@ function getMenuItems(
id: "node-menu-show-source",
label: revealInTreeLabel,
accesskey: revealInTreeKey,
disabled: false,
disabled: isPrettyPrinted,
click: () => showSource(selectedSource.get("id"))
};

Expand Down

0 comments on commit 26e1b1d

Please sign in to comment.