             [inflections.core :refer (pluralize)]
             [om.core :as om :include-macros true]
             [om.dom :as dom :include-macros true])
-  (:require-macros [frontend.utils :refer [html inspect]]))
+  (:require-macros [frontend.utils :refer [html defrender inspect]]))
 
 ;; This is awful, can't we just pass build-head the whole app state?
 ;; splitting it up this way means special purpose paths to find stuff

                                                                    :build-num build-num}])}
                  "Cancel Build"]))
            (when has-write-settings?
              [:div.btn-group.build-action.rebuild
               (forms/managed-button
                 [:button.btn.rebuild-btn
                  {:data-loading-text "Rebuilding",
                   :title             "Retry the same tests",
                   :on-click #(raise! owner [:retry-build-clicked {:build-id build-id
                                                                   :vcs-url vcs-url
                                                                   :build-num build-num
                                                                   :no-cache? false}])}
                  "Rebuild"])
               [:button.btn.dropdown-toggle {:data-toggle "dropdown"} [:span.caret]]
               [:ul.dropdown-menu
                [:li (forms/managed-button
                       [:a
                        {:data-loading-text "Rebuilding",
                         :title             "Retry without cache",
                         :on-click #(raise! owner [:retry-build-clicked {:build-id build-id
                                                                         :vcs-url vcs-url
                                                                         :build-num build-num
                                                                         :no-cache? true}])}
                        "without cache"])]
                ;; XXX Temporarily remove the ssh button for OSX builds
                (when (not (feature/enabled-for-project? project :osx))
                  [:li (forms/managed-button
                         [:a
                          {:data-loading-text "Rebuilding",
                           :title             "Retry with SSH in VM",
                           :on-click #(raise! owner [:ssh-build-clicked {:build-id build-id
                                                                         :vcs-url vcs-url
                                                                         :build-num build-num}])}
                          "with ssh"])])]])
            [:a.build-action
             {:href (routes/v1-project-settings {:org  (get-in data (conj state/project-plan-path :org_name))
                                                 :repo (get-in data (conj state/project-path :reponame))})}

            [:div.build-head
             (om/build build-sub-head-v2 data)]]])))))

(defrender rebuild-actions-v2 [{:keys [build project]} owner]
  (let [build-id (build-model/id build)
        build-num (:build_num build)
        vcs-url (:vcs_url build)]
  (html
    [:div.btn-group.build-action.rebuild
     (forms/managed-button
       [:button.btn.rebuild-btn
        {:data-loading-text "Rebuilding",
         :title             "Retry the same tests",
         :on-click #(raise! owner [:retry-build-clicked {:build-id build-id
                                                         :vcs-url vcs-url
                                                         :build-num build-num
                                                         :no-cache? false}])}
        "Rebuild"])
     [:button.btn.dropdown-toggle {:data-toggle "dropdown"} [:span.caret]]
     [:ul.dropdown-menu
      [:li (forms/managed-button
             [:a
              {:data-loading-text "Rebuilding",
               :title             "Retry without cache",
               :on-click #(raise! owner [:retry-build-clicked {:build-id build-id
                                                               :vcs-url vcs-url
                                                               :build-num build-num
                                                               :no-cache? true}])}
              "without cache"])]
      ;; XXX Temporarily remove the ssh button for OSX builds
      (when (not (feature/enabled-for-project? project :osx))
        [:li (forms/managed-button
               [:a
                {:data-loading-text "Rebuilding",
                 :title             "Retry with SSH in VM",
                 :on-click #(raise! owner [:ssh-build-clicked {:build-id build-id
                                                               :vcs-url vcs-url
                                                               :build-num build-num}])}
                "with ssh"])])]])))

(defn build-head-actions
  [data owner]
  (reify
