mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 07:41:43 -05:00
✨ Change installation data to profile
This commit is contained in:
parent
9a3b5337d7
commit
c24b2dadec
3 changed files with 10 additions and 33 deletions
|
@ -19,6 +19,7 @@
|
||||||
[app.main.data.websocket :as ws]
|
[app.main.data.websocket :as ws]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
|
[app.plugins.register :as register]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
[app.util.storage :as s]
|
[app.util.storage :as s]
|
||||||
|
@ -137,7 +138,9 @@
|
||||||
(swap! s/storage assoc :profile profile)
|
(swap! s/storage assoc :profile profile)
|
||||||
(i18n/set-locale! (:lang profile))
|
(i18n/set-locale! (:lang profile))
|
||||||
(when (not= previous-email email)
|
(when (not= previous-email email)
|
||||||
(set-current-team! nil)))))))
|
(set-current-team! nil))
|
||||||
|
|
||||||
|
(register/init))))))
|
||||||
|
|
||||||
(defn- on-fetch-profile-exception
|
(defn- on-fetch-profile-exception
|
||||||
[cause]
|
[cause]
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
[app.plugins.grid :as grid]
|
[app.plugins.grid :as grid]
|
||||||
[app.plugins.library :as library]
|
[app.plugins.library :as library]
|
||||||
[app.plugins.public-utils]
|
[app.plugins.public-utils]
|
||||||
[app.plugins.register :as register]
|
|
||||||
[app.plugins.shape :as shape]
|
[app.plugins.shape :as shape]
|
||||||
[app.util.globals :refer [global]]
|
[app.util.globals :refer [global]]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
|
@ -25,7 +24,6 @@
|
||||||
(defn init-plugins-runtime!
|
(defn init-plugins-runtime!
|
||||||
[]
|
[]
|
||||||
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
|
(when-let [init-runtime (obj/get global "initPluginsRuntime")]
|
||||||
(register/init)
|
|
||||||
(init-runtime (fn [plugin-id] (api/create-context plugin-id)))))
|
(init-runtime (fn [plugin-id] (api/create-context plugin-id)))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
|
|
|
@ -10,8 +10,10 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
|
[app.main.repo :as rp]
|
||||||
|
[app.main.store :as st]
|
||||||
[app.util.object :as obj]
|
[app.util.object :as obj]
|
||||||
[app.util.storage :refer [storage]]))
|
[beicon.v2.core :as rx]))
|
||||||
|
|
||||||
;; Stores the installed plugins information
|
;; Stores the installed plugins information
|
||||||
(defonce ^:private registry (atom {}))
|
(defonce ^:private registry (atom {}))
|
||||||
|
@ -58,40 +60,14 @@
|
||||||
:icon icon
|
:icon icon
|
||||||
:permissions (into #{} (map str) permissions)}))
|
: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
|
(defn save-to-store
|
||||||
[]
|
[]
|
||||||
(swap! storage assoc :plugins @registry))
|
(->> (rp/cmd! :update-profile-props {:props {:plugins @registry}})
|
||||||
|
(rx/subs! identity)))
|
||||||
|
|
||||||
(defn load-from-store
|
(defn load-from-store
|
||||||
[]
|
[]
|
||||||
(if (:plugins @storage)
|
(reset! registry (get-in @st/state [:profile :props :plugins] {})))
|
||||||
(reset! registry (:plugins @storage))
|
|
||||||
(do (legacy-load-from-store)
|
|
||||||
(save-to-store))))
|
|
||||||
|
|
||||||
(defn init
|
(defn init
|
||||||
[]
|
[]
|
||||||
|
|
Loading…
Add table
Reference in a new issue