Skip to content

Commit 745905e

Browse files
committed
Display plugin source URL when hovering the source badge
Change-Id: Ie9e9f99229d20fa6b9630fd067a30e73646e1d15
1 parent 4c0ebcf commit 745905e

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

jenkins-docker/server/plugin-manager/css/style.css

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,3 +72,17 @@ span.text-bg-primary {
7272
background-color: RGBA(13, 110, 253, 1);
7373
color: #fff!important;
7474
}
75+
76+
div.repo-status-popup {
77+
position: absolute;
78+
z-index: 9999;
79+
padding:8px;
80+
border-radius: 4px;
81+
background: white;
82+
box-shadow: 0 2px 8px 0 rgba(195, 195, 195, 0.12);
83+
border: 1px solid #cfd8e0;
84+
}
85+
86+
.plugin-heading {
87+
position: relative;
88+
}

jenkins-docker/server/plugin-manager/index.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,21 @@
5959
</thead>
6060
<tbody>
6161
<tr ng-repeat="prop in plugins.list | filter:searchPlugin">
62-
<td><h4>{{prop.id}} <span class="badge {{prop.css}}">{{prop.source}}</span><br/><small>{{prop.description.split('.')[0]}}</small></h4></td>
62+
<td>
63+
<h4 class="plugin-heading">
64+
{{prop.id}}
65+
<span
66+
ng-mouseover="showRepoStatus($event, prop.id, prop.jobUrl)"
67+
ng-mouseout="hideRepoStatus(prop.id)"
68+
class="badge {{prop.css}}">{{prop.source}}
69+
<div id="repo-status-popup-{{prop.id}}" style="display: none;" class="repo-status-popup">
70+
<a id="repo-status-popup-a-{{prop.id}}" target="_blank">Source Code</a>
71+
</div>
72+
</span>
73+
<br/>
74+
<small>{{prop.description.split('.')[0]}}</small>
75+
</h4>
76+
</td>
6377
<td>
6478
<p>{{prop.version}}</p>
6579
<div ng-if="prop.update_version">

jenkins-docker/server/plugin-manager/js/plugin-manager.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ var app = angular.module('PluginManager', []).controller(
8181
currPlugin.sha1 = plugin.sha1;
8282
var uiPluginRegex = /(ui-plugin-)(.*)-bazel.*/;
8383
var fileEnding = plugin.name.match(uiPluginRegex) ? '.js' : '.jar';
84+
currPlugin.jobUrl = $scope.getBaseUrl() + '/job/' + plugin.name;
8485
currPlugin.url = $scope.getBaseUrl() + '/job/' + plugin.name + '/lastSuccessfulBuild/artifact/bazel-bin/plugins/' + pluginName + '/' + pluginName + fileEnding;
8586
currPlugin.description = pluginResponse.data.description;
8687
currPlugin.source = source;
@@ -98,13 +99,49 @@ var app = angular.module('PluginManager', []).controller(
9899
});
99100
});
100101
}, function errorCallback(response) {
102+
console.error('Failed to fetch plugin build data for ' + pluginId, response);
101103
});
102104
}
103105

104106
plugins.login = function () {
105107
$window.location.href = 'https://gerrit-ci.gerritforge.com/securityRealm/commenceLogin?from=%2F';
106108
};
107109

110+
$scope.showRepoStatus = function(e, pluginId, pluginJobUrl) {
111+
setTimeout(function() {
112+
$http.get(pluginJobUrl + '/lastSuccessfulBuild/api/json', plugins.httpConfig)
113+
.then(
114+
function successCallback(response) {
115+
var repoStatusPopup = document.getElementById('repo-status-popup-' + pluginId);
116+
var repoStatusPopupAnchor = document.getElementById('repo-status-popup-a-' + pluginId);
117+
if (!repoStatusPopup) return;
118+
119+
var scmAction = response.data.actions.filter(function(action) {
120+
return action._class == "hudson.plugins.git.util.BuildData";
121+
});
122+
if (!scmAction || scmAction.length == 0) return;
123+
124+
var sourceUrl = scmAction[0].remoteUrls.filter(function(url) {
125+
return url.indexOf("gerrit.googlesource.com/a/gerrit") === -1;
126+
});
127+
if (!sourceUrl || sourceUrl.length == 0) return;
128+
129+
repoStatusPopup.style.display = 'block';
130+
repoStatusPopupAnchor.href = sourceUrl[0].replace("/a", "");
131+
}, function errorCallback(response) {}
132+
);
133+
}, 500);
134+
};
135+
136+
$scope.hideRepoStatus = function(pluginId) {
137+
var repoStatusPopup = document.getElementById('repo-status-popup-' + pluginId);
138+
if (repoStatusPopup) {
139+
setTimeout(function() {
140+
repoStatusPopup.style.display = 'none';
141+
}, 1000);
142+
}
143+
};
144+
108145
$scope.refreshAvailable();
109146
});
110147

0 commit comments

Comments
 (0)