Browse Source

fix: publishing showed edit block message

also improve property description formatting in publishing and addressed
some lints
Gabriel Horner 2 years ago
parent
commit
aef5a38a16

+ 1 - 1
src/main/frontend/components/content.cljs

@@ -355,7 +355,7 @@
        (ui/menu-link
         {:key "Configure this property"
          :on-click (fn []
-                     (state/set-modal! #(property/property-config repo property {})))}
+                     (state/set-modal! #(property/property-config property {})))}
         (t :context-menu/configure-property)
         nil))
      (ui/menu-link

+ 23 - 18
src/main/frontend/components/page.cljs

@@ -98,23 +98,28 @@
 
 (declare page)
 
-(rum/defc dummy-block
-  [page-name]
-  (let [handler-fn (fn []
-                     (let [block (editor-handler/insert-first-page-block-if-not-exists! page-name {:redirect? false})]
-                       (js/setTimeout #(editor-handler/edit-block! block :max (:block/uuid block)) 0)))]
-    [:div.ls-block.flex-1.flex-col.rounded-sm {:style {:width "100%"}}
-     [:div.flex.flex-row
-      [:div.flex.flex-row.items-center.mr-2.ml-1 {:style {:height 24}}
-       [:span.bullet-container.cursor
-        [:span.bullet]]]
-      [:div.flex.flex-1 {:tabIndex 0
-                         :on-key-press (fn [e]
-                                         (when (= "Enter" (util/ekey e))
-                                           (handler-fn)))
-                         :on-click handler-fn}
-       [:span.opacity-70
-        "Click here to edit..."]]]]))
+(if config/publishing?
+  (rum/defc dummy-block
+    [_page-name]
+    [:div])
+
+  (rum/defc dummy-block
+    [page-name]
+    (let [handler-fn (fn []
+                       (let [block (editor-handler/insert-first-page-block-if-not-exists! page-name {:redirect? false})]
+                         (js/setTimeout #(editor-handler/edit-block! block :max (:block/uuid block)) 0)))]
+      [:div.ls-block.flex-1.flex-col.rounded-sm {:style {:width "100%"}}
+       [:div.flex.flex-row
+        [:div.flex.flex-row.items-center.mr-2.ml-1 {:style {:height 24}}
+         [:span.bullet-container.cursor
+          [:span.bullet]]]
+        [:div.flex.flex-1 {:tabIndex 0
+                           :on-key-press (fn [e]
+                                           (when (= "Enter" (util/ekey e))
+                                             (handler-fn)))
+                           :on-click handler-fn}
+         [:span.opacity-70
+          "Click here to edit..."]]]])))
 
 (rum/defc add-button
   [args]
@@ -326,7 +331,7 @@
      (when class?
        (page-properties page true))
      (if property?
-       (property/property-config (state/get-current-repo) page opts)
+       (property/property-config page (assoc opts :inline-text component-block/inline-text))
               ;; add new property for normal pages
        (when (and (not class?)
                   (empty? (:block/properties page))

+ 15 - 15
src/main/frontend/components/property.cljs

@@ -13,7 +13,6 @@
             [frontend.handler.property :as property-handler]
             [frontend.handler.reorder :as reorder-handler]
             [frontend.handler.property.util :as pu]
-            [frontend.handler.notification :as notification]
             [frontend.mixins :as mixins]
             [frontend.modules.shortcut.core :as shortcut]
             [frontend.search :as search]
@@ -278,11 +277,11 @@
   (rum/local nil ::property-name)
   (rum/local nil ::property-schema)
   {:will-mount (fn [state]
-                 (let [[_repo property] (:rum/args state)]
+                 (let [[property] (:rum/args state)]
                    (reset! (::property-name state) (:block/original-name property))
                    (reset! (::property-schema state) (:block/schema property))
                    state))}
-  [state repo property {:keys [toggle-fn] :as opts}]
+  [state property {:keys [toggle-fn inline-text] :as opts}]
   (let [*property-name (::property-name state)
         *property-schema (::property-schema state)
         built-in-property? (contains? db-property/built-in-properties-keys-str (:block/original-name property))
@@ -365,11 +364,13 @@
       [:div.grid.grid-cols-4.gap-1.items-start.leading-8
        [:label "Description:"]
        [:div.col-span-3
-        (ui/ls-textarea
-         {:on-change (fn [e]
-                       (swap! *property-schema assoc :description (util/evalue e)))
-          :disabled disabled?
-          :value (:description @*property-schema)})]]
+        (if (and disabled? inline-text)
+          (inline-text {} :markdown (:description @*property-schema))
+          (ui/ls-textarea
+           {:on-change (fn [e]
+                         (swap! *property-schema assoc :description (util/evalue e)))
+            :disabled disabled?
+            :value (:description @*property-schema)}))]]
 
       [:div
        (when-not disabled?
@@ -419,8 +420,7 @@
   shortcut/disable-all-shortcuts
   [state entity *property-key *property-value {:keys [class-schema? page-configure? in-block-container?]
                                                :as opts}]
-  (let [repo (state/get-current-repo)
-        *show-new-property-config? (::show-new-property-config? state)
+  (let [*show-new-property-config? (::show-new-property-config? state)
         entity-properties (->> (keys (:block/properties entity))
                                (map #(:block/original-name (db/entity [:block/uuid %])))
                                (set))
@@ -450,8 +450,7 @@
                   (pv/property-value entity property @*property-value (assoc opts :editing? true)))
                 (fn [{:keys [toggle-fn]}]
                   [:div.p-6
-                   (property-config repo property (merge opts
-                                                         {:toggle-fn toggle-fn
+                   (property-config property (merge opts {:toggle-fn toggle-fn
                                                           :block entity}))])
                 {:initial-open? true
                  :modal-class (util/hiccup->class
@@ -527,7 +526,7 @@
 
 (rum/defcs property-key <
   (rum/local false ::hover?)
-  [state block property {:keys [class-schema? block? collapsed?]}]
+  [state block property {:keys [class-schema? block? collapsed? inline-text]}]
   (let [*hover? (::hover? state)
         repo (state/get-current-repo)
         icon (pu/get-property property :icon)]
@@ -586,7 +585,7 @@
            [:div {:style {:padding-left 6}} (:block/original-name property)]]))
       (fn [{:keys [toggle-fn]}]
         [:div.p-8
-         (property-config repo property {:toggle-fn toggle-fn})])
+         (property-config property {:toggle-fn toggle-fn :inline-text inline-text})])
       {:modal-class (util/hiccup->class
                      "origin-top-right.absolute.left-0.rounded-md.shadow-lg")})]))
 
@@ -637,7 +636,8 @@
               {:class "col-span-2"}
               (property-key block property (assoc (select-keys opts [:class-schema?])
                                                   :block? block?
-                                                  :collapsed? collapsed?))]
+                                                  :collapsed? collapsed?
+                                                  :inline-text inline-text))]
              (if (and (:class-schema? opts) (:page-configure? opts))
                [:div.property-description.text-sm.opacity-70
                 {:class "col-span-3"}