From 7e0a612818cac700decb30e9b20d5815b571e6d1 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Mon, 10 Jul 2023 13:42:33 +0200 Subject: [PATCH 1/9] :bug: Fix problem when sliding color picker in selected-colors --- CHANGES.md | 1 + .../options/menus/color_selection.cljs | 28 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 079eb6291..ab87123b5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -67,6 +67,7 @@ - Fix close overlay from a nested board [Taiga #5587](https://tree.taiga.io/project/penpot/issue/5587) - Fix overlay position when it has shadow or blur [Taiga #4752](https://tree.taiga.io/project/penpot/issue/4752) - Fix overlay position when there are elements fixed when scrolling [Taiga #4383](https://tree.taiga.io/project/penpot/issue/4383) +- Fix problem when sliding color picker in selected-colors [#3150](https://github.com/penpot/penpot/issues/3150) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs index 857e60da5..333103028 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/color_selection.cljs @@ -75,7 +75,7 @@ (d/without-nils {:color (str/lower (dm/get-in shadow [:color :color])) :opacity (dm/get-in shadow [:color :opacity]) :gradient (dm/get-in shadow [:color :gradient])}))] - + {:attrs attrs :prop :shadow @@ -157,41 +157,33 @@ expand-color (mf/use-state false) grouped-colors* (mf/use-var nil) - prev-color* (mf/use-var nil) + prev-colors* (mf/use-var []) on-change (mf/use-fn (fn [new-color old-color from-picker?] - (let [old-color (-> old-color - (dissoc :name) - (dissoc :path) - (d/without-nils)) - - prev-color (when @prev-color* - (-> @prev-color* - (dissoc :name) - (dissoc :path) - (d/without-nils))) + (let [old-color (-> old-color (dissoc :name :path) d/without-nils) ;; When dragging on the color picker sometimes all the shapes hasn't updated the color to the prev value so we need this extra calculation shapes-by-old-color (get @grouped-colors* old-color) + prev-color (d/seek #(get @grouped-colors* %) @prev-colors*) shapes-by-prev-color (get @grouped-colors* prev-color) shapes-by-color (or shapes-by-prev-color shapes-by-old-color)] (when from-picker? - (reset! prev-color* new-color)) + (swap! prev-colors* conj (-> new-color (dissoc :name :path) d/without-nils))) (st/emit! (dc/change-color-in-selected new-color shapes-by-color (or prev-color old-color)))))) on-open (mf/use-fn (fn [] - (reset! prev-color* nil))) + (reset! prev-colors* []))) on-close (mf/use-fn (fn [] - (reset! prev-color* nil))) + (reset! prev-colors* []))) on-detach (mf/use-fn @@ -217,7 +209,7 @@ [:div.element-set-content [:div.selected-colors (for [[index color] (d/enumerate (take 3 library-colors))] - [:& color-row {:key (dm/str "library-color-" index) + [:& color-row {:key (dm/str "library-color-" (:color color)) :color color :index index :on-detach on-detach @@ -231,7 +223,7 @@ [:span.text (tr "workspace.options.more-lib-colors")]]) (when @expand-lib-color (for [[index color] (d/enumerate (drop 3 library-colors))] - [:& color-row {:key (dm/str "library-color-" index) + [:& color-row {:key (dm/str "library-color-" (:color color)) :color color :index index :on-detach on-detach @@ -255,7 +247,7 @@ [:span.text (tr "workspace.options.more-colors")]]) (when @expand-color (for [[index color] (d/enumerate (drop 3 colors))] - [:& color-row {:key (dm/str "color-" index) + [:& color-row {:key (dm/str "color-" (:color color)) :color color :index index :select-only select-only From 66559d3ce34e9ecd02df09cc9b8b01c3add8e2ac Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 10:55:17 +0200 Subject: [PATCH 2/9] :bug: Fix error screen on image upload failure --- CHANGES.md | 1 + frontend/src/app/main/data/workspace/media.cljs | 4 +++- frontend/translations/en.po | 3 +++ frontend/translations/es.po | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index ab87123b5..379b072f2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -68,6 +68,7 @@ - Fix overlay position when it has shadow or blur [Taiga #4752](https://tree.taiga.io/project/penpot/issue/4752) - Fix overlay position when there are elements fixed when scrolling [Taiga #4383](https://tree.taiga.io/project/penpot/issue/4383) - Fix problem when sliding color picker in selected-colors [#3150](https://github.com/penpot/penpot/issues/3150) +- Fix error screen on upload image error [Taiga #5608](https://tree.taiga.io/project/penpot/issue/5608) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/workspace/media.cljs b/frontend/src/app/main/data/workspace/media.cljs index 424899ad8..b7226dd99 100644 --- a/frontend/src/app/main/data/workspace/media.cljs +++ b/frontend/src/app/main/data/workspace/media.cljs @@ -181,7 +181,9 @@ (on-error error) :else - (rx/throw error))))] + (do + (.error js/console "ERROR" error) + (rx/of (msg/error (tr "errors.cannot-upload")))))))] (ptk/reify ::process-media-objects ptk/WatchEvent diff --git a/frontend/translations/en.po b/frontend/translations/en.po index 7c5e2f162..13b41ee30 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -1017,6 +1017,9 @@ msgstr "Email or password is incorrect." msgid "errors.wrong-old-password" msgstr "Old password is incorrect" +msgid "errors.cannot-upload" +msgstr "Cannot upload the media file." + #: src/app/main/ui/settings/feedback.cljs msgid "feedback.description" msgstr "Description" diff --git a/frontend/translations/es.po b/frontend/translations/es.po index dcdd6727b..8076484d0 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -1057,6 +1057,9 @@ msgstr "El email o la contraseña son incorrectos." msgid "errors.wrong-old-password" msgstr "La contraseña anterior no es correcta" +msgid "errors.cannot-upload" +msgstr "No se puede subir el fichero" + #: src/app/main/ui/settings/feedback.cljs msgid "feedback.description" msgstr "Descripción" From 5072c903c5aaa4fb1497030fedc7c501879abe0a Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 13:29:15 +0200 Subject: [PATCH 3/9] :bug: Fix bad frame-id for certain componentes --- CHANGES.md | 1 + common/src/app/common/pages/common.cljc | 2 +- common/src/app/common/pages/migrations.cljc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 379b072f2..8f82cff62 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -69,6 +69,7 @@ - Fix overlay position when there are elements fixed when scrolling [Taiga #4383](https://tree.taiga.io/project/penpot/issue/4383) - Fix problem when sliding color picker in selected-colors [#3150](https://github.com/penpot/penpot/issues/3150) - Fix error screen on upload image error [Taiga #5608](https://tree.taiga.io/project/penpot/issue/5608) +- Fix bad frame-id for certain componentes [#3205](https://github.com/penpot/penpot/issues/3205) ### :arrow_up: Deps updates diff --git a/common/src/app/common/pages/common.cljc b/common/src/app/common/pages/common.cljc index 49e922632..e0443616b 100644 --- a/common/src/app/common/pages/common.cljc +++ b/common/src/app/common/pages/common.cljc @@ -12,7 +12,7 @@ [app.common.schema :as sm] [app.common.uuid :as uuid])) -(def file-version 20) +(def file-version 21) (def default-color clr/gray-20) (def root uuid/zero) diff --git a/common/src/app/common/pages/migrations.cljc b/common/src/app/common/pages/migrations.cljc index 510423710..72205dd4c 100644 --- a/common/src/app/common/pages/migrations.cljc +++ b/common/src/app/common/pages/migrations.cljc @@ -436,7 +436,7 @@ (update :pages-index update-vals update-container) (update :components update-vals update-container)))) -(defmethod migrate 20 +(defmethod migrate 21 [data] (letfn [(update-object [objects object] (let [frame-id (:frame-id object) From 9f121cb38b0566466420e5424a60595a0165f260 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 13:34:26 +0200 Subject: [PATCH 4/9] :bug: Fix problem with comments not sticking --- frontend/src/app/main/ui/workspace/left_toolbar.cljs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/app/main/ui/workspace/left_toolbar.cljs b/frontend/src/app/main/ui/workspace/left_toolbar.cljs index c0b4bce21..6439725af 100644 --- a/frontend/src/app/main/ui/workspace/left_toolbar.cljs +++ b/frontend/src/app/main/ui/workspace/left_toolbar.cljs @@ -85,7 +85,7 @@ dw/clear-edition-mode) ;; Delay so anything that launched :interrupt can finish - (st/emit! 100 (dw/select-for-drawing tool))))) + (ts/schedule 100 #(st/emit! (dw/select-for-drawing tool)))))) toggle-text-palette (mf/use-fn From 5631204567393ab22ef7d09c3712c8328e724f94 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 14:43:30 +0200 Subject: [PATCH 5/9] :bug: Fix paste elements at bottom of frame --- CHANGES.md | 1 + frontend/src/app/main/data/workspace.cljs | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8f82cff62..5617a320b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -70,6 +70,7 @@ - Fix problem when sliding color picker in selected-colors [#3150](https://github.com/penpot/penpot/issues/3150) - Fix error screen on upload image error [Taiga #5608](https://tree.taiga.io/project/penpot/issue/5608) - Fix bad frame-id for certain componentes [#3205](https://github.com/penpot/penpot/issues/3205) +- Fix paste elements at bottom of frame [Taig #5253](https://tree.taiga.io/project/penpot/issue/5253) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 704332767..0e49bf375 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -1694,7 +1694,8 @@ [(:frame-id base) parent-id delta index]) ;; Paste inside selected frame otherwise - (let [origin-frame-id (:frame-id first-selected-obj) + (let [selected-frame-obj (get page-objects (first page-selected)) + 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))) @@ -1720,7 +1721,7 @@ ;; - 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])) + [frame-id frame-id delta (dec (count (:shapes selected-frame-obj )))])) (empty? page-selected) (let [frame-id (ctst/top-nested-frame page-objects mouse-pos) From 872648d393c32481298bcdb96f05cb53b5be2867 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 14:51:10 +0200 Subject: [PATCH 6/9] :bug: Fix new-file button on project not redirecting to the new file --- CHANGES.md | 1 + frontend/src/app/main/ui/dashboard/files.cljs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 5617a320b..f6e0c7250 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -71,6 +71,7 @@ - Fix error screen on upload image error [Taiga #5608](https://tree.taiga.io/project/penpot/issue/5608) - Fix bad frame-id for certain componentes [#3205](https://github.com/penpot/penpot/issues/3205) - Fix paste elements at bottom of frame [Taig #5253](https://tree.taiga.io/project/penpot/issue/5253) +- Fix new-file button on project not redirecting to the new file [Taiga #5610](https://tree.taiga.io/project/penpot/issue/5610) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/ui/dashboard/files.cljs b/frontend/src/app/main/ui/dashboard/files.cljs index b7d9426cf..1ad4e9ada 100644 --- a/frontend/src/app/main/ui/dashboard/files.cljs +++ b/frontend/src/app/main/ui/dashboard/files.cljs @@ -18,6 +18,7 @@ [app.util.dom :as dom] [app.util.i18n :as i18n :refer [tr]] [app.util.keyboard :as kbd] + [app.util.router :as rt] [app.util.webapi :as wapi] [beicon.core :as rx] [cuerdas.core :as str] @@ -142,12 +143,22 @@ (sort-by :modified-at) (reverse))) + on-file-created + (mf/use-fn + (fn [data] + (let [pparams {:project-id (:project-id data) + :file-id (:id data)} + qparams {:page-id (get-in data [:data :pages 0])}] + (st/emit! (rt/nav :workspace pparams qparams))))) + create-file (mf/use-fn (mf/deps project) (fn [origin] - (st/emit! (with-meta (dd/create-file {:project-id (:id project)}) - {::ev/origin origin}))))] + (let [mdata {:on-success on-file-created} + params {:project-id (:id project)}] + (st/emit! (-> (dd/create-file (with-meta params mdata)) + (with-meta {::ev/origin origin}))))))] (mf/with-effect [] (let [node (mf/ref-val rowref) From fc35b0b853f5f763fd8837bc216e68b189b43185 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 15:38:54 +0200 Subject: [PATCH 7/9] :bug: Fix retrieve user comments in dashboard --- CHANGES.md | 1 + frontend/src/app/main/data/comments.cljs | 13 +++++++++++-- frontend/src/app/main/refs.cljs | 3 +++ frontend/src/app/main/ui/dashboard/comments.cljs | 2 +- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f6e0c7250..d4daeef64 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -72,6 +72,7 @@ - Fix bad frame-id for certain componentes [#3205](https://github.com/penpot/penpot/issues/3205) - Fix paste elements at bottom of frame [Taig #5253](https://tree.taiga.io/project/penpot/issue/5253) - Fix new-file button on project not redirecting to the new file [Taiga #5610](https://tree.taiga.io/project/penpot/issue/5610) +- Fix retrieve user comments in dashboard [Taiga #5607](https://tree.taiga.io/project/penpot/issue/5607) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/comments.cljs b/frontend/src/app/main/data/comments.cljs index 65f409178..225ddae8b 100644 --- a/frontend/src/app/main/data/comments.cljs +++ b/frontend/src/app/main/data/comments.cljs @@ -314,9 +314,18 @@ (ptk/reify ::retrieve-unread-comment-threads ptk/WatchEvent (watch [_ _ _] - (let [fetched #(assoc %2 :comment-threads (d/index-by :id %1))] + (let [fetched-comments #(assoc %2 :comment-threads (d/index-by :id %1)) + fetched-users #(assoc %2 :current-team-comments-users %1)] (->> (rp/cmd! :get-unread-comment-threads {:team-id team-id}) - (rx/map #(partial fetched %)) + (rx/merge-map + (fn [comments] + (rx/concat + (rx/of (partial fetched-comments comments)) + + (->> (rx/from (map :file-id comments)) + (rx/merge-map #(rp/cmd! :get-profiles-for-file-comments {:file-id %})) + (rx/reduce #(merge %1 (d/index-by :id %2)) {}) + (rx/map #(partial fetched-users %)))))) (rx/catch #(rx/throw {:type :comment-error}))))))) diff --git a/frontend/src/app/main/refs.cljs b/frontend/src/app/main/refs.cljs index bcb78e7a4..7f7e4bc75 100644 --- a/frontend/src/app/main/refs.cljs +++ b/frontend/src/app/main/refs.cljs @@ -459,6 +459,9 @@ (def current-file-comments-users (l/derived :current-file-comments-users st/state)) +(def current-team-comments-users + (l/derived :current-team-comments-users st/state)) + (def viewer-fullscreen? (l/derived (fn [state] (dm/get-in state [:viewer-local :fullscreen?])) diff --git a/frontend/src/app/main/ui/dashboard/comments.cljs b/frontend/src/app/main/ui/dashboard/comments.cljs index c03518fb9..2da270779 100644 --- a/frontend/src/app/main/ui/dashboard/comments.cljs +++ b/frontend/src/app/main/ui/dashboard/comments.cljs @@ -32,7 +32,7 @@ show-dropdown (mf/use-fn #(reset! show-dropdown? true)) hide-dropdown (mf/use-fn #(reset! show-dropdown? false)) threads-map (mf/deref refs/comment-threads) - users (mf/deref refs/current-file-comments-users) + users (mf/deref refs/current-team-comments-users) tgroups (->> (vals threads-map) (sort-by :modified-at) From 1b0a6b26ce7e574fc0108e24e0831923f30d4cc8 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 15:52:04 +0200 Subject: [PATCH 8/9] :bug: Fix problem with bool contents --- common/src/app/common/file_builder.cljc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/file_builder.cljc b/common/src/app/common/file_builder.cljc index f8faff235..9903d0f9f 100644 --- a/common/src/app/common/file_builder.cljc +++ b/common/src/app/common/file_builder.cljc @@ -341,13 +341,15 @@ :else (let [objects (lookup-objects file) + bool-content (gsh/calc-bool-content bool objects) bool' (gsh/update-bool-selrect bool children objects)] (commit-change file {:type :mod-obj :id bool-id :operations - [{:type :set :attr :selrect :val (:selrect bool') :ignore-touched true} + [{:type :set :attr :bool-content :val bool-content :ignore-touched true} + {:type :set :attr :selrect :val (:selrect bool') :ignore-touched true} {:type :set :attr :points :val (:points bool') :ignore-touched true} {:type :set :attr :x :val (-> bool' :selrect :x) :ignore-touched true} {:type :set :attr :y :val (-> bool' :selrect :y) :ignore-touched true} From 369192a353df1f2e289cf3f28876204139ef04c3 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 11 Jul 2023 16:21:47 +0200 Subject: [PATCH 9/9] :bug: Locks shapes when moved inside a locked parent --- CHANGES.md | 1 + frontend/src/app/main/data/workspace.cljs | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d4daeef64..7ee9836bd 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -73,6 +73,7 @@ - Fix paste elements at bottom of frame [Taig #5253](https://tree.taiga.io/project/penpot/issue/5253) - Fix new-file button on project not redirecting to the new file [Taiga #5610](https://tree.taiga.io/project/penpot/issue/5610) - Fix retrieve user comments in dashboard [Taiga #5607](https://tree.taiga.io/project/penpot/issue/5607) +- Locks shapes when moved inside a locked parent [Taiga #5252](https://tree.taiga.io/project/penpot/issue/5252) ### :arrow_up: Deps updates diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 0e49bf375..95050c190 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -717,17 +717,18 @@ groups-to-delete groups-to-unmask shapes-to-detach shapes-to-reroot shapes-to-deroot shapes-to-unconstraint] (let [ordered-indexes (cph/order-by-indexed-shapes objects ids) - shapes (map (d/getf objects) ordered-indexes)] + shapes (map (d/getf objects) ordered-indexes) + parent (get objects parent-id)] (-> (pcb/empty-changes it page-id) (pcb/with-objects objects) ;; Remove layout-item properties when moving a shape outside a layout - (cond-> (not (ctl/any-layout? objects parent-id)) + (cond-> (not (ctl/any-layout? parent)) (pcb/update-shapes ordered-indexes ctl/remove-layout-item-data)) ;; Remove the hide in viewer flag - (cond-> (and (not= uuid/zero parent-id) (cph/frame-shape? objects parent-id)) + (cond-> (and (not= uuid/zero parent-id) (cph/frame-shape? parent)) (pcb/update-shapes ordered-indexes #(cond-> % (cph/frame-shape? %) (assoc :hide-in-viewer true)))) ;; Move the shapes @@ -759,8 +760,7 @@ ;; Reset constraints depending on the new parent (pcb/update-shapes shapes-to-unconstraint (fn [shape] - (let [parent (get objects parent-id) - frame-id (if (= (:type parent) :frame) + (let [frame-id (if (= (:type parent) :frame) (:id parent) (:frame-id parent)) moved-shape (assoc shape @@ -783,6 +783,10 @@ (assoc :layout-item-v-sizing :fix)) parent))) + ;; If parent locked, lock the added shapes + (cond-> (:blocked parent) + (pcb/update-shapes ordered-indexes #(assoc % :blocked true))) + ;; Resize parent containers that need to (pcb/resize-parents parents))))