Toggle checkbox for forked repositories

* add toggle checkbox for filtering forked repositories
* cleanup, add TODO

Fixes: #47
This commit is contained in:
Teemu Patja 2017-03-23 11:44:07 +02:00
parent bc27ec000f
commit 32dbc257aa
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
3 changed files with 29 additions and 6 deletions

View File

@ -4,8 +4,6 @@
[secretary.core :as secretary]
[goog.events :as events]
[goog.history.EventType :as HistoryEventType]
[markdown.core :refer [md->html]]
[ajax.core :refer [GET POST]]
[commiteth.ajax :refer [load-interceptors!]]
[commiteth.handlers]
[commiteth.subscriptions]
@ -171,6 +169,8 @@
(defonce active-user (r/atom nil))
;; TODO: update-tokens is unnecessarily getting dispatched on every timer tick
(defn load-user []
(if-let [login js/user]
(if (= login @active-user)

View File

@ -1,5 +1,6 @@
(ns commiteth.repos
(:require [re-frame.core :as rf]
[reagent.core :as r]
[commiteth.svg :as svg]))
@ -40,19 +41,36 @@
group)])
(defn show-forks-checkbox [show-atom]
[:div.ui.container
[:div.ui.checkbox.commiteth-toggle
[:input (merge {:type :checkbox
:on-change #(swap! show-atom not)}
(when @show-atom
{:checked :checked}))]
[:label "Show forks"]]])
(defn repos-list []
(let [repos (rf/subscribe [:repos])
user (rf/subscribe [:user])]
user (rf/subscribe [:user])
show-atom (r/atom false)]
(fn []
(let [repo-groups (sort-by identity (fn [a _] (= a (:login @user)))
(keys @repos))]
(into [:div]
(keys @repos))
filter-fn (if @show-atom
identity
(fn [repo]
(not (:fork repo))))]
(into [:div
[show-forks-checkbox show-atom]]
(for [[group group-repos]
(map (fn [group] [group (get @repos group)])
repo-groups)]
[:div.repo-group-title [repo-group-title group (:login @user)]
(into [:div.ui.cards]
(map repo-card group-repos))]))))))
(map repo-card
(filter filter-fn group-repos)))]))))))
(defn repos-page-token-ok []
(println "repos-token-ok")

View File

@ -304,6 +304,11 @@
padding-left: .5em;
}
.commiteth-toggle {
padding-bottom: .5em;
}
.flash-message {
&.success {
background-color: #61deb0;