diff --git a/frontend/src/app/main/ui/dashboard/file_menu.cljs b/frontend/src/app/main/ui/dashboard/file_menu.cljs index bd66900d2..bc539924d 100644 --- a/frontend/src/app/main/ui/dashboard/file_menu.cljs +++ b/frontend/src/app/main/ui/dashboard/file_menu.cljs @@ -24,23 +24,23 @@ [beicon.v2.core :as rx] [rumext.v2 :as mf])) -(defn get-project-name +(defn- get-project-name [project] (if (:is-default project) (tr "labels.drafts") (:name project))) -(defn get-project-id +(defn- get-project-id [project] (str (:id project))) -(defn get-team-name +(defn- get-team-name [team] (if (:is-default team) (tr "dashboard.your-penpot") (:name team))) -(defn group-by-team +(defn- group-by-team "Group projects by team." [projects] (reduce (fn [teams project] @@ -55,14 +55,14 @@ {} projects)) -(mf/defc file-menu - {::mf/wrap-props false} - [{:keys [files show? on-edit on-menu-close top left navigate? origin parent-id can-edit]}] +(mf/defc file-menu* + {::mf/props :obj} + [{:keys [files show on-edit on-menu-close top left navigate origin parent-id can-edit]}] (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-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) is-search-page? (= :search origin) @@ -133,7 +133,7 @@ (if multi? (st/emit! (ntf/success (tr "dashboard.success-move-files"))) (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/fetch-recent-files team-id) (dd/clear-selected-files)))) @@ -213,9 +213,9 @@ mounted-ref (mf/use-ref true)] (mf/use-effect - (mf/deps show?) + (mf/deps show) (fn [] - (when show? + (when show (->> (rp/cmd! :get-all-projects) (rx/map group-by-team) (rx/subs! #(when (mf/ref-val mounted-ref) @@ -335,7 +335,7 @@ [:> context-menu* {:on-close on-menu-close - :show show? + :show show :fixed (or (not= top 0) (not= left 0)) :min-width true :top top diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index b5df948a4..4d45a664a 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -22,7 +22,7 @@ [app.main.repo :as rp] [app.main.store :as st] [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.inline-edition :refer [inline-edition]] [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 ;; so the menu can be handled [:div {:style {:pointer-events "all"}} - [:& file-menu {:files (vals selected-files) - :show? (:menu-open dashboard-local) - :left (+ 24 (:x (:menu-pos dashboard-local))) - :top (:y (:menu-pos dashboard-local)) - :can-edit can-edit - :navigate? true - :on-edit on-edit - :on-menu-close on-menu-close - :origin origin - :parent-id (str file-id "-action-menu")}]])]]]]])) + [:> file-menu* {:files (vals selected-files) + :show (:menu-open dashboard-local) + :left (+ 24 (:x (:menu-pos dashboard-local))) + :top (:y (:menu-pos dashboard-local)) + :can-edit can-edit + :navigate true + :on-edit on-edit + :on-menu-close on-menu-close + :origin origin + :parent-id (dm/str file-id "-action-menu")}]])]]]]])) (mf/defc grid [{:keys [files project origin limit library-view? create-fn can-edit] :as props}]