Make the frontend agnostic to why a trigger can be run manually

This commit is contained in:
Joseph Schorr 2016-09-09 16:54:46 -04:00
parent b979f99964
commit 3f2447d831
4 changed files with 6 additions and 7 deletions

View file

@ -76,7 +76,7 @@ def trigger_view(trigger, can_read=False, can_admin=False, for_build=False):
'repository_url': repo_url if can_read else None,
'config': build_trigger.config if can_admin else {},
'is_connected_user': is_connected_user,
'can_invoke': is_connected_user,
}
if not for_build and can_admin and trigger.pull_robot:

View file

@ -40,8 +40,8 @@
<tr ng-repeat="trigger in triggers">
<td><span class="trigger-description" trigger="trigger"></span></td>
<td>
<button class="btn btn-primary" ng-click="runTriggerNow(trigger)" ng-if="trigger.is_connected_user">Run Trigger</button>
<span class="empty" ng-if="!trigger.is_connected_user">You cannot start triggers created by another user</span>
<button class="btn btn-primary" ng-click="runTriggerNow(trigger)" ng-if="trigger.can_invoke">Run Trigger</button>
<span class="empty" ng-if="!trigger.can_invoke">You do not have permission to run this trigger</span>
</td>
</tr>
</table>

View file

@ -147,7 +147,7 @@
<i class="fa fa-unlock-alt"></i> View Credentials
</span>
<span class="cor-option" option-click="askRunTrigger(trigger)"
ng-class="trigger.is_connected_user ? '' : 'disabled'">
ng-class="trigger.can_invoke ? '' : 'disabled'">
<i class="fa fa-chevron-right"></i> Run Trigger Now
</span>
<span class="cor-option" option-click="askDeleteTrigger(trigger)">

View file

@ -199,9 +199,8 @@ angular.module('quay').directive('repoPanelBuilds', function () {
};
$scope.askRunTrigger = function(trigger) {
if (!trigger.is_connected_user) {
bootbox.alert('For security reasons, only the user that created this trigger can ' +
'manually invoke this trigger');
if (!trigger.can_invoke) {
bootbox.alert('You do not have permission to manually invoke this trigger');
return;
}