From 2a81d8563a13cd47ad5392aac586d9a18de0c033 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 23 Jun 2023 10:49:25 +0200 Subject: [PATCH 1/8] :bug: Fix thumbnails handling on dashboard libraries --- CHANGES.md | 5 +++ backend/src/app/rpc/commands/files.clj | 10 ++++- .../src/app/main/ui/dashboard/libraries.cljs | 41 ++++++++++--------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 6f5187321..7206595e3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,19 +5,24 @@ ### :boom: Breaking changes & Deprecations ### :sparkles: New features + - Default naming of text layers [Taiga #2836](https://tree.taiga.io/project/penpot/us/2836) - Create typography style from a selected text layer[Taiga #3041](https://tree.taiga.io/project/penpot/us/3041) - Board as ruler origin [Taiga #4833](https://tree.taiga.io/project/penpot/us/4833) - Access tokens support [Taiga #4460](https://tree.taiga.io/project/penpot/us/4460) - Show interactions setting at the view mode [Taiga #1330](https://tree.taiga.io/project/penpot/issue/1330) +- Improve dashboard performance related to thumbnails; now the thumbnails are + rendered as bitmap images. ### :bug: Bugs fixed + - Fix files can be opened from multiple urls [Taiga #5310](https://tree.taiga.io/project/penpot/issue/5310) - Fix asset color item was created from the selected layer [Taiga #5180](https://tree.taiga.io/project/penpot/issue/5180) ### :arrow_up: Deps updates ### :heart: Community contributions by (Thank you!) + - Update Typography palette order (by @akshay-gupta7) [Github #3156](https://github.com/penpot/penpot/pull/3156) - Palettes (color, typographies) empty state (by @akshay-gupta7) [Github #3160](https://github.com/penpot/penpot/pull/3160) - Duplicate objects via drag + alt (by @akshay-gupta7) [Github #3147](https://github.com/penpot/penpot/pull/3147) diff --git a/backend/src/app/rpc/commands/files.clj b/backend/src/app/rpc/commands/files.clj index ff24bed62..2bcf8ddf0 100644 --- a/backend/src/app/rpc/commands/files.clj +++ b/backend/src/app/rpc/commands/files.clj @@ -549,9 +549,11 @@ f.created_at, f.modified_at, f.name, - f.is_shared + f.is_shared, + ft.media_id from file as f inner join project as p on (p.id = f.project_id) + left join file_thumbnail as ft on (ft.file_id = f.id and ft.revn = f.revn) where f.is_shared = true and f.deleted_at is null and p.deleted_at is null @@ -582,6 +584,12 @@ (->> (db/exec! conn [sql:team-shared-files team-id]) (into #{} (comp (map decode-row) + (map (fn [row] + (if-let [media-id (:media-id row)] + (-> row + (dissoc :media-id) + (assoc :thumbnail-uri (resolve-public-uri media-id))) + (dissoc row :media-id)))) (map #(assoc % :library-summary (library-summary %))) (map #(dissoc % :data))))))) diff --git a/frontend/src/app/main/ui/dashboard/libraries.cljs b/frontend/src/app/main/ui/dashboard/libraries.cljs index cb49dfa58..4353011a1 100644 --- a/frontend/src/app/main/ui/dashboard/libraries.cljs +++ b/frontend/src/app/main/ui/dashboard/libraries.cljs @@ -23,38 +23,39 @@ [{:keys [team] :as props}] (let [files-map (mf/deref refs/dashboard-shared-files) projects (mf/deref refs/dashboard-projects) + default-project (->> projects vals (d/seek :is-default)) - files (if (nil? files-map) - nil - (->> (vals files-map) - (sort-by :modified-at) - (reverse))) + + files (mf/with-memo [files-map] + (if (nil? files-map) + nil + (->> (vals files-map) + (sort-by :modified-at) + (reverse)))) components-v2 (features/use-feature :components-v2) width (mf/use-state nil) rowref (mf/use-ref) - itemsize (if (>= @width 1030) - 280 - 230) + + itemsize (if (>= @width 1030) 280 230) ratio (if (some? @width) (/ @width itemsize) 0) nitems (mth/floor ratio) limit (min 10 nitems) limit (max 1 limit)] - (mf/use-effect - (mf/deps team) - (fn [] - (when team - (let [tname (if (:is-default team) - (tr "dashboard.your-penpot") - (:name team))] - (dom/set-html-title (tr "title.dashboard.shared-libraries" tname)))))) - (mf/use-effect - #(st/emit! (dd/fetch-shared-files) + (mf/with-effect [team] + (when team + (let [tname (if (:is-default team) + (tr "dashboard.your-penpot") + (:name team))] + (dom/set-html-title (tr "title.dashboard.shared-libraries" tname))))) + + (mf/with-effect [] + (st/emit! (dd/fetch-shared-files) (dd/clear-selected-files))) - (mf/with-effect + (mf/with-effect [] (let [node (mf/ref-val rowref) mnt? (volatile! true) sub (->> (wapi/observe-resize node) @@ -73,7 +74,7 @@ [:header.dashboard-header {:ref rowref} [:div.dashboard-title#dashboard-libraries-title [:h1 (tr "dashboard.libraries-title")]]] - [:section.dashboard-container.no-bg.dashboard-shared + [:section.dashboard-container.no-bg.dashboard-shared [:& grid {:files files :project default-project :origin :libraries From 7feda98eb31b865455a7cdd874760d2fb762dfcc Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 23 Jun 2023 12:22:33 +0200 Subject: [PATCH 2/8] :sparkles: Add the ability to disable the google fonts provider --- CHANGES.md | 3 ++- frontend/src/app/config.cljs | 3 ++- frontend/src/app/main/fonts.cljs | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 7206595e3..f0a812b24 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,6 @@ # CHANGELOG -## :rocket: 1.19.0 +## 1.19.0 ### :boom: Breaking changes & Deprecations @@ -13,6 +13,7 @@ - Show interactions setting at the view mode [Taiga #1330](https://tree.taiga.io/project/penpot/issue/1330) - Improve dashboard performance related to thumbnails; now the thumbnails are rendered as bitmap images. +- Add the ability to disable google fonts provider with the `disable-google-fonts-provider` flag ### :bug: Bugs fixed diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index 70a7e23d3..4e3bda7ce 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -59,7 +59,8 @@ :webworker)) (def default-flags - [:enable-newsletter-subscription]) + [:enable-newsletter-subscription + :enable-google-fonts-provider]) (defn- parse-flags [global] diff --git a/frontend/src/app/main/fonts.cljs b/frontend/src/app/main/fonts.cljs index 96091475c..b04190463 100644 --- a/frontend/src/app/main/fonts.cljs +++ b/frontend/src/app/main/fonts.cljs @@ -65,7 +65,9 @@ (merge db (d/index-by :id fonts)))))) (register! :builtin local-fonts) -(register! :google google-fonts) + +(when (contains? cf/flags :google-fonts-provider) + (register! :google google-fonts)) (defn get-font-data [id] (get @fontsdb id)) From ca1e6c342f1367c156352b29112837b4d76dd8ee Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 23 Jun 2023 12:55:49 +0200 Subject: [PATCH 3/8] :bug: Fix problem with scroll in viewer mode --- frontend/src/app/main/ui/viewer.cljs | 35 +++++++++++++++------------- frontend/src/app/util/dom.cljs | 2 +- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/frontend/src/app/main/ui/viewer.cljs b/frontend/src/app/main/ui/viewer.cljs index d33d9efd8..a9823e025 100644 --- a/frontend/src/app/main/ui/viewer.cljs +++ b/frontend/src/app/main/ui/viewer.cljs @@ -313,22 +313,25 @@ (mf/use-fn (fn [event] (let [event (.getBrowserEvent ^js event) - norm-event ^js (nw/normalize-wheel event) - mod? (kbd/mod? event) - shift? (kbd/shift? event) - delta (.-pixelY norm-event) - viewer-section (.target event) - scroll-pos (if shift? - (dom/get-h-scroll-pos viewer-section) - (dom/get-scroll-pos viewer-section)) - new-scroll-pos (+ scroll-pos delta)] - (when-not mod? - (do - (dom/prevent-default event) - (dom/stop-propagation event) - (if shift? - (dom/set-h-scroll-pos! viewer-section new-scroll-pos) - (dom/set-scroll-pos! viewer-section new-scroll-pos))))))) + wrapper (dom/get-element-by-class "inspect-svg-wrapper") + section (dom/get-element-by-class "inspect-svg-container") + target (.-target event)] + (when (or (dom/child? target wrapper) (dom/class? target "inspect-svg-container")) + (let [norm-event ^js (nw/normalize-wheel event) + mod? (kbd/mod? event) + shift? (kbd/shift? event) + delta (.-pixelY norm-event) + scroll-pos (if shift? + (dom/get-h-scroll-pos section) + (dom/get-scroll-pos section)) + new-scroll-pos (+ scroll-pos delta)] + (when-not mod? + (do + (dom/prevent-default event) + (dom/stop-propagation event) + (if shift? + (dom/set-h-scroll-pos! section new-scroll-pos) + (dom/set-scroll-pos! section new-scroll-pos))))))))) on-exit-fullscreen (mf/use-callback diff --git a/frontend/src/app/util/dom.cljs b/frontend/src/app/util/dom.cljs index b78227180..b07888181 100644 --- a/frontend/src/app/util/dom.cljs +++ b/frontend/src/app/util/dom.cljs @@ -493,7 +493,7 @@ (.remove ^js class-list class-name)))) (defn child? [^js node1 ^js node2] - (when (some? node1) + (when (and (some? node1) (some? node2)) (.contains ^js node2 ^js node1))) (defn get-user-agent [] From 81658c90d111281e4f944d1c80165d3d4a5374fa Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 23 Jun 2023 12:33:34 +0200 Subject: [PATCH 4/8] :sparkles: Add the ability to disable dashboard templates section --- CHANGES.md | 1 + frontend/src/app/config.cljs | 1 + frontend/src/app/main/ui/dashboard.cljs | 24 +++++++++++-------- .../src/app/main/ui/dashboard/projects.cljs | 7 ++++-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f0a812b24..9b9b326f1 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -14,6 +14,7 @@ - Improve dashboard performance related to thumbnails; now the thumbnails are rendered as bitmap images. - Add the ability to disable google fonts provider with the `disable-google-fonts-provider` flag +- Add the ability to disable dashboard templates section with the `disable-dashboard-templates-section` flag ### :bug: Bugs fixed diff --git a/frontend/src/app/config.cljs b/frontend/src/app/config.cljs index 4e3bda7ce..704ac51b8 100644 --- a/frontend/src/app/config.cljs +++ b/frontend/src/app/config.cljs @@ -60,6 +60,7 @@ (def default-flags [:enable-newsletter-subscription + :enable-dashboard-templates-section :enable-google-fonts-provider]) (defn- parse-flags diff --git a/frontend/src/app/main/ui/dashboard.cljs b/frontend/src/app/main/ui/dashboard.cljs index 881928a88..5df57f660 100644 --- a/frontend/src/app/main/ui/dashboard.cljs +++ b/frontend/src/app/main/ui/dashboard.cljs @@ -9,6 +9,7 @@ [app.common.data :as d] [app.common.math :as mth] [app.common.spec :as us] + [app.config :as cf] [app.main.data.dashboard :as dd] [app.main.data.dashboard.shortcuts :as sc] [app.main.data.events :as ev] @@ -259,11 +260,13 @@ :projects projects :profile profile :default-project-id default-project-id}] - [:& templates-section {:profile profile - :project project - :default-project-id default-project-id - :team team - :content-width @content-width}]] + + (when (contains? cf/flags :dashboard-templates-section) + [:& templates-section {:profile profile + :project project + :default-project-id default-project-id + :team team + :content-width @content-width}])] :dashboard-fonts [:& fonts-page {:team team}] @@ -275,11 +278,12 @@ (when project [:* [:& files-section {:team team :project project}] - [:& templates-section {:profile profile - :project project - :default-project-id default-project-id - :team team - :content-width @content-width}]]) + (when (contains? cf/flags :dashboard-templates-section) + [:& templates-section {:profile profile + :project project + :default-project-id default-project-id + :team team + :content-width @content-width}])]) :dashboard-search [:& search-page {:team team diff --git a/frontend/src/app/main/ui/dashboard/projects.cljs b/frontend/src/app/main/ui/dashboard/projects.cljs index 95a9648db..eca9a2342 100644 --- a/frontend/src/app/main/ui/dashboard/projects.cljs +++ b/frontend/src/app/main/ui/dashboard/projects.cljs @@ -9,6 +9,7 @@ [app.common.data :as d] [app.common.geom.point :as gpt] [app.common.math :as mth] + [app.config :as cf] [app.main.data.dashboard :as dd] [app.main.data.events :as ev] [app.main.data.messages :as msg] @@ -195,7 +196,7 @@ on-menu-click (mf/use-fn (fn [event] - (dom/prevent-default event) + (dom/prevent-default event) (let [client-position (dom/get-client-position event) position (if (and (nil? (:y client-position)) (nil? (:x client-position))) @@ -414,7 +415,9 @@ (when team-hero? [:& team-hero {:team team :close-fn close-banner}]) - (when (or (not tutorial-viewed?) (not walkthrough-viewed?)) + (when (and (contains? cf/flags :dashboard-templates-section) + (or (not tutorial-viewed?) + (not walkthrough-viewed?))) [:div.hero-projects (when (and (not tutorial-viewed?) (:is-default team)) [:& tutorial-project From b138550c0d2306b2af84df82d2e631a5d13038ab Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Fri, 23 Jun 2023 12:59:03 +0200 Subject: [PATCH 5/8] :bug: Fix issue on awsns http handler --- backend/src/app/http/awsns.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/app/http/awsns.clj b/backend/src/app/http/awsns.clj index a761ad8d9..681e7045f 100644 --- a/backend/src/app/http/awsns.clj +++ b/backend/src/app/http/awsns.clj @@ -36,10 +36,10 @@ (defmethod ig/init-key ::routes [_ {:keys [::wrk/executor] :as cfg}] - (letfn [(handler [request respond _] + (letfn [(handler [request] (let [data (-> request yrq/body slurp)] (px/run! executor #(handle-request cfg data))) - (respond {::yrs/status 200}))] + {::yrs/status 200})] ["/sns" {:handler handler :allowed-methods #{:post}}])) From c988d5492539334375779ec800649e9754d452b1 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 23 Jun 2023 08:56:27 +0200 Subject: [PATCH 6/8] :bug: Fix hide rulers option not working --- frontend/src/app/main/ui/workspace/header.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/header.cljs b/frontend/src/app/main/ui/workspace/header.cljs index 918238947..ecb76d821 100644 --- a/frontend/src/app/main/ui/workspace/header.cljs +++ b/frontend/src/app/main/ui/workspace/header.cljs @@ -465,8 +465,8 @@ toggle-flag (mf/use-fn (fn [event] - (let [flag (-> (dom/get-target event) - (dom/get-data :flag) + (let [flag (-> (dom/get-current-target event) + (dom/get-data "flag") (keyword))] (st/emit! (-> (dw/toggle-layout-flag flag) From a8e058ada6a037bc21ae27bca17aa14eaf994183 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 23 Jun 2023 11:08:39 +0200 Subject: [PATCH 7/8] :bug: Fix add asset color, invalid color appears --- frontend/src/app/main/data/workspace/colors.cljs | 5 ++--- frontend/src/app/main/ui/workspace/sidebar/assets.cljs | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/main/data/workspace/colors.cljs b/frontend/src/app/main/data/workspace/colors.cljs index baee0e0a2..0d460babb 100644 --- a/frontend/src/app/main/data/workspace/colors.cljs +++ b/frontend/src/app/main/data/workspace/colors.cljs @@ -21,7 +21,6 @@ [app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.texts :as dwt] [app.main.data.workspace.undo :as dwu] - [app.main.store :as st] [app.util.color :as uc] [beicon.core :as rx] [potok.core :as ptk])) @@ -610,7 +609,7 @@ (materialize-color-components))])))))))))) (defn select-color - [position] + [position add-color] (ptk/reify ::select-color ptk/WatchEvent (watch [_ state _] @@ -635,7 +634,7 @@ (rx/of (md/show :colorpicker {:x (:x position) :y (:y position) - :on-accept #(st/emit! (dwl/add-color data)) + :on-accept add-color :data data :position :right}) (ptk/event ::ev/event {::ev/name "add-asset-to-library" diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index c2f26810f..84adf880a 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -1546,11 +1546,16 @@ read-only? (mf/use-ctx ctx/workspace-read-only?) + add-color + (mf/use-fn + (fn [value _] + (st/emit! (dwl/add-color value)))) + add-color-clicked (mf/use-fn (fn [event] (let [position (dom/get-client-position event)] - (st/emit! (dc/select-color position))))) + (st/emit! (dc/select-color position add-color))))) create-group (mf/use-fn From f75b1115648b1a4e548c9c99bea3cf7aa0ba0dd9 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 23 Jun 2023 12:48:09 +0200 Subject: [PATCH 8/8] :bug: Fix impossible to add group to typographies --- frontend/src/app/main/ui/workspace/sidebar/assets.cljs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index 84adf880a..593f3b950 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -1893,7 +1893,7 @@ create-group (mf/use-fn - (mf/deps typographies selected on-clear-selection file-id) + (mf/deps typographies selected on-clear-selection file-id (:id @state)) (fn [group-name] (on-clear-selection) (let [undo-id (js/Symbol)] @@ -1927,7 +1927,7 @@ on-group (mf/use-fn - (mf/deps typographies selected) + (mf/deps typographies selected create-group) (fn [event] (dom/stop-propagation event) (modal/show! :name-group-dialog {:accept create-group})))