Skip to content

Commit

Permalink
fix: bring repo branch back
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Dec 29, 2020
1 parent 724d3ec commit de44259
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
35 changes: 25 additions & 10 deletions src/main/frontend/components/widgets.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@

(rum/defcs add-github-repo <
(rum/local "" ::repo)
(rum/local "" ::branch)
[state]
(let [repo (get state ::repo)]
(let [repo (get state ::repo)
branch (get state ::branch)]
(rum/with-context [[t] i18n/*tongue-context*]
[:div.flex.flex-col
[:div.w-full.mx-auto
Expand All @@ -47,21 +49,34 @@
{:autoFocus true
:placeholder "https://github.com/username/repo"
:on-change (fn [e]
(reset! repo (util/evalue e)))}]]]]
(reset! repo (util/evalue e)))}]]
[:label.font-medium "Default Branch (make sure it's matched with your setting on Github): "]
[:div.mt-2.mb-4.relative.rounded-md.shadow-sm.max-w-xs
[:input#branch.form-input.block.w-full.sm:text-sm.sm:leading-5
{:value @branch
:placeholder "master"
:on-change (fn [e]
(reset! branch (util/evalue e)))}]]]]

(ui/button
(t :git/add-repo-prompt-confirm)
:on-click
(fn []
(let [repo (util/lowercase-first @repo)]
(if (util/starts-with? repo "https://github.com/")
(let [repo (string/replace repo ".git" "")]
(repo-handler/create-repo! repo))

(let [branch (string/trim @branch)]
(if (string/blank? branch)
(notification/show!
[:p "Please input a valid repo url, e.g. https://github.com/username/repo"]
:error
false)))))]])))
[:p.text-gray-700 "Please input a branch, make sure it's matched with your setting on Github."]
:error
false)
(let [repo (util/lowercase-first @repo)]
(if (util/starts-with? repo "https://github.com/")
(let [repo (string/replace repo ".git" "")]
(repo-handler/create-repo! repo branch))

(notification/show!
[:p.text-gray-700 "Please input a valid repo url, e.g. https://github.com/username/repo"]
:error
false)))))))]])))

(rum/defcs add-local-directory
[]
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/handler/repo.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,11 @@
(* (config/git-push-secs) 1000)))

(defn create-repo!
[repo-url]
[repo-url branch]
(spec/validate :repos/url repo-url)
(util/post (str config/api "repos")
{:url repo-url
:branch "main"}
:branch branch}
(fn [result]
(if (:installation_id result)
(set! (.-href js/window.location) config/website)
Expand Down

0 comments on commit de44259

Please sign in to comment.