     :name "project-sidebar-form"
     :mixins [rum/reactive]}))
 
-(def project-sidebar-pagelist
-  (util/component
-   {:render project-sidebar-pagelist-render
-    :name "project-sidebar-pagelist"
-    :mixins [rum/reactive]}))
-
 (defn project-sidebar-render
   [own]
   (let [local (:rum/local own)
+        page (rum/react page-state)
         project (rum/react project-state)]
     (html
      [:div#project-bar.project-bar

      [:span.project-name name]
      [:ul.tree-view
       (for [page pages]
         (let [component (project-sidebar-pageitem local page (count pages))]
           (rum/with-key component (str (:id page)))))]
      [:button.btn-primary.btn-small
       {:on-click #(reset! local {:edit true :form {}})}
       "+ Add new page"]])))

(defn- project-sidebar-form-render
  [own parent]


(defn- project-sidebar-pageitem-render
  [own parent page numpages]
  (println "pageitem-render" (:id page))
  (letfn [(on-edit [e]
            (let [data {:edit true :form page}]
              (reset! parent data)))]
    (let [curpage (rum/react page-state)
          active? (= (:id curpage) (:id page))
          deletable? (> numpages 1)
          navigate #(rs/emit! (dp/go-to-project (:project page) (:id page)))
          delete #(rs/emit! (dp/delete-page (:id page)))]
      (html
       [:li.single-page
        {:class (when active? "current")
         :on-click navigate}
        [:div.tree-icon i/page]
        [:span (:name page)]
        [:div.options
         [:div {:on-click on-edit} i/pencil]
         [:div {:class (when-not deletable? "hide")
                :on-click delete}
          i/trash]]]))))

(def project-sidebar-pageitem
  (util/component
   {:render project-sidebar-pageitem-render
    :name "project-sidebar-pageitem"
    :mixins [rum/reactive]}))

(defn- project-sidebar-pagelist-render
  [own parent]
  (let [project (rum/react project-state)
        pages (rum/react pages-state)
        name (:name project)]
