From d4b4e6be7d0d326c55b32de158aa0d22ecb0c1df Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 09:31:53 +0200 Subject: [PATCH 01/14] :bug: Fix frontend cljs linter issues --- frontend/src/app/worker/import.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/worker/import.cljs b/frontend/src/app/worker/import.cljs index 2e533d894..3fcfe2c68 100644 --- a/frontend/src/app/worker/import.cljs +++ b/frontend/src/app/worker/import.cljs @@ -86,7 +86,7 @@ (progress! context type file nil nil)) ([context type current total] - (keyword? type) + (assert (keyword? type)) (assert (number? current)) (assert (number? total)) (progress! context type nil current total)) From da3c829b1b23e708c299a9df15bc52ea5bcd432a Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 10:36:20 +0200 Subject: [PATCH 02/14] :paperclip: Fix clj linter issues on backend --- backend/src/app/rpc/commands/binfile.clj | 4 ++-- backend/src/app/srepl/helpers.clj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index 632239f2b..bbcca6b88 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -382,8 +382,8 @@ ;; --- GENERAL PURPOSE DYNAMIC VARS -(def ^:dynamic *state*) -(def ^:dynamic *options*) +(def ^:dynamic *state* nil) +(def ^:dynamic *options* nil) ;; --- EXPORT WRITER diff --git a/backend/src/app/srepl/helpers.clj b/backend/src/app/srepl/helpers.clj index ca0982676..d1b893e10 100644 --- a/backend/src/app/srepl/helpers.clj +++ b/backend/src/app/srepl/helpers.clj @@ -33,7 +33,7 @@ [cuerdas.core :as str] [expound.alpha :as expound])) -(def ^:dynamic *conn*) +(def ^:dynamic *conn* nil) (defn reset-password! "Reset a password to a specific one for a concrete user or all users From 50932dea549200ad23d32571baa00272caf7fb3b Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 31 Aug 2023 09:58:04 +0200 Subject: [PATCH 03/14] :bug: Fix list view is discarded on tab change for assets sidebar --- CHANGES.md | 6 ++++ .../src/app/main/data/workspace/assets.cljs | 28 +++++++++++++++++++ .../app/main/ui/workspace/sidebar/assets.cljs | 22 ++++++++++++--- version.txt | 2 +- 4 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 frontend/src/app/main/data/workspace/assets.cljs diff --git a/CHANGES.md b/CHANGES.md index 8529b03ec..f2f50ec2f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # CHANGELOG +## 1.19.3 + +### :bug: Bugs fixed + +- List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547) + ## 1.19.2 ### :sparkles: New features diff --git a/frontend/src/app/main/data/workspace/assets.cljs b/frontend/src/app/main/data/workspace/assets.cljs new file mode 100644 index 000000000..7db9cc1ce --- /dev/null +++ b/frontend/src/app/main/data/workspace/assets.cljs @@ -0,0 +1,28 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) KALEIDOS INC + +(ns app.main.data.workspace.assets + "Workspace assets management events and helpers." + (:require + [app.util.storage :refer [storage]])) + +(defn get-current-assets-ordering + [] + (let [ordering (::ordering @storage)] + (or ordering :asc))) + +(defn set-current-assets-ordering! + [ordering] + (swap! storage assoc ::ordering ordering)) + +(defn get-current-assets-list-style + [] + (let [list-style (::list-style @storage)] + (or list-style :thumbs))) + +(defn set-current-assets-list-style! + [list-style] + (swap! storage assoc ::list-style list-style)) diff --git a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs index b352b755e..5a5f381e6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/assets.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/assets.cljs @@ -16,6 +16,7 @@ [app.main.data.events :as ev] [app.main.data.modal :as modal] [app.main.data.workspace :as dw] + [app.main.data.workspace.assets :as dwa] [app.main.data.workspace.colors :as dc] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.media :as dwm] @@ -2424,19 +2425,32 @@ [] (let [components-v2 (mf/use-ctx ctx/components-v2) read-only? (mf/use-ctx ctx/workspace-read-only?) + filters* (mf/use-state {:term "" :section :all - :ordering :asc - :list-style :thumbs}) + :ordering (dwa/get-current-assets-ordering) + :list-style (dwa/get-current-assets-list-style)}) filters (deref filters*) term (:term filters) + ordering (:ordering filters) + list-style (:list-style filters) toggle-ordering - (mf/use-fn #(swap! filters* update :ordering toggle-values [:asc :desc])) + (mf/use-fn + (mf/deps ordering) + (fn [] + (let [new-value (toggle-values ordering [:asc :desc])] + (swap! filters* assoc :ordering new-value) + (dwa/set-current-assets-ordering! new-value)))) toggle-list-style - (mf/use-fn #(swap! filters* update :list-style toggle-values [:thumbs :list])) + (mf/use-fn + (mf/deps list-style) + (fn [] + (let [new-value (toggle-values list-style [:thumbs :list])] + (swap! filters* assoc :list-style new-value) + (dwa/set-current-assets-list-style! new-value)))) on-search-term-change (mf/use-fn diff --git a/version.txt b/version.txt index 836ae4eda..1b92e588b 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.19.2 +1.19.3 From 09e28076cd6b767e901d7bbbc586509dd4670db2 Mon Sep 17 00:00:00 2001 From: Eva Date: Thu, 31 Aug 2023 10:22:03 +0200 Subject: [PATCH 04/14] :bug: Fix lock and hide tooltip --- .../src/app/main/ui/workspace/sidebar/layer_item.cljs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs index 6fc02c876..25bb03405 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/layer_item.cljs @@ -336,10 +336,16 @@ [:div.element-actions {:class (when (:shapes item) "is-parent")} [:div.toggle-element {:class (when (:hidden item) "selected") + :title (if (:hidden item) + (tr "workspace.shape.menu.show") + (tr "workspace.shape.menu.hide")) :on-click toggle-visibility} (if (:hidden item) i/eye-closed i/eye)] [:div.block-element {:class (when (:blocked item) "selected") - :on-click toggle-blocking} + :on-click toggle-blocking + :title (if (:blocked item) + (tr "workspace.shape.menu.unlock") + (tr "workspace.shape.menu.lock"))} (if (:blocked item) i/lock i/unlock)]] (when (:shapes item) From 288030888a812efbfe152c8a3a443b04b0999c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 31 Aug 2023 09:49:46 +0200 Subject: [PATCH 05/14] :bug: Fix message popup remains open when exiting workspace --- CHANGES.md | 1 + frontend/src/app/main/ui/workspace.cljs | 5 +++++ frontend/src/app/main/ui/workspace/header.cljs | 11 +---------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f2f50ec2f..95336fb7d 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ ### :bug: Bugs fixed - List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547) +- Fix message popup remains open when exiting workspace with browser back button [Taiga #5747](https://tree.taiga.io/project/penpot/issue/5747) ## 1.19.2 diff --git a/frontend/src/app/main/ui/workspace.cljs b/frontend/src/app/main/ui/workspace.cljs index 090fd7f75..a2a278d5e 100644 --- a/frontend/src/app/main/ui/workspace.cljs +++ b/frontend/src/app/main/ui/workspace.cljs @@ -8,8 +8,10 @@ (:require-macros [app.main.style :refer [css]]) (:require [app.common.data.macros :as dm] + [app.main.data.messages :as msg] [app.main.data.modal :as modal] [app.main.data.workspace :as dw] + [app.main.data.workspace.colors :as dc] [app.main.data.workspace.persistence :as dwp] [app.main.features :as features] [app.main.refs :as refs] @@ -185,6 +187,9 @@ (st/emit! (dw/initialize-file project-id file-id)) (fn [] (st/emit! ::dwp/force-persist + (dc/stop-picker) + (modal/hide) + msg/hide (dw/finalize-file project-id file-id)))) [:& (mf/provider ctx/current-file-id) {:value file-id} diff --git a/frontend/src/app/main/ui/workspace/header.cljs b/frontend/src/app/main/ui/workspace/header.cljs index ecb76d821..81f03930d 100644 --- a/frontend/src/app/main/ui/workspace/header.cljs +++ b/frontend/src/app/main/ui/workspace/header.cljs @@ -13,7 +13,6 @@ [app.main.data.exports :as de] [app.main.data.modal :as modal] [app.main.data.workspace :as dw] - [app.main.data.workspace.colors :as dc] [app.main.data.workspace.common :as dwc] [app.main.data.workspace.libraries :as dwl] [app.main.data.workspace.shortcuts :as sc] @@ -162,9 +161,7 @@ (st/emit! (ptk/event ::ev/event {::ev/name "show-release-notes" :version version})) (if (and (kbd/alt? event) (kbd/mod? event)) (st/emit! (modal/show {:type :onboarding})) - (st/emit! (modal/show {:type :release-notes :version version})))))) - - ] + (st/emit! (modal/show {:type :release-notes :version version}))))))] [:& dropdown {:show true :on-close on-close} [:ul.sub-menu.help-info @@ -582,16 +579,10 @@ (dom/prevent-default event) (reset! editing* true))) - close-modals - (mf/use-fn - #(st/emit! (dc/stop-picker) - (modal/hide))) - go-back (mf/use-fn (mf/deps project) (fn [] - (close-modals) (st/emit! (dw/go-to-dashboard project)))) nav-to-viewer From bd3ddebcc452bbeae159e16dc477045651eda069 Mon Sep 17 00:00:00 2001 From: Aitor Date: Wed, 30 Aug 2023 13:09:08 +0200 Subject: [PATCH 06/14] :bug: Fix text shapes rendered with bad proportions --- CHANGES.md | 1 + .../shapes/text/viewport_texts_html.cljs | 41 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 95336fb7d..626be878b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ - List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547) - Fix message popup remains open when exiting workspace with browser back button [Taiga #5747](https://tree.taiga.io/project/penpot/issue/5747) +- When editing text if font is changed, the proportions of the rendered shape are wrong [Taiga #5786](https://tree.taiga.io/project/penpot/issue/5786) ## 1.19.2 diff --git a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs index a6633ccd7..65804663b 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs @@ -26,6 +26,7 @@ [app.util.object :as obj] [app.util.text-editor :as ted] [app.util.text-svg-position :as tsp] + [app.util.timers :as ts] [promesa.core :as p] [rumext.v2 :as mf])) @@ -79,25 +80,29 @@ (defn- update-text-modifier [{:keys [grow-type id] :as shape} node] + (->> (tsp/calc-position-data id) + (p/fmap (fn [position-data] + (let [props {:position-data position-data}] + (if (contains? #{:auto-height :auto-width} grow-type) + (let [{:keys [width height]} (-> (dom/query node ".paragraph-set") (dom/get-client-size)) + width (mth/ceil width) + height (mth/ceil height)] + (if (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height))) + (cond-> props + (= grow-type :auto-width) + (assoc :width width) - (p/let [position-data (tsp/calc-position-data id) - props {:position-data position-data} - - props - (if (contains? #{:auto-height :auto-width} grow-type) - (let [{:keys [width height]} (-> (dom/query node ".paragraph-set") (dom/get-client-size)) - width (mth/ceil width) - height (mth/ceil height)] - (if (and (not (mth/almost-zero? width)) (not (mth/almost-zero? height))) - (cond-> props - (= grow-type :auto-width) - (assoc :width width) - - (or (= grow-type :auto-height) (= grow-type :auto-width)) - (assoc :height height)) - props)) - props)] - (st/emit! (dwt/update-text-modifier id props)))) + (or (= grow-type :auto-height) (= grow-type :auto-width)) + (assoc :height height)) + props)) + props)))) + (p/fmap (fn [props] + ;; We need to wait for the text modifier to be updated before + ;; we can update the position data. Otherwise the position data + ;; will be wrong. + ;; TODO: This is a hack. We need to find a better way to do this. + (st/emit! (dwt/update-text-modifier id props)) + (ts/schedule 30 #(update-text-shape shape node)))))) (mf/defc text-container {::mf/wrap-props false From a0973b9ddf2573f4af331bd2f872e450fb9244fe Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 14:36:31 +0200 Subject: [PATCH 07/14] :sparkles: Improve storage-gc-deleted task reliability --- backend/src/app/storage.clj | 82 +++++++++++---------- backend/test/backend_tests/storage_test.clj | 11 ++- 2 files changed, 52 insertions(+), 41 deletions(-) diff --git a/backend/src/app/storage.clj b/backend/src/app/storage.clj index 20cc8efe6..be0159e0f 100644 --- a/backend/src/app/storage.clj +++ b/backend/src/app/storage.clj @@ -251,53 +251,59 @@ (defmethod ig/init-key ::gc-deleted-task [_ {:keys [::db/pool ::storage ::min-age]}] - (letfn [(retrieve-deleted-objects-chunk [conn min-age cursor] - (let [min-age (db/interval min-age) - rows (db/exec! conn [sql:retrieve-deleted-objects-chunk min-age cursor])] - [(some-> rows peek :created-at) + (letfn [(get-to-delete-chunk [cursor] + (let [sql (str "select s.* " + " from storage_object as s " + " where s.deleted_at is not null " + " and s.deleted_at < ? " + " order by s.deleted_at desc " + " limit 25") + rows (db/exec! pool [sql cursor])] + [(some-> rows peek :deleted-at) (some->> (seq rows) (d/group-by #(-> % :backend keyword) :id #{}) seq)])) - (retrieve-deleted-objects [conn min-age] - (d/iteration (partial retrieve-deleted-objects-chunk conn min-age) - :initk (dt/now) + (get-to-delete-chunks [min-age] + (d/iteration get-to-delete-chunk + :initk (dt/minus (dt/now) min-age) :vf second :kf first)) - (delete-in-bulk [backend-id ids] - (let [backend (impl/resolve-backend storage backend-id)] + (delete-in-bulk! [backend-id ids] + (try + (db/with-atomic [conn pool] + (let [sql "delete from storage_object where id = ANY(?)" + ids' (db/create-array conn "uuid" ids) - (doseq [id ids] - (l/debug :hint "gc-deleted: permanently delete storage object" :backend backend-id :id id)) + total (-> (db/exec-one! conn [sql ids']) + (db/get-update-count))] - (impl/del-objects-in-bulk backend ids)))] + (-> (impl/resolve-backend storage backend-id) + (impl/del-objects-in-bulk ids)) + + (doseq [id ids] + (l/dbg :hint "gc-deleted: permanently delete storage object" :backend backend-id :id id)) + + total)) + + (catch Throwable cause + (l/err :hint "gc-deleted: unexpected error on bulk deletion" + :ids (vec ids) + :cause cause) + 0)))] (fn [params] - (let [min-age (or (:min-age params) min-age)] - (db/with-atomic [conn pool] - (loop [total 0 - groups (retrieve-deleted-objects conn min-age)] - (if-let [[backend-id ids] (first groups)] - (do - (delete-in-bulk backend-id ids) - (recur (+ total (count ids)) - (rest groups))) - (do - (l/info :hint "gc-deleted: task finished" :min-age (dt/format-duration min-age) :total total) - {:deleted total})))))))) - -(def sql:retrieve-deleted-objects-chunk - "with items_part as ( - select s.id - from storage_object as s - where s.deleted_at is not null - and s.deleted_at < (now() - ?::interval) - and s.created_at < ? - order by s.created_at desc - limit 25 - ) - delete from storage_object - where id in (select id from items_part) - returning *;") + (let [min-age (or (some-> params :min-age dt/duration) min-age)] + (loop [total 0 + chunks (get-to-delete-chunks min-age)] + (if-let [[backend-id ids] (first chunks)] + (let [deleted (delete-in-bulk! backend-id ids)] + (recur (+ total deleted) + (rest chunks))) + (do + (l/inf :hint "gc-deleted: task finished" + :min-age (dt/format-duration min-age) + :total total) + {:deleted total}))))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Garbage Collection: Analyze touched objects diff --git a/backend/test/backend_tests/storage_test.clj b/backend/test/backend_tests/storage_test.clj index b0a60c718..ee6045d30 100644 --- a/backend/test/backend_tests/storage_test.clj +++ b/backend/test/backend_tests/storage_test.clj @@ -100,6 +100,7 @@ (configure-storage-backend)) content1 (sto/content "content1") content2 (sto/content "content2") + content3 (sto/content "content3") object1 (sto/put-object! storage {::sto/content content1 ::sto/expired-at (dt/now) :content-type "text/plain" @@ -107,16 +108,20 @@ object2 (sto/put-object! storage {::sto/content content2 ::sto/expired-at (dt/in-past {:hours 2}) :content-type "text/plain" + }) + object3 (sto/put-object! storage {::sto/content content3 + ::sto/expired-at (dt/in-past {:hours 1}) + :content-type "text/plain" })] + (th/sleep 200) - (let [task (:app.storage/gc-deleted-task th/*system*) - res (task {})] + (let [res (th/run-task! :storage-gc-deleted {})] (t/is (= 1 (:deleted res)))) (let [res (db/exec-one! th/*pool* ["select count(*) from storage_object;"])] - (t/is (= 1 (:count res)))))) + (t/is (= 2 (:count res)))))) (t/deftest test-touched-gc-task-1 (let [storage (-> (:app.storage/storage th/*system*) From 0c5c04e58a707d3cb3d563a585e870afbf1f8e50 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 31 Aug 2023 15:16:55 +0200 Subject: [PATCH 08/14] :bug: Fix deleted pages comments shown in right sidebar --- frontend/src/app/main/data/comments.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/data/comments.cljs b/frontend/src/app/main/data/comments.cljs index 4ea5796be..b9fd50a43 100644 --- a/frontend/src/app/main/data/comments.cljs +++ b/frontend/src/app/main/data/comments.cljs @@ -279,8 +279,9 @@ (assoc-in (conj path :position) (:position comment-thread)) (assoc-in (conj path :frame-id) (:frame-id comment-thread)))))) (fetched [[users comments] state] - (let [pages (get-in state [:workspace-data :pages-index]) - comments (filter #(some? (get pages (:page-id %))) comments) + (let [pages (-> (get-in state [:workspace-data :pages]) + set) + comments (filter #(contains? pages (:page-id %)) comments) state (-> state (assoc :comment-threads (d/index-by :id comments)) (update :current-file-comments-users merge (d/index-by :id users)))] From d2d9aeff25c0ed2d3a4f3e1daf4fa1f0852345f7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 20:59:00 +0200 Subject: [PATCH 09/14] :paperclip: Reduce log level of worker submit operation Start logging to as TRACE instead of DEBUG --- backend/src/app/worker.clj | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/app/worker.clj b/backend/src/app/worker.clj index 1c7bcfd1b..4d5a9d728 100644 --- a/backend/src/app/worker.clj +++ b/backend/src/app/worker.clj @@ -678,13 +678,13 @@ (-> (db/exec-one! conn [sql:remove-not-started-tasks task queue label]) :next.jdbc/update-count))] - (l/debug :hint "submit task" - :name task - :queue queue - :label label - :dedupe (boolean dedupe) - :deleted (or deleted 0) - :in (dt/format-duration duration)) + (l/trc :hint "submit task" + :name task + :queue queue + :label label + :dedupe (boolean dedupe) + :deleted (or deleted 0) + :in (dt/format-duration duration)) (db/exec-one! conn [sql:insert-new-task id task props queue label priority max-retries interval]) From 1384219ae72cf4c40848d68f6363e1f64d3fb42b Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 21:08:01 +0200 Subject: [PATCH 10/14] :paperclip: Update devenv logging file --- backend/resources/log4j2-devenv.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/resources/log4j2-devenv.xml b/backend/resources/log4j2-devenv.xml index 8c1142887..947d06e26 100644 --- a/backend/resources/log4j2-devenv.xml +++ b/backend/resources/log4j2-devenv.xml @@ -23,7 +23,7 @@ - + From 750cf0578470e7eeb97611d96c32302d21e61da4 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 21:08:23 +0200 Subject: [PATCH 11/14] :sparkles: Add minor logging related improvements to binfile namespace --- backend/src/app/rpc/commands/binfile.clj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/app/rpc/commands/binfile.clj b/backend/src/app/rpc/commands/binfile.clj index bbcca6b88..140d637f6 100644 --- a/backend/src/app/rpc/commands/binfile.clj +++ b/backend/src/app/rpc/commands/binfile.clj @@ -773,7 +773,7 @@ (defn- lookup-index [id] (let [val (get-in @*state* [:index id])] - (l/debug :fn "lookup-index" :id id :val val ::l/sync? true) + (l/trc :fn "lookup-index" :id id :val val ::l/sync? true) (when (and (not (::ignore-index-errors? *options*)) (not val)) (ex/raise :type :validation :code :incomplete-index From a3495800b57e3cc585c0f638a73dc105f4a6f997 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Thu, 31 Aug 2023 21:09:18 +0200 Subject: [PATCH 12/14] :sparkles: Add minor logging improvements to worker namespace --- backend/src/app/worker.clj | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/app/worker.clj b/backend/src/app/worker.clj index 4d5a9d728..8bafe3a8a 100644 --- a/backend/src/app/worker.clj +++ b/backend/src/app/worker.clj @@ -207,10 +207,10 @@ (db/create-array conn "uuid" ids)]] (db/exec-one! conn sql) - (l/debug :hist "dispatcher: queue tasks" - :queue queue - :tasks (count ids) - :queued res))) + (l/dbg :hist "dispatcher: queue tasks" + :queue queue + :tasks (count ids) + :queued res))) (run-batch! [rconn] (try @@ -433,12 +433,12 @@ :else (try - (l/debug :hint "worker: executing task" - :name (:name task) - :id (:id task) - :queue queue - :worker-id worker-id - :retry (:retry-num task)) + (l/dbg :hint "worker: executing task" + :name (:name task) + :id (str (:id task)) + :queue queue + :worker-id worker-id + :retry (:retry-num task)) (handle-task task) (catch InterruptedException cause (throw cause)) From c83d0284665bba72efc1ff1c65ea92db234d3738 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 1 Sep 2023 07:16:37 +0200 Subject: [PATCH 13/14] :sparkles: Colorpicker: remember las color mode --- CHANGES.md | 4 +++ .../src/app/main/data/workspace/colors.cljs | 10 +++++++ .../app/main/ui/workspace/colorpicker.cljs | 28 ++++++++++++------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 626be878b..a06a37d4c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ## 1.19.3 +### :sparkles: New features + +- Colorpicker: remember last color mode [Taiga #5508](https://tree.taiga.io/project/penpot/issue/5508) + ### :bug: Bugs fixed - List view is discarded on tab change on Workspace Assets Sidebar tab [Github #3547](https://github.com/penpot/penpot/issues/3547) diff --git a/frontend/src/app/main/data/workspace/colors.cljs b/frontend/src/app/main/data/workspace/colors.cljs index 32de9cf96..3fdb48ac9 100644 --- a/frontend/src/app/main/data/workspace/colors.cljs +++ b/frontend/src/app/main/data/workspace/colors.cljs @@ -22,6 +22,7 @@ [app.main.data.workspace.texts :as dwt] [app.main.data.workspace.undo :as dwu] [app.util.color :as uc] + [app.util.storage :refer [storage]] [beicon.core :as rx] [potok.core :as ptk])) @@ -647,3 +648,12 @@ :position :right}) (ptk/event ::ev/event {::ev/name "add-asset-to-library" :asset-type "color"})))))) + +(defn get-active-color-tab + [] + (let [tab (::tab @storage)] + (or tab :ramp))) + +(defn set-active-color-tab! + [tab] + (swap! storage assoc ::tab tab)) diff --git a/frontend/src/app/main/ui/workspace/colorpicker.cljs b/frontend/src/app/main/ui/workspace/colorpicker.cljs index 5b15d247d..9b912afd5 100644 --- a/frontend/src/app/main/ui/workspace/colorpicker.cljs +++ b/frontend/src/app/main/ui/workspace/colorpicker.cljs @@ -56,12 +56,17 @@ current-color (:current-color state) - active-tab (mf/use-state :ramp #_:harmony #_:hsva) - set-ramp-tab! (mf/use-fn #(reset! active-tab :ramp)) - set-harmony-tab! (mf/use-fn #(reset! active-tab :harmony)) - set-hsva-tab! (mf/use-fn #(reset! active-tab :hsva)) - + active-tab (mf/use-state (dc/get-active-color-tab)) drag? (mf/use-state false) + + set-tab! + (mf/use-fn + (fn [event] + (let [tab (-> (dom/get-current-target event) + (dom/get-data "tab") + (keyword))] + (reset! active-tab tab) + (dc/set-active-color-tab! tab)))) handle-change-color (mf/use-fn @@ -81,9 +86,9 @@ (fn [] (if picking-color? (do (modal/disallow-click-outside!) - (st/emit! (dc/stop-picker))) + (st/emit! (dc/stop-picker))) (do (modal/allow-click-outside!) - (st/emit! (dc/start-picker)))))) + (st/emit! (dc/start-picker)))))) handle-change-stop (mf/use-fn @@ -225,15 +230,18 @@ [:div.colorpicker-tab.tooltip.tooltip-bottom.tooltip-expand {:class (when (= @active-tab :ramp) "active") :alt (tr "workspace.libraries.colors.rgba") - :on-click set-ramp-tab!} i/picker-ramp] + :on-click set-tab! + :data-tab "ramp"} i/picker-ramp] [:div.colorpicker-tab.tooltip.tooltip-bottom.tooltip-expand {:class (when (= @active-tab :harmony) "active") :alt (tr "workspace.libraries.colors.rgb-complementary") - :on-click set-harmony-tab!} i/picker-harmony] + :on-click set-tab! + :data-tab "harmony"} i/picker-harmony] [:div.colorpicker-tab.tooltip.tooltip-bottom.tooltip-expand {:class (when (= @active-tab :hsva) "active") :alt (tr "workspace.libraries.colors.hsv") - :on-click set-hsva-tab!} i/picker-hsv]] + :on-click set-tab! + :data-tab "hsva"} i/picker-hsv]] (if picking-color? [:div.picker-detail-wrapper From 92ff5de538d2f9836530c979ca530a3b66085ec1 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 1 Sep 2023 07:46:32 +0200 Subject: [PATCH 14/14] :sparkles: Improve layers multiselection behaviour --- CHANGES.md | 3 ++- frontend/src/app/main/data/workspace/selection.cljs | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a06a37d4c..9acc1d8c0 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,7 +4,8 @@ ### :sparkles: New features -- Colorpicker: remember last color mode [Taiga #5508](https://tree.taiga.io/project/penpot/issue/5508) +- Remember last color mode in colorpicker [Taiga #5508](https://tree.taiga.io/project/penpot/issue/5508) +- Improve layers multiselection behaviour [Github #5741](https://github.com/penpot/penpot/issues/5741) ### :bug: Bugs fixed diff --git a/frontend/src/app/main/data/workspace/selection.cljs b/frontend/src/app/main/data/workspace/selection.cljs index 6cb8c1237..dd2a881fa 100644 --- a/frontend/src/app/main/data/workspace/selection.cljs +++ b/frontend/src/app/main/data/workspace/selection.cljs @@ -122,7 +122,9 @@ (ptk/reify ::select-shape ptk/UpdateEvent (update [_ state] - (update-in state [:workspace-local :selected] d/toggle-selection id toggle?)) + (-> state + (update-in [:workspace-local :selected] d/toggle-selection id toggle?) + (assoc-in [:workspace-local :last-selected] id))) ptk/WatchEvent (watch [_ state _] @@ -185,7 +187,9 @@ (ptk/reify ::deselect-shape ptk/UpdateEvent (update [_ state] - (update-in state [:workspace-local :selected] disj id)))) + (-> state + (update-in [:workspace-local :selected] disj id) + (update :workspace-local dissoc :last-selected))))) (defn shift-select-shapes ([id] @@ -196,12 +200,14 @@ ptk/UpdateEvent (update [_ state] (let [objects (or objects (wsh/lookup-page-objects state)) + append-to-selection (cph/expand-region-selection objects (into #{} [(get-in state [:workspace-local :last-selected]) id])) selection (-> state wsh/lookup-selected (conj id))] (-> state (assoc-in [:workspace-local :selected] - (cph/expand-region-selection objects selection)))))))) + (set/union selection append-to-selection)) + (update :workspace-local assoc :last-selected id))))))) (defn select-shapes [ids]