commit WIP dashboard work

This commit is contained in:
Martin Klepsch 2018-03-30 12:00:07 +02:00 committed by Tetiana Churikova
parent 28ce4db049
commit 339002f8df
2 changed files with 124 additions and 35 deletions

View File

@ -1,5 +1,6 @@
(ns commiteth.manage-payouts (ns commiteth.manage-payouts
(:require [re-frame.core :as rf] (:require [re-frame.core :as rf]
[commiteth.routes :as routes]
[commiteth.common :as common :refer [human-time]])) [commiteth.common :as common :refer [human-time]]))
@ -9,9 +10,57 @@
repo :repo_name}] repo :repo_name}]
(str "https://github.com/" owner "/" repo "/pull/" pr-number)) (str "https://github.com/" owner "/" repo "/pull/" pr-number))
(defn balance-badge
[tla balance]
(let [color (fn balance-badge-color [tla]
(get {"ETH" "#57a7ed"} tla "#4360df"))
tla (if (keyword? tla)
(subs (str tla) 1)
tla)]
[:div.ph2.pv1.relative
{:style {:color (color tla)}}
[:div.absolute.top-0.left-0.right-0.bottom-0.o-10.br2
{:style {:background-color (color tla)}}]
[:span.pg-med (str tla " " balance)]]))
(defn bounty-card [{owner :repo-owner
repo-name :repo-name
issue-title :issue-title
issue-number :issue-number
updated :updated
tokens :tokens
balance-eth :balance-eth
value-usd :value-usd
:as bounty}]
[:div
[:a {:href (common/issue-url owner repo-name issue-number)}
[:span.db.f4.muted-blue.hover-black issue-title]
[:div.mt2
[:span.f5.gray.pg-book (str owner "/" repo-name " #" issue-number) " — " (common/human-time updated)]]
[:div.cf.mt2
[:div.fl.mr2
[balance-badge "ETH" balance-eth]]
(for [[tla balance] tokens]
^{:key tla}
[:div.fl.mr2
[balance-badge tla balance]])
[:div.fl.mr2.pv1
[:span.usd-value-label "Value "]
[:span.usd-balance-label (str "$" value-usd)]]]
#_[:code (pr-str bounty)]
#_(when (> claim-count 0)
[:span.open-claims-label (str claim-count " open claim"
(when (> claim-count 1) "s"))])]])
(defn claim-card [bounty claim] (defn claim-card [bounty claim]
#_(prn claim)
(let [{pr-state :pr_state (let [{pr-state :pr_state
user-name :user_name user-name :user_name
user-login :user_login
avatar-url :user_avatar_url avatar-url :user_avatar_url
issue-id :issue_id issue-id :issue_id
issue-title :issue_title} claim issue-title :issue_title} claim
@ -21,20 +70,26 @@
bot-confirm-unmined? (empty? (:confirm_hash bounty)) bot-confirm-unmined? (empty? (:confirm_hash bounty))
confirming? (:confirming? bounty) confirming? (:confirming? bounty)
updated (:updated bounty)] updated (:updated bounty)]
[:div.activity-item [:div.pa2
[:div.ui.grid.container [:div.dt
[:div.left-column {:class (when (and paid? (not (= user-login winner-login)))
[:div.ui.circular.image "o-50")}
[:img {:src avatar-url}]]] [:div.dtc.v-top
[:div.content [:img.br-100.w3 {:src avatar-url}]]
[:div.header user-name] [:div.dtc.v-top.pl3
[:div.description "Submitted a claim for " [:a {:href (pr-url claim)} [:div
issue-title]] [:span.f4.muted-blue (or user-name user-login) " · "
[:div.description (if paid? (if paid?
(str "(paid to " winner-login ")") (if (= user-login winner-login)
(str "(" (if merged? "merged" "open") ")"))] [:span "Received payout"]
[:div.time (human-time updated)] [:span "No payout"])
[:button.ui.button (if merged? "Merged" "Open"))]
;; [:span.f5 (human-time updated)]
[:div "Submitted a claim via "
[:a {:href (pr-url claim)}
(str (:repo_owner claim) "/" (:repo_name claim) " PR #" (:pr_number claim))]]
(when (and merged? (not paid?))
[:button.mt2.f5.outline-0.bg-sob-blue.white.pv2.ph3.pg-med.br2.bn
(merge (if (and merged? (not paid?)) (merge (if (and merged? (not paid?))
{} {}
{:disabled true}) {:disabled true})
@ -44,18 +99,25 @@
{:class "busy loading" :disabled true})) {:class "busy loading" :disabled true}))
(if paid? (if paid?
"Signed off" "Signed off"
"Confirm")]]]])) "Confirm")])]]]]))
(defn claim-list [bounties] (defn claim-list [bounties]
;; TODO: exclude bounties with no claims ;; TODO: exclude bounties with no claims
(if (empty? bounties) (if (empty? bounties)
[:div.ui.text "No items"] [:div.ui.text "No items"]
(into [:div.activity-item-container] (into [:div]
(for [bounty bounties (for [bounty bounties]
claim (filter #(not (= 2 (:pr_state %))) ;; exclude closed ^{:key (:issue_id bounty)}
(:claims bounty))] [:div.mb2.br3
[claim-card bounty claim])))) [:div.pa3.bg-white.bb.b--light-gray.br3.br--top
[bounty-card bounty]]
[:div.pa3.bg-white.br3.br--bottom
(if (seq (:claims bounty))
(for [claim (:claims bounty)]
^{:key (:pr_id claim)}
[claim-card bounty claim])
[:div.f4.muted-blue "No claims yet."])]]))))
(defn bounty-stats [{:keys [paid unpaid]}] (defn bounty-stats [{:keys [paid unpaid]}]
[:div.cf [:div.cf
@ -69,6 +131,16 @@
[:div.f2.pa2 (common/usd-string (:combined-usd-value paid))] [:div.f2.pa2 (common/usd-string (:combined-usd-value paid))]
[:div (:count paid) " bounties"]]]) [:div (:count paid) " bounties"]]])
(def state-mapping
{:opened :open
:funded :funded
:claimed :claimed
:multiple-claims :claimed
:merged :merged
:pending-contributor-address :pending-contributor-address
:pending-maintainer-confirmation :pending-maintainer-confirmation
:paid :paid})
(defn manage-payouts-page [] (defn manage-payouts-page []
(let [owner-bounties (rf/subscribe [:owner-bounties]) (let [owner-bounties (rf/subscribe [:owner-bounties])
bounty-stats-data (rf/subscribe [:owner-bounties-stats]) bounty-stats-data (rf/subscribe [:owner-bounties-stats])
@ -78,14 +150,25 @@
[:container [:container
[:div.ui.active.inverted.dimmer [:div.ui.active.inverted.dimmer
[:div.ui.text.loader "Loading"]]] [:div.ui.text.loader "Loading"]]]
(let [bounties (vals @owner-bounties)] (let [bounties (vals @owner-bounties)
[:div.ui.container grouped (group-by (comp state-mapping :state) bounties)]
[:div.center.mw7
(when (nil? (common/web3)) (when (nil? (common/web3))
[:div.ui.warning.message [:div.ui.warning.message
[:i.warning.icon] [:i.warning.icon]
"To sign off claims, please view Status Open Bounty in Status, Mist or Metamask"]) "To sign off claims, please view Status Open Bounty in Status, Mist or Metamask"])
[bounty-stats @bounty-stats-data] [bounty-stats @bounty-stats-data]
[:h3 "New claims"] [:div.cf
[claim-list (filter (complement :paid?) bounties)] [:button.pa2.tl.bn.bg-white.muted-blue
[:h3 "Old claims"] {:on-click #(routes/nav! :issuer-dashboard/paid)}
[claim-list (filter :paid? bounties)]]))))) [:span.f4 "Paid"] [:br]
(count (get grouped :paid)) " bounties"]]
(for [[k v] grouped]
[:div
{:key (name k)}
[:h3 (name k) " — " (count v)]
[claim-list (take 10 v)]])
#_[:h3 "New claims"]
#_[claim-list (filter (complement :paid?) bounties)]
#_[:h3 "Old claims"]
#_[claim-list (filter :paid? bounties)]])))))

View File

@ -7,6 +7,12 @@
["/activity" :activity] ["/activity" :activity]
["/repos" :repos] ["/repos" :repos]
["/manage-payouts" :manage-payouts] ["/manage-payouts" :manage-payouts]
["/manage-payouts/open" :issuer-dashboard/open]
["/manage-payouts/funded" :issuer-dashboard/funded]
["/manage-payouts/claimed" :issuer-dashboard/claimed]
["/manage-payouts/merged" :issuer-dashboard/merged]
["/manage-payouts/pending" :issuer-dashboard/pending-maintainer-confirmation]
["/manage-payouts/paid" :issuer-dashboard/paid]
["/settings" :settings] ["/settings" :settings]
["/usage-metrics" :usage-metrics]])) ["/usage-metrics" :usage-metrics]]))