mirror of
https://github.com/logseq/logseq.git
synced 2026-05-26 05:34:07 +00:00
fix: hide page configure for built-in property pages
Also, disabled page delete and rename for built-in property pages
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
[goog.dom :as gdom]
|
||||
[goog.object :as gobj]
|
||||
[rum.core :as rum]
|
||||
))
|
||||
[logseq.graph-parser.property :as gp-property]))
|
||||
|
||||
;; TODO i18n support
|
||||
|
||||
@@ -365,14 +365,16 @@
|
||||
|
||||
(rum/defc property-custom-context-menu-content
|
||||
[block property {:keys [class-schema?]}]
|
||||
(let [repo (state/get-current-repo)]
|
||||
(let [repo (state/get-current-repo)
|
||||
built-in-property? (contains? gp-property/db-built-in-properties-keys-str (:block/name property))]
|
||||
[:.menu-links-wrapper
|
||||
(ui/menu-link
|
||||
{:key "Configure this property"
|
||||
:on-click (fn []
|
||||
(state/set-modal! #(property/property-config repo property)))}
|
||||
(t :context-menu/configure-property)
|
||||
nil)
|
||||
(when-not built-in-property?
|
||||
(ui/menu-link
|
||||
{:key "Configure this property"
|
||||
:on-click (fn []
|
||||
(state/set-modal! #(property/property-config repo property)))}
|
||||
(t :context-menu/configure-property)
|
||||
nil))
|
||||
(ui/menu-link
|
||||
{:key "Delete this property"
|
||||
:on-click (fn []
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
[rum.core :as rum]
|
||||
[logseq.graph-parser.util.page-ref :as page-ref]
|
||||
[logseq.graph-parser.mldoc :as gp-mldoc]
|
||||
[frontend.handler.property.util :as pu]))
|
||||
[frontend.handler.property.util :as pu]
|
||||
[logseq.graph-parser.property :as gp-property]))
|
||||
|
||||
(defn- get-page-name
|
||||
[state]
|
||||
@@ -318,7 +319,11 @@
|
||||
repo
|
||||
(:db/id page)
|
||||
:page))
|
||||
(when (and (not hls-page?) (not fmt-journal?) (not config/publishing?))
|
||||
(when (and (not hls-page?)
|
||||
(not fmt-journal?)
|
||||
(not config/publishing?)
|
||||
(not (and (= "property" (:block/type page))
|
||||
(contains? gp-property/db-built-in-properties-keys-str page-name))))
|
||||
(reset! *input-value (if untitled? "" old-name))
|
||||
(reset! *edit? true)))))}
|
||||
(when (not= icon "") [:span.page-icon icon])
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
[frontend.handler.user :as user-handler]
|
||||
[frontend.handler.file-sync :as file-sync-handler]
|
||||
[logseq.common.path :as path]
|
||||
[frontend.handler.property.util :as pu]))
|
||||
[frontend.handler.property.util :as pu]
|
||||
[logseq.graph-parser.property :as gp-property]))
|
||||
|
||||
(defn- delete-page!
|
||||
[page-name]
|
||||
@@ -78,11 +79,14 @@
|
||||
_ (state/sub :auth/id-token)
|
||||
file-sync-graph-uuid (and (user-handler/logged-in?)
|
||||
(file-sync-handler/enable-sync?)
|
||||
(file-sync-handler/get-current-graph-uuid))]
|
||||
(file-sync-handler/get-current-graph-uuid))
|
||||
built-in-property? (and (= "property" (:block/type page))
|
||||
(contains? gp-property/db-built-in-properties-keys-str page-name))]
|
||||
(when (and page (not block?))
|
||||
(->>
|
||||
[(when (and (not config/publishing?)
|
||||
(config/db-based-graph? repo))
|
||||
(config/db-based-graph? repo)
|
||||
(not built-in-property?))
|
||||
{:title (t :page/configure)
|
||||
:options {:on-click
|
||||
(fn []
|
||||
@@ -118,7 +122,9 @@
|
||||
:options {:on-click #(page-handler/copy-page-url page-original-name)}})
|
||||
|
||||
(when-not (or contents?
|
||||
config/publishing?)
|
||||
config/publishing?
|
||||
(and (config/db-based-graph? repo)
|
||||
built-in-property?))
|
||||
{:title (t :page/delete)
|
||||
:options {:on-click #(state/set-modal! (delete-page-dialog page-name))}})
|
||||
|
||||
|
||||
@@ -36,16 +36,19 @@
|
||||
[state repo property ]
|
||||
(let [*property-name (::property-name state)
|
||||
*property-schema (::property-schema state)
|
||||
disabled? (contains? gp-property/db-built-in-properties-keys-str (:block/original-name property))]
|
||||
built-in-property? (contains? gp-property/db-built-in-properties-keys-str (:block/original-name property))]
|
||||
[:div.property-configure
|
||||
[:h1.title "Configure property"]
|
||||
[:h1.title
|
||||
(if built-in-property?
|
||||
"Built-in property"
|
||||
"Configure property")]
|
||||
|
||||
[:div.grid.gap-2.p-1
|
||||
[:div.grid.grid-cols-4.gap-1.items-center.leading-8
|
||||
[:label "Name:"]
|
||||
[:input.form-input
|
||||
{:on-change #(reset! *property-name (util/evalue %))
|
||||
:disabled disabled?
|
||||
:disabled built-in-property?
|
||||
:value @*property-name}]]
|
||||
|
||||
[:div.grid.grid-cols-4.gap-1.leading-8
|
||||
@@ -55,7 +58,7 @@
|
||||
(map (comp string/capitalize name))
|
||||
(map (fn [type]
|
||||
{:label type
|
||||
:disabled disabled?
|
||||
:disabled built-in-property?
|
||||
:value type
|
||||
:selected (= (keyword (string/lower-case type))
|
||||
(:type @*property-schema))})))]
|
||||
@@ -69,7 +72,7 @@
|
||||
[:label "Multiple values:"]
|
||||
(let [many? (boolean (= :many (:cardinality @*property-schema)))]
|
||||
(ui/checkbox {:checked many?
|
||||
:disabled disabled?
|
||||
:disabled built-in-property?
|
||||
:on-change (fn []
|
||||
(swap! *property-schema assoc :cardinality (if many? :one :many)))}))])
|
||||
|
||||
@@ -79,11 +82,11 @@
|
||||
(ui/ls-textarea
|
||||
{:on-change (fn [e]
|
||||
(swap! *property-schema assoc :description (util/evalue e)))
|
||||
:disabled disabled?
|
||||
:disabled built-in-property?
|
||||
:value (:description @*property-schema)})]]
|
||||
|
||||
[:div
|
||||
(when-not disabled?
|
||||
(when-not built-in-property?
|
||||
(ui/button
|
||||
"Save"
|
||||
:on-click (fn []
|
||||
|
||||
Reference in New Issue
Block a user