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

#4420 Context Menu "Jump to Original Location" should be disabled when not pretty-printed #4497

Merged
merged 2 commits into from
Nov 9, 2017

Conversation

jainsneha23
Copy link
Contributor

Associated Issue: #4420

Summary of Changes

  • Get if selected source is pretty-printed. If yes, disable "Reveal in tree" and "Blackbox script"
  • Get open tabs list. Get pretty url for the selected source. If pretty tab is open, disable "Jump to Original Location"

Test Plan

  • Open a tab, "Jump to Original Location" is disabled
  • Click on pretty print in the footer
  • "Jump to Original Location" is enabled
  • Go to the pretty printed tab
  • "Reveal in tree" and "Blackbox script" are disabled

Screenshots/Videos (OPTIONAL)

Copy link
Contributor

@jasonLaster jasonLaster left a 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!


const jumpLabel = {
accesskey: L10N.getStr("editor.jumpToMappedLocation1.accesskey"),
disabled: false,
label: L10N.getFormatStr("editor.jumpToMappedLocation1", pairedType),
disabled: isGenerated ? false : !isPrettyTabOpen,
Copy link
Contributor

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...

@@ -96,7 +103,7 @@ function getMenuItems(
id: "node-menu-blackbox",
label: toggleBlackBoxLabel,
accesskey: blackboxKey,
disabled: false,
disabled: isGenerated,
Copy link
Contributor

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...

@jainsneha23
Copy link
Contributor Author

@jasonLaster
The spec for this is:

jumpLabel = {
  isOriginal ? false : !isPrettyTabOpen
}

If the file opened is pretty printed(i.e. isOriginal), u will see "jump to generated location" always
Else if its generated, "Jump to Original Location" will be disabled if "!isPrettyTabOpen". As if its not pretty printed, you cannot jump to the original location

const blackBoxMenuItem = { disabled: isOriginal };
"Blackbox source" and "Reveal in tree" are also disabled for pretty printed (i.e, original source)

const pairedType = isOriginalId(selectedLocation.sourceId)
? L10N.getStr("generated")
: L10N.getStr("original");
const isOriginal = isOriginalId(selectedLocation.sourceId);
Copy link
Contributor Author

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 ?

? L10N.getStr("generated")
: L10N.getStr("original");
const isOriginal = isOriginalId(selectedLocation.sourceId);
const isPrettyTabOpen =
Copy link
Contributor Author

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)
};
Copy link
Contributor Author

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

@@ -96,7 +102,7 @@ function getMenuItems(
id: "node-menu-blackbox",
label: toggleBlackBoxLabel,
accesskey: blackboxKey,
disabled: false,
disabled: isOriginal,
click: () => toggleBlackBox(selectedSource.toJS())
Copy link
Contributor Author

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)

@jasonLaster
Copy link
Contributor

Hey @jainsneha23 lets discuss O/G here:

https://github.com/devtools-html/debugger.html/pull/4512/files?short_path=c474cab#diff-c474cab07b2dd9f949f47376f7d47fd2

i'm still a bit confused about how you're using the term... we might also be inconsistent in the app

@jainsneha23
Copy link
Contributor Author

@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.

@jasonLaster
Copy link
Contributor

jasonLaster commented Oct 28, 2017

^ haha - let me check to see what is going on in the debugger. the docs were my assumptions

@jasonLaster
Copy link
Contributor

jasonLaster commented Oct 30, 2017

I just looked into it and found that the pretty source is in fact the original source. Super confusing :P

appStore.getState().sources.sources.valueSeq().toJS()
  .filter(s => s.url && s.url.includes("local"))
  .map(({id, url}) => ({id, url}))

screen shot 2017-10-30 at 9 23 09 am

@jainsneha23
Copy link
Contributor Author

So, if the pretty source is original , the terminology being used right now is correct. Then the code can is ready to review?

: L10N.getStr("original");
const isOriginal = isOriginalId(selectedLocation.sourceId);
const isPrettyTabOpen =
!isOriginal && tabs.includes(getPrettySourceURL(selectedSource.get("url")));
Copy link
Contributor

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

@@ -96,7 +102,7 @@ function getMenuItems(
id: "node-menu-blackbox",
label: toggleBlackBoxLabel,
accesskey: blackboxKey,
disabled: false,
disabled: isOriginal,
click: () => toggleBlackBox(selectedSource.toJS())
Copy link
Contributor

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

@@ -107,7 +113,7 @@ function getMenuItems(
id: "node-menu-show-source",
label: revealInTreeLabel,
accesskey: revealInTreeKey,
disabled: false,
disabled: isOriginal,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -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,
Copy link
Contributor

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

? L10N.getStr("generated")
: L10N.getStr("original");
const isOriginal = isOriginalId(selectedLocation.sourceId);
const isPrettyTabOpen =
Copy link
Contributor

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

Copy link
Contributor Author

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.


const jumpLabel = {
accesskey: L10N.getStr("editor.jumpToMappedLocation1.accesskey"),
disabled: false,
label: L10N.getFormatStr("editor.jumpToMappedLocation1", pairedType),
disabled: isOriginal || hasSourceMap ? false : !isPrettyTabOpen,
Copy link
Contributor

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??

@jasonLaster
Copy link
Contributor

did a rebase here: https://github.com/jasonLaster/debugger.html/tree/jainsneha23-bug-4420

sorry, i couldn't push to your branch

@jasonLaster
Copy link
Contributor

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

@jasonLaster jasonLaster merged commit 26e1b1d into firefox-devtools:master Nov 9, 2017
@jainsneha23
Copy link
Contributor Author

Great

khal0988 pushed a commit to khal0988/debugger.html that referenced this pull request Nov 12, 2017
… be disabled when not pretty-printed (firefox-devtools#4497)

* Bug 4420 fix

* tweaks
@jainsneha23 jainsneha23 deleted the bug-4420 branch November 12, 2017 13:35
@jasonLaster
Copy link
Contributor

screen shot 2017-11-14 at 11 16 09 am

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants