 (defmethod om-write 'filter-all [{:keys [state]} _ _] (swap! state assoc :report/filter :all))
 (defmethod om-write 'filter-failed [{:keys [state]} _ _] (swap! state assoc :report/filter :failed))
 (defmethod om-write 'filter-manual [{:keys [state]} _ _] (swap! state assoc :report/filter :manual))
-(defmethod om-write 'toggle-folded [{:keys [state]} _ {:keys [ns-name]}]
-  {:action #(swap! state update :folded/namespaces (fn [nss]
-                                                     ((if (nss ns-name) disj conj) nss ns-name)))
-   :value [:folded/namespaces]})
 
 (def test-parser (om/parser {:read om-read :mutate om-write}))
 


(defui TestReport
       static om/IQuery
       (query [this] [:top :report/filter :folded/namespaces])
       Object
       (render [this]
               (let [props (om/props this)
                     test-report-data (-> props :top)
                     current-filter (-> props :report/filter)
                     folded-namespaces (-> props :folded/namespaces)
                     make-toggle-fn (fn [n] #(om/transact! this `[(~'toggle-folded {:ns-name ~n})]))]
                 (dom/section #js {:className "test-report"}
                              (dom/div #js {:name "filters" :className "filter-controls"}
                                       (dom/label #js {:htmlFor "filters"} "Filter: ")
                                       (dom/a #js {:className (if (= current-filter :all) "selected" "")

                                                (:test-results test-item-data)))
                                  (dom/ul #js {:className "test-list"}
                                          (mapv (comp test-item #(assoc % :report/filter filter))
                                                (:test-items test-item-data))))))))

(def test-item (om/factory TestItem {:keyfn :id}))

(defui TestNamespace
       Object
       (initLocalState [this] {:folded? false})
       (render
         [this]
         (let [tests-by-namespace (om/props this)
               filter (:report/filter tests-by-namespace)
               {:keys [folded?]} (om/get-state this)]
           (dom/li #js {:className "test-item"}
                   (dom/div #js {:className "test-namespace"}
                            (dom/a #js {:href "#"
                                        :style #js {:textDecoration "none"} ;; TODO: refactor to css
                                        :onClick   #(om/update-state! this update :folded? not)}
                                   (dom/h2 #js {:className (itemclass (:status tests-by-namespace))}
                                           (if folded? \u25BA \u25BC)
                                           " Testing " (:name tests-by-namespace)))
