mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 19:06:11 +02:00
🐛 Fix problem when importing templates
This commit is contained in:
parent
de1dae7f93
commit
9852558a57
1 changed files with 28 additions and 11 deletions
|
@ -345,18 +345,21 @@
|
||||||
edition* (mf/use-state nil)
|
edition* (mf/use-state nil)
|
||||||
edition (deref edition*)
|
edition (deref edition*)
|
||||||
|
|
||||||
|
template-finished* (mf/use-state nil)
|
||||||
|
template-finished (deref template-finished*)
|
||||||
|
|
||||||
on-template-cloned-success
|
on-template-cloned-success
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn []
|
(fn []
|
||||||
(swap! status* (constantly :importing))
|
(reset! status* :importing)
|
||||||
;; (swap! state assoc :status :importing :importing-templates 0)
|
(reset! template-finished* true)
|
||||||
(st/emit! (dd/fetch-recent-files))))
|
(st/emit! (dd/fetch-recent-files))))
|
||||||
|
|
||||||
on-template-cloned-error
|
on-template-cloned-error
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [cause]
|
(fn [cause]
|
||||||
(swap! status* (constantly :error))
|
(reset! status* :error)
|
||||||
;; (swap! state assoc :status :error :importing-templates 0)
|
(reset! template-finished* true)
|
||||||
(errors/print-error! cause)
|
(errors/print-error! cause)
|
||||||
(rx/of (modal/hide)
|
(rx/of (modal/hide)
|
||||||
(msg/error (tr "dashboard.libraries-and-templates.import-error")))))
|
(msg/error (tr "dashboard.libraries-and-templates.import-error")))))
|
||||||
|
@ -434,15 +437,29 @@
|
||||||
1
|
1
|
||||||
(count (filterv has-status-success? entries)))
|
(count (filterv has-status-success? entries)))
|
||||||
|
|
||||||
errors? (or (some has-status-error? entries)
|
errors? (if (some? template)
|
||||||
(zero? (count entries)))
|
(= status :error)
|
||||||
|
(or (some has-status-error? entries)
|
||||||
|
(zero? (count entries))))
|
||||||
|
|
||||||
pending-analysis? (some has-status-analyzing? entries)
|
pending-analysis? (some has-status-analyzing? entries)
|
||||||
pending-import? (pos? num-importing)
|
pending-import? (and (or (nil? template)
|
||||||
valid-all-entries? (or (some? template)
|
(not template-finished))
|
||||||
(not (some has-status-analyze-error? entries)))]
|
(pos? num-importing))
|
||||||
|
|
||||||
|
valid-all-entries? (or (some? template)
|
||||||
|
(not (some has-status-analyze-error? entries)))
|
||||||
|
|
||||||
|
template-status
|
||||||
|
(cond
|
||||||
|
(and (= :importing status) pending-import?)
|
||||||
|
:importing
|
||||||
|
|
||||||
|
(and (= :importing status) (not ^boolean pending-import?))
|
||||||
|
:import-finish
|
||||||
|
|
||||||
|
:else
|
||||||
|
:ready)]
|
||||||
|
|
||||||
;; Run analyze operation on component mount
|
;; Run analyze operation on component mount
|
||||||
(mf/with-effect []
|
(mf/with-effect []
|
||||||
|
@ -486,7 +503,7 @@
|
||||||
:can-be-deleted (> (count entries) 1)}])
|
:can-be-deleted (> (count entries) 1)}])
|
||||||
|
|
||||||
(when (some? template)
|
(when (some? template)
|
||||||
[:& import-entry {:entry (assoc template :status :ready)
|
[:& import-entry {:entry (assoc template :status template-status)
|
||||||
:can-be-deleted false}])]
|
:can-be-deleted false}])]
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-footer)}
|
[:div {:class (stl/css :modal-footer)}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue