Skip to content

Commit

Permalink
Merge pull request #141 from wlach/1059280
Browse files Browse the repository at this point in the history
Bug 1059280 - Loop around when cycling between jobs with 'n' and 'p'
  • Loading branch information
jeads committed Aug 29, 2014
2 parents d2af5b5 + 1f7c8df commit daa8aff
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions ui/js/directives/clonejobs.js
Expand Up @@ -813,6 +813,8 @@ treeherder.directive('thCloneJobs', [

var resultsets = ThResultSetModel.getResultSetsArray($rootScope.repoName);

var firstJob = null;
var foundJob = false;
var startWatch = false;
if(_.isEmpty(currentJob)){
startWatch = true;
Expand Down Expand Up @@ -841,29 +843,37 @@ treeherder.directive('thCloneJobs', [
continue;
}

if(startWatch){
if(startWatch || !firstJob){
if( (jobs[j].visible === true) &&
(classificationRequired[jobs[j].result] === 1) &&
( (parseInt(jobs[j].failure_classification_id, 10) === 1) ||
(jobs[j].failure_classification_id === null) )){

selectJob(jobs[j]);

//Next test failure found
break superloop;

if (startWatch) {
foundJob = true;
selectJob(jobs[j]);
return;
} else {
firstJob = jobs[j];
}
}
}
}
}
}
}

if (!foundJob && firstJob) {
// we were at the last job, start again from the beginning
selectJob(firstJob);
}
};

var getPreviousUnclassifiedFailure = function(currentJob){

var resultsets = ThResultSetModel.getResultSetsArray($rootScope.repoName);

var foundJob = false;
var lastJob = null;
var startWatch = false;
if(_.isEmpty(currentJob)){
startWatch = true;
Expand All @@ -885,29 +895,34 @@ treeherder.directive('thCloneJobs', [
jobs = groups[g].jobs;
var j;
for(j = jobs.length - 1; j >= 0; j--){

if(currentJob.id === jobs[j].id){

//This is the current selection, get the next
startWatch = true;
continue;
}
if(startWatch){
if(startWatch || !lastJob){
if( (jobs[j].visible === true) &&
(classificationRequired[jobs[j].result] === 1) &&
( (parseInt(jobs[j].failure_classification_id, 10) === 1) ||
(jobs[j].failure_classification_id === null) )){

selectJob(jobs[j]);

//Previous test failure found
break superloop;
if (startWatch) {
selectJob(jobs[j]);
return;
} else {
lastJob = jobs[j];
}
}
}
}
}
}
}
if (!foundJob && lastJob) {
// we were at the first job, go to the very end
selectJob(lastJob);
}
};

var scrollToElement = function(el){
Expand Down

0 comments on commit daa8aff

Please sign in to comment.