We observe last build on the repo in order to show the freshest build on
repo page. I moved it to router in order to keep such observers in the
same place, but this was not a wise move. To make it work properly
observer needs to be removed when moving to some other part (like
build's page). The problem is that deactivate function is not called
when we move to the other route in the same nesting. We have our own
'activate' function on repoController, which is better suited for
handling this task.
The hack which is needed for wrong outlet behaviour renders a template
when outlet is not rendered automatically, but it was done immediately.
Because of that when changing routes from index to job route, sometimes
the hack was kicking in and rendering build instead of job template.
This commit fixes it to check if rendering is needed in "afterRender"
phase on runloop.
After changing Ember Data to Ember Model, the default behavior is to
not return promise by default from `find` call. This is better in
general for our use case, because we don't block rendering the UI while
data loads, but we now have to handle cases where model is not yet
loaded in `setupController`
Previously we showed only accounts and repositories, to which you have
admin access. To improve usability, it's better to show all accounts and
all repositories, but explain why part of the repositories are not
manageable.
Previously we were checking if we should display an error message by
adding if statements in a template. This is not the best way to do
it, because it clutters a template and makes code harder to follow.
In this commit I move rendering error templates to the router. Code for
rendering error when there is no builds is not the best way to do it
either, but it can be improved when new router changes are merged to
Ember's master and a way Ember Data is handling promises is revised and
improved.
Till now, when switching between different views, we were switching
different bindings on repo controller. This was quite innefficient,
because then we needed to add bindings also from other controllers and
it's hard to manage such structure when we would like to add specialized
controllers (like LogController).
The new setup is more declarative, meaning that we do such things on the
router and set things on proper controllers. The only drawback is that
now we need to setup a few observers instead of bindings for "current"
views (ie. when viewing the newest repo or when viewing the last build
in current repo).
At this point it may not look like huge improvement, but it will open a
way to more refactorings.
Ember by default sets controller's `model` property which may cause
weird race conditions when connected with a way we handle setting up
controller's content - most of the time we bind things.
This was causing the log to not refresh sometimes when switching from
one repo to another, I'm reverting for now, we will have to have another
look.
This reverts commit 2e8b74160c.
Conflicts:
assets/scripts/app/controllers/build.coffee
assets/scripts/app/models/build.coffee
assets/scripts/app/templates/builds/show.hbs
assets/scripts/app/views/log.coffee
assets/scripts/vendor/log.js