0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-25 00:06:09 -05:00

Merge pull request #3493 from penpot/niwinz-staging-bugfixes-6

🐛 Several bugfixes
This commit is contained in:
Alejandro 2023-08-04 13:35:12 +02:00 committed by GitHub
commit c69f6da2d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 72 additions and 68 deletions

View file

@ -47,7 +47,7 @@
(assoc :public-uri (cf/get :public-uri))
(assoc :logger/name logger)
(assoc :logger/level level)
(dissoc :request/params))]
(dissoc :request/params :value :params :data))]
(merge
{:context (-> (into (sorted-map) context)
(pp/pprint-str :width 200 :length 50 :level 10))
@ -55,7 +55,7 @@
:hint (or (ex-message cause) @message)
:trace (ex/format-throwable cause :data? false :explain? false :header? false :summary? false)}
(when-let [params (:request/params context)]
(when-let [params (or (:request/params context) (:params context))]
{:params (pp/pprint-str params :width 200)})
(when-let [value (:value context)]
@ -67,7 +67,6 @@
(when-let [explain (ex/explain data {:level 10 :length 50})]
{:explain explain}))))
(defn error-record?
[{:keys [::l/level ::l/cause]}]
(and (= :error level)

View file

@ -489,16 +489,8 @@
(l/error :hint "worker: unhandled exception" :cause cause))))))
(defn- get-error-context
[error item]
(let [data (ex-data error)]
(merge
{:hint (ex-message error)
:spec-problems (some->> data ::s/problems (take 10) seq vec)
:spec-value (some->> data ::s/value)
:data (some-> data (dissoc ::s/problems ::s/value ::s/spec))
:params item}
(when-let [explain (ex/explain data)]
{:spec-explain explain}))))
[_ item]
{:params item})
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; CRON
@ -597,10 +589,10 @@
(catch InterruptedException _
(l/debug :hint "cron: task interrupted" :task-id id))
(catch Throwable cause
(binding [l/*context* (get-error-context cause task)]
(l/error :hint "cron: unhandled exception on running task"
::l/context (get-error-context cause task)
:task-id id
:cause cause))
:cause cause)))
(finally
(when-not (px/interrupted? :current)
(schedule-cron-task cfg task))))))

View file

@ -8,6 +8,7 @@
(:require
[app.common.colors :as clr]
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
@ -123,56 +124,65 @@
(assoc-in [:fills 0 :fill-opacity] (-> (get-in shape [:svg-attrs :style :fill-opacity])
(d/parse-double 1)))))))
(defn setup-stroke [shape]
(let [stroke-linecap (-> (or (get-in shape [:svg-attrs :stroke-linecap])
(get-in shape [:svg-attrs :style :stroke-linecap]))
((d/nilf str/trim))
((d/nilf keyword)))
color-attr (str/trim (get-in shape [:svg-attrs :stroke]))
color-attr (if (= color-attr "currentColor") clr/black color-attr)
color-style (str/trim (get-in shape [:svg-attrs :style :stroke]))
color-style (if (= color-style "currentColor") clr/black color-style)
shape
(cond-> shape
;; Color present as attribute
(uc/color? color-attr)
(-> (update :svg-attrs dissoc :stroke)
(assoc-in [:strokes 0 :stroke-color] (uc/parse-color color-attr)))
(defn- setup-stroke
[shape]
(let [attrs (get shape :svg-attrs)
style (get attrs :style)
;; Color present as style
(uc/color? color-style)
(-> (update-in [:svg-attrs :style] dissoc :stroke)
(assoc-in [:strokes 0 :stroke-color] (uc/parse-color color-style)))
stroke (or (str/trim (:stroke attrs))
(str/trim (:stroke style)))
(get-in shape [:svg-attrs :stroke-opacity])
(-> (update :svg-attrs dissoc :stroke-opacity)
(assoc-in [:strokes 0 :stroke-opacity] (-> (get-in shape [:svg-attrs :stroke-opacity])
(d/parse-double 1))))
color (cond
(= stroke "currentColor") clr/black
(= stroke "none") nil
:else (uc/parse-color stroke))
(get-in shape [:svg-attrs :style :stroke-opacity])
(-> (update-in [:svg-attrs :style] dissoc :stroke-opacity)
(assoc-in [:strokes 0 :stroke-opacity] (-> (get-in shape [:svg-attrs :style :stroke-opacity])
(d/parse-double 1))))
opacity (when (some? color)
(d/parse-double
(or (:stroke-opacity attrs)
(:stroke-opacity style))
1))
(get-in shape [:svg-attrs :stroke-width])
(-> (update :svg-attrs dissoc :stroke-width)
(assoc-in [:strokes 0 :stroke-width] (-> (get-in shape [:svg-attrs :stroke-width])
(d/parse-double))))
width (when (some? color)
(d/parse-double
(or (:stroke-width attrs)
(:stroke-width style))
1))
(get-in shape [:svg-attrs :style :stroke-width])
(-> (update-in [:svg-attrs :style] dissoc :stroke-width)
(assoc-in [:strokes 0 :stroke-width] (-> (get-in shape [:svg-attrs :style :stroke-width])
(d/parse-double))))
linecap (or (get attrs :stroke-linecap)
(get style :stroke-linecap))
linecap (some-> linecap str/trim keyword)
(and stroke-linecap (= (:type shape) :path))
(-> (update-in [:svg-attrs :style] dissoc :stroke-linecap)
(cond-> (#{:round :square} stroke-linecap)
(assoc :stroke-cap-start stroke-linecap
:stroke-cap-end stroke-linecap))))]
attrs (-> attrs
(dissoc :stroke)
(dissoc :stroke-width)
(dissoc :stroke-opacity)
(update :style (fn [style]
(-> style
(dissoc :stroke)
(dissoc :stroke-linecap)
(dissoc :stroke-width)
(dissoc :stroke-opacity)))))]
(cond-> shape
(d/any-key? (get-in shape [:strokes 0]) :stroke-color :stroke-opacity :stroke-width :stroke-cap-start :stroke-cap-end)
(cond-> (assoc shape :svg-attrs attrs)
(some? color)
(assoc-in [:strokes 0 :stroke-color] color)
(and (some? color) (some? opacity))
(assoc-in [:strokes 0 :stroke-opacity] opacity)
(and (some? color) (some? width))
(assoc-in [:strokes 0 :stroke-width] width)
(and (some? linecap) (= (:type shape) :path)
(or (= linecap :round) (= linecap :square)))
(assoc :stroke-cap-start linecap
:stroke-cap-end linecap)
(d/any-key? (dm/get-in shape [:strokes 0])
:stroke-color :stroke-opacity :stroke-width
:stroke-cap-start :stroke-cap-end)
(assoc-in [:strokes 0 :stroke-style] :svg))))
(defn setup-opacity [shape]

View file

@ -106,7 +106,7 @@
(mf/set-ref-val! prev-val-ref node))))]
(mf/with-effect []
(mf/with-layout-effect []
;; On dismount we need to disconnect the current observer
(fn []
(when-let [observer (mf/ref-val observer-ref)]

View file

@ -89,7 +89,7 @@
(obj/merge! attrs (clj->js fill-attrs)))))
(defn add-stroke [attrs stroke-data render-id index]
(let [stroke-style (:stroke-style stroke-data :none)
(let [stroke-style (:stroke-style stroke-data :solid)
stroke-color-gradient-id (str "stroke-color-gradient_" render-id "_" index)
stroke-width (:stroke-width stroke-data 1)]
(if (not= stroke-style :none)

View file

@ -8,6 +8,7 @@
"Color conversion utils."
(:require
[app.common.data :as d]
[app.common.data.macros :as dm]
[app.util.i18n :as i18n :refer [tr]]
[app.util.object :as obj]
[app.util.strings :as ust]
@ -176,14 +177,16 @@
(= id :multiple)
(= file-id :multiple)))
(defn color? [^string color-str]
(and (not (nil? color-str))
(seq color-str)
(gcolor/isValidColor color-str)))
(defn color?
[color]
(and (string? color)
(gcolor/isValidColor color)))
(defn parse-color [^string color-str]
(let [result (gcolor/parse color-str)]
(str (.-hex ^js result))))
(defn parse-color
[color]
(when (color? color)
(let [result (gcolor/parse color)]
(dm/str (.-hex ^js result)))))
(def color-names
(obj/get-keys ^js gcolor/names))