mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 04:49:03 -05:00
💄 Add minor improvements to dashboard file menu
This commit is contained in:
parent
ee533e2644
commit
6b997928e5
2 changed files with 24 additions and 24 deletions
|
@ -24,23 +24,23 @@
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(defn get-project-name
|
(defn- get-project-name
|
||||||
[project]
|
[project]
|
||||||
(if (:is-default project)
|
(if (:is-default project)
|
||||||
(tr "labels.drafts")
|
(tr "labels.drafts")
|
||||||
(:name project)))
|
(:name project)))
|
||||||
|
|
||||||
(defn get-project-id
|
(defn- get-project-id
|
||||||
[project]
|
[project]
|
||||||
(str (:id project)))
|
(str (:id project)))
|
||||||
|
|
||||||
(defn get-team-name
|
(defn- get-team-name
|
||||||
[team]
|
[team]
|
||||||
(if (:is-default team)
|
(if (:is-default team)
|
||||||
(tr "dashboard.your-penpot")
|
(tr "dashboard.your-penpot")
|
||||||
(:name team)))
|
(:name team)))
|
||||||
|
|
||||||
(defn group-by-team
|
(defn- group-by-team
|
||||||
"Group projects by team."
|
"Group projects by team."
|
||||||
[projects]
|
[projects]
|
||||||
(reduce (fn [teams project]
|
(reduce (fn [teams project]
|
||||||
|
@ -55,14 +55,14 @@
|
||||||
{}
|
{}
|
||||||
projects))
|
projects))
|
||||||
|
|
||||||
(mf/defc file-menu
|
(mf/defc file-menu*
|
||||||
{::mf/wrap-props false}
|
{::mf/props :obj}
|
||||||
[{:keys [files show? on-edit on-menu-close top left navigate? origin parent-id can-edit]}]
|
[{:keys [files show on-edit on-menu-close top left navigate origin parent-id can-edit]}]
|
||||||
(assert (seq files) "missing `files` prop")
|
(assert (seq files) "missing `files` prop")
|
||||||
(assert (boolean? show?) "missing `show?` prop")
|
(assert (boolean? show) "missing `show` prop")
|
||||||
(assert (fn? on-edit) "missing `on-edit` prop")
|
(assert (fn? on-edit) "missing `on-edit` prop")
|
||||||
(assert (fn? on-menu-close) "missing `on-menu-close` prop")
|
(assert (fn? on-menu-close) "missing `on-menu-close` prop")
|
||||||
(assert (boolean? navigate?) "missing `navigate?` prop")
|
(assert (boolean? navigate) "missing `navigate` prop")
|
||||||
|
|
||||||
(let [is-lib-page? (= :libraries origin)
|
(let [is-lib-page? (= :libraries origin)
|
||||||
is-search-page? (= :search origin)
|
is-search-page? (= :search origin)
|
||||||
|
@ -133,7 +133,7 @@
|
||||||
(if multi?
|
(if multi?
|
||||||
(st/emit! (ntf/success (tr "dashboard.success-move-files")))
|
(st/emit! (ntf/success (tr "dashboard.success-move-files")))
|
||||||
(st/emit! (ntf/success (tr "dashboard.success-move-file"))))
|
(st/emit! (ntf/success (tr "dashboard.success-move-file"))))
|
||||||
(if (or navigate? (not= team-id current-team-id))
|
(if (or navigate (not= team-id current-team-id))
|
||||||
(st/emit! (dd/go-to-files team-id project-id))
|
(st/emit! (dd/go-to-files team-id project-id))
|
||||||
(st/emit! (dd/fetch-recent-files team-id)
|
(st/emit! (dd/fetch-recent-files team-id)
|
||||||
(dd/clear-selected-files))))
|
(dd/clear-selected-files))))
|
||||||
|
@ -213,9 +213,9 @@
|
||||||
mounted-ref (mf/use-ref true)]
|
mounted-ref (mf/use-ref true)]
|
||||||
|
|
||||||
(mf/use-effect
|
(mf/use-effect
|
||||||
(mf/deps show?)
|
(mf/deps show)
|
||||||
(fn []
|
(fn []
|
||||||
(when show?
|
(when show
|
||||||
(->> (rp/cmd! :get-all-projects)
|
(->> (rp/cmd! :get-all-projects)
|
||||||
(rx/map group-by-team)
|
(rx/map group-by-team)
|
||||||
(rx/subs! #(when (mf/ref-val mounted-ref)
|
(rx/subs! #(when (mf/ref-val mounted-ref)
|
||||||
|
@ -335,7 +335,7 @@
|
||||||
|
|
||||||
[:> context-menu*
|
[:> context-menu*
|
||||||
{:on-close on-menu-close
|
{:on-close on-menu-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
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.color-bullet :as bc]
|
[app.main.ui.components.color-bullet :as bc]
|
||||||
[app.main.ui.dashboard.file-menu :refer [file-menu]]
|
[app.main.ui.dashboard.file-menu :refer [file-menu*]]
|
||||||
[app.main.ui.dashboard.import :refer [use-import-file]]
|
[app.main.ui.dashboard.import :refer [use-import-file]]
|
||||||
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
|
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
|
||||||
[app.main.ui.dashboard.placeholder :refer [empty-placeholder loading-placeholder]]
|
[app.main.ui.dashboard.placeholder :refer [empty-placeholder loading-placeholder]]
|
||||||
|
@ -405,16 +405,16 @@
|
||||||
;; When the menu is open we disable events in the dashboard. We need to force pointer events
|
;; When the menu is open we disable events in the dashboard. We need to force pointer events
|
||||||
;; so the menu can be handled
|
;; so the menu can be handled
|
||||||
[:div {:style {:pointer-events "all"}}
|
[:div {:style {:pointer-events "all"}}
|
||||||
[:& file-menu {:files (vals selected-files)
|
[:> file-menu* {:files (vals selected-files)
|
||||||
:show? (:menu-open dashboard-local)
|
:show (:menu-open dashboard-local)
|
||||||
:left (+ 24 (:x (:menu-pos dashboard-local)))
|
:left (+ 24 (:x (:menu-pos dashboard-local)))
|
||||||
:top (:y (:menu-pos dashboard-local))
|
:top (:y (:menu-pos dashboard-local))
|
||||||
:can-edit can-edit
|
:can-edit can-edit
|
||||||
:navigate? true
|
:navigate true
|
||||||
:on-edit on-edit
|
:on-edit on-edit
|
||||||
:on-menu-close on-menu-close
|
:on-menu-close on-menu-close
|
||||||
:origin origin
|
:origin origin
|
||||||
:parent-id (str file-id "-action-menu")}]])]]]]]))
|
:parent-id (dm/str file-id "-action-menu")}]])]]]]]))
|
||||||
|
|
||||||
(mf/defc grid
|
(mf/defc grid
|
||||||
[{:keys [files project origin limit library-view? create-fn can-edit] :as props}]
|
[{:keys [files project origin limit library-view? create-fn can-edit] :as props}]
|
||||||
|
|
Loading…
Add table
Reference in a new issue