Fix JS NPEs

This commit is contained in:
Joseph Schorr 2015-05-04 09:17:58 -07:00
parent 7ec0ad45fc
commit 70cc895b95
4 changed files with 5 additions and 3 deletions

View file

@ -3,7 +3,7 @@
<span class="commit-circle"></span> <span class="commit-circle"></span>
</span> </span>
<span class="anchor" href="{{ getUrl(commitSha, urlTemplate) }}" target="_blank" <span class="anchor" href="{{ getUrl(commitSha, urlTemplate) }}" target="_blank"
is-only-text="!urlTemplate"> is-only-text="!urlTemplate || !getUrl(commitSha, urlTemplate)">
{{ commitSha.substring(0, 8) }} {{ commitSha.substring(0, 8) }}
</span> </span>
</span> </span>

View file

@ -3,13 +3,13 @@
<!-- Branch --> <!-- Branch -->
<span ng-switch-when="heads"> <span ng-switch-when="heads">
<i class="fa fa-code-fork" data-container="body" data-title="Branch" bs-tooltip></i> <i class="fa fa-code-fork" data-container="body" data-title="Branch" bs-tooltip></i>
<span class="anchor" href="{{ getUrl(ref, branchTemplate, 'branch') }}" is-only-text="!branchTemplate" target="_blank">{{ getTitle(ref) }}</span> <span class="anchor" href="{{ getUrl(ref, branchTemplate, 'branch') }}" is-only-text="!branchTemplate || !getUrl(ref, branchTemplate, 'branch')" target="_blank">{{ getTitle(ref) }}</span>
</span> </span>
<!-- Tag --> <!-- Tag -->
<span ng-switch-when="tags"> <span ng-switch-when="tags">
<i class="fa fa-tag" data-container="body" data-title="Tag" bs-tooltip></i> <i class="fa fa-tag" data-container="body" data-title="Tag" bs-tooltip></i>
<span class="anchor" href="{{ getUrl(ref, tagTemplate, 'tag') }}" is-only-text="!tagTemplate" target="_blank">{{ getTitle(ref) }}</span> <span class="anchor" href="{{ getUrl(ref, tagTemplate, 'tag') }}" is-only-text="!tagTemplate || !getUrl(ref, tagTemplate, 'tag')" target="_blank">{{ getTitle(ref) }}</span>
</span> </span>
</span> </span>
</span> </span>

View file

@ -15,6 +15,7 @@ angular.module('quay').directive('sourceCommitLink', function () {
}, },
controller: function($scope, $element) { controller: function($scope, $element) {
$scope.getUrl = function(sha, template) { $scope.getUrl = function(sha, template) {
if (!template) { return ''; }
return template.replace('{sha}', sha); return template.replace('{sha}', sha);
}; };
} }

View file

@ -33,6 +33,7 @@ angular.module('quay').directive('sourceRefLink', function () {
}; };
$scope.getUrl = function(ref, template, kind) { $scope.getUrl = function(ref, template, kind) {
if (!template) { return ''; }
return template.replace('{' + kind + '}', $scope.getTitle(ref)); return template.replace('{' + kind + '}', $scope.getTitle(ref));
}; };
} }