diff --git a/.gitignore b/.gitignore
index 090a1f0..59a8040 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
.idea
.DS_Store
+Archive.zip
diff --git a/css/content.css b/css/content.css
index 3bc27e8..90bcf33 100644
--- a/css/content.css
+++ b/css/content.css
@@ -39,3 +39,15 @@ span.in_review{
background-color: rgba(25, 26, 36, 0.75);
z-index: 101 !important;
}
+
+.merge_conflict_header {
+ width: 1%;
+}
+
+.pivotal_tracker_labels_header {
+ width: 10%
+}
+
+.pivotal_tracker_state_header {
+ width: 6%
+}
diff --git a/js/app/content.js b/js/app/content.js
index 485cd99..e467c1d 100644
--- a/js/app/content.js
+++ b/js/app/content.js
@@ -16,7 +16,17 @@ function addDiffTool(){
function addPullRequestTools(){
var pull_requests_page = jQuery("h2:contains('Pull requests')");
if (pull_requests_page.size() == 1) {
- markMergeConflicts();
+ hideBuildStausValue();
+ addColumnToPullRequestTable('pull-request-merge-conflict-status-column merge_conflict_header','pull-request-merge-conflict-status-value','Merge Conflict',-1);
+ addColumnToPullRequestTable('pull-request-pivotal-tracker-labels-column pivotal_tracker_labels_header','pull-request-pivotal-tracker-labels-value','PivotalTracker Labels',1);
+ addColumnToPullRequestTable('pull-request-pivotal-tracker-state-column pivotal_tracker_state_header','pull-request-pivotal-tracker-state-value','PivotalTracker State',2);
+ var pull_requests = getPullRequests();
+ pull_requests.forEach(function(pull_request){
+ markMergeConflicts(pull_request);
+ if(pull_request.story_number){
+ addPivotalTrackerColumnValues(pull_request);
+ }
+ });
}
}
@@ -24,15 +34,41 @@ function getProjectPath(){
return window.location.pathname.match(/\/projects\/(.*)\/pull-requests/)[1];
}
-function markMergeConflicts() {
- var pull_requests = getPullRequests();
- pull_requests.forEach(function(pull_request){
- hasMergeConflict(pull_request).done(function(){
- applyConflictStyle(pull_request);
+function markMergeConflicts(pull_request) {
+ hasMergeConflict(pull_request).done(function(){
+ applyConflictStyle(pull_request);
+ });
+}
+
+function addPivotalTrackerColumnValues(pull_request){
+ getPivotalTrackerData(pull_request).done(function(data){
+ data.labels.forEach(function(label){
+ addLabel(pull_request,label.name);
});
+ addStateWithLink(pull_request,data);
});
}
+function addColumnToPullRequestTable(thClass,tdClass,thLabel,insertAfterIndex){
+ var pr_table = jQuery('table.pull-requests-table');
+ if(insertAfterIndex === -1){
+ insertAfterIndex = pr_table.find('thead th').length;
+ }
+ var afterElem = pr_table.find('thead tr th:nth-child('+insertAfterIndex+')');
+ jQuery('
'+thLabel+' | ').insertAfter(afterElem);
+ pr_table.find('tbody tr').each(function(){
+ afterElem = jQuery(this).find('td:nth-child('+insertAfterIndex+')');
+ jQuery(' | ').insertAfter(afterElem);
+ });
+}
+
+function hideBuildStausValue(){
+ var build_status_col = jQuery('table.pull-request-table th.build-status-pr-list-col');
+ if(!build_status_col.is(':visible')){
+ jQuery('td.build-status-pr-list-col-value').hide();
+ }
+}
+
function clean(){
var diff = jQuery("span.diff");
var in_review= jQuery("span.in_review");
@@ -76,11 +112,17 @@ function getPullRequests(){
var prs = jQuery('table.pull-requests-table').find('td.title');
return prs.map(function(i,pr){
var id = jQuery(pr).find('a')[0].href.match(/pull-requests\/(.*)\//)[1];
+ var story_number = jQuery(pr).find('a').text().match(/^(\d*).*/);
+ if(story_number){
+ story_number = story_number[1];
+ }
return {
id: id,
name: 'Test',
merge_url: '/rest/api/latest/projects/'+getProjectPath()+'/pull-requests/'+id+'/merge',
- elem: pr
+ elem: pr,
+ story_number: story_number,
+ pivotal_trakcer_url: 'https://www.pivotaltracker.com/services/v5/stories/' + story_number
}
}).toArray();
}
@@ -99,13 +141,60 @@ function hasMergeConflict(pull_request){
return hasConflict;
}
+function getPivotalTrackerData(pull_request){
+ var trackerDataReady = jQuery.Deferred();
+ jQuery.get(pull_request.pivotal_trakcer_url).done(function(data){
+ trackerDataReady.resolve(data);
+ }).fail(function(data){
+ trackerDataReady.reject();
+ });
+ return trackerDataReady;
+}
+
function applyConflictStyle(pull_request){
jQuery(pull_request.elem).
closest('tr').
- find('.build-status-pr-list-col-value').
- append('Possible Merge Conflict').
- css('background-color','#f6c342');
+ find('.pull-request-merge-conflict-status-value').
+ append('' +
+ '' +
+ 'Possible Merge Conflict' +
+ '' +
+ '');
+
+}
+
+function addLabel(pull_request,label){
+ jQuery(pull_request.elem).
+ closest('tr').
+ find('.pull-request-pivotal-tracker-labels-value').
+ append(''+label+' ');
+
+}
+function addStateWithLink(pull_request,data){
+ var state_css = '';
+ switch (data.current_state) {
+ case 'accepted':
+ state_css = 'success';
+ break;
+ case 'rejected':
+ state_css = 'error';
+ break;
+ case 'delivered':
+ state_css = 'moved';
+ break;
+ case 'finished':
+ state_css = 'current';
+ break;
+ case 'started':
+ state_css = 'complete';
+ break;
+ }
+ jQuery(pull_request.elem).
+ closest('tr').
+ find('.pull-request-pivotal-tracker-state-value').
+ append(''+data.current_state+' '+
+ 'Open PivotalTracker');
}
jQuery(document).ready(function() {
diff --git a/manifest.json b/manifest.json
index 1561749..e490d1e 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,6 +1,6 @@
{
"name": "Stash++",
- "version": "2.2.0",
+ "version": "2.3.0",
"manifest_version": 2,
"description": "A Chrome extension to make stash better",
"page_action": {