Require Ethereum address for toggling repos
* do not allow toggling of repositories without a saved Ethereum address (Fixes: #20) * fix react warning on activity view * fix bugs in payout related re-frame handlers * project file tweaks
This commit is contained in:
parent
9f010648aa
commit
442f5c7821
|
@ -44,7 +44,8 @@
|
||||||
[pandect "0.6.1"]
|
[pandect "0.6.1"]
|
||||||
[prismatic/plumbing "0.5.3"]
|
[prismatic/plumbing "0.5.3"]
|
||||||
[cljsjs/moment "2.17.1-0"]
|
[cljsjs/moment "2.17.1-0"]
|
||||||
[org.clojure/tools.nrepl "0.2.12"]]
|
[org.clojure/tools.nrepl "0.2.12"]
|
||||||
|
[com.cemerick/piggieback "0.2.2-SNAPSHOT"]]
|
||||||
|
|
||||||
:min-lein-version "2.0.0"
|
:min-lein-version "2.0.0"
|
||||||
:source-paths ["src/clj" "src/cljc"]
|
:source-paths ["src/clj" "src/cljc"]
|
||||||
|
@ -131,7 +132,8 @@
|
||||||
:doo {:build "test"}
|
:doo {:build "test"}
|
||||||
:source-paths ["env/dev/clj" "test/clj"]
|
:source-paths ["env/dev/clj" "test/clj"]
|
||||||
:resource-paths ["env/dev/resources"]
|
:resource-paths ["env/dev/resources"]
|
||||||
:repl-options {:init-ns user}
|
:repl-options {:init-ns user
|
||||||
|
:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
|
||||||
:injections [(require 'pjstadig.humane-test-output)
|
:injections [(require 'pjstadig.humane-test-output)
|
||||||
(pjstadig.humane-test-output/activate!)]}
|
(pjstadig.humane-test-output/activate!)]}
|
||||||
:test {:resource-paths ["env/dev/resources" "env/test/resources"]
|
:test {:resource-paths ["env/dev/resources" "env/test/resources"]
|
||||||
|
|
|
@ -64,22 +64,26 @@
|
||||||
{repo-id :id
|
{repo-id :id
|
||||||
full-repo :full_name
|
full-repo :full_name
|
||||||
repo :name} params
|
repo :name} params
|
||||||
[owner _] (str/split full-repo #"/")]
|
[owner _] (str/split full-repo #"/")
|
||||||
(try
|
db-user (users/get-user (:id user))]
|
||||||
(let [db-item (repositories/create (merge params {:user_id user-id
|
(if (empty? (:address db-user))
|
||||||
:owner owner}))
|
{:status 400
|
||||||
is-enabled (= 2 (:state db-item))]
|
:body "Please add your ethereum address to your profile first"}
|
||||||
(if is-enabled
|
(try
|
||||||
(disable-repo repo-id full-repo (:hook_id db-item) token)
|
(let [db-item (repositories/create (merge params {:user_id user-id
|
||||||
(enable-repo repo-id repo full-repo token))
|
:owner owner}))
|
||||||
(ok (merge
|
is-enabled (= 2 (:state db-item))]
|
||||||
{:enabled (not is-enabled)}
|
(if is-enabled
|
||||||
(select-keys params [:id :full_name]))))
|
(disable-repo repo-id full-repo (:hook_id db-item) token)
|
||||||
(catch Exception e
|
(enable-repo repo-id repo full-repo token))
|
||||||
(log/info "exception when enabling repo "
|
(ok (merge
|
||||||
|
{:enabled (not is-enabled)}
|
||||||
|
(select-keys params [:id :full_name]))))
|
||||||
|
(catch Exception e
|
||||||
|
(log/info "exception when enabling repo "
|
||||||
(.getMessage e))
|
(.getMessage e))
|
||||||
(repositories/update-repo repo-id {:state -1})
|
(repositories/update-repo repo-id {:state -1})
|
||||||
(internal-server-error)))))
|
(internal-server-error))))))
|
||||||
|
|
||||||
(defn in? [coll elem]
|
(defn in? [coll elem]
|
||||||
(some #(= elem %) coll))
|
(some #(= elem %) coll))
|
||||||
|
|
|
@ -16,11 +16,11 @@
|
||||||
{:href (issue-url repo-owner repo-name issue-number)}
|
{:href (issue-url repo-owner repo-name issue-number)}
|
||||||
issue-title]]
|
issue-title]]
|
||||||
(case item-type
|
(case item-type
|
||||||
"new-bounty" [:p "Opened a bounty for " issue-link]
|
"new-bounty" [:div "Opened a bounty for " issue-link]
|
||||||
"claim-payout" [:p "Received " [:span.balance "ETH " balance]
|
"claim-payout" [:div "Received " [:span.balance "ETH " balance]
|
||||||
" for " issue-link]
|
" for " issue-link]
|
||||||
"open-claim" [:p "Submitted a claim for " issue-link]
|
"open-claim" [:div "Submitted a claim for " issue-link]
|
||||||
"balance-update" [:p issue-link " bounty increased to "
|
"balance-update" [:div issue-link " bounty increased to "
|
||||||
[:div.balance balance]]
|
[:div.balance balance]]
|
||||||
"")))
|
"")))
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@
|
||||||
|
|
||||||
|
|
||||||
(defn claim-list [bounties]
|
(defn claim-list [bounties]
|
||||||
|
;; 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.activity-item-container]
|
||||||
|
|
|
@ -187,6 +187,7 @@
|
||||||
:url "/api/user/repository/toggle"
|
:url "/api/user/repository/toggle"
|
||||||
:on-success #(dispatch [:repo-toggle-success %])
|
:on-success #(dispatch [:repo-toggle-success %])
|
||||||
:on-error #(dispatch [:repo-toggle-error repo %])
|
:on-error #(dispatch [:repo-toggle-error repo %])
|
||||||
|
:finally #(println "finally" %)
|
||||||
:params (select-keys repo [:id :owner :full_name :name])}}))
|
:params (select-keys repo [:id :owner :full_name :name])}}))
|
||||||
|
|
||||||
|
|
||||||
|
@ -207,7 +208,10 @@
|
||||||
(:full_name repo)
|
(:full_name repo)
|
||||||
{:busy? false}))
|
{:busy? false}))
|
||||||
:dispatch [:set-flash-message
|
:dispatch [:set-flash-message
|
||||||
:error (str "Failed to toggle repo: " (:status-text response))]}))
|
:error (if (= 400 (:status response))
|
||||||
|
(:response response)
|
||||||
|
(str "Failed to toggle repo: "
|
||||||
|
(:status-text response)))]}))
|
||||||
|
|
||||||
|
|
||||||
(reg-event-fx
|
(reg-event-fx
|
||||||
|
@ -281,12 +285,12 @@
|
||||||
:payout-confirmed
|
:payout-confirmed
|
||||||
(fn [db [_ issue-id]]
|
(fn [db [_ issue-id]]
|
||||||
(-> db
|
(-> db
|
||||||
(dissoc-in [:owner-bounties (:issue_id issue) :confirming?] false)
|
(dissoc-in [:owner-bounties (:issue_id issue-id) :confirming?])
|
||||||
(assoc-in [:owner-bounties (:issue_id issue) :confirmed?] true))))
|
(assoc-in [:owner-bounties (:issue_id issue-id) :confirmed?] true))))
|
||||||
|
|
||||||
(reg-event-db
|
(reg-event-db
|
||||||
:payout-confirm-failed
|
:payout-confirm-failed
|
||||||
(fn [db [_ issue-id]]
|
(fn [db [_ issue-id]]
|
||||||
(-> db
|
(-> db
|
||||||
(dissoc-in [:owner-bounties (:issue_id issue) :confirming?] false)
|
(dissoc-in [:owner-bounties (:issue_id issue-id) :confirming?])
|
||||||
(assoc-in [:owner-bounties (:issue_id issue) :confirm-failed?] true))))
|
(assoc-in [:owner-bounties (:issue_id issue-id) :confirm-failed?] true))))
|
||||||
|
|
Loading…
Reference in New Issue