From 93c81ea49c7edd580183e1859297d2ab040341ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20L=C3=B3pez?= Date: Wed, 16 Apr 2025 17:17:47 +0200 Subject: [PATCH 1/9] :bug: Fix pricing CTA to be under a config flag (#6304) --- CHANGES.md | 1 + backend/scripts/repl | 3 ++- backend/scripts/start-dev | 3 ++- common/src/app/common/flags.cljc | 3 ++- frontend/src/app/main/ui/dashboard/sidebar.cljs | 15 ++++++++------- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6c020ebb1..c20143fa1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - Increase the height of the right sidebar dropdowns [Taiga #10615](https://tree.taiga.io/project/penpot/issue/10615) - Fix scroll on token themes modal [Taiga #10745](https://tree.taiga.io/project/penpot/issue/10745) - Fix unexpected exception on path editor on merge segments when undo stack is empty +- Fix pricing CTA to be under a config flag [Taiga #10808](https://tree.taiga.io/project/penpot/issue/10808) ## 2.6.1 diff --git a/backend/scripts/repl b/backend/scripts/repl index 6da57ebcc..558a68b95 100755 --- a/backend/scripts/repl +++ b/backend/scripts/repl @@ -30,7 +30,8 @@ export PENPOT_FLAGS="\ enable-access-tokens \ enable-tiered-file-data-storage \ enable-file-validation \ - enable-file-schema-validation"; + enable-file-schema-validation \ + enable-subscriptions-old"; # Default deletion delay for devenv export PENPOT_DELETION_DELAY="24h" diff --git a/backend/scripts/start-dev b/backend/scripts/start-dev index 9fe2ccb1b..dae3af23a 100755 --- a/backend/scripts/start-dev +++ b/backend/scripts/start-dev @@ -23,7 +23,8 @@ export PENPOT_FLAGS="\ enable-access-tokens \ enable-tiered-file-data-storage \ enable-file-validation \ - enable-file-schema-validation"; + enable-file-schema-validation \ + enable-subscriptions-old"; export OPTIONS=" -A:jmx-remote -A:dev \ diff --git a/common/src/app/common/flags.cljc b/common/src/app/common/flags.cljc index cba12a9cd..dbc39e504 100644 --- a/common/src/app/common/flags.cljc +++ b/common/src/app/common/flags.cljc @@ -124,7 +124,8 @@ ;; TODO: deprecate this flag and consolidate the code :export-file-v3 :render-wasm-dpr - :hide-release-modal}) + :hide-release-modal + :subscriptions-old}) (def all-flags (set/union email login varia)) diff --git a/frontend/src/app/main/ui/dashboard/sidebar.cljs b/frontend/src/app/main/ui/dashboard/sidebar.cljs index 1a0d85b74..0a6d07c8b 100644 --- a/frontend/src/app/main/ui/dashboard/sidebar.cljs +++ b/frontend/src/app/main/ui/dashboard/sidebar.cljs @@ -962,13 +962,14 @@ (dom/open-new-window "https://penpot.app/pricing")))] [:* - [:button {:class (stl/css :upgrade-plan-section) - :on-click on-power-up-click} - [:div {:class (stl/css :penpot-free)} - [:span (tr "dashboard.upgrade-plan.penpot-free")] - [:span {:class (stl/css :no-limits)} (tr "dashboard.upgrade-plan.no-limits")]] - [:div {:class (stl/css :power-up)} - (tr "dashboard.upgrade-plan.power-up")]] + (when (contains? cf/flags :subscriptions-old) + [:button {:class (stl/css :upgrade-plan-section) + :on-click on-power-up-click} + [:div {:class (stl/css :penpot-free)} + [:span (tr "dashboard.upgrade-plan.penpot-free")] + [:span {:class (stl/css :no-limits)} (tr "dashboard.upgrade-plan.no-limits")]] + [:div {:class (stl/css :power-up)} + (tr "dashboard.upgrade-plan.power-up")]]) (when (and team profile) [:& comments-section {:profile profile From 70a23a14c44d1af52489d4da8435298bb51d955b Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 16 Apr 2025 17:20:52 +0200 Subject: [PATCH 2/9] :bug: Fix allow moving a main component into another --- CHANGES.md | 1 + common/src/app/common/types/container.cljc | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c20143fa1..84515126b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ - Fix scroll on token themes modal [Taiga #10745](https://tree.taiga.io/project/penpot/issue/10745) - Fix unexpected exception on path editor on merge segments when undo stack is empty - Fix pricing CTA to be under a config flag [Taiga #10808](https://tree.taiga.io/project/penpot/issue/10808) +- Fix allow moving a main component into another [Taiga #10818](https://tree.taiga.io/project/penpot/issue/10818) ## 2.6.1 diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 372b0ce1b..6b714fb46 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -543,14 +543,23 @@ ;; We can always move the children to the parent they already have. ;; But if we are pasting, those are new items, so it is considered a change no-changes? - (and (->> children (every? #(= parent-id (:parent-id %)))) + (and (every? #(= parent-id (:parent-id %)) children) (not pasting?)) all-main? - (->> children (every? #(ctk/main-instance? %)))] + (every? ctk/main-instance? children) + + any-main-descendant + (some + (fn [shape] + (some ctk/main-instance? (cfh/get-children-with-self objects (:id shape)))) + children)] + (if (or no-changes? (and (not (invalid-structure-for-component? objects parent children pasting? libraries)) ;; If we are moving into a variant-container, all the items should be main - (or all-main? (not (ctk/is-variant-container? parent))))) + (or all-main? (not (ctk/is-variant-container? parent))) + ;; If we are moving into a main component, no descendant can be main + (or (nil? any-main-descendant) (not (ctk/main-instance? parent))))) [parent-id (get-frame parent-id)] (recur (:parent-id parent) objects children pasting? libraries)))))) From d5abbd422026a484ac5496af63a0f3ce8c3dfdb6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 09:47:13 +0200 Subject: [PATCH 3/9] :paperclip: Add missing entries on the changelog --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 84515126b..0663499ef 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,6 +9,9 @@ - Fix unexpected exception on path editor on merge segments when undo stack is empty - Fix pricing CTA to be under a config flag [Taiga #10808](https://tree.taiga.io/project/penpot/issue/10808) - Fix allow moving a main component into another [Taiga #10818](https://tree.taiga.io/project/penpot/issue/10818) +- Fix several issues with internal srepl helpers +- Fix unexpected exception on template import from libraries +- Fix incorrect uuid parsing from different parts of code ## 2.6.1 From a209966427770e8f72b7e84cae885978f26d4e9d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 09:47:32 +0200 Subject: [PATCH 4/9] :bug: Don't use schema uuid parsing function on websocket ns --- backend/src/app/http/websocket.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app/http/websocket.clj b/backend/src/app/http/websocket.clj index bcedf31ce..a93fd33cb 100644 --- a/backend/src/app/http/websocket.clj +++ b/backend/src/app/http/websocket.clj @@ -273,7 +273,7 @@ (defn- http-handler [cfg {:keys [params ::session/profile-id] :as request}] - (let [session-id (some-> params :session-id sm/parse-uuid)] + (let [session-id (some-> params :session-id uuid/parse*)] (when-not (uuid? session-id) (ex/raise :type :validation :code :missing-session-id From e69c0c3e27005a98dff5c48db2880e5c74cde061 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 09:51:55 +0200 Subject: [PATCH 5/9] :sparkles: Make schema uuid parsing fns private --- common/src/app/common/schema.cljc | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index b6f1a49c4..cb84052d0 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -390,17 +390,16 @@ (register! :merge (mu/-merge)) (register! :union (mu/-union)) -(def uuid-rx - #"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$") - -(defn parse-uuid +(defn- parse-uuid [s] - (try - (uuid/parse s) - (catch #?(:clj Exception :cljs :default) _cause - s))) + (if (str/empty? s) + nil + (try + (uuid/parse s) + (catch #?(:clj Exception :cljs :default) _cause + s)))) -(defn encode-uuid +(defn- encode-uuid [v] (when (uuid? v) (str v))) From cc7f0b145c476dba3bdc4eb8550ab7a6c87032cc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 17:40:29 +0200 Subject: [PATCH 6/9] :bug: Make shape interaction properly decode on binfile import --- common/src/app/common/schema.cljc | 19 ++++--- .../app/common/types/shape/interactions.cljc | 52 ++++++++++++------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/common/src/app/common/schema.cljc b/common/src/app/common/schema.cljc index cb84052d0..23d32e3e7 100644 --- a/common/src/app/common/schema.cljc +++ b/common/src/app/common/schema.cljc @@ -392,17 +392,20 @@ (defn- parse-uuid [s] - (if (str/empty? s) - nil - (try - (uuid/parse s) - (catch #?(:clj Exception :cljs :default) _cause - s)))) + (if (uuid? s) + s + (if (str/empty? s) + nil + (try + (uuid/parse s) + (catch #?(:clj Exception :cljs :default) _cause + s))))) (defn- encode-uuid [v] - (when (uuid? v) - (str v))) + (if (uuid? v) + (str v) + v)) (register! {:type ::uuid diff --git a/common/src/app/common/types/shape/interactions.cljc b/common/src/app/common/types/shape/interactions.cljc index 111bba5cb..2547f5528 100644 --- a/common/src/app/common/types/shape/interactions.cljc +++ b/common/src/app/common/types/shape/interactions.cljc @@ -109,13 +109,27 @@ (def check-animation! (sm/check-fn schema:animation)) +(def schema:interaction-attrs + [:map {:title "InteractionAttrs"} + [:action-type {:optional true} [::sm/one-of action-types]] + [:event-type {:optional true} [::sm/one-of event-types]] + [:destination {:optional true} [:maybe ::sm/uuid]] + [:preserve-scroll {:optional true} :boolean] + [:animation {:optional true} schema:animation] + [:overlay-position {:optional true} ::gpt/point] + [:overlay-pos-type {:optional true} [::sm/one-of overlay-positioning-types]] + [:close-click-outside {:optional true} :boolean] + [:background-overlay {:optional true} :boolean] + [:position-relative-to {:optional true} [:maybe ::sm/uuid]] + [:url {:optional true} :string]]) + (def schema:navigate-interaction [:map [:action-type [:= :navigate]] [:event-type [::sm/one-of event-types]] [:destination {:optional true} [:maybe ::sm/uuid]] [:preserve-scroll {:optional true} :boolean] - [:animation {:optional true} ::animation]]) + [:animation {:optional true} schema:animation]]) (def schema:open-overlay-interaction [:map @@ -126,7 +140,7 @@ [:destination {:optional true} [:maybe ::sm/uuid]] [:close-click-outside {:optional true} :boolean] [:background-overlay {:optional true} :boolean] - [:animation {:optional true} ::animation] + [:animation {:optional true} schema:animation] [:position-relative-to {:optional true} [:maybe ::sm/uuid]]]) (def schema:toggle-overlay-interaction @@ -138,7 +152,7 @@ [:destination {:optional true} [:maybe ::sm/uuid]] [:close-click-outside {:optional true} :boolean] [:background-overlay {:optional true} :boolean] - [:animation {:optional true} ::animation] + [:animation {:optional true} schema:animation] [:position-relative-to {:optional true} [:maybe ::sm/uuid]]]) (def schema:close-overlay-interaction @@ -146,7 +160,7 @@ [:action-type [:= :close-overlay]] [:event-type [::sm/one-of event-types]] [:destination {:optional true} [:maybe ::sm/uuid]] - [:animation {:optional true} ::animation] + [:animation {:optional true} schema:animation] [:position-relative-to {:optional true} [:maybe ::sm/uuid]]]) (def schema:prev-scren-interaction @@ -161,21 +175,21 @@ [:url :string]]) (def schema:interaction - [:multi {:dispatch :action-type - :title "Interaction" - :gen/gen (sg/one-of (sg/generator schema:navigate-interaction) - (sg/generator schema:open-overlay-interaction) - (sg/generator schema:close-overlay-interaction) - (sg/generator schema:toggle-overlay-interaction) - (sg/generator schema:prev-scren-interaction) - (sg/generator schema:open-url-interaction)) - :decode/json #(update % :action-type keyword)} - [:navigate schema:navigate-interaction] - [:open-overlay schema:open-overlay-interaction] - [:toggle-overlay schema:toggle-overlay-interaction] - [:close-overlay schema:close-overlay-interaction] - [:prev-screen schema:prev-scren-interaction] - [:open-url schema:open-url-interaction]]) + [:and {:title "Interaction" + :gen/gen (sg/one-of (sg/generator schema:navigate-interaction) + (sg/generator schema:open-overlay-interaction) + (sg/generator schema:close-overlay-interaction) + (sg/generator schema:toggle-overlay-interaction) + (sg/generator schema:prev-scren-interaction) + (sg/generator schema:open-url-interaction))} + schema:interaction-attrs + [:multi {:dispatch :action-type} + [:navigate schema:navigate-interaction] + [:open-overlay schema:open-overlay-interaction] + [:toggle-overlay schema:toggle-overlay-interaction] + [:close-overlay schema:close-overlay-interaction] + [:prev-screen schema:prev-scren-interaction] + [:open-url schema:open-url-interaction]]]) (sm/register! ::interaction schema:interaction) From 29cc6b4f9cd17c6dad66882ddca8df8a4e63bdf7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 17:40:34 +0200 Subject: [PATCH 7/9] :sparkles: Print the current seed on test.check fail --- common/src/app/common/schema/test.cljc | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/app/common/schema/test.cljc b/common/src/app/common/schema/test.cljc index 7fa774dd1..c3b38b0a2 100644 --- a/common/src/app/common/schema/test.cljc +++ b/common/src/app/common/schema/test.cljc @@ -60,6 +60,7 @@ (let [smallest (-> params :shrunk :smallest vec)] (println) (println "Condition failed with the following params:") + (println "Seed:" (:seed params)) (println) (pp/pprint smallest))) From 1305ab3cc698ba2958bae3f7c8864aa39eab16ad Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 18:19:34 +0200 Subject: [PATCH 8/9] :bug: Fix issue with empty placeholder on team change --- frontend/src/app/main/ui/dashboard/grid.cljs | 2 ++ .../app/main/ui/dashboard/placeholder.cljs | 31 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index fd5804760..0cfa341b5 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -534,6 +534,7 @@ :create-fn create-fn :origin origin :project-id project-id + :team-id team-id :on-finish-import on-finish-import}])])) (mf/defc line-grid-row @@ -662,4 +663,5 @@ :can-edit can-edit :create-fn create-fn :project-id project-id + :team-id team-id :on-finish-import on-finish-import}])])) diff --git a/frontend/src/app/main/ui/dashboard/placeholder.cljs b/frontend/src/app/main/ui/dashboard/placeholder.cljs index ce6177dac..adfc3b42e 100644 --- a/frontend/src/app/main/ui/dashboard/placeholder.cljs +++ b/frontend/src/app/main/ui/dashboard/placeholder.cljs @@ -8,7 +8,6 @@ (:require-macros [app.main.style :as stl]) (:require [app.main.data.event :as ev] - [app.main.refs :as refs] [app.main.store :as st] [app.main.ui.dashboard.import :as udi] [app.main.ui.ds.product.empty-placeholder :refer [empty-placeholder*]] @@ -16,12 +15,13 @@ [app.main.ui.icons :as i] [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] + [okulary.core :as l] [potok.v2.core :as ptk] [rumext.v2 :as mf])) (mf/defc empty-placeholder-projects* {::mf/wrap-props false} - [{:keys [on-create on-finish-import project-id] :as props}] + [{:keys [on-create on-finish-import project-id]}] (let [file-input (mf/use-ref nil) on-add-library (mf/use-fn (fn [_] @@ -48,17 +48,38 @@ :project-id project-id :on-finish-import on-finish-import}]])) +(defn- make-has-other-files-or-projects-ref + "Return a ref that resolves to true or false if there are at least some + file or some project (a part of the default) exists; this determines + if we need to show a complete placeholder or the small one." + [team-id] + (l/derived (fn [state] + (or (let [projects (get state :projects)] + (some (fn [[_ project]] + (and (= (:team-id project) team-id) + (not (:is-default project)))) + projects)) + (let [files (get state :files)] + (some (fn [[_ file]] + (= (:team-id file) team-id)) + files)))) + st/state)) + (mf/defc empty-placeholder - [{:keys [dragging? limit origin create-fn can-edit project-id on-finish-import]}] + [{:keys [dragging? limit origin create-fn can-edit team-id project-id on-finish-import]}] (let [on-click (mf/use-fn (mf/deps create-fn) (fn [_] (create-fn "dashboard:empty-folder-placeholder"))) + show-text (mf/use-state nil) on-mouse-enter (mf/use-fn #(reset! show-text true)) on-mouse-leave (mf/use-fn #(reset! show-text nil)) - files (mf/deref refs/files)] + + has-other* (mf/with-memo [team-id] + (make-has-other-files-or-projects-ref team-id)) + has-other? (mf/deref has-other*)] (cond (true? dragging?) [:ul @@ -80,7 +101,7 @@ :tag-name "span"}])] :else - (if (= (count files) 0) + (if-not has-other? [:> empty-placeholder-projects* {:on-create on-click :on-finish-import on-finish-import :project-id project-id}] [:div {:class (stl/css :grid-empty-placeholder)} [:button {:class (stl/css :create-new) From 708492afeb2deb9606f323d25263c892d4867976 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 16 Apr 2025 18:30:04 +0200 Subject: [PATCH 9/9] :lipstick: Add mainly cosmetic changes to dashboard placeholder components --- frontend/src/app/main/ui/dashboard/grid.cljs | 12 +-- .../app/main/ui/dashboard/placeholder.cljs | 81 ++++++++++++------- .../src/app/main/ui/dashboard/projects.cljs | 1 + 3 files changed, 60 insertions(+), 34 deletions(-) diff --git a/frontend/src/app/main/ui/dashboard/grid.cljs b/frontend/src/app/main/ui/dashboard/grid.cljs index 0cfa341b5..a8e731ff1 100644 --- a/frontend/src/app/main/ui/dashboard/grid.cljs +++ b/frontend/src/app/main/ui/dashboard/grid.cljs @@ -28,7 +28,7 @@ [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]] + [app.main.ui.dashboard.placeholder :refer [empty-grid-placeholder* loading-placeholder*]] [app.main.ui.ds.product.loader :refer [loader*]] [app.main.ui.hooks :as h] [app.main.ui.icons :as i] @@ -511,7 +511,7 @@ :ref node-ref} (cond (nil? files) - [:& loading-placeholder] + [:> loading-placeholder*] (seq files) (for [[index slice] (d/enumerate (partition-all limit files))] @@ -528,7 +528,7 @@ :can-edit can-edit}])]) :else - [:& empty-placeholder + [:> empty-grid-placeholder* {:limit limit :can-edit can-edit :create-fn create-fn @@ -646,7 +646,7 @@ :on-drop on-drop} (cond (nil? files) - [:& loading-placeholder] + [:> loading-placeholder*] (seq files) [:& line-grid-row {:files files @@ -657,8 +657,8 @@ :limit limit}] :else - [:& empty-placeholder - {:dragging? @dragging? + [:> empty-grid-placeholder* + {:is-dragging @dragging? :limit limit :can-edit can-edit :create-fn create-fn diff --git a/frontend/src/app/main/ui/dashboard/placeholder.cljs b/frontend/src/app/main/ui/dashboard/placeholder.cljs index adfc3b42e..8d6f36956 100644 --- a/frontend/src/app/main/ui/dashboard/placeholder.cljs +++ b/frontend/src/app/main/ui/dashboard/placeholder.cljs @@ -19,30 +19,46 @@ [potok.v2.core :as ptk] [rumext.v2 :as mf])) -(mf/defc empty-placeholder-projects* - {::mf/wrap-props false} +(mf/defc empty-project-placeholder* + {::mf/private true} [{:keys [on-create on-finish-import project-id]}] (let [file-input (mf/use-ref nil) - on-add-library (mf/use-fn - (fn [_] - (st/emit! (ptk/event ::ev/event {::ev/name "explore-libraries-click" - ::ev/origin "dashboard" - :section "empty-placeholder-projects"})) - (dom/open-new-window "https://penpot.app/penpothub/libraries-templates"))) - on-import-files (mf/use-fn #(dom/click (mf/ref-val file-input)))] + + on-add-library + (mf/use-fn + (fn [_] + (st/emit! (ptk/event ::ev/event {::ev/name "explore-libraries-click" + ::ev/origin "dashboard" + :section "empty-placeholder-projects"})) + (dom/open-new-window "https://penpot.app/penpothub/libraries-templates"))) + + on-import + (mf/use-fn #(dom/click (mf/ref-val file-input)))] [:div {:class (stl/css :empty-project-container)} - [:div {:class (stl/css :empty-project-card) :on-click on-create :title (tr "dashboard.add-file")} - [:div {:class (stl/css :empty-project-card-title)} (tr "dashboard.empty-project.create")] - [:div {:class (stl/css :empty-project-card-subtitle)} (tr "dashboard.empty-project.start")]] + [:div {:class (stl/css :empty-project-card) + :on-click on-create + :title (tr "dashboard.add-file")} + [:div {:class (stl/css :empty-project-card-title)} + (tr "dashboard.empty-project.create")] + [:div {:class (stl/css :empty-project-card-subtitle)} + (tr "dashboard.empty-project.start")]] - [:div {:class (stl/css :empty-project-card) :on-click on-import-files :title (tr "dashboard.empty-project.import")} - [:div {:class (stl/css :empty-project-card-title)} (tr "dashboard.empty-project.import")] - [:div {:class (stl/css :empty-project-card-subtitle)} (tr "dashboard.empty-project.import-penpot")]] + [:div {:class (stl/css :empty-project-card) + :on-click on-import + :title (tr "dashboard.empty-project.import")} + [:div {:class (stl/css :empty-project-card-title)} + (tr "dashboard.empty-project.import")] + [:div {:class (stl/css :empty-project-card-subtitle)} + (tr "dashboard.empty-project.import-penpot")]] - [:div {:class (stl/css :empty-project-card) :on-click on-add-library :title (tr "dashboard.empty-project.go-to-libraries")} - [:div {:class (stl/css :empty-project-card-title)} (tr "dashboard.empty-project.add-library")] - [:div {:class (stl/css :empty-project-card-subtitle)} (tr "dashboard.empty-project.explore")]] + [:div {:class (stl/css :empty-project-card) + :on-click on-add-library + :title (tr "dashboard.empty-project.go-to-libraries")} + [:div {:class (stl/css :empty-project-card-title)} + (tr "dashboard.empty-project.add-library")] + [:div {:class (stl/css :empty-project-card-subtitle)} + (tr "dashboard.empty-project.explore")]] [:& udi/import-form {:ref file-input :project-id project-id @@ -65,23 +81,26 @@ files)))) st/state)) -(mf/defc empty-placeholder - [{:keys [dragging? limit origin create-fn can-edit team-id project-id on-finish-import]}] +(mf/defc empty-grid-placeholder* + [{:keys [is-dragging limit origin create-fn can-edit team-id project-id on-finish-import]}] (let [on-click (mf/use-fn (mf/deps create-fn) (fn [_] (create-fn "dashboard:empty-folder-placeholder"))) - show-text (mf/use-state nil) - on-mouse-enter (mf/use-fn #(reset! show-text true)) - on-mouse-leave (mf/use-fn #(reset! show-text nil)) + show-text* (mf/use-state nil) + show-text? (deref show-text*) + + on-mouse-enter (mf/use-fn #(reset! show-text* true)) + on-mouse-leave (mf/use-fn #(reset! show-text* nil)) has-other* (mf/with-memo [team-id] (make-has-other-files-or-projects-ref team-id)) has-other? (mf/deref has-other*)] + (cond - (true? dragging?) + (true? is-dragging) [:ul {:class (stl/css :grid-row :no-wrap) :style {:grid-template-columns (str "repeat(" limit ", 1fr)")}} @@ -102,17 +121,23 @@ :else (if-not has-other? - [:> empty-placeholder-projects* {:on-create on-click :on-finish-import on-finish-import :project-id project-id}] + [:> empty-project-placeholder* + {:on-create on-click + :on-finish-import on-finish-import + :project-id project-id}] [:div {:class (stl/css :grid-empty-placeholder)} [:button {:class (stl/css :create-new) :on-click on-click :on-mouse-enter on-mouse-enter :on-mouse-leave on-mouse-leave} - (if @show-text (tr "dashboard.empty-project.create") i/add)]])))) + (if show-text? + (tr "dashboard.empty-project.create") + i/add)]])))) -(mf/defc loading-placeholder +(mf/defc loading-placeholder* [] [:> loader* {:width 32 :title (tr "labels.loading") :class (stl/css :placeholder-loader)} - [:span {:class (stl/css :placeholder-text)} (tr "dashboard.loading-files")]]) + [:span {:class (stl/css :placeholder-text)} + (tr "dashboard.loading-files")]]) diff --git a/frontend/src/app/main/ui/dashboard/projects.cljs b/frontend/src/app/main/ui/dashboard/projects.cljs index 3aaa590f8..cf013de2a 100644 --- a/frontend/src/app/main/ui/dashboard/projects.cljs +++ b/frontend/src/app/main/ui/dashboard/projects.cljs @@ -371,6 +371,7 @@ show-team-hero? can-invite))} (for [{:keys [id] :as project} projects] + ;; FIXME: refactor this, looks inneficient (let [files (when recent-map (->> (vals recent-map) (filterv #(= id (:project-id %)))