Przeglądaj źródła

enhance(plugin): install plugin from Github releases for development mode

charlie 9 miesięcy temu
rodzic
commit
a15a9e15b1

+ 22 - 0
src/main/frontend/components/plugins.cljs

@@ -509,6 +509,28 @@
                     :on-click handle-submit!}
         (if pending? (ui/loading) "Install"))]]))
 
+(rum/defc install-from-github-release-container
+  []
+  (let [[url set-url!] (rum/use-state "")
+        *input (rum/use-ref nil)]
+    [:div.p-4.flex.flex-col.pb-0
+     (shui/input {:placeholder "GitHub repo url"
+                  :value url
+                  :ref *input
+                  :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?"]]]
+     [: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")]]))
+
 (rum/defc auto-check-for-updates-control
   []
   (let [[enabled, set-enabled!] (rum/use-state (plugin-handler/get-enabled-auto-check-for-updates?))

+ 4 - 0
src/main/frontend/handler/events.cljs

@@ -412,6 +412,10 @@
 (defmethod handle :go/plugins-from-file [[_ plugins]]
   (plugin/open-plugins-from-file-modal! plugins))
 
+(defmethod handle :go/install-plugin-from-github [[_]]
+  (shui/dialog-open!
+    (plugin/install-from-github-release-container)))
+
 (defmethod handle :go/plugins-settings [[_ pid nav? title]]
   (when pid
     (state/set-state! :plugin/focused-settings pid)

+ 4 - 0
src/main/frontend/handler/plugin_config.cljs

@@ -75,6 +75,10 @@ returns map of plugins to install and uninstall"
                       (set/difference edn-plugins-set installed-plugins-set))
        :uninstall (vec (set/difference installed-plugins-set edn-plugins-set))})))
 
+(defn open-install-plugin-from-github-modal
+  []
+  (state/pub-event! [:go/install-plugin-from-github]))
+
 (defn open-replace-plugins-modal
   []
   (p/catch

+ 6 - 1
src/main/frontend/modules/shortcut/config.cljs

@@ -568,10 +568,14 @@
                                              :inactive (not config/lsp-enabled?)
                                              :fn       plugin-handler/goto-plugins-dashboard!}
 
-   :ui/install-plugins-from-file            {:binding  false
+   :ui/install-plugins-from-file            {:binding  []
                                              :inactive (not (config/plugin-config-enabled?))
                                              :fn       plugin-config-handler/open-replace-plugins-modal}
 
+   :ui/install-plugin-from-github           {:binding  []
+                                             :inactive (or (not config/lsp-enabled?) (not (util/electron?)))
+                                             :fn       plugin-config-handler/open-install-plugin-from-github-modal}
+
    :ui/clear-all-notifications              {:binding []
                                              :fn      :frontend.handler.notification/clear-all!}
 
@@ -804,6 +808,7 @@
           :ui/select-theme-color
           :ui/goto-plugins
           :ui/install-plugins-from-file
+          :ui/install-plugin-from-github
           :editor/toggle-open-blocks
           :ui/clear-all-notifications
           :git/commit

+ 1 - 1
src/main/frontend/utils.js

@@ -13,7 +13,7 @@ if (typeof window === 'undefined') {
   if (!window?.console) return
   const originalError = console.error
   console.error = (...args) => {
-    if (args[0]?.startsWith(
+    if (typeof args[0] === 'string' && args[0].startsWith(
       `Warning: Each child in a list should have a unique "key" prop`)) {
       console.groupCollapsed('[React] ⚠️ key warning!')
       console.warn(...args)

+ 1 - 0
src/resources/dicts/en.edn

@@ -790,6 +790,7 @@
   :ui/select-theme-color "Select available theme colors"
   :ui/goto-plugins "Go to plugins dashboard"
   :ui/install-plugins-from-file "Install plugins from plugins.edn"
+  :ui/install-plugin-from-github "Install plugin from GitHub release"
   :editor/toggle-open-blocks "Toggle open blocks (collapse or expand all blocks)"
   :ui/clear-all-notifications "Clear all notifications"
   :git/commit "Create git commit with message"