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:
Piotr Sarnacki 2016-01-21 16:33:08 +01:00
parent add716945f
commit 069f7ddbeb
5 changed files with 62 additions and 37 deletions

View File

@ -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');
}
} }
}); });

View File

@ -1,3 +1,4 @@
{{#if defaultBranch}}
<div class="branches"> <div class="branches">
<section> <section>
<h2 class="small-title">Default Branch</h2> <h2 class="small-title">Default Branch</h2>
@ -28,3 +29,6 @@
</section> </section>
{{/if}} {{/if}}
</div> </div>
{{else}}
{{no-builds}}
{{/if}}

View File

@ -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>

View File

@ -0,0 +1 @@
{{no-builds}}

View File

@ -0,0 +1 @@
{{not-active user=currentUser repo=repo}}