New console frontend: Add support for network event message #262
New console frontend: Add support for network event message #262
Conversation
@@ -140,7 +140,6 @@ a { | |||
} | |||
|
|||
.message-body > * { | |||
white-space: pre-wrap; |
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.
We want to be careful about changes to the CSS in this file. This gets applied to the old console as well.
You should be able to add overrides to the NEW CONSOLE OUTPUT section, and scope them using one of the new-console specific classes for now.
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'll move this part into NEW CONSOLE OUTPUT section :)
BTW, I don't know why white-space: pre-wrap;
doesn't seem to take effect to render a space after a method. Thus, I used this workaround to produce a space for new UI and it seems to work great.
I just downloaded this and tested it out. It looks really good! I'm going to do another pass through the code tomorrow morning, so I will likely have more specific comments. But I think this is basically doing everything right. |
@rickychien One thing that we will need for this is tests. You will probably need to add another stub generator in order to get the necessary stubs. That can be challenging, so let me know if you run into any problems with that. |
let Xhr = l10n.getStr("webConsoleXhrIndicator"); | ||
|
||
function onUrlClick(evt) { | ||
evt.preventDefault(); |
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.
This preventDefault
is required because we're using the a
tag for the URLs, right? We can probably just change the a
to a span
instead. In the current console, it doesn't seem like you can click on the link to navigate to the URL anyway, so there's no reason that I can see for it being an a
tag. @bgrins, what do you think?
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.
It's OK to go away from an <a>
tag if we do a <span>
with tabindex of 0: https://bugzilla.mozilla.org/show_bug.cgi?id=987373#c39. If it will require re-styling things we might consider waiting, but I'd be fine with making the change now
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 keep a
tag here but remove its href
? It seems to work for me after removing evt.preventDefault()
and also keep a
's underline and hover styling as it is.
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.
@bgrins the thing is, I don't think that we actually do want a tabindex if clicking on it does nothing... do we? In the current console, clicking on the link doesn't take you there, AFAICT.
@rickychien I don't think the styling matters too much. I believe the only styling that we might want is the underline, but I'm fine with leaving that out for now. If clicking on the link doesn't do anything, then a hover state is confusing anyway.
UPDATE: I realized I didn't have network panel turned on when I was testing this in old console.
@linclark |
"type": "log" | ||
})); | ||
|
||
stubPreparedMessages.set("undefined", new NetworkEventMessage({ |
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.
It looks like it's generating a stub with the key undefined
here. This probably means the event listener is getting two packets but only has one key.
@rickychien It's so awesome to see the test in here! Thanks for taking care of all that. A few minor issues, but once those are resolved I think this is ready. Once it's in, we can start on #196... would you be interested in taking on that issue? |
You're right, we probably can't ensure much for this in the unit tests. I'll create an issue to make sure that we have an end-to-end test for it. |
dom.span({ className: "method" }, method), | ||
isXHR ? dom.span({ className: "xhr" }, xhr) : null, | ||
dom.a({ className: "url", title: url, onClick: onUrlClick }, | ||
getURLDisplayString(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.
@linclark
Could you check the display url on webconsole? I followed you suggestion to use this API from reps and url string is limited by 50 characters. It looks weird to me.
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.
Ah, yeah. I'd say just keep it like you had it then.
Github's new pull request reviews looks pretty cool! @linclark Last issues has been addressed and I can't wait to see your PR approval. |
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.
Unfortunately there are still a few outstanding changes from the previous reviews. Once those are cleared up, this will be ready.
@@ -13,15 +13,20 @@ const ReactDOM = require("devtools/client/shared/vendor/react-dom"); | |||
const { connect } = require("devtools/client/shared/vendor/react-redux"); | |||
|
|||
const { getAllMessages, getAllMessagesUiById } = require("devtools/client/webconsole/new-console-output/selectors/messages"); | |||
const { getAllUi } = require("devtools/client/webconsole/new-console-output/selectors/ui"); |
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 believe this should have been removed when the currentLocation code was removed. This component is no longer using anything from the UI selector.
When we do implement the location stuff, the UI reducer/selector is probably not the best place for it. Instead, I'm thinking we'll probably want to create a part of the state tree that is just in charge of backend state.
sourceMapService: PropTypes.object, | ||
onViewSourceInDebugger: PropTypes.func.isRequired, | ||
openNetworkPanel: PropTypes.func.isRequired, | ||
openLink: PropTypes.func.isRequired, | ||
ui: PropTypes.object.isRequired, |
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.
Same as above.
onViewSourceInDebugger, | ||
openNetworkPanel, | ||
openLink, | ||
ui, |
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.
Same as above.
@@ -77,7 +87,8 @@ function isScrolledToBottom(outputNode, scrollNode) { | |||
function mapStateToProps(state) { | |||
return { | |||
messages: getAllMessages(state), | |||
messagesUi: getAllMessagesUiById(state) | |||
messagesUi: getAllMessagesUiById(state), | |||
ui: getAllUi(state), |
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.
Same as above.
@@ -8,15 +8,16 @@ const React = require("devtools/client/shared/vendor/react"); | |||
const ReactDOM = require("devtools/client/shared/vendor/react-dom"); | |||
const { Provider } = require("devtools/client/shared/vendor/react-redux"); | |||
|
|||
const actions = require("devtools/client/webconsole/new-console-output/actions/messages"); | |||
const messageActions = require("devtools/client/webconsole/new-console-output/actions/messages"); | |||
const uiActions = require("devtools/client/webconsole/new-console-output/actions/ui"); |
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.
Same as above (regarding UI selectors/reducers).
@@ -8,15 +8,16 @@ const React = require("devtools/client/shared/vendor/react"); | |||
const ReactDOM = require("devtools/client/shared/vendor/react-dom"); | |||
const { Provider } = require("devtools/client/shared/vendor/react-redux"); | |||
|
|||
const actions = require("devtools/client/webconsole/new-console-output/actions/messages"); | |||
const messageActions = require("devtools/client/webconsole/new-console-output/actions/messages"); |
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.
Message actions can be renamed to actions again.
isXHR: networkEvent.isXHR, | ||
request: networkEvent.request, | ||
response: networkEvent.response, | ||
source: MESSAGE_SOURCE.NETWORK, |
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.
When I said these could be hardcoded, I meant you could move them to the definition of NetworkEventMessage
in types.js
.
@rickychien agreed, the new review system is awesome! |
MozReview-Commit-ID: 6RcVt7BZFr2
Issues addressed again. @linclark thanks for your carefully review. |
This looks great. Thanks so much for taking the time on it. |
Fixes #195
Support for network event message