enhance: clicking on properties navigates in publishing

Previously this did nothing since publishing is read only. This is
also more user friendly as clicking on a page normally navigates to it
This commit is contained in:
Gabriel Horner
2023-09-11 17:16:36 -04:00
parent 59567321f1
commit da4beef34d

View File

@@ -19,7 +19,8 @@
[frontend.ui :as ui]
[frontend.util :as util]
[logseq.db.property :as db-property]
[rum.core :as rum]))
[rum.core :as rum]
[frontend.handler.route :as route-handler]))
(rum/defc icon
[block {:keys [_type id]}] ; only :emoji supported yet
@@ -334,18 +335,22 @@
{:modal-class (util/hiccup->class
"origin-top-right.absolute.left-0.rounded-md.shadow-lg.mt-2")})
(ui/dropdown
(if config/publishing?
(fn [_opts]
[:a.property-k
{:on-click #(route-handler/redirect-to-page! (:block/name property))}
[:div.ml-1 (:block/original-name property)]])
(fn [{:keys [toggle-fn]}]
[:a.property-k
{:data-propertyid (:block/uuid property)
:data-blockid (:block/uuid block)
:data-class-schema (boolean class-schema?)
:title (str "Configure property: " (:block/original-name property))
:on-click toggle-fn}
[:div.ml-1 (:block/original-name property)]]))
(fn [{:keys [toggle-fn]}]
[:a.property-k
{:data-propertyid (:block/uuid property)
:data-blockid (:block/uuid block)
:data-class-schema (boolean class-schema?)
:title (str "Configure property: " (:block/original-name property))
:on-click toggle-fn}
[:div.ml-1 (:block/original-name property)]])
(fn [{:keys [toggle-fn]}]
(when (not config/publishing?)
[:div.p-8
(property-config repo property {:toggle-fn toggle-fn})]))
[:div.p-8
(property-config repo property {:toggle-fn toggle-fn})])
{:modal-class (util/hiccup->class
"origin-top-right.absolute.left-0.rounded-md.shadow-lg")})]))