Fix regression + UI tweaks

This commit is contained in:
Teemu Patja 2017-02-18 22:46:59 +02:00
parent 354c262301
commit e265e967e2
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
9 changed files with 27 additions and 24 deletions

View File

@ -17,15 +17,14 @@
(defn add-bounty-for-issue [repo repo-id login issue]
(log/debug "add-bounty-for-issue" issue)
(let [{issue-id :id
issue-number :number
issue-title :title} issue
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))
(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 )
(issues/update-transaction-hash issue-id transaction-hash))
(log/debug "Issue already exists in DB, ignoring"))))
@ -34,7 +33,6 @@
(defn add-bounties-for-existing-issues [repo repo-id login]
(let [issues (github/get-issues login repo)
bounty-issues (filter has-bounty-label? issues)]
(log/debug bounty-issues)
(log/debug "adding bounties for"
(count bounty-issues) " existing issues")
(doall

View File

@ -1,6 +1,7 @@
(ns commiteth.db.users
(: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]))
(defn create-user
@ -28,6 +29,7 @@
(defn update-user-address
[user-id address]
(log/debug "update-user-address" user-id address)
(jdbc/with-db-connection [con-db *db*]
(db/update-user-address! con-db {:id user-id :address address})))

View File

@ -30,27 +30,27 @@
(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)
(let [hook-secret (random/base64 32)]
(try
(repositories/update-repo repo-id {:state 1
: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)
(github/create-label repo token)
(github/create-label full-repo token)
(repositories/update-repo repo-id {:state 2
:hook_id (:id created-hook)})
(bounties/add-bounties-for-existing-issues repo repo-id login))
(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})))))
(defn disable-repo [repo-id repo hook-id token]
(log/debug "disable-repo" repo-id repo)
(defn disable-repo [repo-id full-repo hook-id token]
(log/debug "disable-repo" repo-id full-repo)
(do
(github/remove-webhook repo hook-id token)
(github/remove-webhook full-repo hook-id token)
(repositories/update-repo repo-id {:hook_secret ""
:state 0
:hook_id nil})))
@ -62,13 +62,14 @@
login :login
user-id :id} user
{repo-id :id
repo :full_name} params
full-repo :full_name
repo :name} params
db-item (repositories/create (merge params {:user_id user-id
:login login}))
is-enabled (= 2 (:state db-item))]
(if is-enabled
(disable-repo repo-id repo (:hook_id db-item) token)
(enable-repo repo-id repo login token))
(disable-repo repo-id full-repo (:hook_id db-item) token)
(enable-repo repo-id repo full-repo login token))
(merge
{:enabled (not is-enabled)}
(select-keys params [:id :full_name]))))
@ -108,9 +109,9 @@
(ok {:user (users/get-user (:id user))}))
(POST "/address" []
:auth-rules authenticated?
:body-params [user-id :- String, address :- String]
:body-params [user-id :- Long, address :- String]
: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)
(ok)
(internal-server-error))))

View File

@ -46,7 +46,7 @@
repo-name :name
{login :login} :owner} (:repository webhook-payload)
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
;; TODO: does not work in case the issue is closed on github web ui

View File

@ -3,4 +3,5 @@
(defn activity-page []
(fn []
[:div "This will be the activity view"]))
[:div.ui.container
[:div.ui.text "This will be the activity view"]]))

View File

@ -3,4 +3,5 @@
(defn bounties-page []
(fn []
[:div "Bounties view not implemented"]))
[:div.ui.container
[:div.ui.text "Bounties view coming soon"]]))

View File

@ -1,6 +1,6 @@
(ns commiteth.manage
(:require [re-frame.core :as rf]
[commiteth.common :refer [input checkbox]]
[commiteth.common :refer [input]]
[commiteth.issues :refer [issues-list-table issue-url]]
[clojure.set :refer [rename-keys]]))
@ -16,7 +16,7 @@
^{:key repo-id}
[:div.d-table.width-full
[: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}
:on-change #(rf/dispatch [:toggle-repo repo])}]
[:div.d-table-cell.col-11.pr-3.v-align-top

View File

@ -21,7 +21,7 @@
(defn repo-card [repo]
[:div.ui.card
[: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-button-container
[repo-toggle-button

View File

@ -18,7 +18,7 @@
[:div.ui.container.grid
[:div.ui.form.eight.wide.column
[: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
(if-not (empty? web3-accounts)
[dropdown "Select address"