Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
(ns memory-hole.pages.home
(:require [reagent.core :as r]
[re-frame.core :refer [subscribe dispatch]]
[memory-hole.pages.issues :refer [markdown-preview]]
[memory-hole.key-events :refer [on-enter]]
[memory-hole.bootstrap :as bs]
[memory-hole.routes :refer [href navigate!]]
:refer [box v-box h-split v-split title flex-child-style input-text input-textarea]]))
(defn issue-search []
(r/with-let [search (r/atom nil)
do-search #(when-let [value (not-empty @search)]
(navigate! (str "/search/" value)))]
{:type "text"
:class "input-sm"
:placeholder "Type in issue details to find matching issues"
:on-change #(reset! search (-> % .-target .-value))
:on-key-down #(on-enter % do-search)}]
{:on-click do-search}
(defn new-issue []
(href "/create-issue") "Add Issue"])
(defn issue-panel [{:keys [support-issue-id title summary views]}]
[:h3>a (href (str "/issue/" support-issue-id))
[:span.pull-right [bs/Badge views]]]]
[:div.panel-body summary]])
(defn sorted-tags [tags sort-type]
(let [tags (filter #(pos? (:tag-count %)) tags)]
(case sort-type
:name (sort-by :tag tags)
:count (->> tags
(sort-by :tag-count)
(defn tag-control [tag count selected]
{:on-click #(navigate! (str "/issues/" (js/encodeURIComponent tag)))
:active (= tag selected)}
[:b tag] " "
(when count [bs/Badge count])])
(defn tags-panel [tags selected]
(r/with-let [sort-type (r/atom :count)]
[:h2 "Tags"]
[:li {:class (when (= @sort-type :count) "active")}
[:a {:on-click #(reset! sort-type :count)}
"# Issues"]]
[:li {:class (when (= @sort-type :name) "active")}
[:a {:on-click #(reset! sort-type :name)}
(for [{:keys [tag-id tag tag-count]} (sorted-tags tags @sort-type)]
^{:key tag-id}
[tag-control tag tag-count selected])]]]))
(defn filter-control [title selected on-click]
{:on-click on-click
:class (if (= title selected) "btn-success" "btn-default")}
(defn filters [selected]
#(navigate! "/all-issues")]
#(navigate! "/recent-issues")]
"Most Viewed"
#(navigate! "/most-viewed-issues")]
(when-not (contains? #{"All" "Recent" "Most Viewed"} selected)
[:button.btn.btn-xs.btn-success selected])])
(defn admin-groups-toggle []
(r/with-let [admin? (subscribe [:admin?])
show-all-groups? (subscribe [:admin/show-all-groups?])]
(when @admin?
[:h3 "Admin: "
{:class (if @show-all-groups? "btn-default" "btn-success")
:on-click #(dispatch [:admin/show-all-groups? false])}
"Only my groups"]
{:class (if @show-all-groups? "btn-success" "btn-default")
:on-click #(dispatch [:admin/show-all-groups? true])}
"All groups"]]]]])))
(defn home-page []
(r/with-let [tags (subscribe [:visible-tags])
issues (subscribe [:visible-issues])
selected (subscribe [:selected-tag])]
[tags-panel @tags @selected]]
[:h2 "Issues "
[filters @selected]
(for [issue-summary @issues]
^{:key (:support-issue-id issue-summary)}
[issue-panel issue-summary])]]]))