Fix displaying no-builds and not-active errors
This commit unifies the behaviour of displaying no-builds and not-active errors for repo and fixes the error when user can't access repo settings when the project is not active.
This commit is contained in:
parent
add716945f
commit
069f7ddbeb
|
@ -7,14 +7,41 @@ export default TravisRoute.extend({
|
||||||
return this.controllerFor('repo').activate('current');
|
return this.controllerFor('repo').activate('current');
|
||||||
},
|
},
|
||||||
|
|
||||||
renderTemplate() {
|
|
||||||
return this.render('build');
|
|
||||||
},
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
var repo;
|
var repo;
|
||||||
repo = this.controllerFor('repo');
|
repo = this.controllerFor('repo');
|
||||||
this.controllerFor('build').set('build', null);
|
this.controllerFor('build').set('build', null);
|
||||||
this.controllerFor('job').set('job', null);
|
this.controllerFor('job').set('job', null);
|
||||||
|
this.stopObservingRepoStatus();
|
||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
activate() {
|
||||||
|
this.observeRepoStatus();
|
||||||
|
return this._super.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
observeRepoStatus() {
|
||||||
|
let controller = this.controllerFor('repo');
|
||||||
|
controller.addObserver('repo.active', this, 'renderTemplate');
|
||||||
|
controller.addObserver('repo.lastBuildId', this, 'renderTemplate');
|
||||||
|
},
|
||||||
|
|
||||||
|
stopObservingRepoStatus() {
|
||||||
|
let controller = this.controllerFor('repo');
|
||||||
|
controller.removeObserver('repo.active', this, 'renderTemplate');
|
||||||
|
controller.removeObserver('repo.lastBuildId', this, 'renderTemplate');
|
||||||
|
},
|
||||||
|
|
||||||
|
renderTemplate() {
|
||||||
|
let controller = this.controllerFor('repo');
|
||||||
|
|
||||||
|
if(!controller.get('repo.active')) {
|
||||||
|
this.render('repo/not-active');
|
||||||
|
} else if(!controller.get('repo.lastBuildId')) {
|
||||||
|
this.render('repo/no-build');
|
||||||
|
} else {
|
||||||
|
this.render('build');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,30 +1,34 @@
|
||||||
<div class="branches">
|
{{#if defaultBranch}}
|
||||||
<section>
|
<div class="branches">
|
||||||
<h2 class="small-title">Default Branch</h2>
|
|
||||||
<ul class="blank-list">
|
|
||||||
{{branch-row build=defaultBranch}}
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
|
|
||||||
{{#if activeBranches.length}}
|
|
||||||
<section>
|
<section>
|
||||||
<h2 class="small-title">Active Branches</h2>
|
<h2 class="small-title">Default Branch</h2>
|
||||||
<ul class="blank-list">
|
<ul class="blank-list">
|
||||||
{{#each activeBranches as |branch|}}
|
{{branch-row build=defaultBranch}}
|
||||||
{{branch-row build=branch}}
|
|
||||||
{{/each}}
|
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
{{#if inactiveBranches.length}}
|
{{#if activeBranches.length}}
|
||||||
<section>
|
<section>
|
||||||
<h2 class="small-title">Inactive Branches</h2>
|
<h2 class="small-title">Active Branches</h2>
|
||||||
<ul class="blank-list">
|
<ul class="blank-list">
|
||||||
{{#each inactiveBranches as |branch|}}
|
{{#each activeBranches as |branch|}}
|
||||||
{{branch-row build=branch inactive=true}}
|
{{branch-row build=branch}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
|
||||||
|
{{#if inactiveBranches.length}}
|
||||||
|
<section>
|
||||||
|
<h2 class="small-title">Inactive Branches</h2>
|
||||||
|
<ul class="blank-list">
|
||||||
|
{{#each inactiveBranches as |branch|}}
|
||||||
|
{{branch-row build=branch inactive=true}}
|
||||||
|
{{/each}}
|
||||||
|
</ul>
|
||||||
|
</section>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
{{else}}
|
||||||
|
{{no-builds}}
|
||||||
|
{{/if}}
|
||||||
|
|
|
@ -23,15 +23,7 @@
|
||||||
{{repo-show-tabs repo=repo tab=tab build=build job=job}}
|
{{repo-show-tabs repo=repo tab=tab build=build job=job}}
|
||||||
</div>
|
</div>
|
||||||
<div class="tabbody repo-body">
|
<div class="tabbody repo-body">
|
||||||
{{#if showCurrentBuild}}
|
{{outlet}}
|
||||||
{{outlet}}
|
|
||||||
{{else}}
|
|
||||||
{{#if repo.lastBuildId}}
|
|
||||||
{{not-active user=currentUser repo=repo}}
|
|
||||||
{{else}}
|
|
||||||
{{no-builds}}
|
|
||||||
{{/if}}
|
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</article>
|
</article>
|
||||||
|
|
1
app/templates/repo/no-build.hbs
Normal file
1
app/templates/repo/no-build.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{no-builds}}
|
1
app/templates/repo/not-active.hbs
Normal file
1
app/templates/repo/not-active.hbs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{not-active user=currentUser repo=repo}}
|
Loading…
Reference in New Issue
Block a user