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"]
|
||||
[prismatic/plumbing "0.5.3"]
|
||||
[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"
|
||||
:source-paths ["src/clj" "src/cljc"]
|
||||
|
@ -131,7 +132,8 @@
|
|||
:doo {:build "test"}
|
||||
:source-paths ["env/dev/clj" "test/clj"]
|
||||
: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)
|
||||
(pjstadig.humane-test-output/activate!)]}
|
||||
:test {:resource-paths ["env/dev/resources" "env/test/resources"]
|
||||
|
|
|
@ -64,22 +64,26 @@
|
|||
{repo-id :id
|
||||
full-repo :full_name
|
||||
repo :name} params
|
||||
[owner _] (str/split full-repo #"/")]
|
||||
(try
|
||||
(let [db-item (repositories/create (merge params {:user_id user-id
|
||||
:owner owner}))
|
||||
is-enabled (= 2 (:state db-item))]
|
||||
(if is-enabled
|
||||
(disable-repo repo-id full-repo (:hook_id db-item) token)
|
||||
(enable-repo repo-id repo full-repo token))
|
||||
(ok (merge
|
||||
{:enabled (not is-enabled)}
|
||||
(select-keys params [:id :full_name]))))
|
||||
(catch Exception e
|
||||
(log/info "exception when enabling repo "
|
||||
[owner _] (str/split full-repo #"/")
|
||||
db-user (users/get-user (:id user))]
|
||||
(if (empty? (:address db-user))
|
||||
{:status 400
|
||||
:body "Please add your ethereum address to your profile first"}
|
||||
(try
|
||||
(let [db-item (repositories/create (merge params {:user_id user-id
|
||||
:owner owner}))
|
||||
is-enabled (= 2 (:state db-item))]
|
||||
(if is-enabled
|
||||
(disable-repo repo-id full-repo (:hook_id db-item) token)
|
||||
(enable-repo repo-id repo full-repo token))
|
||||
(ok (merge
|
||||
{:enabled (not is-enabled)}
|
||||
(select-keys params [:id :full_name]))))
|
||||
(catch Exception e
|
||||
(log/info "exception when enabling repo "
|
||||
(.getMessage e))
|
||||
(repositories/update-repo repo-id {:state -1})
|
||||
(internal-server-error)))))
|
||||
(repositories/update-repo repo-id {:state -1})
|
||||
(internal-server-error))))))
|
||||
|
||||
(defn in? [coll elem]
|
||||
(some #(= elem %) coll))
|
||||
|
|
|
@ -16,11 +16,11 @@
|
|||
{:href (issue-url repo-owner repo-name issue-number)}
|
||||
issue-title]]
|
||||
(case item-type
|
||||
"new-bounty" [:p "Opened a bounty for " issue-link]
|
||||
"claim-payout" [:p "Received " [:span.balance "ETH " balance]
|
||||
"new-bounty" [:div "Opened a bounty for " issue-link]
|
||||
"claim-payout" [:div "Received " [:span.balance "ETH " balance]
|
||||
" for " issue-link]
|
||||
"open-claim" [:p "Submitted a claim for " issue-link]
|
||||
"balance-update" [:p issue-link " bounty increased to "
|
||||
"open-claim" [:div "Submitted a claim for " issue-link]
|
||||
"balance-update" [:div issue-link " bounty increased to "
|
||||
[:div.balance balance]]
|
||||
"")))
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
|
||||
(defn claim-list [bounties]
|
||||
;; TODO: exclude bounties with no claims
|
||||
(if (empty? bounties)
|
||||
[:div.ui.text "No items"]
|
||||
(into [:div.activity-item-container]
|
||||
|
|
|
@ -187,6 +187,7 @@
|
|||
:url "/api/user/repository/toggle"
|
||||
:on-success #(dispatch [:repo-toggle-success %])
|
||||
:on-error #(dispatch [:repo-toggle-error repo %])
|
||||
:finally #(println "finally" %)
|
||||
:params (select-keys repo [:id :owner :full_name :name])}}))
|
||||
|
||||
|
||||
|
@ -207,7 +208,10 @@
|
|||
(:full_name repo)
|
||||
{:busy? false}))
|
||||
: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
|
||||
|
@ -281,12 +285,12 @@
|
|||
:payout-confirmed
|
||||
(fn [db [_ issue-id]]
|
||||
(-> db
|
||||
(dissoc-in [:owner-bounties (:issue_id issue) :confirming?] false)
|
||||
(assoc-in [:owner-bounties (:issue_id issue) :confirmed?] true))))
|
||||
(dissoc-in [:owner-bounties (:issue_id issue-id) :confirming?])
|
||||
(assoc-in [:owner-bounties (:issue_id issue-id) :confirmed?] true))))
|
||||
|
||||
(reg-event-db
|
||||
:payout-confirm-failed
|
||||
(fn [db [_ issue-id]]
|
||||
(-> db
|
||||
(dissoc-in [:owner-bounties (:issue_id issue) :confirming?] false)
|
||||
(assoc-in [:owner-bounties (:issue_id issue) :confirm-failed?] true))))
|
||||
(dissoc-in [:owner-bounties (:issue_id issue-id) :confirming?])
|
||||
(assoc-in [:owner-bounties (:issue_id issue-id) :confirm-failed?] true))))
|
||||
|
|
Loading…
Reference in New Issue