From 78aea0f24e420dcb4affd05319912ed78a6c1ba2 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Tue, 7 Feb 2023 18:38:54 +0100 Subject: [PATCH 1/8] :bug: Fix incorrect props cleaning on auditlog --- backend/src/app/loggers/audit.clj | 34 ++++++++++++------------------- backend/src/app/rpc.clj | 3 +-- common/src/app/common/data.cljc | 19 +++++++++-------- 3 files changed, 25 insertions(+), 31 deletions(-) diff --git a/backend/src/app/loggers/audit.clj b/backend/src/app/loggers/audit.clj index 93a363727..68aa0b116 100644 --- a/backend/src/app/loggers/audit.clj +++ b/backend/src/app/loggers/audit.clj @@ -77,28 +77,20 @@ (merge (:props profile)) (d/without-nils))) -(defn clean-props - [{:keys [profile-id] :as event}] - (let [invalid-keys #{:session-id - :password - :old-password - :token} - xform (comp - (remove (fn [kv] - (qualified-keyword? (first kv)))) - (remove (fn [kv] - (contains? invalid-keys (first kv)))) - (remove (fn [[k v]] - (and (= k :profile-id) - (= v profile-id)))) - (filter (fn [[_ v]] - (or (string? v) - (keyword? v) - (uuid? v) - (boolean? v) - (number? v)))))] +(def reserved-props + #{:session-id + :password + :old-password + :token}) - (update event :props #(into {} xform %)))) +(defn clean-props + [props] + (into {} + (comp + (d/without-nils) + (d/without-qualified) + (remove #(contains? reserved-props (key %)))) + props)) ;; --- SPECS diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index cdda84a0b..d365fd909 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -181,8 +181,7 @@ (merge (::audit/props resultm)) (dissoc :profile-id) (dissoc :type))) - (d/without-qualified) - (d/without-nils)) + (audit/clean-props)) event {:type (or (::audit/type resultm) (::type cfg)) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index ae52003c1..1a9806958 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -203,19 +203,22 @@ ([coll value] (sequence (replace-by-id value) coll))) -(defn without-nils - "Given a map, return a map removing key-value - pairs when value is `nil`." - [data] - (into {} (remove (comp nil? second)) data)) - (defn vec-without-nils [coll] (into [] (remove nil?) coll)) +(defn without-nils + "Given a map, return a map removing key-value + pairs when value is `nil`." + ([] (remove (comp nil? val))) + ([data] + (into {} (without-nils) data))) + (defn without-qualified - [data] - (into {} (remove (comp qualified-keyword? first)) data)) + ([] + (remove (comp qualified-keyword? key))) + ([data] + (into {} (without-qualified) data))) (defn without-keys "Return a map without the keys provided From be3a973d09cc052510f97b02091262425651dca4 Mon Sep 17 00:00:00 2001 From: Eva Date: Thu, 2 Feb 2023 14:32:59 +0100 Subject: [PATCH 2/8] :bug: Fix paste a frame inside itself --- CHANGES.md | 5 ++ frontend/src/app/main/data/workspace.cljs | 81 +++++++++++++++-------- 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 190729d82..42c3513c4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # CHANGELOG +## 1.17.2 + +### :bug: Bugs fixed +- Fix paste board inside itself [Taiga #4775](https://tree.taiga.io/project/penpot/issue/4775) + ## 1.17.1 ### :bug: Bugs fixed diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 826ee7be6..f5ec2bfb7 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1440,6 +1440,19 @@ (and (= 1 (count selected)) (= :frame (get-in objects [(first selected) :type]))))) +(defn same-frame-from-selected? [state frame-id] + (let [selected (wsh/lookup-selected state)] + (contains? frame-id (first selected)))) + +(defn frame-same-size? + [paste-obj frame-obj] + (and + (= (:heigth (:selrect (first (vals paste-obj)))) + (:heigth (:selrect frame-obj))) + (= (:width (:selrect (first (vals paste-obj)))) + (:width (:selrect frame-obj))))) + + (defn- paste-shape [{selected :selected paste-objects :objects ;; rename this because here comes only the clipboard shapes, @@ -1478,55 +1491,67 @@ item)) (calculate-paste-position [state mouse-pos in-viewport?] - (let [page-objects (wsh/lookup-page-objects state) - selected-objs (map #(get paste-objects %) selected) - page-selected (wsh/lookup-selected state) - wrapper (gsh/selection-rect selected-objs) - orig-pos (gpt/point (:x1 wrapper) (:y1 wrapper))] + (let [page-objects (wsh/lookup-page-objects state) + selected-objs (map #(get paste-objects %) selected) + first-selected-obj (first selected-objs) + page-selected (wsh/lookup-selected state) + wrapper (gsh/selection-rect selected-objs) + orig-pos (gpt/point (:x1 wrapper) (:y1 wrapper)) + frame-id (first page-selected) + frame-object (get page-objects frame-id) + base (cph/get-base-shape page-objects page-selected) + index (cph/get-position-on-parent page-objects (:id base))] (cond - ;; Pasting inside a frame (selected-frame? state) - (let [frame-id (first page-selected) - frame-object (get page-objects frame-id) - origin-frame-id (:frame-id (first selected-objs)) - origin-frame-object (get page-objects origin-frame-id) + (if (or (same-frame-from-selected? state (first (vals paste-objects))) + (frame-same-size? paste-objects frame-object)) + ;; Paste next to selected frame, if selected is itself or of the same size as the copied + (let [selected-frame-obj (get page-objects (first page-selected)) + parent-id (:parent-id base) + paste-x (+ (:width selected-frame-obj) (:x selected-frame-obj) 50) + paste-y (:y selected-frame-obj) + delta (gpt/subtract (gpt/point paste-x paste-y) orig-pos)] - margin-x (-> (- (:width origin-frame-object) (+ (:x wrapper) (:width wrapper))) - (min (- (:width frame-object) (:width wrapper)))) + [(:frame-id base) parent-id delta index]) - margin-y (-> (- (:height origin-frame-object) (+ (:y wrapper) (:height wrapper))) - (min (- (:height frame-object) (:height wrapper)))) + ;; Paste inside selected frame otherwise + (let [origin-frame-id (:frame-id first-selected-obj) + origin-frame-object (get page-objects origin-frame-id) + + margin-x (-> (- (:width origin-frame-object) (+ (:x wrapper) (:width wrapper))) + (min (- (:width frame-object) (:width wrapper)))) + + margin-y (-> (- (:height origin-frame-object) (+ (:y wrapper) (:height wrapper))) + (min (- (:height frame-object) (:height wrapper)))) ;; Pasted objects mustn't exceed the selected frame x limit - paste-x (if (> (+ (:width wrapper) (:x1 wrapper)) (:width frame-object)) - (+ (- (:x frame-object) (:x orig-pos)) (- (:width frame-object) (:width wrapper) margin-x)) - (:x frame-object)) + paste-x (if (> (+ (:width wrapper) (:x1 wrapper)) (:width frame-object)) + (+ (- (:x frame-object) (:x orig-pos)) (- (:width frame-object) (:width wrapper) margin-x)) + (:x frame-object)) ;; Pasted objects mustn't exceed the selected frame y limit - paste-y (if (> (+ (:height wrapper) (:y1 wrapper)) (:height frame-object)) - (+ (- (:y frame-object) (:y orig-pos)) (- (:height frame-object) (:height wrapper) margin-y)) - (:y frame-object)) + paste-y (if (> (+ (:height wrapper) (:y1 wrapper)) (:height frame-object)) + (+ (- (:y frame-object) (:y orig-pos)) (- (:height frame-object) (:height wrapper) margin-y)) + (:y frame-object)) - delta (if (= origin-frame-id uuid/zero) + delta (if (= origin-frame-id uuid/zero) ;; When the origin isn't in a frame the result is pasted in the center. - (gpt/subtract (gsh/center-shape frame-object) (gsh/center-selrect wrapper)) + (gpt/subtract (gsh/center-shape frame-object) (gsh/center-selrect wrapper)) ;; When pasting from one frame to another frame the object position must be limited to container boundaries. If the pasted object doesn't fit we try to: ;; - Align it to the limits on the x and y axis ;; - Respect the distance of the object to the right and bottom in the original frame - (gpt/point paste-x paste-y))] - [frame-id frame-id delta]) - + (gpt/point paste-x paste-y))] + [frame-id frame-id delta])) + (empty? page-selected) (let [frame-id (ctst/top-nested-frame page-objects mouse-pos) delta (gpt/subtract mouse-pos orig-pos)] [frame-id frame-id delta]) :else - (let [base (cph/get-base-shape page-objects page-selected) - index (cph/get-position-on-parent page-objects (:id base)) - frame-id (:frame-id base) + (let [frame-id (:frame-id base) parent-id (:parent-id base) delta (if in-viewport? (gpt/subtract mouse-pos orig-pos) From d49e1f16414063d8ddc414102fa6fd5e313ebdf5 Mon Sep 17 00:00:00 2001 From: Pablo Alba Date: Wed, 8 Feb 2023 12:19:29 +0100 Subject: [PATCH 3/8] :bug: Fix middle button panning can drag guides --- CHANGES.md | 1 + backend/src/app/rpc.clj | 1 - frontend/src/app/main/ui/workspace/viewport/guides.cljs | 9 +++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 42c3513c4..48abb34f7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ ### :bug: Bugs fixed - Fix paste board inside itself [Taiga #4775](https://tree.taiga.io/project/penpot/issue/4775) +- Fix middle button panning can drag guides [Taiga #4266](https://tree.taiga.io/project/penpot/issue/4266) ## 1.17.1 diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index d365fd909..9b1f9509a 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -7,7 +7,6 @@ (ns app.rpc (:require [app.auth.ldap :as-alias ldap] - [app.common.data :as d] [app.common.exceptions :as ex] [app.common.logging :as l] [app.common.spec :as us] diff --git a/frontend/src/app/main/ui/workspace/viewport/guides.cljs b/frontend/src/app/main/ui/workspace/viewport/guides.cljs index 97aa1d805..dd624febd 100644 --- a/frontend/src/app/main/ui/workspace/viewport/guides.cljs +++ b/frontend/src/app/main/ui/workspace/viewport/guides.cljs @@ -69,10 +69,11 @@ on-pointer-down (mf/use-callback (fn [event] - (dom/capture-pointer event) - (mf/set-ref-val! dragging-ref true) - (mf/set-ref-val! start-ref (dom/get-client-position event)) - (mf/set-ref-val! start-pos-ref (get @ms/mouse-position axis)))) + (when (= 0 (.-button event)) + (dom/capture-pointer event) + (mf/set-ref-val! dragging-ref true) + (mf/set-ref-val! start-ref (dom/get-client-position event)) + (mf/set-ref-val! start-pos-ref (get @ms/mouse-position axis))))) on-pointer-up (mf/use-callback From da209b75072038f3ba523da5738b6cd9fb88c842 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 9 Feb 2023 10:41:18 +0100 Subject: [PATCH 4/8] :bug: Fix problem with auto sizes --- common/src/app/common/geom/shapes/flex_layout/bounds.cljc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/src/app/common/geom/shapes/flex_layout/bounds.cljc b/common/src/app/common/geom/shapes/flex_layout/bounds.cljc index fea42fcad..9cce53ed4 100644 --- a/common/src/app/common/geom/shapes/flex_layout/bounds.cljc +++ b/common/src/app/common/geom/shapes/flex_layout/bounds.cljc @@ -68,6 +68,12 @@ (gpt/add base-p (hv 0.01)) (gpt/add base-p (vv 0.01))] + col? + (conj (gpt/add base-p (vv min-height))) + + row? + (conj (gpt/add base-p (hv min-width))) + (and col? h-start?) (conj (gpt/add base-p (hv min-width))) From ee42dd8b01902dd4dbf5ab0a750a4e71bb522413 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 9 Feb 2023 10:42:57 +0100 Subject: [PATCH 5/8] :bug: Fix layout on multiple selection --- backend/src/app/rpc.clj | 1 - .../app/main/ui/workspace/sidebar/options/shapes/multiple.cljs | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/src/app/rpc.clj b/backend/src/app/rpc.clj index d365fd909..9b1f9509a 100644 --- a/backend/src/app/rpc.clj +++ b/backend/src/app/rpc.clj @@ -7,7 +7,6 @@ (ns app.rpc (:require [app.auth.ldap :as-alias ldap] - [app.common.data :as d] [app.common.exceptions :as ex] [app.common.logging :as l] [app.common.spec :as us] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs index 3ca283c50..7245fe2ad 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/shapes/multiple.cljs @@ -340,8 +340,7 @@ (when-not (empty? measure-ids) [:& measures-menu {:type type :all-types all-types :ids measure-ids :values measure-values :shape shapes}]) - (when has-layout-container? - [:& layout-container-menu {:type type :ids layout-container-ids :values layout-container-values :multiple true}]) + [:& layout-container-menu {:type type :ids layout-container-ids :values layout-container-values :multiple true}] (when (or is-layout-child? has-layout-container?) [:& layout-item-menu From a98ba72c12e3f9e214bd59a12b25647d1d603031 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Kone=C4=8Dn=C3=BD?= Date: Wed, 8 Feb 2023 12:16:34 +0100 Subject: [PATCH 6/8] added width property to avoid shrinking on icons --- frontend/resources/styles/main/partials/modal.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/resources/styles/main/partials/modal.scss b/frontend/resources/styles/main/partials/modal.scss index 580ffe0f6..79cf01609 100644 --- a/frontend/resources/styles/main/partials/modal.scss +++ b/frontend/resources/styles/main/partials/modal.scss @@ -1403,6 +1403,7 @@ align-items: center; justify-content: center; background: #31efb8; + min-width: 28px; width: 28px; height: 28px; border-radius: 50%; From 6a5bfdd7fbdb2b74e462d110e8bda9d0d8220496 Mon Sep 17 00:00:00 2001 From: Eva Date: Thu, 9 Feb 2023 13:36:26 +0100 Subject: [PATCH 7/8] :heart: Add thanks for ondrejkonec --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 42c3513c4..2cc735ccb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,10 @@ ### :bug: Bugs fixed - Fix paste board inside itself [Taiga #4775](https://tree.taiga.io/project/penpot/issue/4775) +### :heart: Community contributions by (Thank you!) + +- To @ondrejkonec: for some code contributions on this release. + ## 1.17.1 ### :bug: Bugs fixed From 7f963edf9e73be06927dfbaae550208708ac81aa Mon Sep 17 00:00:00 2001 From: Eva Date: Wed, 8 Feb 2023 11:57:17 +0100 Subject: [PATCH 8/8] :bug: Fix invite members text on modal button --- CHANGES.md | 4 ++++ .../resources/styles/main/partials/modal.scss | 18 +++++++++++++----- .../app/main/ui/onboarding/team_choice.cljs | 5 ++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 2cc735ccb..603c5b7af 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,8 @@ # CHANGELOG +## 1.17.2 + +### :bug: Bugs fixed +- Fix invite members button text [Taiga #4794](https://tree.taiga.io/project/penpot/issue/4794) ## 1.17.2 diff --git a/frontend/resources/styles/main/partials/modal.scss b/frontend/resources/styles/main/partials/modal.scss index 79cf01609..06c7210c3 100644 --- a/frontend/resources/styles/main/partials/modal.scss +++ b/frontend/resources/styles/main/partials/modal.scss @@ -1495,10 +1495,6 @@ display: grid; grid-template-columns: 1fr auto; gap: 8px; - .btn-large { - overflow: hidden; - text-overflow: ellipsis; - } .btn-primary { max-width: 250px; } @@ -1587,7 +1583,19 @@ } } .buttons { - margin-top: 12px; + margin: 12px 0; + button { + height: auto; + } + input { + white-space: break-spaces; + word-break: break-word; + height: fit-content; + margin: 0; + padding: 5px 10px; + min-height: 40px; + max-height: 90px; + } } } } diff --git a/frontend/src/app/main/ui/onboarding/team_choice.cljs b/frontend/src/app/main/ui/onboarding/team_choice.cljs index 36700ca72..b1a1e5342 100644 --- a/frontend/src/app/main/ui/onboarding/team_choice.cljs +++ b/frontend/src/app/main/ui/onboarding/team_choice.cljs @@ -196,9 +196,8 @@ :name name :step 2}))} (tr "labels.back")] - [:div {:title (tr "onboarding.choice.team-up.invite-members-submit")} - [:& fm/submit-button - {:label (tr "onboarding.choice.team-up.invite-members-submit")}]]] + [:& fm/submit-button + {:label (tr "onboarding.choice.team-up.invite-members-submit")}]] [:div.skip-action {:on-click on-skip} [:div.action (tr "onboarding.choice.team-up.invite-members-skip")]]]]