mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 18:18:24 -05:00
Merge pull request #5068 from penpot/alotor-plugins-install-profile
✨ Change installation data to profile
This commit is contained in:
commit
cfad1d178f
3 changed files with 10 additions and 33 deletions
|
@ -19,6 +19,7 @@
|
|||
[app.main.data.websocket :as ws]
|
||||
[app.main.features :as features]
|
||||
[app.main.repo :as rp]
|
||||
[app.plugins.register :as register]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[app.util.storage :as s]
|
||||
|
@ -137,7 +138,9 @@
|
|||
(swap! s/storage assoc :profile profile)
|
||||
(i18n/set-locale! (:lang profile))
|
||||
(when (not= previous-email email)
|
||||
(set-current-team! nil)))))))
|
||||
(set-current-team! nil))
|
||||
|
||||
(register/init))))))
|
||||
|
||||
(defn- on-fetch-profile-exception
|
||||
[cause]
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
[app.plugins.grid :as grid]
|
||||
[app.plugins.library :as library]
|
||||
[app.plugins.public-utils]
|
||||
[app.plugins.register :as register]
|
||||
[app.plugins.shape :as shape]
|
||||
[app.util.globals :refer [global]]
|
||||
[app.util.object :as obj]
|
||||
|
@ -25,7 +24,6 @@
|
|||
(defn init-plugins-runtime!
|
||||
[]
|
||||
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
|
||||
(register/init)
|
||||
(init-runtime (fn [plugin-id] (api/create-context plugin-id)))))
|
||||
|
||||
(defn initialize
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.util.object :as obj]
|
||||
[app.util.storage :refer [storage]]))
|
||||
[beicon.v2.core :as rx]))
|
||||
|
||||
;; Stores the installed plugins information
|
||||
(defonce ^:private registry (atom {}))
|
||||
|
@ -58,40 +60,14 @@
|
|||
:icon icon
|
||||
:permissions (into #{} (map str) permissions)}))
|
||||
|
||||
;; FIXME: LEGACY version of the load from store
|
||||
;; can be removed before deploying plugins to production
|
||||
;; Needs to be preserved for the beta users
|
||||
(defn legacy-load-from-store
|
||||
[]
|
||||
(let [parse-plugin-data
|
||||
(fn [^js data]
|
||||
{:plugin-id (obj/get data "plugin-id")
|
||||
:name (obj/get data "name")
|
||||
:description (obj/get data "description")
|
||||
:host (obj/get data "host")
|
||||
:code (obj/get data "code")
|
||||
:icon (obj/get data "icon")
|
||||
:permissions (into #{} (obj/get data "permissions"))})
|
||||
|
||||
ls (.-localStorage js/window)
|
||||
plugins-val (.getItem ls "plugins")]
|
||||
(when plugins-val
|
||||
(let [stored (->> (.parse js/JSON plugins-val)
|
||||
(map parse-plugin-data))]
|
||||
(reset! registry
|
||||
{:ids (->> stored (map :plugin-id))
|
||||
:data (d/index-by :plugin-id stored)})))))
|
||||
|
||||
(defn save-to-store
|
||||
[]
|
||||
(swap! storage assoc :plugins @registry))
|
||||
(->> (rp/cmd! :update-profile-props {:props {:plugins @registry}})
|
||||
(rx/subs! identity)))
|
||||
|
||||
(defn load-from-store
|
||||
[]
|
||||
(if (:plugins @storage)
|
||||
(reset! registry (:plugins @storage))
|
||||
(do (legacy-load-from-store)
|
||||
(save-to-store))))
|
||||
(reset! registry (get-in @st/state [:profile :props :plugins] {})))
|
||||
|
||||
(defn init
|
||||
[]
|
||||
|
|
Loading…
Add table
Reference in a new issue