mirror of
https://github.com/penpot/penpot.git
synced 2025-12-23 22:48:40 -05:00
⚡ Add minor efficiency improvements to deleted dashboard page
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
(ns app.main.ui.dashboard.deleted
|
(ns app.main.ui.dashboard.deleted
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
[app.common.geom.point :as gpt]
|
[app.common.geom.point :as gpt]
|
||||||
[app.main.data.common :as dcm]
|
[app.main.data.common :as dcm]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
@@ -40,10 +41,12 @@
|
|||||||
|
|
||||||
(mf/defc deleted-project-menu*
|
(mf/defc deleted-project-menu*
|
||||||
[{:keys [project files team-id show on-close top left]}]
|
[{:keys [project files team-id show on-close top left]}]
|
||||||
(let [top (or top 0)
|
(let [top (d/nilv top 0)
|
||||||
left (or left 0)
|
left (d/nilv left 0)
|
||||||
|
|
||||||
file-ids (into #{} (map :id files))
|
file-ids
|
||||||
|
(mf/with-memo [files]
|
||||||
|
(into #{} d/xf:map-id files))
|
||||||
|
|
||||||
restore-fn
|
restore-fn
|
||||||
(fn [_]
|
(fn [_]
|
||||||
@@ -89,15 +92,14 @@
|
|||||||
:id "project-delete"
|
:id "project-delete"
|
||||||
:handler on-delete-project}]]
|
:handler on-delete-project}]]
|
||||||
|
|
||||||
[:*
|
[:> context-menu*
|
||||||
[:> context-menu*
|
{:on-close on-close
|
||||||
{:on-close on-close
|
:show show
|
||||||
:show show
|
:fixed (or (not= top 0) (not= left 0))
|
||||||
:fixed (or (not= top 0) (not= left 0))
|
:min-width true
|
||||||
:min-width true
|
:top top
|
||||||
:top top
|
:left left
|
||||||
:left left
|
:options options}]))
|
||||||
:options options}]]))
|
|
||||||
|
|
||||||
(mf/defc deleted-project-item*
|
(mf/defc deleted-project-item*
|
||||||
{::mf/props :obj
|
{::mf/props :obj
|
||||||
@@ -111,9 +113,10 @@
|
|||||||
dstate (mf/deref refs/dashboard-local)
|
dstate (mf/deref refs/dashboard-local)
|
||||||
edit-id (:project-for-edit dstate)
|
edit-id (:project-for-edit dstate)
|
||||||
|
|
||||||
local (mf/use-state {:menu-open false
|
local (mf/use-state
|
||||||
:menu-pos nil
|
#(do {:menu-open false
|
||||||
:edition (= (:id project) edit-id)})
|
:menu-pos nil
|
||||||
|
:edition (= (:id project) edit-id)}))
|
||||||
|
|
||||||
[rowref limit] (hooks/use-dynamic-grid-item-width)
|
[rowref limit] (hooks/use-dynamic-grid-item-width)
|
||||||
|
|
||||||
@@ -144,6 +147,7 @@
|
|||||||
(when (kbd/enter? event)
|
(when (kbd/enter? event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(on-menu-click event))))]
|
(on-menu-click event))))]
|
||||||
|
|
||||||
[:article {:class (stl/css-case :dashboard-project-row true)}
|
[:article {:class (stl/css-case :dashboard-project-row true)}
|
||||||
[:header {:class (stl/css :project)}
|
[:header {:class (stl/css :project)}
|
||||||
[:div {:class (stl/css :project-name-wrapper)}
|
[:div {:class (stl/css :project-name-wrapper)}
|
||||||
@@ -163,14 +167,15 @@
|
|||||||
:on-key-down handle-menu-click}
|
:on-key-down handle-menu-click}
|
||||||
menu-icon]]
|
menu-icon]]
|
||||||
|
|
||||||
[:> deleted-project-menu*
|
(when (:menu-open @local)
|
||||||
{:project project
|
[:> deleted-project-menu*
|
||||||
:files project-files
|
{:project project
|
||||||
:team-id (:id team)
|
:files project-files
|
||||||
:show (:menu-open @local)
|
:team-id (:id team)
|
||||||
:left (+ 24 (:x (:menu-pos @local)))
|
:show (:menu-open @local)
|
||||||
:top (:y (:menu-pos @local))
|
:left (+ 24 (:x (:menu-pos @local)))
|
||||||
:on-close on-menu-close}]])]]
|
:top (:y (:menu-pos @local))
|
||||||
|
:on-close on-menu-close}])])]]
|
||||||
|
|
||||||
[:div {:class (stl/css :grid-container) :ref rowref}
|
[:div {:class (stl/css :grid-container) :ref rowref}
|
||||||
(if ^boolean empty?
|
(if ^boolean empty?
|
||||||
|
|||||||
Reference in New Issue
Block a user