-
Notifications
You must be signed in to change notification settings - Fork 759
#4420 Context Menu "Jump to Original Location" should be disabled when not pretty-printed #4497
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skimmed it quickly and it looks great!
src/components/Editor/EditorMenu.js
Outdated
|
||
const jumpLabel = { | ||
accesskey: L10N.getStr("editor.jumpToMappedLocation1.accesskey"), | ||
disabled: false, | ||
label: L10N.getFormatStr("editor.jumpToMappedLocation1", pairedType), | ||
disabled: isGenerated ? false : !isPrettyTabOpen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused by this so i'll share the spec as i see it:
- original files can not be pretty printed
- generated files that have a source map cannot be pretty printed
- if the source has been pretty printed, jumping should jump between the pretty and "ugly" file :) this might be new behavior...
src/components/Editor/EditorMenu.js
Outdated
@@ -96,7 +103,7 @@ function getMenuItems( | |||
id: "node-menu-blackbox", | |||
label: toggleBlackBoxLabel, | |||
accesskey: blackboxKey, | |||
disabled: false, | |||
disabled: isGenerated, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so... i think the comment before might help...
we want it to be disabled for pretty printed files, but nothing else...
@jasonLaster
If the file opened is pretty printed(i.e. isOriginal), u will see "jump to generated location" always
|
const pairedType = isOriginalId(selectedLocation.sourceId) | ||
? L10N.getStr("generated") | ||
: L10N.getStr("original"); | ||
const isOriginal = isOriginalId(selectedLocation.sourceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check if the source is original, or generated ?
src/components/Editor/EditorMenu.js
Outdated
? L10N.getStr("generated") | ||
: L10N.getStr("original"); | ||
const isOriginal = isOriginalId(selectedLocation.sourceId); | ||
const isPrettyTabOpen = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the source is generated, check if there is a open tab with its original
label: L10N.getFormatStr( | ||
"editor.jumpToMappedLocation1", | ||
isOriginal ? L10N.getStr("generated") : L10N.getStr("original") | ||
), | ||
click: () => jumpToMappedLocation(sourceLocation) | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jump to generated location is always enabled for original source
Jump to original location is enabled only if, its original location is open in a tab
src/components/Editor/EditorMenu.js
Outdated
@@ -96,7 +102,7 @@ function getMenuItems( | |||
id: "node-menu-blackbox", | |||
label: toggleBlackBoxLabel, | |||
accesskey: blackboxKey, | |||
disabled: false, | |||
disabled: isOriginal, | |||
click: () => toggleBlackBox(selectedSource.toJS()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blackbox menu is disabled for original source (prettified)
Hey @jainsneha23 lets discuss O/G here: i'm still a bit confused about how you're using the term... we might also be inconsistent in the app |
@jasonLaster Even I am confused here for terminology. For me the pretty printed file is generated, and the one i open first is original. But the terminology used in the same file before was the opposite. So, I sticked to it. If the code looks fine apart from the terminology for generated/original, please suggest the proper names. I will add it. |
^ haha - let me check to see what is going on in the debugger. the docs were my assumptions |
So, if the pretty source is original , the terminology being used right now is correct. Then the code can is ready to review? |
src/components/Editor/EditorMenu.js
Outdated
: L10N.getStr("original"); | ||
const isOriginal = isOriginalId(selectedLocation.sourceId); | ||
const isPrettyTabOpen = | ||
!isOriginal && tabs.includes(getPrettySourceURL(selectedSource.get("url"))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this fail if we were looking at a different original file?
I think we should be able to get the selectedSource, which would have the URL and ignore the tab stuff
src/components/Editor/EditorMenu.js
Outdated
@@ -96,7 +102,7 @@ function getMenuItems( | |||
id: "node-menu-blackbox", | |||
label: toggleBlackBoxLabel, | |||
accesskey: blackboxKey, | |||
disabled: false, | |||
disabled: isOriginal, | |||
click: () => toggleBlackBox(selectedSource.toJS()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
true, we don't want to blackbox original sources. This is because we don't know how to blackbox an original source that is part of a larger bundled (generated) source
src/components/Editor/EditorMenu.js
Outdated
@@ -107,7 +113,7 @@ function getMenuItems( | |||
id: "node-menu-show-source", | |||
label: revealInTreeLabel, | |||
accesskey: revealInTreeKey, | |||
disabled: false, | |||
disabled: isOriginal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pretty printed files are not in the tree, but other original files that come from a bundle are.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. I will fix this.
src/components/Editor/EditorMenu.js
Outdated
@@ -168,9 +174,11 @@ class EditorMenu extends PureComponent { | |||
export default connect( | |||
state => { | |||
const selectedSource = getSelectedSource(state); | |||
const tabs = getSourceTabs(state); | |||
return { | |||
selectedLocation: getSelectedLocation(state), | |||
selectedSource, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh good, we have a selectedSource
src/components/Editor/EditorMenu.js
Outdated
? L10N.getStr("generated") | ||
: L10N.getStr("original"); | ||
const isOriginal = isOriginalId(selectedLocation.sourceId); | ||
const isPrettyTabOpen = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the idea of having an isPrettyPrinted
variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we will need both isOriginal and isPrettyPrinted. As they can be different.
src/components/Editor/EditorMenu.js
Outdated
|
||
const jumpLabel = { | ||
accesskey: L10N.getStr("editor.jumpToMappedLocation1.accesskey"), | ||
disabled: false, | ||
label: L10N.getFormatStr("editor.jumpToMappedLocation1", pairedType), | ||
disabled: isOriginal || hasSourceMap ? false : !isPrettyTabOpen, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use !isPrettyPrinted
here instead of !isPrettyTabOpen
then we won't need line 82??
did a rebase here: https://github.com/jasonLaster/debugger.html/tree/jainsneha23-bug-4420 sorry, i couldn't push to your branch |
I think this is good to go. Sorry for the delay on reviewing. I ended up doing some small tweaks to clean it up as it's super confusing |
Great |
… be disabled when not pretty-printed (firefox-devtools#4497) * Bug 4420 fix * tweaks
Associated Issue: #4420
Summary of Changes
Test Plan
Screenshots/Videos (OPTIONAL)