Skip to content

Commit e443151

Browse files
author
Christoph Wolfes
committed
updated markdown widget to handle repositories without branch support
1 parent 7bc50f8 commit e443151

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

src/markdownPreview/edit.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
</option>
1010
</select>
1111
</p>
12-
<p ng-if="config.repository"><label for="branch">Branch</label>
12+
13+
<p ng-if="vm.branches"><label for="branch">Branch</label>
1314
<select name="branch" id="branch" class="form-control" ng-model="config.branch">
1415
<option ng-repeat="branch in vm.branches| orderBy: 'name'" value="{{branch.id}}">
1516
{{branch.name}}

src/markdownPreview/markdownPreviewEdit.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ angular.module('adf.widget.scm')
88
vm.getBranchesByRepositoryId = function (repositoryId) {
99
if (repositoryId) {
1010
SCM.getBranchesByRepositoryId(repositoryId).then(function (result) {
11-
if (result.branch) {
11+
// catch repositories without branch support
12+
if (result.status == 400) {
13+
vm.branches = null;
14+
}else{
1215
vm.branches = result.branch;
1316
}
1417
});

src/service.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626

2727
angular.module('adf.widget.scm')
2828
.factory('SCM', function (scmEndpoint, $http) {
29-
function data(response) {
30-
return response.data;
31-
}
3229

3330
function request(url) {
34-
return $http.get(scmEndpoint + url).then(data);
31+
return $http.get(scmEndpoint + url).then(function (response) {
32+
if (response.status == 200) {
33+
return response.data;
34+
}
35+
}, function (error) {
36+
return error;
37+
});
3538
}
3639

3740
function getRepositories() {

0 commit comments

Comments
 (0)