Răsfoiți Sursa

Merge branch 'feat/db' into refactor/block-schema

Gabriel Horner 11 luni în urmă
părinte
comite
2e846f78fc

+ 3 - 4
packages/ui/@/components/ui/popover.tsx

@@ -15,8 +15,8 @@ const PopoverClose = PopoverPrimitive.Close
 
 const PopoverContent = React.forwardRef<
   React.ElementRef<typeof PopoverPrimitive.Content>,
-  React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content>
->(({ className, align = 'center', sideOffset = 4, ...props }, ref) => (
+  React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> & any
+>(({ className, align = 'center', sideOffset = 4, withoutAnimation, ...props }, ref) => (
   <PopoverPrimitive.Portal>
     <PopoverPrimitive.Content
       ref={ref}
@@ -25,8 +25,7 @@ const PopoverContent = React.forwardRef<
       className={cn(
         'ui__popover-content',
         'z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none',
-        // @ts-ignore
-        !props.withoutAnimation && 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
+        !withoutAnimation && 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2',
         className
       )}
       {...props}

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

@@ -162,7 +162,7 @@
              :options {:on-click (fn []
                                    (db-page-handler/convert-to-tag! page))}})
 
-          (when (and db-based? (ldb/class? page))
+          (when (and db-based? (ldb/class? page) (not (:logseq.property/built-in? page)))
             {:title (t :page/convert-tag-to-page)
              :options {:on-click (fn []
                                    (db-page-handler/convert-tag-to-page! page))}})

+ 25 - 4
src/main/frontend/components/plugins.cljs

@@ -511,6 +511,8 @@
 (rum/defc install-from-github-release-container
   []
   (let [[url set-url!] (rum/use-state "")
+        [opts set-opts!] (rum/use-state {:theme? false :effect? false})
+        [pending set-pending!] (rum/use-state false)
         *input (rum/use-ref nil)]
     [:div.p-4.flex.flex-col.pb-0
      (shui/input {:placeholder "GitHub repo url"
@@ -519,16 +521,35 @@
                   :on-change #(set-url! (util/evalue %))
                   :auto-focus true})
      [:div.flex.gap-6.pt-3.items-center.select-none
-      [:label.flex.items-center.gap-2 (shui/checkbox) [:span.opacity-60 "theme?"]]
-      [:label.flex.items-center.gap-2 (shui/checkbox) [:span.opacity-60 "effect?"]]]
+      [:label.flex.items-center.gap-2
+       (shui/checkbox {:checked (:theme? opts)
+                       :on-checked-change #(set-opts! (assoc opts :theme? %))})
+       [:span.opacity-60 "theme?"]]
+      [:label.flex.items-center.gap-2
+       (shui/checkbox {:checked (:effect? opts)
+                       :on-checked-change #(set-opts! (assoc opts :effect? %))})
+       [:span.opacity-60 "effect?"]]]
      [:div.flex.justify-end.pt-3
       (shui/button
         {:on-click (fn []
                      (if (or (string/blank? (util/trim-safe url))
                            (not (string/starts-with? url "https://")))
                        (.focus (rum/deref *input))
-                       (shui/toast! url)))}
-        "Install")]]))
+                       (let [url (string/replace-first url "https://github.com/" "")
+                             matched (re-find #"([^\/]+)/([^\/]+)" url)]
+                         (if-let [id (some-> matched (nth 2))]
+                           (do
+                             (set-pending! true)
+                             (-> #js {:id id :repo (first matched)
+                                      :theme (:theme? opts)
+                                      :effect (:effect? opts)}
+                               (js/window.logseq.api.__install_plugin)
+                               (p/then #(shui/dialog-close!))
+                               (p/catch #(notification/show! (str %) :error))
+                               (p/finally #(set-pending! false))))
+                           (notification/show! "Invalid GitHub repo url" :error)))))
+         :disabled pending}
+        (if pending (ui/loading "Installing") "Install"))]]))
 
 (rum/defc auto-check-for-updates-control
   []

+ 12 - 12
src/main/frontend/components/property/config.cljs

@@ -708,25 +708,25 @@
                        :on-select (fn []
                                     (shui/popup-hide-all!)
                                     (route-handler/redirect-to-page! (:block/uuid property)))}})])
-     (when enable-closed-values?
+     (when (and enable-closed-values? owner-block)
        (let [values (:property/closed-values property)]
          (when (>= (count values) 2)
            (let [checked? (contains?
                            (set (map :db/id (:logseq.property/checkbox-display-properties owner-block)))
                            (:db/id property))]
              (dropdown-editor-menuitem
-              {:icon :checkbox :title "Show as checkbox on node"
+              {:icon :checkbox
+               :title (if class-schema? "Show as checkbox on tagged nodes" "Show as checkbox on node")
                :disabled? config/publishing?
-               :desc (when owner-block
-                       (shui/switch
-                        {:id "show as checkbox" :size "sm"
-                         :checked checked?
-                         :on-click util/stop-propagation
-                         :on-checked-change
-                         (fn [value]
-                           (if value
-                             (db-property-handler/set-block-property! (:db/id owner-block) :logseq.property/checkbox-display-properties (:db/id property))
-                             (db-property-handler/delete-property-value! (:db/id owner-block) :logseq.property/checkbox-display-properties (:db/id property))))}))})))))
+               :desc (shui/switch
+                      {:id "show as checkbox" :size "sm"
+                       :checked checked?
+                       :on-click util/stop-propagation
+                       :on-checked-change
+                       (fn [value]
+                         (if value
+                           (db-property-handler/set-block-property! (:db/id owner-block) :logseq.property/checkbox-display-properties (:db/id property))
+                           (db-property-handler/delete-property-value! (:db/id owner-block) :logseq.property/checkbox-display-properties (:db/id property))))})})))))
 
      (when (and owner-block
                 ;; Any property should be removable from Tag Properties

+ 2 - 2
src/main/frontend/components/property/value.cljs

@@ -252,8 +252,8 @@
                                                                                                (:db/id property))
                                                       (db-property-handler/remove-block-property! (:db/id block)
                                                                                                   :logseq.task/scheduled-on-property)))))]
-       (if (= :logseq.task/deadline (:db/ident property))
-         [:div "Set as repeated task"]
+       (if (#{:logseq.task/deadline :logseq.task/scheduled} (:db/ident property))
+         [:div "Repeat task"]
          [:div "Repeat " (if (= :date (:logseq.property/type property)) "date" "datetime")])]]
      [:div.flex.flex-row.gap-2
       [:div.flex.text-muted-foreground.mr-4

+ 5 - 8
src/main/frontend/handler/common/plugin.cljs

@@ -67,14 +67,11 @@
   "Installs plugin given plugin map with id"
   [{:keys [id] :as manifest}]
   (when-not (and (:plugin/installing @state/state)
-                 (installed? id))
-    (p/create
-     (fn [resolve]
-       (state/set-state! :plugin/installing manifest)
-       (if (util/electron?)
-         (ipc/ipc :installMarketPlugin manifest)
-         (async-install-or-update-for-web! manifest))
-       (resolve id)))))
+              (installed? id))
+    (state/set-state! :plugin/installing manifest)
+    (if (util/electron?)
+      (ipc/ipc :installMarketPlugin manifest)
+      (async-install-or-update-for-web! manifest))))
 
 (defn unregister-plugin
   "Unregister and uninstall plugin given plugin id"

+ 20 - 19
src/main/frontend/handler/db_based/page.cljs

@@ -59,25 +59,26 @@
   [page-entity]
   (if (db/page-exists? (:block/title page-entity) #{:logseq.class/Page})
     (notification/show! (str "A page with the name \"" (:block/title page-entity) "\" already exists.") :warning false)
-    (p/let [objects (db-async/<get-tag-objects (state/get-current-repo) (:db/id page-entity))]
-      (let [convert-fn
-            (fn convert-fn []
-              (let [page-txs [[:db/retract (:db/id page-entity) :db/ident]
-                              [:db/retract (:db/id page-entity) :block/tags :logseq.class/Tag]
-                              [:db/add (:db/id page-entity) :block/tags :logseq.class/Page]]
-                    obj-txs (mapcat (fn [obj]
-                                      (let [tags (map #(db/entity (state/get-current-repo) (:db/id %)) (:block/tags obj))]
-                                        [{:db/id (:db/id obj)
-                                          :block/title (db-content/replace-tag-refs-with-page-refs (:block/title obj) tags)}
-                                         [:db/retract (:db/id obj) :block/tags (:db/id page-entity)]]))
-                                    objects)
-                    txs (concat page-txs obj-txs)]
-                (db/transact! (state/get-current-repo) txs {:outliner-op :save-block})))]
-        (-> (shui/dialog-confirm!
-             "Converting a tag to page also removes tags from any nodes that have that tag. Are you ok with that?"
-             {:id :convert-tag-to-page
-              :data-reminder :ok})
-            (p/then convert-fn))))))
+    (when-not (:logseq.property/built-in? page-entity)
+     (p/let [objects (db-async/<get-tag-objects (state/get-current-repo) (:db/id page-entity))]
+       (let [convert-fn
+             (fn convert-fn []
+               (let [page-txs [[:db/retract (:db/id page-entity) :db/ident]
+                               [:db/retract (:db/id page-entity) :block/tags :logseq.class/Tag]
+                               [:db/add (:db/id page-entity) :block/tags :logseq.class/Page]]
+                     obj-txs (mapcat (fn [obj]
+                                       (let [tags (map #(db/entity (state/get-current-repo) (:db/id %)) (:block/tags obj))]
+                                         [{:db/id (:db/id obj)
+                                           :block/title (db-content/replace-tag-refs-with-page-refs (:block/title obj) tags)}
+                                          [:db/retract (:db/id obj) :block/tags (:db/id page-entity)]]))
+                                     objects)
+                     txs (concat page-txs obj-txs)]
+                 (db/transact! (state/get-current-repo) txs {:outliner-op :save-block})))]
+         (-> (shui/dialog-confirm!
+              "Converting a tag to page also removes tags from any nodes that have that tag. Are you ok with that?"
+              {:id :convert-tag-to-page
+               :data-reminder :ok})
+             (p/then convert-fn)))))))
 
 (defn <create-class!
   "Creates a class page and provides class-specific error handling"

+ 1 - 3
src/main/frontend/handler/plugin.cljs

@@ -628,9 +628,7 @@
             dotroot (get-ls-dotdir-root)
             filepath (util/node-path.join dotroot dirname (str key ".json"))]
         (if (util/electron?)
-          (p/let [exist? (fs/file-exists? filepath)
-                  _ (when-not exist? (fs/mkdir! filepath))
-                  _ (fs/create-if-not-exists repo nil filepath (js/JSON.stringify default))
+          (p/let [_ (fs/create-if-not-exists repo nil filepath (js/JSON.stringify default))
                   json (fs/read-file nil filepath)]
             [filepath (js/JSON.parse json)])
           (p/let [data (idb/get-item filepath)]