             [discuss.communication.auth :as auth]
             [discuss.communication.main :as com]
             [discuss.communication.lib :as comlib]
-            [discuss.history :as history]
             [discuss.references.lib :as rlib]
             [discuss.translations :refer [translate] :rename {translate t}]
             [discuss.utils.bootstrap :as bs]



;;;; Elements
(defn error-view
  "Display error message if there are errors."
  [data owner]
  (reify
    om/IRender
    (render [_]
      (when (lib/error?)
        (dom/div #js {:className "alert alert-info alert-dismissable"
                      :role      "alert"}
                 (dom/button #js {:className    "close"
                                  :data-dismiss "alert"
                                  :aria-label   "Close"}
                             (dom/span #js {:aria-hidden "true"}
                                       (vlib/safe-html "&times;")))
                 (lib/get-error))))))

(defn control-elements
  {:deprecated 0.4}
  []
  (reify
    om/IRender
    (render [_]
      (dom/div nil
               (dom/hr nil)
               (dom/div #js {:className "row"}
                        (dom/div #js {:className "col-md-offset-4 col-sm-offset-4 col-xs-offset-4 col-md-4 col-sm-4 col-xs-4 text-center"}
                                 (dom/button #js {:className "btn btn-default btn-sm"
                                                  :onClick   history/back!
                                                  :disabled  (> 2 (count (re-seq #"/" (lib/get-last-api))))}
                                             (vlib/fa-icon "fa-step-backward")
                                             (t :common :back :space)))
                        (dom/div #js {:className "col-md-4 col-sm-4 col-xs-4 text-right"}
                                 (bs/button-default-sm comlib/init! (vlib/fa-icon "fa-refresh") (t :discussion :restart :space))))))))

(defn close-button
  {:deprecated 0.4}
  []
  (reify om/IRender
    (render [_]
      (dom/div nil
               (dom/hr nil)
               (dom/div #js {:className "text-center"}
                        (bs/button-default-sm lib/change-to-next-view! (vlib/fa-icon "fa-times") (t :common :close :space)))))))

(defn avatar-view
  "Get the user's avatar and add login + logout functions to it."
  []

                 [:span {:aria-hidden "true"}
                  (vlib/safe-html "&times;")]]
                error])))))
(def error-alert (om/factory ErrorAlert))

;; ----------

