Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1465987 - Convert the BugFiler to ReactJS #3878

Merged
merged 2 commits into from Aug 6, 2018
Merged

Conversation

camd
Copy link
Contributor

@camd camd commented Aug 3, 2018

Bug 1465987

This is a straight over conversion. I had to re-write quite a bit of the BugFiler but tried to keep at least some of the structure of functions the same.

A big chunk of this change is the tests. I had to modify them to from Angular to React, of course, but the content of what they test didn't change. Still the same input and expected outputs. The only new test is the last one. So you can largely skip reviewing them in detail, if you like. :)

Testing

This calls to the Treeherder API which then, in turn, POSTs to the bug to bugzilla. So to test, I stubbed out the back-end to just print out the payload JSON that would be sent to BZ. Then I created a bug with the original code and then this new code and compared the payloads to ensure they were identical.

@@ -144,7 +144,7 @@ export default class ErrorLine extends React.Component {
*/
onOptionChange(option) {
this.initOption(option);
this.setState({ selectedOption: option });
Copy link
Contributor Author

@camd camd Aug 3, 2018

Choose a reason for hiding this comment

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

This makes it so that the new bug # that comes back from the BugFiler gets added to the manual bug input field in autoclassify.

This was actually an older bug I'd missed. When setting state, you need to set it to a new Object not just the same object that had a field modified, as we did in this case. So doing the spread remedies that.

@camd
Copy link
Contributor Author

camd commented Aug 3, 2018

@sarah-clements : Since Ed's on PTO, you're the only one on board to review this. Sorry it's another whopper, but it's fairly contained. This functionality is only available in two places:

  1. When a failed job is selected, there is a little "Bug" icon that you can click to pull up this dialog next to each failed line.
  2. In the AutoclassifyTab there's a button that looks the same. But to enable that tab, you have to add &autoclassify to the url and reload the page. Then when you select a failure, you'll see the new tab.

To be honest, since the AutoclassifyTab is disabled by default and no one is using it, you don't need to worry about it too much. When we decide to re-enable it in some capacity after more of George's work (we may do away with it altogether and incorporate his work into the normal Failure Summary tab anyway...) then we'll go through the UI with more pointed testing. But your call there.

name="modalProductFinderSearch"
id="modalProductFinderSearch"
onKeyDown={this.productSearchEnter}
onChange={evt => this.setState({ productSearch: evt.target.value })}
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought calling setState in render was problematic due to the state/render cycle? Is that not the case if its in-lined in jsx? (seems to work fine when testing)

line-height: 16px;
}

#suggestedProducts {
Copy link
Contributor

Choose a reason for hiding this comment

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

These margin attributes seem quite precise, but I wonder if you couldn't use some of the bootstrap utility spacing classes for some or if it'd be worth making them into general spacing classes for future modals and forms to use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is a really good point. I spent some time laying this out with just the bootstrap classes. Very educational. :) But I eliminated most of the CSS file in the process.

Copy link
Contributor

@sarah-clements sarah-clements left a comment

Choose a reason for hiding this comment

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

I tested the modal/form (only from the Failure Summary tab) locally and it looks and works well.

@camd camd merged commit ed2e800 into master Aug 6, 2018
@camd camd deleted the bugfiler-to-react branch August 6, 2018 17:54
@@ -133,3 +133,9 @@ export const getRepoUrl = function getRepoUrl(newRepoName) {
params.set('repo', newRepoName);
return `${uiJobsUrlBase}?${params.toString()}`;
};

export const bzBaseUrl = 'https://bugzilla.mozilla.org/';
Copy link
Contributor

Choose a reason for hiding this comment

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

The existing bugzilla.mozilla.org instances in this file can be switched to use this at some point (perhaps after some more of the react changes land, we can have a cleanup of the helpers since we'll have a better idea of what's used?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm certain a good audit/cleanup will be in order on the helpers after all this. We're getting close! :) I wish there was a better name than helpers. I almost prefer lib but not really sure. Still kind of meaninglessly generic... Names are hard..

// submit the new bug. Only request the versions because some products
// take quite a long time to fetch the full object
try {
const productResp = await fetch(`${bzBaseUrl}rest/product/${product}?include_fields=versions`);
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 could use bugzillaBugsApi() from url helpers

suggestions={[errorLine.data.bug_suggestions]}
fullLog={logUrl}
parsedLog={`${location.origin}/${getLogViewerUrl(job.id, repoName)}`}
reftestUrl={isReftest(job) ? `${getReftestUrl(logUrl)}&only_show_unexpected=1` : ''}
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 the &only_show_unexpected=1 should be moved into getReftestUrl() (since it's duplicated at several of the getReftestUrl() callsites)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh, ends up that param was already in the helper. So these were adding it twice. Just had to remove them.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe "utils" or else just put them in "shared"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants