       "Container Pills")
     om/IInitState
     (init-state [_]
-      {:container-index 0})
+      {:paging-offset 0})
     om/IRenderState
     (render-state [_ state]
       (let [container-data (:container-data data)
             build-running? (:build-running? data)
             build (:build data)
-            paging-width 10
             {:keys [containers current-container-id]} container-data
             container-count (count containers)
-            container-index (:container-index state)
-            previous-container-count (max 0 (- container-index 1))
-            subsequent-container-count (min paging-width (- container-count (+ container-index paging-width)))
+            paging-offset (:paging-offset state)
+            previous-container-count (max 0 (- paging-offset 1))
+            subsequent-container-count (min paging-width (- container-count (+ paging-offset paging-width)))
 
             hide-pills? (or (>= 1 (count containers))
                             (empty? (remove :filler-action (mapcat :actions containers))))

;; TODO this seems a little bit slow when calculating durations for really complex builds with
;; lots of containers. Is there a good way to avoid recalculating this when selecting container pills? (Perhaps caching the calculated value using IWillUpdate / IShouldUpdate?)
(defn container-utilization-duration
  [container]
  (apply + (map action-duration-ms (:actions container))))

(defn container-pill-v2 [{:keys [container current-container-id build-running?]} owner]
  (reify

                 [:div.container-list-v2
                  (if (> previous-container-count 0)
                    [:a.container-selector-v2.page-container-pills
                     {:on-click #(om/set-state! owner :paging-offset (- paging-offset paging-width))}
                     [:div.nav-caret
                      [:i.fa.fa-2x.fa-angle-left]]
                     [:div.pill-details ;; just for flexbox container
                      [:div "Previous " paging-width]
                      [:div (count containers) " total"]]])
                  (for [container (subvec containers
                                          paging-offset
                                          (min container-count (+ paging-offset paging-width)))]
                    (om/build container-pill-v2
                              {:container container
                               :build-running? build-running?
