Install and uninstall plugins from file

Change plugins.edn to key off id as it is unique and all operations
work off of it.
Note: there are still some bugs with certain plugin installs
This commit is contained in:
Gabriel Horner
2022-10-10 11:43:39 -04:00
parent da6c617a5b
commit bf79db9d54
8 changed files with 191 additions and 64 deletions

View File

@@ -225,7 +225,7 @@
:on-confirm (fn [_ {:keys [close-fn]}]
(close-fn)
(plugin-handler/unregister-plugin id)
(plugin-config/remove-plugin name))})]
(plugin-config/remove-plugin id))})]
(state/set-sub-modal! confirm-fn {:center? true}))}
(t :plugin/uninstall)]]]
@@ -547,6 +547,9 @@
[{:title [:span.flex.items-center (ui/icon "world") (t :settings-page/network-proxy)]
:options {:on-click #(state/pub-event! [:go/proxy-settings agent-opts])}}]
[{:title [:span.flex.items-center (ui/icon "arrow-down-circle") (t :plugin/install-from-file)]
:options {:on-click plugin-config/open-sync-modal}}]
(when (state/developer-mode?)
[{:hr true}
{:title [:span.flex.items-center (ui/icon "file-code") "Open Preferences"]
@@ -796,6 +799,36 @@
(and (seq unchecked)
(= (count unchecked) (count updates)))))])]))
(rum/defc plugins-from-file
< rum/reactive
[plugins]
[:div.cp__plugins-fom-file
[:h1.mb-4.text-2xl.p-1 "Install plugins from plugins.edn"]
(if (seq plugins)
[:div
[:div.mb-2.text-xl (util/format "The following %s plugin(s) will replace your %s plugin(s):"
(count (:install plugins))
(count (:uninstall plugins)))]
;; lists
[:ul
(for [it (:install plugins)
:let [k (str "lsp-it-" (name (:id it)))]]
[:li.flex.items-center
{:key k}
[:label.flex-1
{:for k}
[:strong.px-3 (str (:name it) " " (:version it))]]])]
;; actions
[:div.pt-5
(ui/button [:span "Install"]
:on-click #(do
(plugin-config/update-plugins plugins)
(state/close-sub-modal! "ls-plugins-from-file-modal")))]]
;; all done
[:div.py-4 [:strong.text-xl "\uD83C\uDF89 All synced!"]])])
(defn open-select-theme!
[]
(state/set-sub-modal! installed-themes))
@@ -1041,6 +1074,14 @@
(waiting-coming-updates))
{:center? true}))
(defn open-plugins-from-file-modal!
[plugins]
(state/set-sub-modal!
(fn [_close!]
(plugins-from-file plugins))
{:center? true
:id "ls-plugins-from-file-modal"}))
(defn open-focused-settings-modal!
[title]
(state/set-sub-modal!