Skip to content

Commit

Permalink
use title in rename dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Weihua Lu authored and tiensonqin committed Mar 16, 2021
1 parent 68be5a3 commit 95a6848
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/main/frontend/components/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@

(rum/defcs rename-page-dialog-inner <
(rum/local "" ::input)
[state page-name close-fn]
[state title page-name close-fn]
(let [input (get state ::input)]
(rum/with-context [[t] i18n/*tongue-context*]
[:div.w-full.sm:max-w-lg.sm:w-96
[:div.sm:flex.sm:items-start
[:div.mt-3.text-center.sm:mt-0.sm:text-left
[:h3#modal-headline.text-lg.leading-6.font-medium
(t :page/rename-to page-name)]]]
(t :page/rename-to title)]]]

[:input.form-input.block.w-full.sm:text-sm.sm:leading-5.my-2
{:auto-focus true
Expand All @@ -193,11 +193,10 @@
[: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 @input]
(let [value (string/trim value)]
(when-not (string/blank? value)
(page-handler/rename! page-name value)
(state/close-modal!)))))}
(let [value (string/trim @input)]
(when-not (string/blank? value)
(page-handler/rename! page-name value)
(state/close-modal!))))}
(t :submit)]]
[: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 All @@ -206,9 +205,9 @@
(t :cancel)]]]])))

(defn rename-page-dialog
[page-name]
[title page-name]
(fn [close-fn]
(rename-page-dialog-inner page-name close-fn)))
(rename-page-dialog-inner title page-name close-fn)))

(defn tagged-pages
[repo tag]
Expand Down Expand Up @@ -274,7 +273,7 @@
(db/transact! repo [{:page/name page-name
:page/original-name path-page-name}])
(db/entity repo [:page/name page-name])))
properties (:page/properties page)
{:keys [title] :as properties} (:page/properties page)
page-name (:page/name page)
page-original-name (:page/original-name page)
file (:page/file page)
Expand Down Expand Up @@ -302,7 +301,7 @@

(when-not contents?
{:title (t :page/rename)
:options {:on-click #(state/set-modal! (rename-page-dialog page-name))}})
:options {:on-click #(state/set-modal! (rename-page-dialog title page-name))}})

(when (and file-path (util/electron?))
[{:title (t :page/open-in-finder)
Expand Down

0 comments on commit 95a6848

Please sign in to comment.