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

    :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)
        project (rum/react project-state)]
    (html
     [:div#project-bar.project-bar

    (rs/emit! (dp/initialize-workspace projectid pageid))
    own))

(defn workspace-transfer-state
  [old-state state]
  (let [[projectid pageid] (:rum/props state)]
    (println "workspace-transfer-state" old-state)
    (println "workspace-transfer-state" state)
    (rs/emit! (dp/initialize-workspace projectid pageid))))

(def ^:static workspace
  (util/component
   {:render workspace-render
    :will-mount workspace-will-mount
    :transfer-state workspace-transfer-state
    :name "workspace"
    :mixins [rum/static]}))

