mirror of
https://github.com/penpot/penpot.git
synced 2025-05-05 06:45:53 +02:00
✨ Improve builtin template fetching management
This commit is contained in:
parent
a665339c98
commit
02b41abaf8
3 changed files with 16 additions and 6 deletions
|
@ -412,10 +412,17 @@
|
||||||
(binfile/import!))))
|
(binfile/import!))))
|
||||||
|
|
||||||
|
|
||||||
;; --- COMMAND: Retrieve list of builtin templates
|
;; --- COMMAND: Get list of builtin templates
|
||||||
|
|
||||||
(s/def ::retrieve-list-of-builtin-templates any?)
|
(s/def ::retrieve-list-of-builtin-templates any?)
|
||||||
|
|
||||||
(sv/defmethod ::retrieve-list-of-builtin-templates
|
(sv/defmethod ::retrieve-list-of-builtin-templates
|
||||||
|
{::doc/added "1.10"
|
||||||
|
::doc/deprecated "1.19"}
|
||||||
|
[cfg _params]
|
||||||
|
(mapv #(select-keys % [:id :name :thumbnail-uri]) (:templates cfg)))
|
||||||
|
|
||||||
|
(sv/defmethod ::get-builtin-templates
|
||||||
|
{::doc/added "1.19"}
|
||||||
[cfg _params]
|
[cfg _params]
|
||||||
(mapv #(select-keys % [:id :name :thumbnail-uri]) (:templates cfg)))
|
(mapv #(select-keys % [:id :name :thumbnail-uri]) (:templates cfg)))
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
(declare fetch-projects)
|
(declare fetch-projects)
|
||||||
(declare fetch-team-members)
|
(declare fetch-team-members)
|
||||||
(declare fetch-builtin-templates)
|
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
[{:keys [id] :as params}]
|
[{:keys [id] :as params}]
|
||||||
|
@ -62,8 +61,7 @@
|
||||||
(ptk/watch (fetch-projects) state stream)
|
(ptk/watch (fetch-projects) state stream)
|
||||||
(ptk/watch (fetch-team-members) state stream)
|
(ptk/watch (fetch-team-members) state stream)
|
||||||
(ptk/watch (du/fetch-teams) state stream)
|
(ptk/watch (du/fetch-teams) state stream)
|
||||||
(ptk/watch (du/fetch-users {:team-id id}) state stream)
|
(ptk/watch (du/fetch-users {:team-id id}) state stream)))))
|
||||||
(ptk/watch (fetch-builtin-templates) state stream)))))
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Data Fetching (context aware: current team)
|
;; Data Fetching (context aware: current team)
|
||||||
|
@ -275,7 +273,7 @@
|
||||||
(ptk/reify ::fetch-builtin-templates
|
(ptk/reify ::fetch-builtin-templates
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(->> (rp/cmd! :retrieve-list-of-builtin-templates)
|
(->> (rp/cmd! :get-builtin-templates)
|
||||||
(rx/map builtin-templates-fetched)))))
|
(rx/map builtin-templates-fetched)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
|
@ -226,6 +227,10 @@
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
(mf/with-effect [collapsed]
|
||||||
|
(when-not collapsed
|
||||||
|
(st/emit! (dd/fetch-builtin-templates))))
|
||||||
|
|
||||||
[:div.dashboard-templates-section
|
[:div.dashboard-templates-section
|
||||||
{:class (when ^boolean collapsed "collapsed")}
|
{:class (when ^boolean collapsed "collapsed")}
|
||||||
[:& title {:collapsed collapsed}]
|
[:& title {:collapsed collapsed}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue