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

Share querystring logic with tabs & breakpoints sidebar #7206

Conversation

WenInCode
Copy link
Contributor

@WenInCode WenInCode commented Oct 31, 2018

Fixes #7159

Summary of Changes

  • Share query string logic with tabs
  • Share query string logic with breakpoints sidebar

Test Plan

  1. Open the test URL https://shimmer-ostrich.glitch.me/
  2. Open debugger.
  3. Reload the test URL.
  4. Open one of the script.js source and observe the query string appended to the name in the tab
  5. Add a debugger to the script.js and observe the query string appended to the name in the breakpoints sidebar

Mochitests

  • Add check for querystring in tab name to dbg-sources-querystring
  • Add check for querystring in breakpoints side bar in dbg-sources-querystring

Screenshots

screen shot 2018-11-04 at 4 45 44 pm

Questions/Thoughts

I considered moving https://github.com/wenincode/debugger.html/blob/7159-source-querystring-logic-tabs-sidebar/src/reducers/sources.js#L434-L449 into a separate utils because they aren't actual reducers and aren't actually being used by the reducer in this file. I think they are in here because the code is a bit tied to the OuterState type. I was going to move it and change the types to just be an array of sources to try and decouple it from this file, but the more I work with it the more I see why it is the way it is now. Just seemed a bit odd to have these functions in here.

For the adding logic to sidebar stuff I am thinking of moving [this code] into a sub-component. The reasoning being that I think I could leverage a similar mapStateToProps with OuterState approach as the other two areas. I am not entirely sure how that all works yet, still pretty new to redux land. I just don't currently see how I can get the right state to pass into those functions in the reducer without moving this code. Just wanted to capture my thoughts before I shut down for the night 😄

@@ -198,6 +204,7 @@ class Tab extends PureComponent<Props> {
/>
<div className="filename">
{getTruncatedFileName(source)}
{query}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The source tree item stuff has this in a span, but I wasn't sure if this needed to be. I think it looks better sans span in the tab, but I am open to feedback 😄

@@ -440,6 +440,14 @@ export function getSourcesUrlsInSources(state: OuterState, url: string) {
return [...new Set(Object.keys(urls).filter(Boolean))];
}

export function getHasSiblingOfSameName(state: OuterState, source: ?Source) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function is in the SourcesTree file, so I think we should move it somewhere in utils/source.js

Copy link
Contributor

@darkwing darkwing Oct 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, missed the change about it 🤕

@darkwing
Copy link
Contributor

This works great! 👍

The sub-component allows us to leverage the OuterState to see
if there are any siblings with matching names. Applied the same
querystring logic as Tab & SourceTreeItem
@WenInCode
Copy link
Contributor Author

I wanted to add a breakpoint to one of the files and assert that the query shows in the panel. I'm having issues getting the breakpoint to show up in the panel when adding it with the helpers.

diff --cc src/test/mochitest/browser_dbg-sources-querystring.js
index f381197a,f381197a..6b7067e8
--- a/src/test/mochitest/browser_dbg-sources-querystring.js
+++ b/src/test/mochitest/browser_dbg-sources-querystring.js
@@@ -33,4 -33,4 +33,7 @@@ add_task(async function()
    const activeSourceLabel = getLabel(dbg, 3);
    const tab = findElement(dbg, "activeTab");
    is(tab.innerText, activeSourceLabel, `Tab label is ${activeSourceLabel}`);
++
++  await addBreakpoint(dbg, activeSourceLabel, 4, 0);
++  await waitForever();
  });

@darkwing
Copy link
Contributor

darkwing commented Nov 5, 2018

Hello @WenInCode! It took me a while to track down but try this:

// Select the source so that the breakpoint displays in sidebar
  const source = findSource(dbg, "simple1.js?x=1");
  await selectSource(dbg, source);
  await addBreakpoint(dbg, "simple1.js?x=1", 6);
  await waitForever();

@WenInCode WenInCode changed the title [wip] Share querystring logic with tabs & breakpoints sidebar Share querystring logic with tabs & breakpoints sidebar Nov 6, 2018
@WenInCode
Copy link
Contributor Author

@darkwing that makes a lot of sense 😂 thanks! I also didn't realize you could just use selectSource with the name of the source. I've added the test for the BreakpointHeading.

I am going to start looking more into getting the project search to work with params again. That work can either land in this, or separate, whatever works best 👍

Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work so far @WenInCode ! Only one quick thing to look at:

longquerystrings

We need to ensure truncation occurs within tabs and sidebar. The tabs already use a truncate function, so you simply need to concat the filename add the querystring before using the function there.

For the sidebar, we need to (1) remove the space between the querystring and the filename, and then ensure we use text-overflow: ellipsis

@WenInCode
Copy link
Contributor Author

@darkwing I truncated the long file names 👍 I also noticed that the title attributes for the heading and the tab were not consistent. The heading showed the entire file url, whereas the tab showed a truncated portion which ended up just being part of the query. I updated them to be consistent. Let me know if you think it should be different 😄

New:
screen shot 2018-11-06 at 8 50 21 pm
screen shot 2018-11-06 at 8 50 07 pm

Old:
screen shot 2018-11-06 at 8 51 38 pm

@darkwing darkwing merged commit a485600 into firefox-devtools:master Nov 13, 2018
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.

2 participants