diff --git a/src/main/frontend/components/db_based/page.cljs b/src/main/frontend/components/db_based/page.cljs index f5d26c0757..c573bef3be 100644 --- a/src/main/frontend/components/db_based/page.cljs +++ b/src/main/frontend/components/db_based/page.cljs @@ -27,8 +27,16 @@ configure-opts {:selected? false :page-configure? true} has-viewable-properties? (db-property-handler/block-has-viewable-properties? page) - has-class-properties? (seq (:properties (:block/schema page)))] - (when (or configure? has-viewable-properties? has-class-properties? property?) + has-class-properties? (seq (:properties (:block/schema page))) + has-tags? (seq (:block/tags page)) + hide-properties? (get-in page [:block/metadata :hide-properties?])] + (when (or configure? + (and + (not hide-properties?) + (or has-viewable-properties? + has-class-properties? + property? + has-tags?))) [:div.ls-page-properties (cond (= mode :class) @@ -46,7 +54,7 @@ (component-block/db-properties-cp {:editor-box editor/box} page (str edit-input-id-prefix "-page") - (assoc configure-opts :class-schema? false)))]))) + (assoc configure-opts :class-schema? false :page? true)))]))) (rum/defc icon-row < rum/reactive [page] @@ -138,9 +146,10 @@ [:div.flex.flex-row.items-center.gap-1 (for [mode modes] (let [mode' (keyword (string/lower-case mode)) - selected? (= mode' current-mode)] + selected? (and (= mode' current-mode) (> (count modes) 1))] (shui-ui/button {:class (when-not selected? "opacity-70") - :variant (if selected? :outline :ghost) :size :sm + :variant (if selected? :outline :ghost) + :size :sm :on-click (fn [e] (util/stop-propagation e) (reset! *mode mode'))} @@ -189,8 +198,7 @@ [:<> (if has-tags? [:div.px-1 {:style {:min-height 28}}] - (shui-ui/button {:variant :ghost :size :sm :class "fade-link"} - (ui/icon "tags"))) + [:a.flex.fade-link.ml-2 (ui/icon "tags")]) (if (and config/publishing? (seq (set/intersection #{"class" "property"} types))) [:div [:div.opacity-50.pointer.text-sm "Expand for more info"]] @@ -198,22 +206,20 @@ (tags page)])] [:div.page-info-title-placeholder]) [:div.flex.flex-row.items-center.gap-1 - (shui-ui/button {:variant :ghost :size :sm :class "fade-link"} - (ui/icon "info-circle")) - [:a.text-sm.font-medium.fade-link - "Configure:"] + [:a.flex.fade-link.ml-3 (ui/icon "info-circle")] (mode-switch types *mode)])] (when (or @*hover? (not collapsed?)) - (shui-ui/button - {:variant :ghost :size :sm :class "fade-link"} - (ui/icon (if collapsed? - "chevron-down" - "chevron-up"))))])] + [:div.px-1 + (shui-ui/button + {:variant :ghost :size :sm :class "fade-link"} + (if collapsed? + [:span.text-xs.font-normal "Configure"] + (ui/icon "x")))])])] (when show-info? (if collapsed? (when (or (seq (:block/properties page)) (and class? (seq (:properties (:block/schema page))))) - [:div.py-2.px-4 + [:div.px-4 (page-properties page {:mode (if class? :class :page)})]) [:div.py-2.px-4 (page-configure page *mode)]))]]))) diff --git a/src/main/frontend/components/page_menu.cljs b/src/main/frontend/components/page_menu.cljs index 181efb17e9..e4c4c166a3 100644 --- a/src/main/frontend/components/page_menu.cljs +++ b/src/main/frontend/components/page_menu.cljs @@ -81,7 +81,8 @@ (file-sync-handler/current-graph-sync-on?) (file-sync-handler/get-current-graph-uuid)) built-in-property? (and (contains? (:block/type page) "property") - (contains? db-property/built-in-properties-keys-str page-name))] + (contains? db-property/built-in-properties-keys-str page-name)) + db-based? (config/db-based-graph? repo)] (when (and page (not block?)) (->> [(when-not config/publishing? @@ -116,7 +117,7 @@ (when-not (or contents? config/publishing? - (and (config/db-based-graph? repo) + (and db-based? built-in-property?)) {:title (t :page/delete) :options {:on-click #(state/set-modal! (delete-page-dialog page-name))}}) @@ -170,6 +171,11 @@ :options {:on-click #(commands/exec-plugin-simple-command! pid (assoc cmd :page page-name) action)}})) + (when db-based? + {:title (t :page/toggle-properties) + :options {:on-click (fn [] + (page-handler/toggle-properties! page))}}) + (when developer-mode? {:title (t :dev/show-page-data) :options {:on-click (fn [] @@ -177,7 +183,7 @@ (when (and developer-mode? ;; Remove when we have an easy way to fetch file content for a DB graph - (not (config/db-based-graph? repo))) + (not db-based?)) {:title (t :dev/show-page-ast) :options {:on-click (fn [] (let [page (db/pull '[:block/format {:block/file [:file/content]}] (:db/id page))] diff --git a/src/main/frontend/components/property.cljs b/src/main/frontend/components/property.cljs index 9198e7e9b6..2d8f02edfa 100644 --- a/src/main/frontend/components/property.cljs +++ b/src/main/frontend/components/property.cljs @@ -638,7 +638,7 @@ (rum/defcs ^:large-vars/cleanup-todo properties-area < rum/reactive {:init (fn [state] (assoc state ::id (str (random-uuid))))} - [state target-block edit-input-id {:keys [in-block-container? page-configure? class-schema?] :as opts}] + [state target-block edit-input-id {:keys [in-block-container? page? page-configure? class-schema?] :as opts}] (let [id (::id state) block (resolve-linked-block-if-exists target-block) block-properties (:block/properties block) @@ -664,7 +664,7 @@ root-block? (= (:id opts) (str (:block/uuid block))) ;; This section produces own-properties and full-hidden-properties hide-with-property-id (fn [property-id] - (if (or root-block? page-configure?) + (if (or root-block? page? page-configure?) false (let [eid (if (uuid? property-id) [:block/uuid property-id] property-id)] (boolean (:hide? (:block/schema (db/entity eid))))))) diff --git a/src/main/frontend/handler/page.cljs b/src/main/frontend/handler/page.cljs index 150ef5e6e8..169834b559 100644 --- a/src/main/frontend/handler/page.cljs +++ b/src/main/frontend/handler/page.cljs @@ -425,3 +425,10 @@ (util/copy-to-clipboard! (url-util/get-logseq-graph-page-url nil (state/get-current-repo) page-name)) (notification/show! "No page found to copy" :warning)))) + +(defn toggle-properties! + [page-entity] + (let [current-value (get-in page-entity [:block/metadata :hide-properties?])] + (db/transact! [{:db/id (:db/id page-entity) + :block/metadata (assoc (:block/metadata page-entity) + :hide-properties? (not current-value))}]))) diff --git a/src/resources/dicts/en.edn b/src/resources/dicts/en.edn index cd94709782..5ccb8eeccd 100644 --- a/src/resources/dicts/en.edn +++ b/src/resources/dicts/en.edn @@ -188,6 +188,7 @@ :page/illegal-page-name "Illegal page name!" :page/page-already-exists "Page “{1}” already exists!" :page/whiteboard-to-journal-error "Whiteboard pages cannot be renamed to journal titles!" + :page/toggle-properties "Toggle properties" :file/name "File name" :file/last-modified-at "Last modified at" :file/no-data "No data"