add permissions mixin to dashboard row

This commit is contained in:
Lisa P 2016-03-15 13:45:37 +01:00 committed by Piotr Sarnacki
parent 2220334265
commit 65cf81169b
2 changed files with 31 additions and 10 deletions

View File

@ -1,8 +1,9 @@
import Ember from 'ember';
import { githubCommit as githubCommitUrl } from 'travis/utils/urls';
import config from 'travis/config/environment';
import Permissions from 'travis/mixins/permissions';
export default Ember.Component.extend({
export default Ember.Component.extend(Permissions, {
tagName: 'li',
classNameBindings: ['repo.default_branch.last_build.state'],
classNames: ['rows', 'rows--dashboard'],
@ -15,6 +16,14 @@ export default Ember.Component.extend({
return githubCommitUrl(this.get('repo.slug'), this.get('repo.default_branch.last_build.commit.sha'));
}.property('repo'),
displayMenuTofu: function() {
return this.hasPushPermission(this.get('currentUser'), this.get('repo.id'));
},
displayActivateLink: function() {
return this.hasAdminPermission(this.get('currentUser'), this.get('repo.id'));
},
actions: {
tiggerBuild(branch) {
this.set('isTriggering', true);

View File

@ -60,16 +60,28 @@
</div>
</section>
<div class="dash-menu">
<div class="dropup {{if dropupIsOpen "is-open"}}">
<button type="button" class="dropup-tofu" {{action "openDropup"}}>open action menu</button>
<ul class="dropup-list">
<li><a href="#" title="Trigger a new build"><span class="icon-trigger"></span><span class="label-align">Trigger a build</span></a></li>
<li><a href="#" title="Deactivate builds for this repository"><span class="icon-deactivate"></span><span class="label-align">Deactivate repository</span></a></li>
<li><a href="#" title="See the settings for this repository"><span class="icon-settings"></span><span class="label-align">Settings</span></a></li>
</ul>
{{#if displayMenuTofu}}
<div class="dash-menu">
<div class="dropup {{if dropupIsOpen "is-open"}}">
<button type="button" class="dropup-tofu" {{action "openDropup"}}>open action menu</button>
<ul class="dropup-list">
<li><a href="#" title="Trigger a new build">
<span class="icon-trigger"></span>
<span class="label-align">Trigger a build</span></a></li>
{{#if displayActiavteLink}}
<li><a href="#" title="Deactivate builds for this repository">
<span class="icon-deactivate"></span>
<span class="label-align">Deactivate repository</span></a></li>
{{/if}}
<li>
{{#link-to 'settings' repo title="Settings for this repository"}}
<span class="icon-settings"></span>
<span class="label-align">Settings</span>
{{/link-to}}</li>
</ul>
</div>
</div>
</div>
{{/if}}
</div>
<aside class="dash-aside">