Merge branch 'develop' into fix/update-github-comment-339

This commit is contained in:
Tetiana Churikova 2018-03-16 12:48:39 +02:00 committed by GitHub
commit d7dc1b297e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 44 deletions

View File

@ -5,7 +5,7 @@
:exclusions [joda-time]]
[re-frame "0.10.2"]
[cljs-ajax "0.7.2"]
[secretary "1.2.3"]
[funcool/bide "1.6.0"]
[reagent-utils "0.2.1"]
[reagent "0.7.0"]
[org.clojure/clojurescript "1.9.946"]

View File

@ -1,10 +1,10 @@
(ns commiteth.core
(:require [reagent.core :as r]
[re-frame.core :as rf]
[secretary.core :as secretary]
[goog.events :as events]
[goog.history.EventType :as HistoryEventType]
[commiteth.ajax :refer [load-interceptors!]]
[commiteth.routes]
[commiteth.handlers]
[commiteth.subscriptions]
[commiteth.activity :refer [activity-page]]
@ -53,7 +53,7 @@
[:a
(merge props
(if (keyword? target)
{:on-click #(rf/dispatch [target])}
{:on-click #(commiteth.routes/nav! target)}
{:href target}))
caption]]))]]))
@ -66,7 +66,7 @@
[:div.ui.container.user-component
[user-dropdown
@user
[[:update-address "My Payment Details" {}]
[[:settings "My Payment Details" {}]
["/logout" "Sign Out" {:class "logout-link"}]]
mobile?]]
[:a.ui.button.small.login-button {:href js/authorizeUrl} (str "LOG IN"
@ -89,7 +89,7 @@
(for [[page caption] tabs]
(let [props {:class (str "ui item"
(when (= @current-page page) " active"))
:on-click #(rf/dispatch [:set-active-page page])}]
:on-click #(commiteth.routes/nav! page)}]
^{:key page} [:div props caption])))))))
@ -124,15 +124,6 @@
[flash-message-pane])])))
(def pages
{:activity #'activity-page
:bounties #'bounties-page
:repos #'repos-page
:manage-payouts #'manage-payouts-page
:update-address #'update-address-page
:usage-metrics #'usage-metrics-page})
(defn top-hunters []
(let [top-hunters (rf/subscribe [:top-hunters])]
(fn []
@ -211,7 +202,13 @@
[:div {:class (str (if (show-top-hunters?) "eleven" "sixteen")
" wide computer sixteen wide tablet column")}
[:div.ui.container
[(pages @current-page)]]]
(case @current-page
:activity [activity-page]
:bounties [bounties-page]
:repos [repos-page]
:manage-payouts [manage-payouts-page]
:settings [update-address-page]
:usage-metrics [usage-metrics-page])]]
(when (show-top-hunters?)
[:div.five.wide.column.computer.only
[:div.ui.container.top-hunters
@ -220,28 +217,6 @@
[top-hunters]]])]]]
[footer]])))
(secretary/set-config! :prefix "#")
(secretary/defroute "/" []
(rf/dispatch [:set-active-page :bounties]))
(secretary/defroute "/activity" []
(rf/dispatch [:set-active-page :activity]))
(secretary/defroute "/repos" []
(if js/user
(rf/dispatch [:set-active-page :repos])
(secretary/dispatch! "/")))
(defn hook-browser-navigation! []
(doto (History.)
(events/listen
HistoryEventType/NAVIGATE
(fn [event]
(secretary/dispatch! (.-token event))))
(.setEnabled true)))
(defn mount-components []
(r/render [#'page] (.getElementById js/document "app")))
@ -286,7 +261,7 @@
(when config/debug?
(enable-re-frisk!))
(load-interceptors!)
(hook-browser-navigation!)
(commiteth.routes/setup-nav!)
(load-data true)
(.addEventListener js/window "click" #(rf/dispatch [:clear-flash-message]))
(on-js-load))

View File

@ -312,12 +312,6 @@
(:status-text response)))]}))
(reg-event-fx
:update-address
(fn [{:keys [db]} [_]]
{:db db
:dispatch [:set-active-page :update-address]}))
(reg-event-db
:update-user
(fn [db [_ fields]]

View File

@ -0,0 +1,25 @@
(ns commiteth.routes
(:require [bide.core :as bide]
[re-frame.core :as rf]))
(defonce router
(bide/router [["/" :bounties]
["/activity" :activity]
["/repos" :repos]
["/manage-payouts" :manage-payouts]
["/settings" :settings]
["/usage-metrics" :usage-metrics]]))
(defn on-navigate
"A function which will be called on each route change."
[name params query]
(println "Route change to: " name params query)
(rf/dispatch [:set-active-page name]))
(defn setup-nav! []
(bide/start! router {:default :bounties
:on-navigate on-navigate}))
(defn nav! [route-id]
(bide/navigate! router route-id {}))