Skip to content

Commit

Permalink
Enter to commit
Browse files Browse the repository at this point in the history
Resolved logseq#431
  • Loading branch information
tiensonqin committed Oct 7, 2020
1 parent 3f26565 commit 758729e
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions web/src/main/frontend/components/commit.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,25 @@
[goog.dom :as gdom]
[goog.object :as gobj]))

(defn commit-and-push!
[]
(let [value (gobj/get (gdom/getElement "commit-message") "value")]
(when (and value (>= (count value) 1))
(repo-handler/git-commit-and-push! value)
(state/close-modal!))))

(rum/defcs add-commit-message <
{:did-update (fn [state]
(when-let [input (gdom/getElement "commit-message")]
(.focus input)
(util/move-cursor-to-end input))
state)}
state)}
(mixins/event-mixin
(fn [state]
(mixins/on-enter state
:node (gdom/getElement "commit-message")
:on-enter (fn []
(commit-and-push!)))))
[state close-fn]
(when-let [repo (state/sub :git/current-repo)]
[:div
Expand All @@ -34,11 +47,7 @@
[:span.flex.w-full.rounded-md.shadow-sm.sm:ml-3.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-transparent.px-4.py-2.bg-indigo-600.text-base.leading-6.font-medium.text-white.shadow-sm.hover:bg-indigo-500.focus:outline-none.focus:border-indigo-700.focus:shadow-outline-indigo.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
{:type "button"
:on-click (fn []
(let [value (gobj/get (gdom/getElement "commit-message") "value")]
(when (and value (>= (count value) 1))
(repo-handler/git-commit-and-push! value)
(state/close-modal!))))}
:on-click commit-and-push!}
"Commit and push!"]]
[:span.mt-3.flex.w-full.rounded-md.shadow-sm.sm:mt-0.sm:w-auto
[:button.inline-flex.justify-center.w-full.rounded-md.border.border-gray-300.px-4.py-2.bg-white.text-base.leading-6.font-medium.text-gray-700.shadow-sm.hover:text-gray-500.focus:outline-none.focus:border-blue-300.focus:shadow-outline-blue.transition.ease-in-out.duration-150.sm:text-sm.sm:leading-5
Expand Down

0 comments on commit 758729e

Please sign in to comment.