From 78ab683a28b219598f3eb75c7ccd01edfc524aed Mon Sep 17 00:00:00 2001 From: Chris Hutchinson Date: Wed, 17 Jan 2018 03:13:06 -0600 Subject: [PATCH 01/17] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a961a5d..eb161ec 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Commiteth +# Status Open Bounty Allows you to set bounties for Github issues, paid out in Ether. More information: -http://wiki.status.im/proposals/commiteth/ +https://wiki.status.im/Status_Open_Bounty -Live beta version: +Live production version: https://openbounty.status.im The `master` branch is automatically deployed here. From df68be9ba79c75d85933055c8f9c37eb6fb14266 Mon Sep 17 00:00:00 2001 From: Chris Hutchinson Date: Wed, 17 Jan 2018 03:15:46 -0600 Subject: [PATCH 02/17] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb161ec..bb7bc5b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Status Open Bounty -Allows you to set bounties for Github issues, paid out in Ether. +Allows you to set bounties for Github issues, paid out in Ether or any ERC-20 token. More information: https://wiki.status.im/Status_Open_Bounty From 03ab5b05398215e08dd0e4859decd709cbfb178a Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Fri, 19 Jan 2018 15:41:33 +0200 Subject: [PATCH 03/17] Pagination: add cursor pointer for buttons; scroll to top when changing page --- src/cljs/commiteth/activity.cljs | 1 + src/cljs/commiteth/bounties.cljs | 5 +++-- src/cljs/commiteth/handlers.cljs | 24 ++++++++++++++++++------ src/less/style.less | 1 + 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/cljs/commiteth/activity.cljs b/src/cljs/commiteth/activity.cljs index 69b4d34..0d199dd 100644 --- a/src/cljs/commiteth/activity.cljs +++ b/src/cljs/commiteth/activity.cljs @@ -59,6 +59,7 @@ (defn activity-list [activity-page-data] [:div.ui.container.activity-container + {:id "activity-container"} (if (empty? (:items activity-page-data)) [:div.view-no-data-container [:p "No recent activity yet"]] diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index 26957e3..ebe63d2 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -47,15 +47,16 @@ (defn bounties-list [{:keys [items item-count page-number total-count] :as bounty-page-data}] [:div.ui.container.open-bounties-container + {:id "open-bounties-container"} [:div.open-bounties-header "Bounties"] (if (empty? items) [:div.view-no-data-container [:p "No recent activity yet"]] - [:div + [:div (let [left (inc (* (dec page-number) items-per-page)) right (dec (+ left item-count))] [:div.item-counts-label - [:span (str "Showing " left "-" right " of " total-count)]]) + [:span (str "Showing " left "-" right " of " total-count)]]) (display-data-page bounty-page-data bounty-item :set-bounty-page-number)])]) (defn bounties-page [] diff --git a/src/cljs/commiteth/handlers.cljs b/src/cljs/commiteth/handlers.cljs index 1cf2562..f50ad77 100644 --- a/src/cljs/commiteth/handlers.cljs +++ b/src/cljs/commiteth/handlers.cljs @@ -6,6 +6,7 @@ reg-fx inject-cofx]] [ajax.core :refer [GET POST]] + [clojure.browser.dom :as dom :refer [get-element]] [cuerdas.core :as str] [cljs-web3.core :as web3] [cljs-web3.eth :as web3-eth] @@ -38,6 +39,15 @@ (println "redirecting to" path) (set! (.-pathname js/location) path))) +(reg-fx + :bounty-scroll-pos + (fn [scroll-pos] + (.scrollIntoView (get-element "open-bounties-container")) )) + +(reg-fx + :activity-scroll-pos + (fn [scroll-pos] + (.scrollIntoView (get-element "activity-container")))) (reg-event-fx :initialize-db @@ -68,15 +78,17 @@ (fn [db [_ page]] (assoc db :page page))) -(reg-event-db +(reg-event-fx :set-bounty-page-number - (fn [db [_ page]] - (assoc db :bounty-page-number page))) + (fn [{:keys [db]} [_ page]] + {:db (assoc db :bounty-page-number page) + :bounty-scroll-pos 0})) -(reg-event-db +(reg-event-fx :set-activity-page-number - (fn [db [_ page]] - (assoc db :activity-page-number page))) + (fn [{:keys [db]} [_ page]] + {:db (assoc db :activity-page-number page) + :activity-scroll-pos 0})) (reg-event-fx :set-flash-message diff --git a/src/less/style.less b/src/less/style.less index c21473f..145aca5 100644 --- a/src/less/style.less +++ b/src/less/style.less @@ -887,6 +887,7 @@ body { flex: none; align-items: center; justify-content: center; + cursor: pointer; } .grayed-out { From 55cbb713f916af5a810ab7f278b39c610981a0f0 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Fri, 19 Jan 2018 21:01:35 +0200 Subject: [PATCH 04/17] Pagination: use React Refs in order to obtain DOM element for scrolling --- src/cljs/commiteth/activity.cljs | 32 ++++++++++++++--------- src/cljs/commiteth/bounties.cljs | 45 ++++++++++++++++++-------------- src/cljs/commiteth/handlers.cljs | 24 +++++------------ 3 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/cljs/commiteth/activity.cljs b/src/cljs/commiteth/activity.cljs index 0d199dd..d59ed19 100644 --- a/src/cljs/commiteth/activity.cljs +++ b/src/cljs/commiteth/activity.cljs @@ -58,19 +58,25 @@ (defn activity-list [activity-page-data] - [:div.ui.container.activity-container - {:id "activity-container"} - (if (empty? (:items activity-page-data)) - [:div.view-no-data-container - [:p "No recent activity yet"]] - (display-data-page activity-page-data activity-item :set-activity-page-number))]) + (if (empty? (:items activity-page-data)) + [:div.view-no-data-container + [:p "No recent activity yet"]] + (display-data-page activity-page-data activity-item :set-activity-page-number))) (defn activity-page [] (let [activity-page-data (rf/subscribe [:activities-page]) - activity-feed-loading? (rf/subscribe [:get-in [:activity-feed-loading?]])] - (fn [] - (if @activity-feed-loading? - [:div.view-loading-container - [:div.ui.active.inverted.dimmer - [:div.ui.text.loader.view-loading-label "Loading"]]] - [activity-list @activity-page-data])))) + activity-feed-loading? (rf/subscribe [:get-in [:activity-feed-loading?]]) + container-element (atom nil) + render-fn (fn [] + (if @activity-feed-loading? + [:div.view-loading-container + [:div.ui.active.inverted.dimmer + [:div.ui.text.loader.view-loading-label "Loading"]]] + [:div.ui.container.activity-container + {:ref #(reset! container-element %1)} + [activity-list @activity-page-data]]))] + (r/create-class + {:component-did-update (fn [] + (when @container-element + (.scrollIntoView @container-element))) + :reagent-render render-fn}))) diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index ebe63d2..2868da3 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -1,5 +1,6 @@ (ns commiteth.bounties (:require [re-frame.core :as rf] + [reagent.core :as r] [commiteth.common :refer [moment-timestamp display-data-page items-per-page @@ -46,25 +47,31 @@ (defn bounties-list [{:keys [items item-count page-number total-count] :as bounty-page-data}] - [:div.ui.container.open-bounties-container - {:id "open-bounties-container"} - [:div.open-bounties-header "Bounties"] - (if (empty? items) - [:div.view-no-data-container - [:p "No recent activity yet"]] - [:div - (let [left (inc (* (dec page-number) items-per-page)) - right (dec (+ left item-count))] - [:div.item-counts-label - [:span (str "Showing " left "-" right " of " total-count)]]) - (display-data-page bounty-page-data bounty-item :set-bounty-page-number)])]) + (if (empty? items) + [:div.view-no-data-container + [:p "No recent activity yet"]] + [:div + (let [left (inc (* (dec page-number) items-per-page)) + right (dec (+ left item-count))] + [:div.item-counts-label + [:span (str "Showing " left "-" right " of " total-count)]]) + (display-data-page bounty-page-data bounty-item :set-bounty-page-number)])) (defn bounties-page [] (let [bounty-page-data (rf/subscribe [:open-bounties-page]) - open-bounties-loading? (rf/subscribe [:get-in [:open-bounties-loading?]])] - (fn [] - (if @open-bounties-loading? - [:div.view-loading-container - [:div.ui.active.inverted.dimmer - [:div.ui.text.loader.view-loading-label "Loading"]]] - [bounties-list @bounty-page-data])))) + open-bounties-loading? (rf/subscribe [:get-in [:open-bounties-loading?]]) + container-element (atom nil) + render-fn (fn [] + (if @open-bounties-loading? + [:div.view-loading-container + [:div.ui.active.inverted.dimmer + [:div.ui.text.loader.view-loading-label "Loading"]]] + [:div.ui.container.open-bounties-container + {:ref #(reset! container-element %1)} + [:div.open-bounties-header "Bounties"] + [bounties-list @bounty-page-data]]))] + (r/create-class + {:component-did-update (fn [] + (when @container-element + (.scrollIntoView @container-element))) + :reagent-render render-fn}))) diff --git a/src/cljs/commiteth/handlers.cljs b/src/cljs/commiteth/handlers.cljs index f50ad77..671dbd8 100644 --- a/src/cljs/commiteth/handlers.cljs +++ b/src/cljs/commiteth/handlers.cljs @@ -39,16 +39,6 @@ (println "redirecting to" path) (set! (.-pathname js/location) path))) -(reg-fx - :bounty-scroll-pos - (fn [scroll-pos] - (.scrollIntoView (get-element "open-bounties-container")) )) - -(reg-fx - :activity-scroll-pos - (fn [scroll-pos] - (.scrollIntoView (get-element "activity-container")))) - (reg-event-fx :initialize-db [(inject-cofx :store)] @@ -78,17 +68,15 @@ (fn [db [_ page]] (assoc db :page page))) -(reg-event-fx +(reg-event-db :set-bounty-page-number - (fn [{:keys [db]} [_ page]] - {:db (assoc db :bounty-page-number page) - :bounty-scroll-pos 0})) + (fn [db [_ page]] + (assoc db :bounty-page-number page))) -(reg-event-fx +(reg-event-db :set-activity-page-number - (fn [{:keys [db]} [_ page]] - {:db (assoc db :activity-page-number page) - :activity-scroll-pos 0})) + (fn [db [_ page]] + (assoc db :activity-page-number page))) (reg-event-fx :set-flash-message From b2ab0949f6010a650555a9872728912dec383b79 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Fri, 19 Jan 2018 21:02:51 +0200 Subject: [PATCH 05/17] handlers: remove require for clojure.browser.dom --- src/cljs/commiteth/handlers.cljs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/cljs/commiteth/handlers.cljs b/src/cljs/commiteth/handlers.cljs index 671dbd8..b1114fe 100644 --- a/src/cljs/commiteth/handlers.cljs +++ b/src/cljs/commiteth/handlers.cljs @@ -6,7 +6,6 @@ reg-fx inject-cofx]] [ajax.core :refer [GET POST]] - [clojure.browser.dom :as dom :refer [get-element]] [cuerdas.core :as str] [cljs-web3.core :as web3] [cljs-web3.eth :as web3-eth] From 326c221988e5dff5ace552deb892233cfe750fe1 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Mon, 22 Jan 2018 13:53:33 +0200 Subject: [PATCH 06/17] [FIX #226] UI changes; refactor React refs usage --- src/cljs/commiteth/activity.cljs | 39 ++++++++++++++------------- src/cljs/commiteth/bounties.cljs | 30 ++++++++++----------- src/cljs/commiteth/common.cljs | 34 ++++++++++++++++------- src/cljs/commiteth/db.cljs | 3 +-- src/cljs/commiteth/handlers.cljs | 17 +++++------- src/cljs/commiteth/subscriptions.cljs | 13 +++------ src/less/style.less | 20 +++++++++++--- 7 files changed, 88 insertions(+), 68 deletions(-) diff --git a/src/cljs/commiteth/activity.cljs b/src/cljs/commiteth/activity.cljs index d59ed19..2e9444e 100644 --- a/src/cljs/commiteth/activity.cljs +++ b/src/cljs/commiteth/activity.cljs @@ -2,7 +2,9 @@ (:require [re-frame.core :as rf] [reagent.core :as r] [commiteth.common :refer [moment-timestamp + items-per-page display-data-page + scroll-div issue-url]])) @@ -55,28 +57,29 @@ (str (subs (str tla) 1) " " balance)])]) [:div.time (moment-timestamp updated)]]]]) - - -(defn activity-list [activity-page-data] +(defn activity-list [{:keys [items item-count page-number total-count] + :as activity-page-data}] (if (empty? (:items activity-page-data)) [:div.view-no-data-container [:p "No recent activity yet"]] - (display-data-page activity-page-data activity-item :set-activity-page-number))) + [:div + (let [left (inc (* (dec page-number) items-per-page)) + right (dec (+ left item-count))] + [:div.item-counts-label + [:span (str "Showing " left "-" right " of " total-count)]]) + (display-data-page activity-page-data activity-item)])) (defn activity-page [] (let [activity-page-data (rf/subscribe [:activities-page]) activity-feed-loading? (rf/subscribe [:get-in [:activity-feed-loading?]]) - container-element (atom nil) - render-fn (fn [] - (if @activity-feed-loading? - [:div.view-loading-container - [:div.ui.active.inverted.dimmer - [:div.ui.text.loader.view-loading-label "Loading"]]] - [:div.ui.container.activity-container - {:ref #(reset! container-element %1)} - [activity-list @activity-page-data]]))] - (r/create-class - {:component-did-update (fn [] - (when @container-element - (.scrollIntoView @container-element))) - :reagent-render render-fn}))) + container-element (atom nil)] + (fn [] + (if @activity-feed-loading? + [:div.view-loading-container + [:div.ui.active.inverted.dimmer + [:div.ui.text.loader.view-loading-label "Loading"]]] + [:div.ui.container.activity-container + {:ref #(reset! container-element %1)} + [scroll-div container-element] + [:div.activity-header "Activities"] + [activity-list @activity-page-data]])))) diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index 2868da3..fdf741d 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -3,6 +3,7 @@ [reagent.core :as r] [commiteth.common :refer [moment-timestamp display-data-page + scroll-div items-per-page issue-url]])) @@ -55,23 +56,20 @@ right (dec (+ left item-count))] [:div.item-counts-label [:span (str "Showing " left "-" right " of " total-count)]]) - (display-data-page bounty-page-data bounty-item :set-bounty-page-number)])) + (display-data-page bounty-page-data bounty-item)])) (defn bounties-page [] (let [bounty-page-data (rf/subscribe [:open-bounties-page]) open-bounties-loading? (rf/subscribe [:get-in [:open-bounties-loading?]]) - container-element (atom nil) - render-fn (fn [] - (if @open-bounties-loading? - [:div.view-loading-container - [:div.ui.active.inverted.dimmer - [:div.ui.text.loader.view-loading-label "Loading"]]] - [:div.ui.container.open-bounties-container - {:ref #(reset! container-element %1)} - [:div.open-bounties-header "Bounties"] - [bounties-list @bounty-page-data]]))] - (r/create-class - {:component-did-update (fn [] - (when @container-element - (.scrollIntoView @container-element))) - :reagent-render render-fn}))) + container-element (atom nil)] + (fn [] + (if @open-bounties-loading? + [:div.view-loading-container + [:div.ui.active.inverted.dimmer + [:div.ui.text.loader.view-loading-label "Loading"]]] + [:div.ui.container.open-bounties-container + {:ref #(reset! container-element %1)} + [scroll-div container-element] + [:div.open-bounties-header "Bounties"] + [bounties-list @bounty-page-data]])) + )) diff --git a/src/cljs/commiteth/common.cljs b/src/cljs/commiteth/common.cljs index 6eed787..417dea1 100644 --- a/src/cljs/commiteth/common.cljs +++ b/src/cljs/commiteth/common.cljs @@ -1,6 +1,7 @@ (ns commiteth.common (:require [reagent.core :as r] [re-frame.core :as rf] + [clojure.string :as str] [cljsjs.moment])) (defn input [val-ratom props] @@ -30,9 +31,22 @@ (defn issue-url [owner repo number] (str "https://github.com/" owner "/" repo "/issues/" number)) +(defn scroll-div [container-element] + "This is an invisible div that exists + for the sole purpose of scrolling the container-element into view + when page-number is updated" + (let [page-number (rf/subscribe [:page-number])] + (r/create-class + {:component-did-update (fn [] + (when @container-element + (.scrollIntoView @container-element))) + :reagent-render (fn [] + [:div {:style {:display "none"}} + @page-number])}))) + (def items-per-page 15) -(defn draw-page-numbers [page-number page-count set-page-kw] +(defn draw-page-numbers [page-number page-count] "Draw page numbers for the pagination component. Inserts ellipsis when list is too long, by default max 6 items are allowed" @@ -41,8 +55,8 @@ [:div.rectangle-rounded (cond-> {} (not current?) - (assoc :class "grayed-out" - :on-click #(rf/dispatch [set-page-kw i]))) + (assoc :class "grayed-out-page-num" + :on-click #(rf/dispatch [:set-page-number i]))) i]) max-page-nums 6] [:div.page-nums-container @@ -78,8 +92,7 @@ total-count page-number page-count]} - draw-item-fn - set-page-kw] + draw-item-fn] "Draw data items along with pagination controls" (let [draw-items (fn [] (into [:div.ui.items] @@ -90,14 +103,17 @@ forward?) (and (< 1 page-number) (not forward?))) - (rf/dispatch [set-page-kw + (rf/dispatch [:set-page-number (if forward? (inc page-number) (dec page-number))]))) draw-rect (fn [direction] - (let [forward? (= direction :forward)] + (let [forward? (= direction :forward) + gray-out? (or (and forward? (= page-number page-count)) + (and (not forward?) (= page-number 1))) ] [:div.rectangle-rounded - {:on-click (on-direction-click forward?)} + (cond-> {:on-click (on-direction-click forward?)} + gray-out? (assoc :class "grayed-out-direction")) [:img.icon-forward-gray (cond-> {:src "icon-forward-gray.svg"} forward? (assoc :class "flip-horizontal"))]]))] @@ -110,6 +126,6 @@ [draw-rect :backward] [draw-rect :forward] [:div.page-nav-text [:span (str "Page " page-number " of " page-count)]] - [draw-page-numbers page-number page-count set-page-kw]]]))) + [draw-page-numbers page-number page-count]]]))) diff --git a/src/cljs/commiteth/db.cljs b/src/cljs/commiteth/db.cljs index a93c8bc..76b9a1c 100644 --- a/src/cljs/commiteth/db.cljs +++ b/src/cljs/commiteth/db.cljs @@ -8,8 +8,7 @@ :activity-feed-loading? false :open-bounties-loading? false :open-bounties [] - :bounty-page-number 1 - :activity-page-number 1 + :page-number 1 :owner-bounties {} :top-hunters [] :activity-feed []}) diff --git a/src/cljs/commiteth/handlers.cljs b/src/cljs/commiteth/handlers.cljs index b1114fe..077d280 100644 --- a/src/cljs/commiteth/handlers.cljs +++ b/src/cljs/commiteth/handlers.cljs @@ -63,19 +63,15 @@ (reg-event-db - :set-active-page - (fn [db [_ page]] - (assoc db :page page))) + :set-active-page + (fn [db [_ page]] + (assoc db :page page + :page-number 1))) (reg-event-db - :set-bounty-page-number + :set-page-number (fn [db [_ page]] - (assoc db :bounty-page-number page))) - -(reg-event-db - :set-activity-page-number - (fn [db [_ page]] - (assoc db :activity-page-number page))) + (assoc db :page-number page))) (reg-event-fx :set-flash-message @@ -90,7 +86,6 @@ (fn [db _] (dissoc db :flash-message))) - (defn assoc-in-if-not-empty [m path val] (if (seq val) (assoc-in m path val) diff --git a/src/cljs/commiteth/subscriptions.cljs b/src/cljs/commiteth/subscriptions.cljs index f9cb555..c1b8952 100644 --- a/src/cljs/commiteth/subscriptions.cljs +++ b/src/cljs/commiteth/subscriptions.cljs @@ -37,14 +37,14 @@ (vec (:open-bounties db)))) (reg-sub - :bounty-page-number + :page-number (fn [db _] - (:bounty-page-number db))) + (:page-number db))) (reg-sub :open-bounties-page :<- [:open-bounties] - :<- [:bounty-page-number] + :<- [:page-number] (fn [[open-bounties page-number] _] (let [total-count (count open-bounties) start (* (dec page-number) items-per-page) @@ -77,15 +77,10 @@ (fn [db _] (vec (:activity-feed db)))) -(reg-sub - :activity-page-number - (fn [db _] - (:activity-page-number db))) - (reg-sub :activities-page :<- [:activity-feed] - :<- [:activity-page-number] + :<- [:page-number] (fn [[activities page-number] _] (let [total-count (count activities) start (* (dec page-number) items-per-page) diff --git a/src/less/style.less b/src/less/style.less index 145aca5..07e3646 100644 --- a/src/less/style.less +++ b/src/less/style.less @@ -523,7 +523,7 @@ } } - border: #e7e7e7 solid 0.1em!important; + border-bottom: #eaecee 1px solid !important; box-shadow: none!important; border-radius: 0.3em!important; padding: 0.8em 1em 1.1em!important; @@ -588,9 +588,16 @@ } .activity-container { + background-color: #fff; transform: translate(0, -45px); border-radius: 10px; - + padding: 24px; + .activity-header { + font-family: "PostGrotesk-Medium"; + font-size: 21px; + font-weight: 500; + color: #42505c; + } } .footer-row { @@ -890,12 +897,19 @@ body { cursor: pointer; } -.grayed-out { +.grayed-out-page-num { color: #8d99a4; background-color: #f2f5f8; opacity: 1.0; } +.grayed-out-direction { + color: #8d99a4; + background-color: #f2f5f8; + opacity: 0.4; + cursor: auto +} + .flip-horizontal { -moz-transform: scaleX(-1); -webkit-transform: scaleX(-1); From df8de465320cb50142e6168d6d6d8287f0a105ef Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Mon, 22 Jan 2018 17:42:01 +0200 Subject: [PATCH 07/17] Pagination controls: apply CSS media queries for mobile devices --- src/cljs/commiteth/common.cljs | 5 +++-- src/less/style.less | 27 ++++++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/cljs/commiteth/common.cljs b/src/cljs/commiteth/common.cljs index 417dea1..8cb213d 100644 --- a/src/cljs/commiteth/common.cljs +++ b/src/cljs/commiteth/common.cljs @@ -123,8 +123,9 @@ [:div [draw-items] [:div.page-nav-container - [draw-rect :backward] - [draw-rect :forward] + [:div.page-direction-container + [draw-rect :backward] + [draw-rect :forward]] [:div.page-nav-text [:span (str "Page " page-number " of " page-count)]] [draw-page-numbers page-number page-count]]]))) diff --git a/src/less/style.less b/src/less/style.less index 07e3646..d8c078c 100644 --- a/src/less/style.less +++ b/src/less/style.less @@ -919,15 +919,6 @@ body { filter: fliph; } -.pagination-text { - width: 83px; - height: 15px; - font-family: PostGrotesk; - font-size: 15px; - text-align: center; - color: #8d99a4; -} - .icon-forward-gray { width: 24px; height: 24px; @@ -937,10 +928,24 @@ body { .page-nav-container { display: flex; margin: 0 -6px; + @media (max-width: 767px) { + align-items: center; + flex-direction: column; + } +} + +.page-direction-container { + display: flex; + @media (max-width: 767px) { + flex-direction: row; + } } .page-nums-container { display: flex; + @media (max-width: 767px) { + display: none; + } margin-left: auto; justify-content: space-between; } @@ -955,6 +960,10 @@ body { flex: none; align-items: center; justify-content: center; + + @media (max-width: 767px) { + margin-top: 12px; + } } .item-counts-label { From 0db8136730cc97177bdefa2d352e1e21ac9a09f4 Mon Sep 17 00:00:00 2001 From: Anton Danchenko Date: Mon, 22 Jan 2018 18:19:05 +0200 Subject: [PATCH 08/17] added local env --- test/end-to-end/pages/thirdparty/github.py | 2 +- test/end-to-end/tests/basetestcase.py | 17 +++++++++++------ test/end-to-end/tests/conftest.py | 4 ++++ test/end-to-end/tests/test_contracts.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/test/end-to-end/pages/thirdparty/github.py b/test/end-to-end/pages/thirdparty/github.py index 2585c91..eaf3c84 100644 --- a/test/end-to-end/pages/thirdparty/github.py +++ b/test/end-to-end/pages/thirdparty/github.py @@ -84,7 +84,7 @@ class LabelsButton(BaseButton): class BountyLabel(BaseButton): def __init__(self, driver): super(LabelsButton.BountyLabel, self).__init__(driver) - self.locator = self.Locator.css_selector("[data-name='bounty']") + self.locator = self.Locator.css_selector("[data-name='748942015']") class CrossButton(BaseButton): def __init__(self, driver): diff --git a/test/end-to-end/tests/basetestcase.py b/test/end-to-end/tests/basetestcase.py index 398673b..b658ed1 100644 --- a/test/end-to-end/tests/basetestcase.py +++ b/test/end-to-end/tests/basetestcase.py @@ -39,16 +39,21 @@ class BaseTestCase: desired_caps['captureHtml'] = False return desired_caps + @property + def environment(self): + return pytest.config.getoption('env') + def setup_method(self): self.errors = [] - # options = webdriver.ChromeOptions() - # options.add_argument('--start-fullscreen') - # options.add_extension(path.abspath('/resources/metamask3_12_0.crx')) - - self.driver = webdriver.Remote(self.executor_sauce_lab, - desired_capabilities=self.capabilities_sauce_lab) + if self.environment == 'local': + options = webdriver.ChromeOptions() + options.add_argument('--start-fullscreen') + self.driver = webdriver.Chrome(options=options) + if self.environment == 'sauce': + self.driver = webdriver.Remote(self.executor_sauce_lab, + desired_capabilities=self.capabilities_sauce_lab) self.driver.implicitly_wait(5) def verify_no_errors(self): diff --git a/test/end-to-end/tests/conftest.py b/test/end-to-end/tests/conftest.py index 62f296e..c0abbae 100644 --- a/test/end-to-end/tests/conftest.py +++ b/test/end-to-end/tests/conftest.py @@ -11,6 +11,10 @@ def pytest_addoption(parser): action='store', default=True, help='Display each test step in terminal as plain text: True/False') + parser.addoption('--env', + action='store', + default='sauce', + help='Specify environment, sauce or local') def pytest_configure(config): diff --git a/test/end-to-end/tests/test_contracts.py b/test/end-to-end/tests/test_contracts.py index 68bb4cb..6e617f3 100644 --- a/test/end-to-end/tests/test_contracts.py +++ b/test/end-to-end/tests/test_contracts.py @@ -17,6 +17,6 @@ class TestLogin(BaseTestCase): bounties_page = github.authorize_sob.click() github.install_sob_plugin() assert bounties_page.bounties_header.text == 'Bounties' - assert bounties_page.top_hunters_header.text == 'Top hunters' + assert bounties_page.top_hunters_header.text == 'Top 5 hunters' github.create_new_bounty() github.get_deployed_contract() From 3310a34566920c98869c9a252e24e0c2ae77e18d Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Tue, 23 Jan 2018 12:25:56 +0200 Subject: [PATCH 09/17] Dev fix: add cljs source paths to :dev profile and remove CIDER dep. Additional source paths help to resolve the Piggieback REPL issue. I was getting annoying "No such namespace warnings" for commiteth.* namespaces --- project.clj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/project.clj b/project.clj index e6af24a..3c8bd92 100644 --- a/project.clj +++ b/project.clj @@ -69,7 +69,6 @@ [lein-auto "0.1.2"] [lein-less "1.7.5"] [lein-shell "0.5.0"] - [cider/cider-nrepl "0.15.0-SNAPSHOT"] [lein-sha-version "0.1.1"]] @@ -144,7 +143,7 @@ :prep-tasks ["build-contracts" "javac"] :doo {:build "test"} - :source-paths ["env/dev/clj" "test/clj"] + :source-paths ["env/dev/clj" "test/clj" "src/cljs" "env/dev/cljs"] :resource-paths ["env/dev/resources"] :repl-options {:init-ns user :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]} From 8414d19404fc26a9219e4ec7d7a9f6e92debfb7b Mon Sep 17 00:00:00 2001 From: Tetiana Churikova Date: Wed, 24 Jan 2018 12:58:58 +0200 Subject: [PATCH 10/17] Config support and other little improvements (#231) * Configure work with remote config; add stepa to verify issue title; * transfer settings to global .gitignore * Change channel and repo path * Delete local env by default * change locator for BountyFooters --- .gitignore | 1 - doc/testing.md | 4 +-- test/end-to-end/pages/openbounty/bounties.py | 28 ++++++++++++++++++++ test/end-to-end/pages/openbounty/landing.py | 3 ++- test/end-to-end/pages/thirdparty/github.py | 6 ++++- test/end-to-end/tests/__init__.py | 11 +++++++- test/end-to-end/tests/basetestcase.py | 14 +++++++--- test/end-to-end/tests/config_example.ini | 13 +++++++++ test/end-to-end/tests/test_contracts.py | 24 +++++++++++++++-- 9 files changed, 92 insertions(+), 12 deletions(-) create mode 100644 test/end-to-end/tests/config_example.ini diff --git a/.gitignore b/.gitignore index 0e3eb68..4f4f73c 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,3 @@ profiles.clj .idea resources/contracts node_modules -.DS_Store diff --git a/doc/testing.md b/doc/testing.md index a3e59d0..c0ad83f 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -10,7 +10,7 @@ For testing you will need: * a Github account with administrative access to one or more repositories * for approving bounty payouts you will additionally need access to an Ethereum wallet. So far, Mist and [MetaMask](https://metamask.io/) have been used, but anything that provides the web3 javascript interface should work. -The developers can be reached on the `#commiteth` channel in the [Status slack](http://slack.status.im/). +The developers can be reached on the `#openbounty` channel in the [Status slack](http://slack.status.im/). ### Signing up @@ -60,6 +60,6 @@ To remove issue from the Bounties list you can close it in GitHub. ### Reporting bugs -All bugs should be reported as issues in the [CommitETH Github repository](https://github.com/status-im/commiteth/issues). +All bugs should be reported as issues in the [OpenBounty Github repository](https://github.com/status-im/open-bounty/issues). Please first check that there is not already a duplicate issue. Issues should contain exact and minimal step-by-step instructions for reproducing the problem. diff --git a/test/end-to-end/pages/openbounty/bounties.py b/test/end-to-end/pages/openbounty/bounties.py index 91415fd..24a47bc 100644 --- a/test/end-to-end/pages/openbounty/bounties.py +++ b/test/end-to-end/pages/openbounty/bounties.py @@ -1,5 +1,6 @@ from pages.base_page import BasePageObject from pages.base_element import * +from tests import test_data class BountiesHeader(BaseText): @@ -15,11 +16,38 @@ class TopHuntersHeader(BaseText): super(TopHuntersHeader, self).__init__(driver) self.locator = self.Locator.css_selector('.top-hunters-header') +class BountyTitles(BaseText): + + def __init__(self, driver): + super(BountyTitles, self).__init__(driver) + self.locator = self.Locator.css_selector('.open-bounty-item-content .header') + + +class BountyItemRows(BaseText): + + def __init__(self, driver): + super(BountyItemRows, self).__init__(driver) + self.locator = self.Locator.css_selector('.open-bounty-item-content .bounty-item-row') + +class BountyFooters(BaseText): + + def __init__(self, driver): + super(BountyFooters, self).__init__(driver) + self.locator = self.Locator.css_selector('.open-bounty-item-content .footer-row') + class BountiesPage(BasePageObject): def __init__(self, driver): super(BountiesPage, self).__init__(driver) + self.driver = driver self.bounties_header = BountiesHeader(self.driver) self.top_hunters_header = TopHuntersHeader(self.driver) + self.bounty_titles = BountyTitles(self.driver) + self.bounty_item_rows = BountyItemRows(self.driver) + self.bounty_footers = BountyFooters(self.driver) + + def get_bounties_page(self): + self.driver.get(test_data.config['Common']['url'] + 'app') + diff --git a/test/end-to-end/pages/openbounty/landing.py b/test/end-to-end/pages/openbounty/landing.py index 7886f90..71f47f1 100644 --- a/test/end-to-end/pages/openbounty/landing.py +++ b/test/end-to-end/pages/openbounty/landing.py @@ -1,5 +1,6 @@ from pages.base_page import BasePageObject from pages.base_element import * +from tests import test_data class LoginButton(BaseButton): @@ -20,4 +21,4 @@ class LandingPage(BasePageObject): self.login_button = LoginButton(self.driver) def get_landing_page(self): - self.driver.get('https://openbounty.status.im:444/') + self.driver.get(test_data.config['Common']['url']) diff --git a/test/end-to-end/pages/thirdparty/github.py b/test/end-to-end/pages/thirdparty/github.py index eaf3c84..0d00335 100644 --- a/test/end-to-end/pages/thirdparty/github.py +++ b/test/end-to-end/pages/thirdparty/github.py @@ -1,6 +1,7 @@ import time, pytest from pages.base_element import * from pages.base_page import BasePageObject +from tests import test_data class EmailEditbox(BaseEditBox): @@ -156,11 +157,14 @@ class GithubPage(BasePageObject): def create_new_bounty(self): self.get_issues_page() self.new_issue_button.click() - self.issue_title_input.send_keys('auto_test_bounty_%s' % self.time_now) + test_data.issue = dict() + test_data.issue['title'] = 'auto_test_bounty_%s' % self.time_now + self.issue_title_input.send_keys(test_data.issue['title']) self.labels_button.click() self.bounty_label.click() self.cross_button.click() self.submit_new_issue_button.click() + return test_data.issue['title'] def get_deployed_contract(self, wait=120): for i in range(wait): diff --git a/test/end-to-end/tests/__init__.py b/test/end-to-end/tests/__init__.py index d9e141d..41ae6be 100644 --- a/test/end-to-end/tests/__init__.py +++ b/test/end-to-end/tests/__init__.py @@ -1,8 +1,17 @@ - +import configparser class TestData(object): def __init__(self): self.test_name = None + self.config = configparser.ConfigParser() + + # define here path to your config.ini file + #example - config_example.ini + + self.config.read('config.ini') + self.base_case_issue = dict() + self.base_case_issue['title'] = 'Very first auto_test_bounty' + test_data = TestData() diff --git a/test/end-to-end/tests/basetestcase.py b/test/end-to-end/tests/basetestcase.py index b658ed1..9ba9409 100644 --- a/test/end-to-end/tests/basetestcase.py +++ b/test/end-to-end/tests/basetestcase.py @@ -46,16 +46,22 @@ class BaseTestCase: def setup_method(self): self.errors = [] + self.cleanup = None if self.environment == 'local': options = webdriver.ChromeOptions() options.add_argument('--start-fullscreen') - self.driver = webdriver.Chrome(options=options) + options.add_extension( + path.abspath(test_data.config['Paths']['tests_absolute'] + 'resources/metamask3_12_0.crx')) + # for chromedriver 2.35 + self.driver = webdriver.Chrome(chrome_options=options) if self.environment == 'sauce': self.driver = webdriver.Remote(self.executor_sauce_lab, desired_capabilities=self.capabilities_sauce_lab) self.driver.implicitly_wait(5) + + def verify_no_errors(self): if self.errors: msg = '' @@ -64,9 +70,9 @@ class BaseTestCase: pytest.fail(msg, pytrace=False) def teardown_method(self): - - remove_application(self.driver) - remove_installation(self.driver) + if self.cleanup: + remove_application(self.driver) + remove_installation(self.driver) try: self.print_sauce_lab_info(self.driver) diff --git a/test/end-to-end/tests/config_example.ini b/test/end-to-end/tests/config_example.ini new file mode 100644 index 0000000..4b52a24 --- /dev/null +++ b/test/end-to-end/tests/config_example.ini @@ -0,0 +1,13 @@ +[Common] +;app URL +url = https://openbounty.status.im:444/ +[Paths] +;AbsolutePath to 'tests' folder +tests_absolute = /usr/dir/open-bounty/test/end-to-end/tests/ +[ORG] +;GitHub credentials for organization +gh_login = login +gh_password = password +;MetaMask password for organization +mm_password = password + diff --git a/test/end-to-end/tests/test_contracts.py b/test/end-to-end/tests/test_contracts.py index 6e617f3..5564b7b 100644 --- a/test/end-to-end/tests/test_contracts.py +++ b/test/end-to-end/tests/test_contracts.py @@ -1,22 +1,42 @@ import pytest from os import environ from pages.openbounty.landing import LandingPage +from pages.openbounty.bounties import BountiesPage from tests.basetestcase import BaseTestCase +from tests import test_data @pytest.mark.sanity class TestLogin(BaseTestCase): def test_deploy_new_contract(self): + self.cleanup = True landing = LandingPage(self.driver) landing.get_landing_page() + + # Sign Up to SOB github = landing.login_button.click() - github.sign_in('anna04test', - 'f@E23D3H15Rd') + github.sign_in(test_data.config['ORG']['gh_login'], + test_data.config['ORG']['gh_password']) assert github.permission_type.text == 'Personal user data' bounties_page = github.authorize_sob.click() + + # SOB Plugin installation and navigate to "Open bounties" github.install_sob_plugin() assert bounties_page.bounties_header.text == 'Bounties' assert bounties_page.top_hunters_header.text == 'Top 5 hunters' + + # Waiting for deployed contract; test_data.issue created here github.create_new_bounty() github.get_deployed_contract() + + # Navigate and check top bounty in "Open bounties" + bounties_page = BountiesPage(self.driver) + bounties_page.get_bounties_page() + titles = bounties_page.bounty_titles.find_elements() + assert titles[0].text == test_data.issue['title'] + + + + + From 41e15937c45f0b0f6dd97d66e9f5f63276de3393 Mon Sep 17 00:00:00 2001 From: Noman Date: Wed, 24 Jan 2018 23:54:45 -0500 Subject: [PATCH 11/17] Ensure Google Analytics using correct ID --- resources/public/dest/img/new-site/icon_rt_black.svg | 2 +- resources/templates/home.html | 2 +- static_langing_page/dest/img/new-site/icon_rt_black.svg | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/public/dest/img/new-site/icon_rt_black.svg b/resources/public/dest/img/new-site/icon_rt_black.svg index 835f3d5..7a31f8b 100644 --- a/resources/public/dest/img/new-site/icon_rt_black.svg +++ b/resources/public/dest/img/new-site/icon_rt_black.svg @@ -1 +1 @@ -icon_sl \ No newline at end of file +icon_sl \ No newline at end of file diff --git a/resources/templates/home.html b/resources/templates/home.html index 76e60f3..590156e 100644 --- a/resources/templates/home.html +++ b/resources/templates/home.html @@ -72,7 +72,7 @@ height="0" width="0" style="display:none;visibility:hidden"> (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); - ga('create', 'UA-79146816-2', 'auto'); + ga('create', 'UA-79146816-1', 'auto'); ga('send', 'pageview'); diff --git a/static_langing_page/dest/img/new-site/icon_rt_black.svg b/static_langing_page/dest/img/new-site/icon_rt_black.svg index 835f3d5..7a31f8b 100644 --- a/static_langing_page/dest/img/new-site/icon_rt_black.svg +++ b/static_langing_page/dest/img/new-site/icon_rt_black.svg @@ -1 +1 @@ -icon_sl \ No newline at end of file +icon_sl \ No newline at end of file From 5c163773b49977713ec8d9b122470e2ceeed3e63 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Thu, 25 Jan 2018 13:14:51 +0200 Subject: [PATCH 12/17] Add config-related docs; add cookbook.md for common issue troubleshooting --- README.md | 42 +++++++++++++++++++++++++++++++++++++----- doc/cookbook.md | 18 ++++++++++++++++++ doc/testing.md | 8 ++------ 3 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 doc/cookbook.md diff --git a/README.md b/README.md index bb7bc5b..597831f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ Live production version: https://openbounty.status.im The `master` branch is automatically deployed here. - Live testnet (Ropsten) version: https://openbounty.status.im:444 The `develop` branch is automatically deployed here. @@ -20,7 +19,6 @@ The `develop` branch is automatically deployed here. You will need [Leiningen](https://github.com/technomancy/leiningen) 2.0 or above installed. ### PostgreSQL -<<<<<<< HEAD Make sure you install [PostgreSQL](https://www.postgresql.org/) and properly set it up: @@ -39,7 +37,6 @@ lein figwheel lein less auto ``` -======= Make sure you install [PostgreSQL](https://www.postgresql.org/) and properly set it up: @@ -56,9 +53,40 @@ Solidity compiler [0.4.15](https://github.com/ethereum/solidity/releases/tag/v0. Web3j [2.3.0](https://github.com/web3j/web3j/releases/tag/v2.3.0) is required and the command line tools need to be in $PATH. -## Running +## Application config -Make sure `env/dev/resources/config.edn` is correctly populated. +Make sure that `env/dev/resources/config.edn` is correctly populated. Description of config fields is given below: + +Key | Description +--- | --- +dev | Currently specifies whether Swagger UI endpoints should be added to routes +port | HTTP port for the Ring web app +nrepl-port | nREPL port for development +jdbc-database-url | PostgreSQL database URL. For instance, URL to local db would be `jdbc:postgresql://localhost/commiteth?user=commiteth&password=commiteth` +server-address | URL and port of local server that can be resolved from public internet. It will be used as a redirect URI during GitHub OAuth authorization process +eth-account | Ethereum account ID for the bot +eth-password | Ethereum account password for the bot +eth-rpc-url | RPC URL to Ethereum node, e.g. Geth. Either local or remote +eth-wallet-file | Location of wallet file. If Geth is run with the parameters as given below, it will reside under `$HOME/.ropsten/keystore` +tokenreg-base-format | Should be set to `:status` +github-client-id | Related to OAuth. Copied from GitHub account Settings->Developer settings->OAuth Apps +github-client-secret | Related to OAuth. Copied from GitHub account Settings->Developer settings->OAuth Apps +github-user | GitHub username for bot account. It is used for posting bounty comments +github-password | GitHub password for bot account +webhook-secret | Secret string to be used when creating a GitHub App +user-whitelist | Set of GitHub user/org IDs to be whitelisted. E.g. `#{"status-im" "your_org"}` +testnet-token-data | Token data map, useful if there are Geth connectivity problems + +## GitHub integration +Open Bounty uses both OAuth App and GitHub App integration. + +### OAuth App +Follow the steps [here](https://developer.github.com/apps/building-oauth-apps/creating-an-oauth-app/). Specify the value of `:server-address` as "Homepage URL", and `:server-address` + `/callback` as "Authorization callback URL". Be sure to copy Client ID and Client Secret values to `config.edn`. + +### GitHub App +Follow the steps [here](https://developer.github.com/apps/building-github-apps/creating-a-github-app/). Be sure to specify `:server-address` + `/webhook-app` as "Webhook URL", and `:webhook-secret` as "Webhook Secret". + +## Running Lauch a local geth node with the bot account unlocked: @@ -141,6 +169,10 @@ Landing page is static and different CSS and JS due to time constraints. This copies over necessary artifacts to `resources` dir. + +### Troubleshooting +See the [Cookbook](doc/cookbook.md). + ## License Licensed under the [Affero General Public License v3.0](https://github.com/status-im/commiteth/blob/master/LICENSE.md) diff --git a/doc/cookbook.md b/doc/cookbook.md new file mode 100644 index 0000000..e76ad48 --- /dev/null +++ b/doc/cookbook.md @@ -0,0 +1,18 @@ +# Cookbook + +Here some common tasks/issues are listed along with their solutions. + +## Change config and restart the service + - ssh to the host running commiteth + - go to `/opt/commiteth` for prod or `/opt/commiteth-test` for test environment. + - there edit `config.edn` + - restart the service with `sudo service commiteth-test restart` + +## Manually add a GitHub repo to SOB app +Sometimes SOB will not + - connect to Postgres instance. Get DB name and username/password from respective `config.edn` (see previous answer). These are set in `:jdbc-database-url` field. + - execute the query, e.g. +``` +insert into repositories(repo_id,user_id,owner,repo,hook_id,state,hook_secret,owner_avatar_url) values(116971984,447328, 'aragon', 'aragon-monthly', 0, 2, '', 'https://avatars1.githubusercontent.com/u/24612534?v=4'); +``` +Note that the value for repo_id field is GitHub's internal repo ID. One way of obtaining it is navigating to `api.github.com/repos/:owner/:repo_name`, e.g. `https://api.github.com/repos/aragon/aragon-monthly`. diff --git a/doc/testing.md b/doc/testing.md index c0ad83f..91f955a 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -29,13 +29,9 @@ You should now see `Bounties`, `Activity`, `Repositories` and `Manage Payouts` t ### Creating bounty issues -Before you can create bounties, you need to have administrative access to one or more GitHub repositories. These can be either in the scope of your personal user account or in the scope of a Github orgnazation. +Before you can create bounties, you need to add Open Bounty GitHub App to your account or repos. Go to https://github.com/apps/status-open-bounty-app-test (or link to another GitHub App you've created for testing, as described in the [README](README.md) and click Install. Specify whether access to all org repos or specific repos is granted. This will install webhooks for SOB in your repos. -* click the `Repositories` tab -* click on the button `Enable Github Account` -* If you have 1 or more Organisation repositories then grant Organisation access to each of them by clicking on the button `Grant` -* grant Status Open Bounty the needed addtional permissions for managing repository webhooks, adding and modifying comments by clicking on the button `Authorize status-open-bounty` -* now you should see your repositories on the `Repositories` tab, click `Add` on one. If your account isn't whitelisted you will see instructions how to request an access. If your account is whitelisted then new `bounty` label will become available in the GitHub repository's labels and a new webhook should now exist for the repository. +* Request for your account to be whitelisted. Contact [Riot](https://chat.status.im) for more information * now, add the `bounty` label to a new or an existing issue. This should cause Status Open Bounty to post a new comment for the issue containing an image with text `Deploying contract, please wait` * once the contract has been mined, the comment will be updated to contain the bounty contract's address and a QR code From bb71d830a88fa82c78443a98d494eda550e49e60 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Thu, 25 Jan 2018 13:43:15 +0200 Subject: [PATCH 13/17] Add page-num-active style disabling pointer cursor --- src/cljs/commiteth/common.cljs | 12 ++++++------ src/less/style.less | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/cljs/commiteth/common.cljs b/src/cljs/commiteth/common.cljs index 8cb213d..25b47b3 100644 --- a/src/cljs/commiteth/common.cljs +++ b/src/cljs/commiteth/common.cljs @@ -48,15 +48,15 @@ (defn draw-page-numbers [page-number page-count] "Draw page numbers for the pagination component. - Inserts ellipsis when list is too long, by default - max 6 items are allowed" + Inserts ellipsis when list is too long, by default + max 6 items are allowed" (let [draw-page-num-fn (fn [current? i] ^{:key i} [:div.rectangle-rounded - (cond-> {} - (not current?) - (assoc :class "grayed-out-page-num" - :on-click #(rf/dispatch [:set-page-number i]))) + (if current? + {:class "page-num-active"} + {:class "grayed-out-page-num" + :on-click #(rf/dispatch [:set-page-number i])}) i]) max-page-nums 6] [:div.page-nums-container diff --git a/src/less/style.less b/src/less/style.less index d8c078c..063f7bb 100644 --- a/src/less/style.less +++ b/src/less/style.less @@ -897,6 +897,10 @@ body { cursor: pointer; } +.page-num-active { + cursor: auto; +} + .grayed-out-page-num { color: #8d99a4; background-color: #f2f5f8; From dbffabffe0db5f45e7d668884689db56e4c0fdf6 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Thu, 25 Jan 2018 17:04:00 +0200 Subject: [PATCH 14/17] Remove scroll-div; pass container element ref to on-click handlers --- src/cljs/commiteth/activity.cljs | 9 ++++----- src/cljs/commiteth/bounties.cljs | 9 ++++----- src/cljs/commiteth/common.cljs | 29 ++++++++++------------------- 3 files changed, 18 insertions(+), 29 deletions(-) diff --git a/src/cljs/commiteth/activity.cljs b/src/cljs/commiteth/activity.cljs index 2e9444e..887b8c7 100644 --- a/src/cljs/commiteth/activity.cljs +++ b/src/cljs/commiteth/activity.cljs @@ -4,7 +4,6 @@ [commiteth.common :refer [moment-timestamp items-per-page display-data-page - scroll-div issue-url]])) @@ -58,7 +57,8 @@ [:div.time (moment-timestamp updated)]]]]) (defn activity-list [{:keys [items item-count page-number total-count] - :as activity-page-data}] + :as activity-page-data} + container-element] (if (empty? (:items activity-page-data)) [:div.view-no-data-container [:p "No recent activity yet"]] @@ -67,7 +67,7 @@ right (dec (+ left item-count))] [:div.item-counts-label [:span (str "Showing " left "-" right " of " total-count)]]) - (display-data-page activity-page-data activity-item)])) + (display-data-page activity-page-data activity-item container-element)])) (defn activity-page [] (let [activity-page-data (rf/subscribe [:activities-page]) @@ -80,6 +80,5 @@ [:div.ui.text.loader.view-loading-label "Loading"]]] [:div.ui.container.activity-container {:ref #(reset! container-element %1)} - [scroll-div container-element] [:div.activity-header "Activities"] - [activity-list @activity-page-data]])))) + [activity-list @activity-page-data container-element]])))) diff --git a/src/cljs/commiteth/bounties.cljs b/src/cljs/commiteth/bounties.cljs index fdf741d..bfa73a4 100644 --- a/src/cljs/commiteth/bounties.cljs +++ b/src/cljs/commiteth/bounties.cljs @@ -3,7 +3,6 @@ [reagent.core :as r] [commiteth.common :refer [moment-timestamp display-data-page - scroll-div items-per-page issue-url]])) @@ -47,7 +46,8 @@ [:img {:src avatar-url}]]]])) (defn bounties-list [{:keys [items item-count page-number total-count] - :as bounty-page-data}] + :as bounty-page-data} + container-element] (if (empty? items) [:div.view-no-data-container [:p "No recent activity yet"]] @@ -56,7 +56,7 @@ right (dec (+ left item-count))] [:div.item-counts-label [:span (str "Showing " left "-" right " of " total-count)]]) - (display-data-page bounty-page-data bounty-item)])) + (display-data-page bounty-page-data bounty-item container-element)])) (defn bounties-page [] (let [bounty-page-data (rf/subscribe [:open-bounties-page]) @@ -69,7 +69,6 @@ [:div.ui.text.loader.view-loading-label "Loading"]]] [:div.ui.container.open-bounties-container {:ref #(reset! container-element %1)} - [scroll-div container-element] [:div.open-bounties-header "Bounties"] - [bounties-list @bounty-page-data]])) + [bounties-list @bounty-page-data container-element]])) )) diff --git a/src/cljs/commiteth/common.cljs b/src/cljs/commiteth/common.cljs index 25b47b3..f89e5e1 100644 --- a/src/cljs/commiteth/common.cljs +++ b/src/cljs/commiteth/common.cljs @@ -31,22 +31,9 @@ (defn issue-url [owner repo number] (str "https://github.com/" owner "/" repo "/issues/" number)) -(defn scroll-div [container-element] - "This is an invisible div that exists - for the sole purpose of scrolling the container-element into view - when page-number is updated" - (let [page-number (rf/subscribe [:page-number])] - (r/create-class - {:component-did-update (fn [] - (when @container-element - (.scrollIntoView @container-element))) - :reagent-render (fn [] - [:div {:style {:display "none"}} - @page-number])}))) - (def items-per-page 15) -(defn draw-page-numbers [page-number page-count] +(defn draw-page-numbers [page-number page-count container-element] "Draw page numbers for the pagination component. Inserts ellipsis when list is too long, by default max 6 items are allowed" @@ -56,7 +43,9 @@ (if current? {:class "page-num-active"} {:class "grayed-out-page-num" - :on-click #(rf/dispatch [:set-page-number i])}) + :on-click #(do + (rf/dispatch [:set-page-number i]) + (.scrollIntoView @container-element))}) i]) max-page-nums 6] [:div.page-nums-container @@ -92,7 +81,8 @@ total-count page-number page-count]} - draw-item-fn] + draw-item-fn + container-element] "Draw data items along with pagination controls" (let [draw-items (fn [] (into [:div.ui.items] @@ -106,11 +96,12 @@ (rf/dispatch [:set-page-number (if forward? (inc page-number) - (dec page-number))]))) + (dec page-number))]) + (.scrollIntoView @container-element))) draw-rect (fn [direction] (let [forward? (= direction :forward) gray-out? (or (and forward? (= page-number page-count)) - (and (not forward?) (= page-number 1))) ] + (and (not forward?) (= page-number 1)))] [:div.rectangle-rounded (cond-> {:on-click (on-direction-click forward?)} gray-out? (assoc :class "grayed-out-direction")) @@ -127,6 +118,6 @@ [draw-rect :backward] [draw-rect :forward]] [:div.page-nav-text [:span (str "Page " page-number " of " page-count)]] - [draw-page-numbers page-number page-count]]]))) + [draw-page-numbers page-number page-count container-element]]]))) From 3813e191508a48d1a74c885a7fc19087cb4f6994 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Fri, 26 Jan 2018 12:46:50 +0200 Subject: [PATCH 15/17] Add check for container-element --- src/cljs/commiteth/common.cljs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cljs/commiteth/common.cljs b/src/cljs/commiteth/common.cljs index f89e5e1..1213395 100644 --- a/src/cljs/commiteth/common.cljs +++ b/src/cljs/commiteth/common.cljs @@ -45,7 +45,8 @@ {:class "grayed-out-page-num" :on-click #(do (rf/dispatch [:set-page-number i]) - (.scrollIntoView @container-element))}) + (when @container-element + (.scrollIntoView @container-element)))}) i]) max-page-nums 6] [:div.page-nums-container @@ -97,7 +98,8 @@ (if forward? (inc page-number) (dec page-number))]) - (.scrollIntoView @container-element))) + (when @container-element + (.scrollIntoView @container-element)))) draw-rect (fn [direction] (let [forward? (= direction :forward) gray-out? (or (and forward? (= page-number page-count)) From 2f2431792ae6a4af8c9040902168d1848375b0af Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Fri, 26 Jan 2018 15:54:35 +0200 Subject: [PATCH 16/17] Revert CIDER removal and update to recent version --- project.clj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/project.clj b/project.clj index 3c8bd92..5f822e7 100644 --- a/project.clj +++ b/project.clj @@ -69,6 +69,7 @@ [lein-auto "0.1.2"] [lein-less "1.7.5"] [lein-shell "0.5.0"] + [cider/cider-nrepl "0.15.0-SNAPSHOT"] [lein-sha-version "0.1.1"]] @@ -143,7 +144,7 @@ :prep-tasks ["build-contracts" "javac"] :doo {:build "test"} - :source-paths ["env/dev/clj" "test/clj" "src/cljs" "env/dev/cljs"] + :source-paths ["env/dev/clj" "test/clj"] :resource-paths ["env/dev/resources"] :repl-options {:init-ns user :nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]} @@ -167,3 +168,4 @@ :output-to "resources/public/js/compiled/devcards.js" :output-dir "resources/public/js/compiled/out" :source-map-timestamp true}}}}}}) + From 3f883a36c1ed99555fe101347e82566cc70eff12 Mon Sep 17 00:00:00 2001 From: Vitaliy Vlasov Date: Fri, 26 Jan 2018 19:24:25 +0200 Subject: [PATCH 17/17] Remove empty line --- project.clj | 1 - 1 file changed, 1 deletion(-) diff --git a/project.clj b/project.clj index 5f822e7..e6af24a 100644 --- a/project.clj +++ b/project.clj @@ -168,4 +168,3 @@ :output-to "resources/public/js/compiled/devcards.js" :output-dir "resources/public/js/compiled/out" :source-map-timestamp true}}}}}}) -