Hide repo star control when not logged in

Fixes #1756
This commit is contained in:
Joseph Schorr 2016-08-23 13:02:55 -04:00
parent de41c613e4
commit e3ed2c8a92
4 changed files with 15 additions and 5 deletions

View file

@ -24,7 +24,8 @@
</td>
<td class="hidden-xs"
ng-class="tablePredicateClass('is_starred', options.predicate, options.reverse)"
style="width: 70px">
style="width: 70px"
ng-if="loggedIn">
<a ng-click="orderBy('is_starred')">Star</a>
</td>
</thead>
@ -48,9 +49,10 @@
<span class="strength-indicator" value="repository.popularity" maximum="maxPopularity"
log-base="10"></span>
</td>
<td>
<td ng-show="loggedIn">
<span class="repo-star" repository="repository"
star-toggled="starToggled({'repository': repository})"></span></td>
star-toggled="starToggled({'repository': repository})"></span>
</td>
</tr>
</tbody>
</table>

View file

@ -1,5 +1,5 @@
<span class="repo-star-element">
<i ng-class="repository.is_starred ? 'starred fa fa-star' : 'fa fa-star-o'"
class="star-icon" ng-click="toggleStar()">
class="star-icon" ng-click="toggleStar()" ng-show="loggedIn">
</i>
</span>

View file

@ -13,7 +13,7 @@ angular.module('quay').directive('repoListTable', function () {
'namespaces': '=namespaces',
'starToggled': '&starToggled'
},
controller: function($scope, $element, $filter, TableService) {
controller: function($scope, $element, $filter, TableService, UserService) {
$scope.repositories = null;
$scope.orderedRepositories = [];
@ -93,6 +93,8 @@ angular.module('quay').directive('repoListTable', function () {
});
buildOrderedRepositories();
$scope.loggedIn = !UserService.currentUser().anonymous;
}, /* deep */ true);
}
};

View file

@ -13,6 +13,8 @@ angular.module('quay').directive('repoStar', function () {
starToggled: '&starToggled'
},
controller: function($scope, $element, UserService, ApiService) {
$scope.loggedIn = false;
// Star a repository or unstar a repository.
$scope.toggleStar = function() {
if ($scope.repository.is_starred) {
@ -46,6 +48,10 @@ angular.module('quay').directive('repoStar', function () {
$scope.starToggled({'repository': $scope.repository});
}, ApiService.errorDisplay('Could not unstar repository'));
};
$scope.$watch('repository', function() {
$scope.loggedIn = !UserService.currentUser().anonymous;
});
}
};