mirror of
https://github.com/status-im/open-bounty.git
synced 2025-01-12 10:34:30 +00:00
Fix regression + UI tweaks
This commit is contained in:
parent
354c262301
commit
e265e967e2
@ -17,15 +17,14 @@
|
|||||||
|
|
||||||
|
|
||||||
(defn add-bounty-for-issue [repo repo-id login issue]
|
(defn add-bounty-for-issue [repo repo-id login issue]
|
||||||
(log/debug "add-bounty-for-issue" issue)
|
|
||||||
(let [{issue-id :id
|
(let [{issue-id :id
|
||||||
issue-number :number
|
issue-number :number
|
||||||
issue-title :title} issue
|
issue-title :title} issue
|
||||||
created-issue (issues/create repo-id issue-id issue-number issue-title)
|
created-issue (issues/create repo-id issue-id issue-number issue-title)
|
||||||
repo-owner (:address (users/get-repo-owner repo-id))]
|
repo-owner-address (:address (users/get-repo-owner repo-id))]
|
||||||
(log/info (format "Issue %s/%s/%s labeled as bounty" login repo issue-number))
|
(log/info (format "Issue %s/%s/%s labeled as bounty" login repo issue-number))
|
||||||
(if (= 1 created-issue)
|
(if (= 1 created-issue)
|
||||||
(let [transaction-hash (eth/deploy-contract repo-owner)]
|
(let [transaction-hash (eth/deploy-contract repo-owner-address)]
|
||||||
(log/info "Contract deployed, transaction-hash:" transaction-hash )
|
(log/info "Contract deployed, transaction-hash:" transaction-hash )
|
||||||
(issues/update-transaction-hash issue-id transaction-hash))
|
(issues/update-transaction-hash issue-id transaction-hash))
|
||||||
(log/debug "Issue already exists in DB, ignoring"))))
|
(log/debug "Issue already exists in DB, ignoring"))))
|
||||||
@ -34,7 +33,6 @@
|
|||||||
(defn add-bounties-for-existing-issues [repo repo-id login]
|
(defn add-bounties-for-existing-issues [repo repo-id login]
|
||||||
(let [issues (github/get-issues login repo)
|
(let [issues (github/get-issues login repo)
|
||||||
bounty-issues (filter has-bounty-label? issues)]
|
bounty-issues (filter has-bounty-label? issues)]
|
||||||
(log/debug bounty-issues)
|
|
||||||
(log/debug "adding bounties for"
|
(log/debug "adding bounties for"
|
||||||
(count bounty-issues) " existing issues")
|
(count bounty-issues) " existing issues")
|
||||||
(doall
|
(doall
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
(ns commiteth.db.users
|
(ns commiteth.db.users
|
||||||
(:require [commiteth.db.core :refer [*db*] :as db]
|
(:require [commiteth.db.core :refer [*db*] :as db]
|
||||||
[clojure.java.jdbc :as jdbc])
|
[clojure.java.jdbc :as jdbc]
|
||||||
|
[clojure.tools.logging :as log])
|
||||||
(:import [java.util Date]))
|
(:import [java.util Date]))
|
||||||
|
|
||||||
(defn create-user
|
(defn create-user
|
||||||
@ -28,6 +29,7 @@
|
|||||||
|
|
||||||
(defn update-user-address
|
(defn update-user-address
|
||||||
[user-id address]
|
[user-id address]
|
||||||
|
(log/debug "update-user-address" user-id address)
|
||||||
(jdbc/with-db-connection [con-db *db*]
|
(jdbc/with-db-connection [con-db *db*]
|
||||||
(db/update-user-address! con-db {:id user-id :address address})))
|
(db/update-user-address! con-db {:id user-id :address address})))
|
||||||
|
|
||||||
|
@ -30,27 +30,27 @@
|
|||||||
(update-in acc [:letks] into [binding `(:identity ~'+compojure-api-request+)]))
|
(update-in acc [:letks] into [binding `(:identity ~'+compojure-api-request+)]))
|
||||||
|
|
||||||
|
|
||||||
(defn enable-repo [repo-id repo login token]
|
(defn enable-repo [repo-id repo full-repo login token]
|
||||||
(log/debug "enable-repo" repo-id repo)
|
(log/debug "enable-repo" repo-id repo)
|
||||||
(let [hook-secret (random/base64 32)]
|
(let [hook-secret (random/base64 32)]
|
||||||
(try
|
(try
|
||||||
(repositories/update-repo repo-id {:state 1
|
(repositories/update-repo repo-id {:state 1
|
||||||
:hook_secret hook-secret})
|
:hook_secret hook-secret})
|
||||||
(let [created-hook (github/add-webhook repo token hook-secret)]
|
(let [created-hook (github/add-webhook full-repo token hook-secret)]
|
||||||
(log/debug "Created webhook:" created-hook)
|
(log/debug "Created webhook:" created-hook)
|
||||||
(github/create-label repo token)
|
(github/create-label full-repo token)
|
||||||
(repositories/update-repo repo-id {:state 2
|
(repositories/update-repo repo-id {:state 2
|
||||||
:hook_id (:id created-hook)})
|
:hook_id (:id created-hook)})
|
||||||
(bounties/add-bounties-for-existing-issues repo repo-id login))
|
(bounties/add-bounties-for-existing-issues repo repo-id login))
|
||||||
(catch Exception e
|
(catch Exception e
|
||||||
(log/info "exception when creating webhook" (.getMessage e))
|
(log/info "exception when creating webhook" (.getMessage e) e)
|
||||||
(repositories/update-repo repo-id {:state -1})))))
|
(repositories/update-repo repo-id {:state -1})))))
|
||||||
|
|
||||||
|
|
||||||
(defn disable-repo [repo-id repo hook-id token]
|
(defn disable-repo [repo-id full-repo hook-id token]
|
||||||
(log/debug "disable-repo" repo-id repo)
|
(log/debug "disable-repo" repo-id full-repo)
|
||||||
(do
|
(do
|
||||||
(github/remove-webhook repo hook-id token)
|
(github/remove-webhook full-repo hook-id token)
|
||||||
(repositories/update-repo repo-id {:hook_secret ""
|
(repositories/update-repo repo-id {:hook_secret ""
|
||||||
:state 0
|
:state 0
|
||||||
:hook_id nil})))
|
:hook_id nil})))
|
||||||
@ -62,13 +62,14 @@
|
|||||||
login :login
|
login :login
|
||||||
user-id :id} user
|
user-id :id} user
|
||||||
{repo-id :id
|
{repo-id :id
|
||||||
repo :full_name} params
|
full-repo :full_name
|
||||||
|
repo :name} params
|
||||||
db-item (repositories/create (merge params {:user_id user-id
|
db-item (repositories/create (merge params {:user_id user-id
|
||||||
:login login}))
|
:login login}))
|
||||||
is-enabled (= 2 (:state db-item))]
|
is-enabled (= 2 (:state db-item))]
|
||||||
(if is-enabled
|
(if is-enabled
|
||||||
(disable-repo repo-id repo (:hook_id db-item) token)
|
(disable-repo repo-id full-repo (:hook_id db-item) token)
|
||||||
(enable-repo repo-id repo login token))
|
(enable-repo repo-id repo full-repo login token))
|
||||||
(merge
|
(merge
|
||||||
{:enabled (not is-enabled)}
|
{:enabled (not is-enabled)}
|
||||||
(select-keys params [:id :full_name]))))
|
(select-keys params [:id :full_name]))))
|
||||||
@ -108,9 +109,9 @@
|
|||||||
(ok {:user (users/get-user (:id user))}))
|
(ok {:user (users/get-user (:id user))}))
|
||||||
(POST "/address" []
|
(POST "/address" []
|
||||||
:auth-rules authenticated?
|
:auth-rules authenticated?
|
||||||
:body-params [user-id :- String, address :- String]
|
:body-params [user-id :- Long, address :- String]
|
||||||
:summary "Update user address"
|
:summary "Update user address"
|
||||||
(let [result (users/update-user-address (Integer/parseInt user-id) address)]
|
(let [result (users/update-user-address user-id address)]
|
||||||
(if (= 1 result)
|
(if (= 1 result)
|
||||||
(ok)
|
(ok)
|
||||||
(internal-server-error))))
|
(internal-server-error))))
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
repo-name :name
|
repo-name :name
|
||||||
{login :login} :owner} (:repository webhook-payload)
|
{login :login} :owner} (:repository webhook-payload)
|
||||||
repo-map {:repo repo-name :login login :repo_id repo-id}]
|
repo-map {:repo repo-name :login login :repo_id repo-id}]
|
||||||
(bounties/add-bounty-for-issue repo-map issue)))
|
(bounties/add-bounty-for-issue repo-name repo-id issue)))
|
||||||
|
|
||||||
(defn handle-issue-closed
|
(defn handle-issue-closed
|
||||||
;; TODO: does not work in case the issue is closed on github web ui
|
;; TODO: does not work in case the issue is closed on github web ui
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
|
|
||||||
(defn activity-page []
|
(defn activity-page []
|
||||||
(fn []
|
(fn []
|
||||||
[:div "This will be the activity view"]))
|
[:div.ui.container
|
||||||
|
[:div.ui.text "This will be the activity view"]]))
|
||||||
|
@ -3,4 +3,5 @@
|
|||||||
|
|
||||||
(defn bounties-page []
|
(defn bounties-page []
|
||||||
(fn []
|
(fn []
|
||||||
[:div "Bounties view not implemented"]))
|
[:div.ui.container
|
||||||
|
[:div.ui.text "Bounties view coming soon"]]))
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
(ns commiteth.manage
|
(ns commiteth.manage
|
||||||
(:require [re-frame.core :as rf]
|
(:require [re-frame.core :as rf]
|
||||||
[commiteth.common :refer [input checkbox]]
|
[commiteth.common :refer [input]]
|
||||||
[commiteth.issues :refer [issues-list-table issue-url]]
|
[commiteth.issues :refer [issues-list-table issue-url]]
|
||||||
[clojure.set :refer [rename-keys]]))
|
[clojure.set :refer [rename-keys]]))
|
||||||
|
|
||||||
@ -16,7 +16,7 @@
|
|||||||
^{:key repo-id}
|
^{:key repo-id}
|
||||||
[:div.d-table.width-full
|
[:div.d-table.width-full
|
||||||
[:div.d-table.col-12.width-full.py-4.border-bottom.issue
|
[:div.d-table.col-12.width-full.py-4.border-bottom.issue
|
||||||
[checkbox {:value-path [:enabled-repos repo-id]
|
#_[checkbox {:value-path [:enabled-repos repo-id]
|
||||||
:style {:width 32 :margin-left 10}
|
:style {:width 32 :margin-left 10}
|
||||||
:on-change #(rf/dispatch [:toggle-repo repo])}]
|
:on-change #(rf/dispatch [:toggle-repo repo])}]
|
||||||
[:div.d-table-cell.col-11.pr-3.v-align-top
|
[:div.d-table-cell.col-11.pr-3.v-align-top
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
(defn repo-card [repo]
|
(defn repo-card [repo]
|
||||||
[:div.ui.card
|
[:div.ui.card
|
||||||
[:div.content
|
[:div.content
|
||||||
[:div.repo-label (:full_name repo)]
|
[:div.repo-label [:a {:href (:html_url repo)} (:full_name repo)]]
|
||||||
[:div.repo-description (:description repo)]]
|
[:div.repo-description (:description repo)]]
|
||||||
[:div.repo-button-container
|
[:div.repo-button-container
|
||||||
[repo-toggle-button
|
[repo-toggle-button
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
[:div.ui.container.grid
|
[:div.ui.container.grid
|
||||||
[:div.ui.form.eight.wide.column
|
[:div.ui.form.eight.wide.column
|
||||||
[:h3 "Update address"]
|
[:h3 "Update address"]
|
||||||
[:p "Placeholder text for explaining what an Etheum address is."]
|
[:p "Placeholder text for explaining what an Ethereum address is."]
|
||||||
[:div.field
|
[:div.field
|
||||||
(if-not (empty? web3-accounts)
|
(if-not (empty? web3-accounts)
|
||||||
[dropdown "Select address"
|
[dropdown "Select address"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user