Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

New console frontend: Add support for network event message #262

Merged
merged 2 commits into from Sep 15, 2016
Merged

New console frontend: Add support for network event message #262

merged 2 commits into from Sep 15, 2016

Conversation

rickychien
Copy link

@rickychien rickychien commented Sep 8, 2016

Fixes #195

Support for network event message

  • Method
  • XHR
  • URL
  • click URL and link to Network Panel
  • Partial support for network status (it will be fully supported in NetworkUpdateMessage)

@@ -140,7 +140,6 @@ a {
}

.message-body > * {
white-space: pre-wrap;
Copy link

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.

Copy link
Author

@rickychien rickychien Sep 9, 2016

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.

@linclark
Copy link

linclark commented Sep 8, 2016

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.

@linclark
Copy link

linclark commented Sep 8, 2016

@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();
Copy link

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?

Copy link

@bgrins bgrins Sep 9, 2016

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

Copy link
Author

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.

Copy link

@linclark linclark Sep 12, 2016

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.

@rickychien
Copy link
Author

@linclark
Do you think it makes sense to simulate("click") to test for a url clicking? Since behavior of url clicking is pretty simple and I'm not sure what things we're able to ensure for this.

"type": "log"
}));

stubPreparedMessages.set("undefined", new NetworkEventMessage({

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.

@linclark
Copy link

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

@linclark
Copy link

Do you think it makes sense to simulate("click") to test for a url clicking? Since behavior of url clicking is pretty simple and I'm not sure what things we're able to ensure for this.

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)),
Copy link
Author

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.

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.

@rickychien
Copy link
Author

rickychien commented Sep 15, 2016

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.

Copy link

@linclark linclark left a 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");
Copy link

@linclark linclark Sep 15, 2016

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,

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,

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),

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");
Copy link

@linclark linclark Sep 15, 2016

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");

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,

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.

@linclark
Copy link

@rickychien agreed, the new review system is awesome!

@rickychien
Copy link
Author

Issues addressed again. @linclark thanks for your carefully review.

@linclark
Copy link

This looks great. Thanks so much for taking the time on it.

@linclark linclark merged commit 9000dbc into firefox-devtools:console-frontend Sep 15, 2016
@rickychien rickychien deleted the network-event-messages branch September 16, 2016 02:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants