Skip to content

Commit bd99aa5

Browse files
author
Florent Dubost
committed
Merge pull request #26 from VincentCATILLON/feature-labels
Adds labels and milestones display to PR
2 parents be563cc + f758726 commit bd99aa5

8 files changed

Lines changed: 87 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Options :
3636
* *org* : an array of Github organizations,
3737
* *apiUrl* : url of your Github API (optional, default is `https://api.github.com`),
3838
* *descendingOrder* : allow to change ordering of pull requests (optional, default is `true`).
39+
* *labels* : display labels of pull requests (optional, default is `false`).
40+
* *milestones* : display milestones of pull requests (optional, default is `false`).
3941
* *token* : authorization token for API calls (optional, it can allow access to more repos and increase API rate limit) NB: if a token is set, OAuth will be ignored for the team
4042
* *oauthAppClientId* : clientId of the OAuth app the team depends on (optional)
4143
* **githubOAuth** : OAuth config (optional)

app/scripts/controllers/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ angular.module('gtrApp')
2222
$scope.descendingOrder = true;
2323
}
2424

25+
if (typeof(config.teams[team].labels) !== 'undefined') {
26+
$scope.labels = config.teams[team].labels;
27+
} else {
28+
$scope.labels = false;
29+
}
30+
31+
if (typeof(config.teams[team].milestones) !== 'undefined') {
32+
$scope.milestones = config.teams[team].milestones;
33+
} else {
34+
$scope.milestones = false;
35+
}
36+
2537
var statePriorities = {
2638
'error': 4,
2739
'failure': 3,

app/scripts/services/pullFetcher.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,26 @@ angular.module('gtrApp')
7171
});
7272
};
7373

74+
var addLabelsToPull = function (pull) {
75+
return request(pull.issue_url + '/labels').then(function (response) {
76+
pull.labels = response.data;
77+
});
78+
};
79+
80+
var removeMilestoneToPull = function (pull) {
81+
pull.milestone = null;
82+
};
83+
7484
var getRepoPulls = function (repo) {
7585
return request(repo.pulls_url.replace('{/number}', ''))
7686
.then(function (response) {
7787
var filtered = response.data.filter(filterPulls);
88+
if (currentTeam.labels) {
89+
filtered.map(addLabelsToPull);
90+
}
91+
if (!currentTeam.milestones) {
92+
filtered.map(removeMilestoneToPull);
93+
}
7894

7995
return $q.all(filtered.map(addStatusToPull)).then(function() {
8096
return filtered;

app/styles/main.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,19 @@ ul {
170170
.pr-counter {
171171
margin-right: 10px;
172172
}
173+
174+
.badge {
175+
padding: 4px 8px;
176+
border-radius: 4px;
177+
font-size: 0.875em;
178+
color: black;
179+
}
180+
181+
.badge-label {
182+
margin-left: 4px;
183+
}
184+
185+
.badge-milestone {
186+
background-color: white;
187+
margin-right: 4px;
188+
}

app/views/main.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,13 @@
1919
<div class="container">
2020
<ul class="pulls">
2121
<li ng-repeat="pr in toArray(pulls) | orderBy:'updated_at':descendingOrder" ng-class="pr.statuses[0].state" class="status">
22-
<span class="link"><img class="avatar" ng-src="{{ pr.user.avatar_url}}" title="{{ pr.user.login }}" /><a ng-href="{{pr.html_url}}" >#{{ pr.number }} {{ pr.title }}</a></span>
22+
<span class="link">
23+
<img class="avatar" ng-src="{{ pr.user.avatar_url}}" title="{{ pr.user.login }}" />
24+
<a ng-href="{{pr.html_url}}" >#{{ pr.number }} {{ pr.title }}</a>
25+
<span class="badge badge-label" ng-repeat="label in toArray(pr.labels)" style="background-color: #{{ label.color }}">{{ label.name }}</span>
26+
</span>
2327
<span class="pull-right">
28+
<span class="badge badge-milestone" ng-show="pr.milestone != null">{{ pr.milestone.title }}</span>
2429
<span class="repo"><a ng-href="{{pr.head.repo.html_url}}" >{{ pr.head.repo.full_name }}</a></span>
2530
<span class="date">{{pr.updated_at | date:"dd/MM/yyyy"}}</span>
2631
</span>

config/config.json.dist

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"projects": ["repo1", "repo2"],
88
"orgs": ["orgname1", "orgname2"],
99
"token": "apiToken",
10-
"descendingOrder": true
10+
"descendingOrder": true,
11+
"labels": true,
12+
"milestones": true
1113
},
1214
"teamWithOAuth": {
1315
"members": ["username4", "username2", "username5"],

config/config_test.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
"burton": {
2424
"members": ["papy", "worker"],
2525
"orgs": ["m6web"],
26-
"apiUrl": "/api/v3"
26+
"apiUrl": "/api/v3",
27+
"labels": true
2728
},
2829
"service-polls": {
2930
"descendingOrder": false,
3031
"projects": ["service-polls"],
3132
"orgs": ["m6web", "replay"],
32-
"apiUrl": "/api/v3"
33+
"apiUrl": "/api/v3",
34+
"milestones": true
3335
}
3436
}
3537
}

test/e2e/main.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ describe('Test GTR screen', function () {
7979
backend.whenGET('/api/v3/repos/m6web/service-polls/pulls').respond([{
8080
'id': 6467,
8181
'html_url': 'http://example.com/m6web/service-polls/pull/54',
82+
'issue_url': '/api/v3/repos/m6web/service-polls/issues/54',
8283
'number': 54,
8384
'title': 'PR 54',
8485
'state': 'open',
@@ -97,11 +98,13 @@ describe('Test GTR screen', function () {
9798
'full_name': 'm6web/service-polls',
9899
'name': 'service-polls'
99100
}
100-
}
101+
},
102+
'milestone': null
101103
},
102104
{
103105
'id': 6468,
104106
'html_url': 'http://example.com/m6web/service-polls/pull/55',
107+
'issue_url': '/api/v3/repos/m6web/service-polls/issues/55',
105108
'number': 55,
106109
'title': 'PR 55',
107110
'state': 'open',
@@ -120,11 +123,15 @@ describe('Test GTR screen', function () {
120123
'full_name': 'm6web/service-polls',
121124
'name': 'service-polls'
122125
}
126+
},
127+
'milestone': {
128+
'title': 'release-1.1.0'
123129
}
124130
},
125131
{
126132
'id': 6469,
127133
'html_url': 'http://example.com/m6web/service-polls/pull/56',
134+
'issue_url': '/api/v3/repos/m6web/service-polls/issues/56',
128135
'number': 56,
129136
'title': 'PR 56',
130137
'state': 'open',
@@ -143,11 +150,15 @@ describe('Test GTR screen', function () {
143150
'full_name': 'm6web/service-polls',
144151
'name': 'service-polls'
145152
}
153+
},
154+
'milestone': {
155+
'title': 'release-1.0.0'
146156
}
147157
}]);
148158
backend.whenGET('/api/v3/repos/replay/bundle-polls-client/pulls').respond([{
149159
'id': 5895,
150160
'html_url': 'http://example.com/replay/bundle-polls-client/pull/49',
161+
'issue_url': '/api/v3/repos/replay/bundle-polls-client/issues/49',
151162
'number': 49,
152163
'title': 'PR 49',
153164
'state': 'open',
@@ -166,11 +177,13 @@ describe('Test GTR screen', function () {
166177
'full_name': 'replay/bundle-polls-client',
167178
'name': 'bundle-polls-client'
168179
}
169-
}
180+
},
181+
'milestone': null
170182
},
171183
{
172184
'id': 5896,
173185
'html_url': 'http://example.com/replay/bundle-polls-client/pull/50',
186+
'issue_url': '/api/v3/repos/replay/bundle-polls-client/issues/50',
174187
'number': 50,
175188
'title': 'PR 50',
176189
'state': 'open',
@@ -189,7 +202,8 @@ describe('Test GTR screen', function () {
189202
'full_name': 'replay/bundle-polls-client',
190203
'name': 'bundle-polls-client'
191204
}
192-
}
205+
},
206+
'milestone': null
193207
}]);
194208

195209
//Statuses
@@ -220,6 +234,14 @@ describe('Test GTR screen', function () {
220234
'state': 'success'
221235
}]);
222236

237+
// Labels
238+
backend.whenGET('/api/v3/repos/m6web/service-polls/issues/55/labels').respond([
239+
{
240+
'name': 'need_review',
241+
'color': 'b60205'
242+
}
243+
]);
244+
223245
// Others
224246
backend.whenGET(/.*/).passThrough();
225247
});
@@ -288,7 +310,7 @@ describe('Test GTR screen', function () {
288310

289311
expect(pulls).toEqual([{
290312
index: 0,
291-
text: '#55 PR 55\nm6web/service-polls 28/08/2014',
313+
text: '#55 PR 55 need_review\nm6web/service-polls 28/08/2014',
292314
class: '',
293315
avatar: 'http://example.com/papy.jpg',
294316
pullUrl: 'http://example.com/m6web/service-polls/pull/55'
@@ -310,14 +332,14 @@ describe('Test GTR screen', function () {
310332
},
311333
{
312334
index: 1,
313-
text: '#55 PR 55\nm6web/service-polls 28/08/2014',
335+
text: '#55 PR 55\nrelease-1.1.0 m6web/service-polls 28/08/2014',
314336
class: '',
315337
avatar: 'http://example.com/papy.jpg',
316338
pullUrl: 'http://example.com/m6web/service-polls/pull/55'
317339
},
318340
{
319341
index: 2,
320-
text: '#56 PR 56\nm6web/service-polls 28/10/2014',
342+
text: '#56 PR 56\nrelease-1.0.0 m6web/service-polls 28/10/2014',
321343
class: 'success',
322344
avatar: 'http://example.com/bieber.jpg',
323345
pullUrl: 'http://example.com/m6web/service-polls/pull/56'

0 commit comments

Comments
 (0)