mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 04:49:03 -05:00
Merge remote-tracking branch 'origin/staging' into develop
This commit is contained in:
commit
496afb0f25
11 changed files with 40 additions and 63 deletions
|
@ -15,7 +15,7 @@ export PENPOT_FLAGS="\
|
||||||
enable-fdata-storage-objets-map \
|
enable-fdata-storage-objets-map \
|
||||||
disable-secure-session-cookies \
|
disable-secure-session-cookies \
|
||||||
enable-smtp \
|
enable-smtp \
|
||||||
enable-webhooks";
|
enable-access-tokens";
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
(let [explain (ex/explain data)]
|
(let [explain (ex/explain data)]
|
||||||
{::yrs/status 400
|
{::yrs/status 400
|
||||||
::yrs/body (-> data
|
::yrs/body (-> data
|
||||||
(dissoc ::s/problems ::s/value)
|
(dissoc ::s/problems ::s/value ::s/spec)
|
||||||
(cond-> explain (assoc :explain explain)))})
|
(cond-> explain (assoc :explain explain)))})
|
||||||
|
|
||||||
(= code :params-validation)
|
(= code :params-validation)
|
||||||
|
|
|
@ -516,6 +516,9 @@
|
||||||
:media (count media)
|
:media (count media)
|
||||||
::l/sync? true)
|
::l/sync? true)
|
||||||
|
|
||||||
|
(doseq [item media]
|
||||||
|
(l/debug :hint "write penpot file media object" :id (:id item) ::l/sync? true))
|
||||||
|
|
||||||
(doto output
|
(doto output
|
||||||
(write-obj! file)
|
(write-obj! file)
|
||||||
(write-obj! media))
|
(write-obj! media))
|
||||||
|
@ -770,7 +773,7 @@
|
||||||
(defn- lookup-index
|
(defn- lookup-index
|
||||||
[id]
|
[id]
|
||||||
(let [val (get-in @*state* [:index id])]
|
(let [val (get-in @*state* [:index id])]
|
||||||
(l/trace :fn "lookup-index" :id id :val val ::l/sync? true)
|
(l/debug :fn "lookup-index" :id id :val val ::l/sync? true)
|
||||||
(when (and (not (::ignore-index-errors? *options*)) (not val))
|
(when (and (not (::ignore-index-errors? *options*)) (not val))
|
||||||
(ex/raise :type :validation
|
(ex/raise :type :validation
|
||||||
:code :incomplete-index
|
:code :incomplete-index
|
||||||
|
@ -783,7 +786,7 @@
|
||||||
index index]
|
index index]
|
||||||
(if-let [id (first items)]
|
(if-let [id (first items)]
|
||||||
(let [new-id (if (::overwrite? *options*) id (uuid/next))]
|
(let [new-id (if (::overwrite? *options*) id (uuid/next))]
|
||||||
(l/trace :fn "update-index" :id id :new-id new-id ::l/sync? true)
|
(l/debug :fn "update-index" :id id :new-id new-id ::l/sync? true)
|
||||||
(recur (rest items)
|
(recur (rest items)
|
||||||
(assoc index id new-id)))
|
(assoc index id new-id)))
|
||||||
index)))
|
index)))
|
||||||
|
@ -801,8 +804,7 @@
|
||||||
(update-in [:metadata :id] lookup-index)
|
(update-in [:metadata :id] lookup-index)
|
||||||
|
|
||||||
;; Relink paths with fill image
|
;; Relink paths with fill image
|
||||||
(and (map? (:fill-image form))
|
(map? (:fill-image form))
|
||||||
(= :path (:type form)))
|
|
||||||
(update-in [:fill-image :id] lookup-index)
|
(update-in [:fill-image :id] lookup-index)
|
||||||
|
|
||||||
;; This covers old shapes and the new :fills.
|
;; This covers old shapes and the new :fills.
|
||||||
|
|
|
@ -378,21 +378,6 @@
|
||||||
[{:keys [::rpc/profile-id]} {:keys [modified-at revn]}]
|
[{:keys [::rpc/profile-id]} {:keys [modified-at revn]}]
|
||||||
(str profile-id (dt/format-instant modified-at :iso) revn))
|
(str profile-id (dt/format-instant modified-at :iso) revn))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(sv/defmethod ::hey
|
|
||||||
{::doc/added "1.17"
|
|
||||||
::rpc/auth false}
|
|
||||||
[_ _]
|
|
||||||
(str (rand-int 100)))
|
|
||||||
|
|
||||||
(sv/defmethod ::ho
|
|
||||||
{::doc/added "1.17"
|
|
||||||
::rpc/auth false}
|
|
||||||
[_ _]
|
|
||||||
(str (rand-int 1000)))
|
|
||||||
|
|
||||||
|
|
||||||
(sv/defmethod ::get-file
|
(sv/defmethod ::get-file
|
||||||
"Retrieve a file by its ID. Only authenticated users."
|
"Retrieve a file by its ID. Only authenticated users."
|
||||||
{::doc/added "1.17"
|
{::doc/added "1.17"
|
||||||
|
|
|
@ -113,8 +113,15 @@
|
||||||
(mapcat vals)
|
(mapcat vals)
|
||||||
(keep (fn [{:keys [type] :as obj}]
|
(keep (fn [{:keys [type] :as obj}]
|
||||||
(case type
|
(case type
|
||||||
:path (get-in obj [:fill-image :id])
|
:path (get-in obj [:fill-image :id])
|
||||||
|
:bool (get-in obj [:fill-image :id])
|
||||||
|
;; NOTE: because of some bug, we ended with
|
||||||
|
;; many shape types having the ability to
|
||||||
|
;; have fill-image attribute (which initially
|
||||||
|
;; designed for :path shapes).
|
||||||
|
:group (get-in obj [:fill-image :id])
|
||||||
:image (get-in obj [:metadata :id])
|
:image (get-in obj [:metadata :id])
|
||||||
|
|
||||||
nil))))
|
nil))))
|
||||||
pages (concat
|
pages (concat
|
||||||
(vals (:pages-index data))
|
(vals (:pages-index data))
|
||||||
|
|
|
@ -574,8 +574,11 @@
|
||||||
(l/trace :hint "register cron task" :id id :cron (str cron))
|
(l/trace :hint "register cron task" :id id :cron (str cron))
|
||||||
(db/exec-one! conn [sql:upsert-cron-task id (str cron) (str cron)]))))
|
(db/exec-one! conn [sql:upsert-cron-task id (str cron) (str cron)]))))
|
||||||
|
|
||||||
(def sql:lock-cron-task
|
(defn- lock-scheduled-task!
|
||||||
"select id from scheduled_task where id=? for update skip locked")
|
[conn id]
|
||||||
|
(let [sql (str "SELECT id FROM scheduled_task "
|
||||||
|
" WHERE id=? FOR UPDATE SKIP LOCKED")]
|
||||||
|
(some? (db/exec-one! conn [sql (d/name id)]))))
|
||||||
|
|
||||||
(defn- execute-cron-task
|
(defn- execute-cron-task
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [id] :as task}]
|
[{:keys [::db/pool] :as cfg} {:keys [id] :as task}]
|
||||||
|
@ -583,11 +586,16 @@
|
||||||
{:name (str "penpot/cront-task/" id)}
|
{:name (str "penpot/cront-task/" id)}
|
||||||
(try
|
(try
|
||||||
(db/with-atomic [conn pool]
|
(db/with-atomic [conn pool]
|
||||||
(when (db/exec-one! conn [sql:lock-cron-task (d/name id)])
|
(db/exec-one! conn ["SET statement_timeout=0;"])
|
||||||
|
(db/exec-one! conn ["SET idle_in_transaction_session_timeout=0;"])
|
||||||
|
(when (lock-scheduled-task! conn id)
|
||||||
(l/trace :hint "cron: execute task" :task-id id)
|
(l/trace :hint "cron: execute task" :task-id id)
|
||||||
((:fn task) task)))
|
((:fn task) task))
|
||||||
|
(db/rollback! conn))
|
||||||
|
|
||||||
(catch InterruptedException _
|
(catch InterruptedException _
|
||||||
(l/debug :hint "cron: task interrupted" :task-id id))
|
(l/debug :hint "cron: task interrupted" :task-id id))
|
||||||
|
|
||||||
(catch Throwable cause
|
(catch Throwable cause
|
||||||
(binding [l/*context* (get-error-context cause task)]
|
(binding [l/*context* (get-error-context cause task)]
|
||||||
(l/error :hint "cron: unhandled exception on running task"
|
(l/error :hint "cron: unhandled exception on running task"
|
||||||
|
|
|
@ -382,8 +382,10 @@
|
||||||
keyword
|
keyword
|
||||||
identity)}}))})
|
identity)}}))})
|
||||||
|
|
||||||
(def max-safe-int (int 1e6))
|
;; Integer/MAX_VALUE
|
||||||
(def min-safe-int (int -1e6))
|
(def max-safe-int 2147483647)
|
||||||
|
;; Integer/MIN_VALUE
|
||||||
|
(def min-safe-int -2147483648)
|
||||||
|
|
||||||
(def! ::safe-int
|
(def! ::safe-int
|
||||||
{:type ::safe-int
|
{:type ::safe-int
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
(log/setup! {:app :info})
|
(log/setup! {:app :info})
|
||||||
|
|
||||||
(when (= :browser cf/target)
|
(when (= :browser cf/target)
|
||||||
(log/info :message "Hey!,Welcome to penpot"
|
(log/info :message "Welcome to penpot"
|
||||||
:version (:full cf/version)
|
:version (:full cf/version)
|
||||||
:asserts *assert*
|
:asserts *assert*
|
||||||
:build-date cf/build-date
|
:build-date cf/build-date
|
||||||
|
|
|
@ -518,29 +518,6 @@
|
||||||
(->> (rp/cmd! :get-access-tokens)
|
(->> (rp/cmd! :get-access-tokens)
|
||||||
(rx/map access-tokens-fetched)))))
|
(rx/map access-tokens-fetched)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn heyhey-fetched
|
|
||||||
[value]
|
|
||||||
(ptk/reify ::heyhey-fetched
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(assoc state :hey-value value))))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn fetch-heyhey
|
|
||||||
[]
|
|
||||||
(ptk/reify ::fetch-heyhey
|
|
||||||
ptk/WatchEvent
|
|
||||||
(watch [_ _ _]
|
|
||||||
(->> (rp/cmd! :hey)
|
|
||||||
(rx/map heyhey-fetched)))))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;; --- EVENT: create-access-token
|
;; --- EVENT: create-access-token
|
||||||
|
|
||||||
(defn access-token-created
|
(defn access-token-created
|
||||||
|
|
|
@ -260,21 +260,16 @@
|
||||||
[:& access-token-actions
|
[:& access-token-actions
|
||||||
{:on-delete on-delete}]]]))
|
{:on-delete on-delete}]]]))
|
||||||
|
|
||||||
(def hey-ref
|
|
||||||
(l/derived :hey-value st/state))
|
|
||||||
|
|
||||||
(mf/defc access-tokens-page
|
(mf/defc access-tokens-page
|
||||||
[]
|
[]
|
||||||
(mf/with-effect []
|
(mf/with-effect []
|
||||||
(dom/set-html-title (tr "title.settings.access-tokens"))
|
(dom/set-html-title (tr "title.settings.access-tokens"))
|
||||||
(st/emit! (du/fetch-access-tokens))
|
(st/emit! (du/fetch-access-tokens)))
|
||||||
(st/emit! (du/fetch-heyhey)))
|
|
||||||
|
|
||||||
(let [tokens (mf/deref tokens-ref)
|
(let [tokens (mf/deref tokens-ref)]
|
||||||
hey (mf/deref hey-ref)]
|
[:div.dashboard-access-tokens
|
||||||
[:div.dashboard-access-tokens {:style {:background "pink"}}
|
|
||||||
[:div
|
[:div
|
||||||
[:div {:on-click #(st/emit! (du/fetch-heyhey))} hey]
|
[:& access-tokens-hero]
|
||||||
(if (empty? tokens)
|
(if (empty? tokens)
|
||||||
[:div.access-tokens-empty
|
[:div.access-tokens-empty
|
||||||
[:div (tr "dashboard.access-tokens.empty.no-access-tokens")]
|
[:div (tr "dashboard.access-tokens.empty.no-access-tokens")]
|
||||||
|
|
|
@ -97,11 +97,12 @@
|
||||||
(defn- svg-update-image!
|
(defn- svg-update-image!
|
||||||
"Updates an image in an SVG to a Data URI."
|
"Updates an image in an SVG to a Data URI."
|
||||||
[image]
|
[image]
|
||||||
(when-let [href (dom/get-attribute image "href")]
|
(if-let [href (dom/get-attribute image "href")]
|
||||||
(->> (fetch-as-data-uri href)
|
(->> (fetch-as-data-uri href)
|
||||||
(rx/map (fn [url]
|
(rx/map (fn [url]
|
||||||
(dom/set-attribute! image "href" url)
|
(dom/set-attribute! image "href" url)
|
||||||
image)))))
|
image)))
|
||||||
|
(rx/empty)))
|
||||||
|
|
||||||
(defn- svg-resolve-images!
|
(defn- svg-resolve-images!
|
||||||
"Resolves all images in an SVG to Data URIs."
|
"Resolves all images in an SVG to Data URIs."
|
||||||
|
|
Loading…
Add table
Reference in a new issue