mirror of
https://github.com/penpot/penpot.git
synced 2026-08-19 19:28:36 +00:00
🐛 Fix use single point for retrieving state and propagate it
This commit is contained in:
parent
9311737f66
commit
1c650fe5a7
@ -27,6 +27,7 @@
|
|||||||
[app.main.ui.dashboard.files :refer [files-section*]]
|
[app.main.ui.dashboard.files :refer [files-section*]]
|
||||||
[app.main.ui.dashboard.fonts :refer [fonts-page* font-providers-page*]]
|
[app.main.ui.dashboard.fonts :refer [fonts-page* font-providers-page*]]
|
||||||
[app.main.ui.dashboard.import]
|
[app.main.ui.dashboard.import]
|
||||||
|
[app.main.ui.dashboard.layout-toggle :as lt]
|
||||||
[app.main.ui.dashboard.libraries :refer [libraries-page*]]
|
[app.main.ui.dashboard.libraries :refer [libraries-page*]]
|
||||||
[app.main.ui.dashboard.projects :refer [projects-section*]]
|
[app.main.ui.dashboard.projects :refer [projects-section*]]
|
||||||
[app.main.ui.dashboard.search :refer [search-page*]]
|
[app.main.ui.dashboard.search :refer [search-page*]]
|
||||||
@ -51,7 +52,7 @@
|
|||||||
|
|
||||||
(mf/defc dashboard-content*
|
(mf/defc dashboard-content*
|
||||||
{::mf/private true}
|
{::mf/private true}
|
||||||
[{:keys [team projects project section search-term profile default-project]}]
|
[{:keys [team projects project section search-term profile default-project layout on-layout-change]}]
|
||||||
(let [container (mf/use-ref)
|
(let [container (mf/use-ref)
|
||||||
content-width (mf/use-state 0)
|
content-width (mf/use-state 0)
|
||||||
|
|
||||||
@ -100,18 +101,18 @@
|
|||||||
:dashboard-recent
|
:dashboard-recent
|
||||||
(when (seq projects)
|
(when (seq projects)
|
||||||
[:*
|
[:*
|
||||||
[:> projects-section*
|
[:> projects-section* {:team team
|
||||||
{:team team
|
:projects projects
|
||||||
:projects projects
|
:profile profile
|
||||||
:profile profile}]
|
:layout layout
|
||||||
|
:on-layout-change on-layout-change}]
|
||||||
|
|
||||||
(when ^boolean show-templates?
|
(when ^boolean show-templates?
|
||||||
[:> templates-section*
|
[:> templates-section* {:profile profile
|
||||||
{:profile profile
|
:project-id project-id
|
||||||
:project-id project-id
|
:team-id team-id
|
||||||
:team-id team-id
|
:default-project-id default-project-id
|
||||||
:default-project-id default-project-id
|
:content-width @content-width}])])
|
||||||
:content-width @content-width}])])
|
|
||||||
|
|
||||||
:dashboard-fonts
|
:dashboard-fonts
|
||||||
[:> fonts-page* {:team team}]
|
[:> fonts-page* {:team team}]
|
||||||
@ -123,14 +124,15 @@
|
|||||||
(when project
|
(when project
|
||||||
[:*
|
[:*
|
||||||
[:> files-section* {:team team
|
[:> files-section* {:team team
|
||||||
:project project}]
|
:project project
|
||||||
|
:layout layout
|
||||||
|
:on-layout-change on-layout-change}]
|
||||||
(when ^boolean show-templates?
|
(when ^boolean show-templates?
|
||||||
[:> templates-section*
|
[:> templates-section* {:profile profile
|
||||||
{:profile profile
|
:team-id team-id
|
||||||
:team-id team-id
|
:project-id project-id
|
||||||
:project-id project-id
|
:default-project-id default-project-id
|
||||||
:default-project-id default-project-id
|
:content-width @content-width}])])
|
||||||
:content-width @content-width}])])
|
|
||||||
|
|
||||||
:dashboard-search
|
:dashboard-search
|
||||||
[:> search-page* {:team team
|
[:> search-page* {:team team
|
||||||
@ -155,7 +157,9 @@
|
|||||||
:dashboard-deleted
|
:dashboard-deleted
|
||||||
[:> deleted-section* {:team team
|
[:> deleted-section* {:team team
|
||||||
:projects projects
|
:projects projects
|
||||||
:profile profile}]
|
:profile profile
|
||||||
|
:layout layout
|
||||||
|
:on-layout-change on-layout-change}]
|
||||||
|
|
||||||
nil)]))
|
nil)]))
|
||||||
|
|
||||||
@ -313,7 +317,15 @@
|
|||||||
(mf/with-memo [projects]
|
(mf/with-memo [projects]
|
||||||
(->> projects
|
(->> projects
|
||||||
(filter :is-default)
|
(filter :is-default)
|
||||||
(first)))]
|
(first)))
|
||||||
|
|
||||||
|
layout* (hooks/use-persisted-state lt/layout-key lt/default-layout)
|
||||||
|
layout (deref layout*)
|
||||||
|
|
||||||
|
on-layout-change
|
||||||
|
(mf/use-fn
|
||||||
|
(fn [value]
|
||||||
|
(reset! layout* (keyword value))))]
|
||||||
|
|
||||||
(hooks/use-shortcuts ::dashboard sc/shortcuts-dashboard :dashboard)
|
(hooks/use-shortcuts ::dashboard sc/shortcuts-dashboard :dashboard)
|
||||||
|
|
||||||
@ -347,22 +359,22 @@
|
|||||||
;; team is already set so don't put the team into mf/deps.
|
;; team is already set so don't put the team into mf/deps.
|
||||||
[:main {:class (stl/css :dashboard)
|
[:main {:class (stl/css :dashboard)
|
||||||
:key (dm/str (:id team))}
|
:key (dm/str (:id team))}
|
||||||
[:> sidebar*
|
[:> sidebar* {:team team
|
||||||
{:team team
|
:projects projects
|
||||||
:projects projects
|
:project project
|
||||||
:project project
|
:default-project default-project
|
||||||
:default-project default-project
|
:profile profile
|
||||||
:profile profile
|
:section section
|
||||||
:section section
|
:search-term search-term}]
|
||||||
:search-term search-term}]
|
[:> dashboard-content* {:projects projects
|
||||||
[:> dashboard-content*
|
:profile profile
|
||||||
{:projects projects
|
:project project
|
||||||
:profile profile
|
:default-project default-project
|
||||||
:project project
|
:section section
|
||||||
:default-project default-project
|
:search-term search-term
|
||||||
:section section
|
:team team
|
||||||
:search-term search-term
|
:layout layout
|
||||||
:team team}]]]))
|
:on-layout-change on-layout-change}]]]))
|
||||||
|
|
||||||
(mf/defc dashboard-page*
|
(mf/defc dashboard-page*
|
||||||
{::mf/lazy-load true}
|
{::mf/lazy-load true}
|
||||||
|
|||||||
@ -219,16 +219,8 @@
|
|||||||
(tr "labels.deleted")]]]))
|
(tr "labels.deleted")]]]))
|
||||||
|
|
||||||
(mf/defc deleted-section*
|
(mf/defc deleted-section*
|
||||||
[{:keys [team projects]}]
|
[{:keys [team projects layout on-layout-change]}]
|
||||||
(let [layout* (hooks/use-persisted-state lt/layout-key lt/default-layout)
|
(let [deleted-map
|
||||||
layout (deref layout*)
|
|
||||||
|
|
||||||
on-layout-change
|
|
||||||
(mf/use-fn
|
|
||||||
(fn [value]
|
|
||||||
(reset! layout* (keyword value))))
|
|
||||||
|
|
||||||
deleted-map
|
|
||||||
(mf/deref ref:deleted-files)
|
(mf/deref ref:deleted-files)
|
||||||
|
|
||||||
projects
|
projects
|
||||||
|
|||||||
@ -137,7 +137,7 @@
|
|||||||
:on-import on-import}])]]))
|
:on-import on-import}])]]))
|
||||||
|
|
||||||
(mf/defc files-section*
|
(mf/defc files-section*
|
||||||
[{:keys [project team]}]
|
[{:keys [project team layout on-layout-change]}]
|
||||||
(let [files (mf/deref refs/files)
|
(let [files (mf/deref refs/files)
|
||||||
project-id (get project :id)
|
project-id (get project :id)
|
||||||
|
|
||||||
@ -160,14 +160,6 @@
|
|||||||
|
|
||||||
selected-files (mf/deref refs/selected-files)
|
selected-files (mf/deref refs/selected-files)
|
||||||
|
|
||||||
layout* (hooks/use-persisted-state lt/layout-key lt/default-layout)
|
|
||||||
layout (deref layout*)
|
|
||||||
|
|
||||||
on-layout-change
|
|
||||||
(mf/use-fn
|
|
||||||
(fn [value]
|
|
||||||
(reset! layout* (keyword value))))
|
|
||||||
|
|
||||||
on-file-created
|
on-file-created
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [file-data]
|
(fn [file-data]
|
||||||
|
|||||||
@ -313,7 +313,7 @@
|
|||||||
(l/derived :recent-files st/state))
|
(l/derived :recent-files st/state))
|
||||||
|
|
||||||
(mf/defc projects-section*
|
(mf/defc projects-section*
|
||||||
[{:keys [team projects profile]}]
|
[{:keys [team projects profile layout on-layout-change]}]
|
||||||
|
|
||||||
(let [team-id (get team :id)
|
(let [team-id (get team :id)
|
||||||
|
|
||||||
@ -334,14 +334,6 @@
|
|||||||
|
|
||||||
show-deleted? (:can-edit permisions)
|
show-deleted? (:can-edit permisions)
|
||||||
|
|
||||||
layout* (hooks/use-persisted-state lt/layout-key lt/default-layout)
|
|
||||||
layout (deref layout*)
|
|
||||||
|
|
||||||
on-layout-change
|
|
||||||
(mf/use-fn
|
|
||||||
(fn [value]
|
|
||||||
(reset! layout* (keyword value))))
|
|
||||||
|
|
||||||
projects
|
projects
|
||||||
(mf/with-memo [projects]
|
(mf/with-memo [projects]
|
||||||
(->> projects
|
(->> projects
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user