From c24b2dadec3c46430864ddf3c5b00bb3f9a2b5d7 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 6 Sep 2024 09:56:19 +0200 Subject: [PATCH] :sparkles: Change installation data to profile --- frontend/src/app/main/data/users.cljs | 5 +++- frontend/src/app/plugins.cljs | 2 -- frontend/src/app/plugins/register.cljs | 36 +++++--------------------- 3 files changed, 10 insertions(+), 33 deletions(-) diff --git a/frontend/src/app/main/data/users.cljs b/frontend/src/app/main/data/users.cljs index 854777904..b3c4e8f05 100644 --- a/frontend/src/app/main/data/users.cljs +++ b/frontend/src/app/main/data/users.cljs @@ -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] diff --git a/frontend/src/app/plugins.cljs b/frontend/src/app/plugins.cljs index 8fccc0dcb..a66d1f023 100644 --- a/frontend/src/app/plugins.cljs +++ b/frontend/src/app/plugins.cljs @@ -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 diff --git a/frontend/src/app/plugins/register.cljs b/frontend/src/app/plugins/register.cljs index 1579b24b7..2ebe1912d 100644 --- a/frontend/src/app/plugins/register.cljs +++ b/frontend/src/app/plugins/register.cljs @@ -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 []