-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbranchCommitSelectorDirective.js
More file actions
51 lines (49 loc) · 1.31 KB
/
branchCommitSelectorDirective.js
File metadata and controls
51 lines (49 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
require('app')
.directive('branchCommitSelector', branchCommitSelector);
/*
* This directive requires the following values to be on data:
* branch,
* commit,
* latestCommit,
*/
function branchCommitSelector(
$q,
errs,
fetchCommitData,
promisify,
github
) {
return {
restrict: 'A',
templateUrl: 'branchCommitSelectorView',
controller: 'BranchCommitSelectorController',
controllerAs: 'BCSC',
bindToController: true,
scope: {
data: '=', //Probably a containerFile,
hideBranchSelector: '=',
updateInstance: '&'
},
link: function ($scope, element, attrs) {
$scope.$watch('BCSC.data.branch', function (branch) {
if (branch) {
$scope.fetchingCommits = true;
var acv = $scope.BCSC.data.acv;
return $q.all({
branchOrPRCommits: github.branchOrPRCommits(acv),
activeCommit: fetchCommitData.activeCommit(acv)
})
.then(function(commitPromises) {
$scope.BCSC.data.commit = commitPromises.activeCommit;
return $scope.BCSC.onCommitFetch(commitPromises.branchOrPRCommits);
})
.catch(errs.handler)
.finally(function () {
$scope.fetchingCommits = false;
});
}
});
}
};
}