diff --git a/app/routes/repo/index.js b/app/routes/repo/index.js
index 3ae29393..8c0615d6 100644
--- a/app/routes/repo/index.js
+++ b/app/routes/repo/index.js
@@ -7,14 +7,41 @@ export default TravisRoute.extend({
return this.controllerFor('repo').activate('current');
},
- renderTemplate() {
- return this.render('build');
- },
deactivate() {
var repo;
repo = this.controllerFor('repo');
this.controllerFor('build').set('build', null);
this.controllerFor('job').set('job', null);
+ this.stopObservingRepoStatus();
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');
+ }
}
});
diff --git a/app/templates/branches.hbs b/app/templates/branches.hbs
index f94b7b78..0f977b11 100644
--- a/app/templates/branches.hbs
+++ b/app/templates/branches.hbs
@@ -1,30 +1,34 @@
-
-
- Default Branch
-
- {{branch-row build=defaultBranch}}
-
-
-
- {{#if activeBranches.length}}
+{{#if defaultBranch}}
+
- Active Branches
+ Default Branch
- {{#each activeBranches as |branch|}}
- {{branch-row build=branch}}
- {{/each}}
+ {{branch-row build=defaultBranch}}
- {{/if}}
- {{#if inactiveBranches.length}}
-
- Inactive Branches
-
- {{#each inactiveBranches as |branch|}}
- {{branch-row build=branch inactive=true}}
- {{/each}}
-
-
- {{/if}}
-
+ {{#if activeBranches.length}}
+
+ Active Branches
+
+ {{#each activeBranches as |branch|}}
+ {{branch-row build=branch}}
+ {{/each}}
+
+
+ {{/if}}
+
+ {{#if inactiveBranches.length}}
+
+ Inactive Branches
+
+ {{#each inactiveBranches as |branch|}}
+ {{branch-row build=branch inactive=true}}
+ {{/each}}
+
+
+ {{/if}}
+
+{{else}}
+ {{no-builds}}
+{{/if}}
diff --git a/app/templates/repo.hbs b/app/templates/repo.hbs
index 1e4aaa17..ae42ffac 100644
--- a/app/templates/repo.hbs
+++ b/app/templates/repo.hbs
@@ -23,15 +23,7 @@
{{repo-show-tabs repo=repo tab=tab build=build job=job}}
- {{#if showCurrentBuild}}
- {{outlet}}
- {{else}}
- {{#if repo.lastBuildId}}
- {{not-active user=currentUser repo=repo}}
- {{else}}
- {{no-builds}}
- {{/if}}
- {{/if}}
+ {{outlet}}
diff --git a/app/templates/repo/no-build.hbs b/app/templates/repo/no-build.hbs
new file mode 100644
index 00000000..2d9b8892
--- /dev/null
+++ b/app/templates/repo/no-build.hbs
@@ -0,0 +1 @@
+{{no-builds}}
diff --git a/app/templates/repo/not-active.hbs b/app/templates/repo/not-active.hbs
new file mode 100644
index 00000000..7028061e
--- /dev/null
+++ b/app/templates/repo/not-active.hbs
@@ -0,0 +1 @@
+{{not-active user=currentUser repo=repo}}