mirror of
https://github.com/penpot/penpot.git
synced 2026-09-24 12:56:15 +00:00
🐛 Fix disconnection of lib (#11742)
This commit is contained in:
parent
b32a73519e
commit
56bf0e3ebb
@ -389,16 +389,17 @@
|
|||||||
|
|
||||||
(mf/defc library-resolution*
|
(mf/defc library-resolution*
|
||||||
{::mf/private true}
|
{::mf/private true}
|
||||||
[{:keys [unresolved-file selection on-select]}]
|
[{:keys [unresolved-file selection on-select on-disconnect]}]
|
||||||
(let [candidates (:pending unresolved-file)
|
(let [candidates (:pending unresolved-file)
|
||||||
disconnected* (mf/use-state #{})
|
|
||||||
disconnected (deref disconnected*)
|
|
||||||
on-change-disconnected
|
on-change-disconnected
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
(mf/deps selection candidates on-select on-disconnect)
|
||||||
(fn [id]
|
(fn [id]
|
||||||
(swap! disconnected*
|
(if (contains? selection id)
|
||||||
(fn [s]
|
(on-disconnect id)
|
||||||
(if (contains? s id) (disj s id) (conj s id))))))]
|
(let [{:keys [candidates]} (d/seek #(= id (:id %)) candidates)]
|
||||||
|
(when-let [first-c (first candidates)]
|
||||||
|
(on-select id (str (:id first-c))))))))]
|
||||||
|
|
||||||
;; Pre-select first candidate for each library
|
;; Pre-select first candidate for each library
|
||||||
(mf/with-effect [candidates]
|
(mf/with-effect [candidates]
|
||||||
@ -435,7 +436,7 @@
|
|||||||
:label (str (:name c) " (" (:project-name c) ")")})
|
:label (str (:name c) " (" (:project-name c) ")")})
|
||||||
candidates)
|
candidates)
|
||||||
selected (get selection id)
|
selected (get selection id)
|
||||||
is-conected (not (contains? disconnected id))]
|
is-conected (contains? selection id)]
|
||||||
[:tr {:class (stl/css :library-resolution-item)
|
[:tr {:class (stl/css :library-resolution-item)
|
||||||
:key (dm/str id)}
|
:key (dm/str id)}
|
||||||
[:td {:class (stl/css :library-resolution-item-name)}
|
[:td {:class (stl/css :library-resolution-item-name)}
|
||||||
@ -645,7 +646,7 @@
|
|||||||
|
|
||||||
(mf/defc import-library-resolution-stage*
|
(mf/defc import-library-resolution-stage*
|
||||||
{::mf/private true}
|
{::mf/private true}
|
||||||
[{:keys [current-unresolved-file selection on-select
|
[{:keys [current-unresolved-file selection on-select on-disconnect
|
||||||
visited all-visited?
|
visited all-visited?
|
||||||
on-wizard-prev on-wizard-next on-wizard-skip]}]
|
on-wizard-prev on-wizard-next on-wizard-skip]}]
|
||||||
[:*
|
[:*
|
||||||
@ -653,7 +654,8 @@
|
|||||||
[:> library-resolution*
|
[:> library-resolution*
|
||||||
{:unresolved-file current-unresolved-file
|
{:unresolved-file current-unresolved-file
|
||||||
:selection selection
|
:selection selection
|
||||||
:on-select on-select}]]
|
:on-select on-select
|
||||||
|
:on-disconnect on-disconnect}]]
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-footer)}
|
[:div {:class (stl/css :modal-footer)}
|
||||||
[:div {:class (stl/css :action-buttons)}
|
[:div {:class (stl/css :action-buttons)}
|
||||||
@ -913,7 +915,12 @@
|
|||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps selection)
|
(mf/deps selection)
|
||||||
(fn [old-lib-id candidate-id]
|
(fn [old-lib-id candidate-id]
|
||||||
(swap! selection* assoc old-lib-id candidate-id)))]
|
(swap! selection* assoc old-lib-id candidate-id)))
|
||||||
|
|
||||||
|
manage-on-disconnect
|
||||||
|
(mf/use-fn
|
||||||
|
(fn [old-lib-id]
|
||||||
|
(swap! selection* dissoc old-lib-id)))]
|
||||||
|
|
||||||
(mf/with-effect [visited unresolved-files]
|
(mf/with-effect [visited unresolved-files]
|
||||||
(when (and (seq unresolved-files)
|
(when (and (seq unresolved-files)
|
||||||
@ -982,6 +989,7 @@
|
|||||||
{:current-unresolved-file current-unresolved-file
|
{:current-unresolved-file current-unresolved-file
|
||||||
:selection selection
|
:selection selection
|
||||||
:on-select manage-on-select
|
:on-select manage-on-select
|
||||||
|
:on-disconnect manage-on-disconnect
|
||||||
:visited visited
|
:visited visited
|
||||||
:all-visited? all-visited?
|
:all-visited? all-visited?
|
||||||
:on-wizard-prev on-wizard-prev
|
:on-wizard-prev on-wizard-prev
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user