diff --git a/extension/chrome/src/js/stash_page.js b/extension/chrome/src/js/stash_page.js
index 63fe665..ae6a93e 100644
--- a/extension/chrome/src/js/stash_page.js
+++ b/extension/chrome/src/js/stash_page.js
@@ -1542,52 +1542,11 @@
}
});
- define('bitbucket-plugin/pullrequest-list-page', [
- 'aui',
- 'aui/flag',
- 'jquery',
- 'lodash',
- 'bitbucket/util/events',
- 'bitbucket/util/server',
- 'bitbucket/util/state',
- 'bitbucket/util/navbuilder',
- 'bitbucket/internal/feature/pull-request/pull-request-table',
- 'bitbucket/internal/widget/searchable-multi-selector',
- 'bitbucket/internal/feature/user/user-multi-selector',
- 'bitbucket/internal/widget/avatar-list',
- 'bitbucket/internal/feature/repository/branch-selector',
- 'bitbucket/internal/model/revision-reference'
- ], function (
- AJS,
- auiFlag,
- jQuery,
- _,
- events,
- ajax,
- pageState,
- nav,
- PullRequestsTable,
- SearchableMultiSelector,
- UserMultiSelector,
- avatarList,
- BranchSelector,
- revisionReference
- ) {
+ define('bitbucket-plugin/pullrequest-list-modifier', [
+ 'bitbucket/internal/feature/pull-request/pull-request-table'
+ ], function(PullRequestsTable) {
'use strict';
- //////////////////////////////////////////////////// Add filter to Pull Request list
- // utilities
- function getParameterByName(name) {
- name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
- var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
- results = regex.exec(location.search);
- return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
- }
-
- function addPrFilters() {
- if(jQuery('#pull-requests-content').length === 0) {
- return;
- }
- jQuery('.spinner').show();
+ function redefinePullRequestTable() {
//redefined filter builder to include new parameters
PullRequestsTable.prototype.buildUrl = function (start, limit) {
var self = this;
@@ -1665,6 +1624,156 @@
return builder.build();
};
+ var originalRowHandler = PullRequestsTable.prototype.handleNewRows
+ PullRequestsTable.prototype.handleNewRows = function (data, attachmentMethod) {
+ var self = this;
+ originalRowHandler.call(self, data, attachmentMethod);
+ var commitList = data.values.map(function(pr) {
+ return { commit: pr.fromRef.latestCommit, prId: pr.id }
+ });
+
+ getPRBuildStatus(commitList).done(function(buildDetails){
+ // add build column
+ if(self.$table.find('th.build-status-pr-list-col').length == 0) {
+ var $buildCol = jQuery('
', {
+ class: "build-status-pr-list-col",
+ title: 'Builds',
+ scope: 'col',
+ style: "display: table-cell;",
+ text: 'Builds'
+ });
+ self.$table.find('tr:first').append($buildCol);
+ }
+
+ var rows = self.$table.find('tr.pull-request-row');
+ rows.each(function(_index, row){
+ var $row = jQuery(row);
+ if($row.find('.build-status-pr-list-col-value').length == 0) {
+ var $buildCell = jQuery(' | ', { class: "build-status-pr-list-col-value" });
+ $buildCell.data('pullrequestid', $row.data('pullrequestid'));
+ $row.append($buildCell);
+ }
+ });
+
+ // add data to build cell
+ var rows = self.$table.find('tr.pull-request-row');
+ buildDetails.forEach(function(buildStatus) {
+ // find row and add build status
+ var cells = jQuery('td.build-status-pr-list-col-value');
+ var cell = cells.filter(function(_, td) { return jQuery(td).data('pullrequestid') == buildStatus.prId });
+ if(cell) {
+ var $buildInfoLink = jQuery('', {
+ href:"#",
+ class:"aui-icon aui-icon-small build-icon",
+ 'data-commit-id': buildStatus.commit
+ });
+
+ var appendIcon = false;
+ if(buildStatus.inProgress) {
+ $buildInfoLink.data('data-build-status', 'INPROGRESS');
+ $buildInfoLink.attr('title', buildStatus.inProgress + ' builds in progress');
+ $buildInfoLink.addClass('aui-iconfont-time');
+ $buildInfoLink.addClass('inprogress-build-icon');
+ appendIcon = true;
+ } else if(buildStatus.failed) {
+ $buildInfoLink.data('data-build-status', 'FAILED');
+ $buildInfoLink.attr('title', buildStatus.failed + ' builds failed');
+ $buildInfoLink.addClass('aui-iconfont-error');
+ $buildInfoLink.addClass('failed-build-icon');
+ appendIcon = true;
+ } else if(buildStatus.successful > 0) {
+ $buildInfoLink.data('data-build-status', 'SUCCESSFUL');
+ $buildInfoLink.attr('title', buildStatus.successful + ' builds passed');
+ $buildInfoLink.addClass('aui-iconfont-approve');
+ $buildInfoLink.addClass('successful-build-icon');
+ appendIcon = true;
+ }
+
+ if(appendIcon) {
+ cell.html($buildInfoLink);
+ $buildInfoLink.tooltip();
+ }
+ }
+ });
+ });
+ };
+ }
+
+ function getPRBuildStatus(commitList) {
+ var commitIds = commitList.map(function(pr) { return pr.commit });
+ return jQuery.ajax('/rest/build-status/latest/commits/stats', {
+ method: 'POST',
+ headers: {
+ Accept : "application/json, text/javascript, */*;",
+ "Content-Type": "application/json"
+ },
+ data: JSON.stringify(commitIds),
+ dataType: 'json'
+ })
+ .then(function(data) {
+ jQuery.each(data, function(commitId, info){
+ var commit = commitList.filter(function(cl) { return cl.commit === commitId });
+ if(commit.length > 0) {
+ jQuery.extend(commit[0], info);
+ }
+ });
+
+ return commitList;
+ });
+ }
+
+ return {
+ redefinePullRequestTable: redefinePullRequestTable
+ }
+ });
+
+ define('bitbucket-plugin/pullrequest-list-page', [
+ 'aui',
+ 'aui/flag',
+ 'jquery',
+ 'lodash',
+ 'bitbucket/util/events',
+ 'bitbucket/util/server',
+ 'bitbucket/util/state',
+ 'bitbucket/util/navbuilder',
+ 'bitbucket/internal/feature/pull-request/pull-request-table',
+ 'bitbucket/internal/widget/searchable-multi-selector',
+ 'bitbucket/internal/feature/user/user-multi-selector',
+ 'bitbucket/internal/widget/avatar-list',
+ 'bitbucket/internal/feature/repository/branch-selector',
+ 'bitbucket/internal/model/revision-reference'
+ ], function (
+ AJS,
+ auiFlag,
+ jQuery,
+ _,
+ events,
+ ajax,
+ pageState,
+ nav,
+ PullRequestsTable,
+ SearchableMultiSelector,
+ UserMultiSelector,
+ avatarList,
+ BranchSelector,
+ revisionReference
+ ) {
+ 'use strict';
+ //////////////////////////////////////////////////// Add filter to Pull Request list
+ // utilities
+ function getParameterByName(name) {
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
+ var regex = new RegExp("[\\?&]" + name + "=([^]*)"),
+ results = regex.exec(location.search);
+ return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
+ }
+
+ function addPrFilters() {
+ if(jQuery('#pull-requests-content').length === 0) {
+ return;
+ }
+ jQuery('.spinner').show();
+
function getPullRequestsUrlBuilder(state) {
return nav.rest().currentRepo().allPullRequests().withParams({ state: state });
}
@@ -1901,6 +2010,7 @@
var pageState;
var loadRequirement = jQuery.Deferred();
var loadAuiFlag = jQuery.Deferred();
+ var loadPrRequirement = jQuery.Deferred();
try {
WRM.require("wr!" + 'com.atlassian.auiplugin:aui-flag').then(function(d) {
@@ -1928,7 +2038,20 @@
}
}
- jQuery.when(loadRequirement, loadAuiFlag).done(function(){
+ // improve PR page
+ try {
+ WRM.require("wr!" + 'com.atlassian.bitbucket.server.bitbucket-web:pull-request-table').then(function(){
+ require(['bitbucket-plugin/pullrequest-list-modifier'], function(prListModifier) {
+ prListModifier.redefinePullRequestTable();
+ loadPrRequirement.resolve();
+ });
+ });
+ }
+ catch (_) {
+ loadPrRequirement.resolve();
+ }
+
+ jQuery.when(loadRequirement, loadAuiFlag, loadPrRequirement).done(function(){
var user = pageState.getCurrentUser();
var project = pageState.getProject();
var repository = pageState.getRepository();
diff --git a/extension/chrome/src/manifest.json b/extension/chrome/src/manifest.json
index a400146..0c490d5 100644
--- a/extension/chrome/src/manifest.json
+++ b/extension/chrome/src/manifest.json
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Bitbucket Server Extension",
"description": "Allow to add group of reviewers for pull request in bitbucket server + other features",
- "version": "2.2.8",
+ "version": "2.2.9",
"permissions": [
"storage",
"alarms",
diff --git a/history b/history
index abe97f8..34be995 100644
--- a/history
+++ b/history
@@ -1,3 +1,7 @@
+2.2.9
+============================
+- Display build status in PR list page
+
2.2.8
===================
- feature: add an option to disable check for new notification in background
diff --git a/version b/version
index 23a63f5..a6333e4 100644
--- a/version
+++ b/version
@@ -1 +1 @@
-2.2.8
+2.2.9
|