Skip to content

Commit

Permalink
Bug 1438410 - Fix filing with bugfiler from Failure Summary tab
Browse files Browse the repository at this point in the history
This was using an angular $timeout in the thPinboard service addBug
function.  That caused the value to not be persisted.  Moved the $timeout
to the ReactJS failure_summary_panel since that's where it's needed.
  • Loading branch information
Cameron Dawson committed Feb 27, 2018
1 parent 9e56a35 commit ac12ac0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
22 changes: 8 additions & 14 deletions ui/js/services/pinboard.js
@@ -1,8 +1,8 @@
treeherder.factory('thPinboard', [
'ThJobClassificationModel', '$rootScope', 'thEvents', '$timeout',
'ThJobClassificationModel', '$rootScope', 'thEvents',
'ThBugJobMapModel', 'thNotify', 'ThModelErrors', 'ThResultSetStore', 'thPinboardCountError',
function (
ThJobClassificationModel, $rootScope, thEvents, $timeout,
ThJobClassificationModel, $rootScope, thEvents,
ThBugJobMapModel, thNotify, ThModelErrors, ThResultSetStore, thPinboardCountError) {

var pinnedJobs = {};
Expand Down Expand Up @@ -33,7 +33,7 @@ treeherder.factory('thPinboard', [
};

var saveBugs = function (job) {
Object.entries(relatedBugs).forEach(function ([, bug]) {
Object.values(relatedBugs).forEach(function (bug) {
var bjm = new ThBugJobMapModel({
bug_id: bug.id,
job_id: job.id,
Expand Down Expand Up @@ -92,18 +92,12 @@ treeherder.factory('thPinboard', [
},

addBug: (bug, job) => {
// If this was invoked from ReactJS, then Angular's watch cycle
// won't be invoked and the UI won't update right away. Use
// $timeout to kick it off.
$timeout(() => {
relatedBugs[bug.id] = bug;
api.count.numRelatedBugs = _.size(relatedBugs);

if (job) {
api.pinJob(job);
}
});
relatedBugs[bug.id] = bug;
api.count.numRelatedBugs = _.size(relatedBugs);

if (job) {
api.pinJob(job);
}
},

removeBug: function (id) {
Expand Down
6 changes: 5 additions & 1 deletion ui/plugins/failure_summary_panel.jsx
Expand Up @@ -46,6 +46,7 @@ class SuggestionsListItem extends React.Component {
getBugUrl={this.props.getBugUrl} pinboardService={this.props.pinboardService}
escapeHTMLFilter={this.props.escapeHTMLFilter} suggestion={this.props.suggestion}
highlightCommonTermsFilter={this.props.highlightCommonTermsFilter}
$timeout={this.props.$timeout}
/>))}

</ul>}
Expand Down Expand Up @@ -90,7 +91,8 @@ const ListItem = props => (

const BugListItem = (props) => {
const pinboardServiceEvent = () => {
props.pinboardService.addBug(props.bug, props.selectedJob);
const { bug, selectedJob, pinboardService, $timeout } = props;
$timeout(() => (pinboardService.addBug(bug, selectedJob)));
};

const getBugUrl = props.getBugUrl(props.bug.id);
Expand Down Expand Up @@ -140,6 +142,7 @@ class FailureSummaryPanel extends React.Component {
render() {
const escapeHTMLFilter = this.props.$injector.get('$filter')('escapeHTML');
const highlightCommonTermsFilter = this.props.$injector.get('$filter')('highlightCommonTerms');
const $timeout = this.props.$injector.get('$timeout');

return (
<ul className="list-unstyled failure-summary-list">
Expand All @@ -151,6 +154,7 @@ class FailureSummaryPanel extends React.Component {
escapeHTMLFilter={escapeHTMLFilter} getBugUrl={this.props.getBugUrl}
bugLimit={this.props.bugLimit} pinboardService={this.props.pinboardService}
selectedJob={this.props.selectedJob}
$timeout={$timeout}
/>))}

{this.props.errors && this.props.errors.length > 0 &&
Expand Down

0 comments on commit ac12ac0

Please sign in to comment.