Skip to content

Commit

Permalink
params page: add link for go to upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
liying2008 committed Dec 9, 2019
1 parent ab68803 commit d6195de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
31 changes: 30 additions & 1 deletion js/params.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,17 @@ new Vue({
var causes = actions[i].causes;
for (var cIndex = 0; cIndex < causes.length; cIndex++) {
var shortDescription = causes[cIndex].shortDescription;
_self.causes.push(shortDescription)
var upstreamUrl = '';
if (causes[cIndex].upstreamUrl && causes[cIndex].upstreamBuild) {
var rootUrl = _self.getJenkinsRootUrl(data.url, data.fullDisplayName);
if (rootUrl) {
upstreamUrl = rootUrl + '/' + causes[cIndex].upstreamUrl + causes[cIndex].upstreamBuild + '/'
}
}
_self.causes.push({
shortDescription: shortDescription,
url: upstreamUrl
})
}
}
}
Expand Down Expand Up @@ -222,5 +232,24 @@ new Vue({
console.log('window', window)
})
},
getJenkinsRootUrl(url, fullDisplayName) {
if (url[url.length - 1] === '/') {
url = url.substring(0, url.length - 1);
}
fullDisplayName = encodeURIComponent(fullDisplayName);
// %20%C2%BB%20: »
// %20%23: #
var path = fullDisplayName.replace('%20%C2%BB%20', '/job/').replace('%20%23', '/');
path = '/job/' + path;
var index = url.lastIndexOf(path);
if (index > 0) {
var rootUrl = url.substring(0, index);
console.log('rootUrl', rootUrl);
return rootUrl
} else {
console.log('error: url:', url, 'fullDisplayName', fullDisplayName, 'path:', path);
return ''
}
},
}
});
5 changes: 4 additions & 1 deletion params.html
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@
<!--Build Causes-->
<div class="row" v-for="cause in causes" style="margin-top: 10px">
<div class="col-xs-12"><i class="glyphicon glyphicon-flash" title="Build Cause"></i>
<span style="margin-left: 8px">{{cause}}</span></div>
<span style="margin-left: 8px">{{cause.shortDescription}}</span>
<a :href="cause.url" target="_blank" style="margin-left: 6px;" v-if="cause.url">
<i class="glyphicon glyphicon-circle-arrow-right" title="Go"></i></a>
</div>
</div>
</div>
</li>
Expand Down

0 comments on commit d6195de

Please sign in to comment.