0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-01 11:59:17 -05:00

Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Andrey Antukh 2024-11-05 09:10:14 +01:00
commit e6a9e27802
17 changed files with 143 additions and 53 deletions

View file

@ -6,7 +6,10 @@
### :boom: Breaking changes & Deprecations ### :boom: Breaking changes & Deprecations
- Use [nginx-unprivileged](https://hub.docker.com/r/nginxinc/nginx-unprivileged) as base image for Penpot's frontend docker image. Now all the docker images runs with the same unprivileged user (penpot). Because of that, the default NGINX listen port now is 8080, instead of 80, so you will have to modify your infrastructure to apply this change. - Use [nginx-unprivileged](https://hub.docker.com/r/nginxinc/nginx-unprivileged) as base image for
Penpot's frontend docker image. Now all the docker images runs with the same unprivileged user
(penpot). Because of that, the default NGINX listen port now is 8080, instead of 80, so you will
have to modify your infrastructure to apply this change.
### :heart: Community contributions (Thank you!) ### :heart: Community contributions (Thank you!)
@ -17,6 +20,14 @@
### :bug: Bugs fixed ### :bug: Bugs fixed
## 2.3.1
### :bug: Bugs fixed
- Fix unexpected issue on interaction between plugins sandbox and
internal impl of promise
## 2.3.0 ## 2.3.0
### :rocket: Epics and highlights ### :rocket: Epics and highlights

View file

@ -374,7 +374,7 @@
f.revn, f.revn,
f.vern, f.vern,
f.is_shared, f.is_shared,
ft.media_id ft.media_id AS thumbnail_id
from file as f from file as f
left join file_thumbnail as ft on (ft.file_id = f.id left join file_thumbnail as ft on (ft.file_id = f.id
and ft.revn = f.revn and ft.revn = f.revn
@ -385,13 +385,7 @@
(defn get-project-files (defn get-project-files
[conn project-id] [conn project-id]
(->> (db/exec! conn [sql:project-files project-id]) (db/exec! conn [sql:project-files project-id]))
(mapv (fn [row]
(if-let [media-id (:media-id row)]
(-> row
(dissoc :media-id)
(assoc :thumbnail-uri (resolve-public-uri media-id)))
(dissoc row :media-id))))))
(def schema:get-project-files (def schema:get-project-files
[:map {:title "get-project-files"} [:map {:title "get-project-files"}

View file

@ -467,7 +467,7 @@
#?(:clj (validate-shapes! data result items)) #?(:clj (validate-shapes! data result items))
result)))) result))))
;; DEPRECATED: remove before 2.3 release ;; DEPRECATED: remove after 2.3 release
(defmethod process-change :set-option (defmethod process-change :set-option
[data _] [data _]
data) data)

View file

@ -6,4 +6,4 @@
(ns app.common.files.defaults) (ns app.common.files.defaults)
(def version 56) (def version 57)

View file

@ -13,6 +13,7 @@
[app.common.files.defaults :as cfd] [app.common.files.defaults :as cfd]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt]
[app.common.geom.rect :as grc] [app.common.geom.rect :as grc]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.path :as gsp]
@ -1102,6 +1103,33 @@
(update :pages-index update-vals update-container) (update :pages-index update-vals update-container)
(update :components update-vals update-container)))) (update :components update-vals update-container))))
(defn migrate-up-57
[data]
(letfn [(fix-thread-positions [positions]
(reduce-kv (fn [result id {:keys [position] :as data}]
(let [data (cond
(gpt/point? position)
data
(and (map? position)
(gpt/valid-point-attrs? position))
(assoc data :position (gpt/point position))
:else
(assoc data :position (gpt/point 0 0)))]
(assoc result id data)))
positions
positions))
(update-page [page]
(d/update-when page :comment-thread-positions fix-thread-positions))]
(-> data
(update :pages (fn [pages] (into [] (remove nil?) pages)))
(update :pages-index dissoc nil)
(update :pages-index update-vals update-page))))
(def migrations (def migrations
"A vector of all applicable migrations" "A vector of all applicable migrations"
[{:id 2 :migrate-up migrate-up-2} [{:id 2 :migrate-up migrate-up-2}
@ -1149,4 +1177,6 @@
{:id 53 :migrate-up migrate-up-26} {:id 53 :migrate-up migrate-up-26}
{:id 54 :migrate-up migrate-up-54} {:id 54 :migrate-up migrate-up-54}
{:id 55 :migrate-up migrate-up-55} {:id 55 :migrate-up migrate-up-55}
{:id 56 :migrate-up migrate-up-56}]) {:id 56 :migrate-up migrate-up-56}
{:id 57 :migrate-up migrate-up-57}])

View file

@ -56,6 +56,9 @@
[:x ::sm/safe-number] [:x ::sm/safe-number]
[:y ::sm/safe-number]]) [:y ::sm/safe-number]])
(def valid-point-attrs?
(sm/validator schema:point-attrs))
(def valid-point? (def valid-point?
(sm/validator (sm/validator
[:and [:fn point?] schema:point-attrs])) [:and [:fn point?] schema:point-attrs]))

View file

@ -40,6 +40,7 @@
"watch:app": "concurrently \"clojure -M:dev:shadow-cljs watch main worker\" \"yarn run watch:app:libs\"", "watch:app": "concurrently \"clojure -M:dev:shadow-cljs watch main worker\" \"yarn run watch:app:libs\"",
"watch": "yarn run watch:app:assets", "watch": "yarn run watch:app:assets",
"watch:app:assets": "node ./scripts/watch.js", "watch:app:assets": "node ./scripts/watch.js",
"watch:app": "clojure -M:dev:shadow-cljs watch main",
"watch:storybook": "concurrently \"clojure -M:dev:shadow-cljs watch storybook\" \"storybook dev -p 6006 --no-open\" \"yarn run watch:storybook:assets\"", "watch:storybook": "concurrently \"clojure -M:dev:shadow-cljs watch storybook\" \"storybook dev -p 6006 --no-open\" \"yarn run watch:storybook:assets\"",
"watch:storybook:assets": "node ./scripts/watch-storybook.js" "watch:storybook:assets": "node ./scripts/watch-storybook.js"
}, },

View file

@ -18,6 +18,7 @@
[app.common.types.shape-tree :as ctst] [app.common.types.shape-tree :as ctst]
[app.main.data.changes :as dch] [app.main.data.changes :as dch]
[app.main.data.comments :as dc] [app.main.data.comments :as dc]
[app.main.data.events :as ev]
[app.main.data.workspace.edition :as dwe] [app.main.data.workspace.edition :as dwe]
[app.main.data.workspace.selection :as dws] [app.main.data.workspace.selection :as dws]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
@ -129,7 +130,9 @@
(dwu/commit-undo-transaction undo-id)) (dwu/commit-undo-transaction undo-id))
(when (cfh/text-shape? shape) (when (cfh/text-shape? shape)
(->> (rx/of (dwe/start-edition-mode (:id shape))) (->> (rx/of (dwe/start-edition-mode (:id shape)))
(rx/observe-on :async))))))))) (rx/observe-on :async)))
(when (cfh/frame-shape? shape)
(rx/of (ptk/event ::ev/event {::ev/name "add-frame"})))))))))
(defn move-shapes-into-frame (defn move-shapes-into-frame
[frame-id shapes] [frame-id shapes]

View file

@ -40,8 +40,7 @@
[app.plugins.viewport :as viewport] [app.plugins.viewport :as viewport]
[app.util.code-gen :as cg] [app.util.code-gen :as cg]
[app.util.object :as obj] [app.util.object :as obj]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]))
[promesa.core :as p]))
;; ;;
;; PLUGINS PUBLIC API - The plugins will able to access this functions ;; PLUGINS PUBLIC API - The plugins will able to access this functions
@ -174,7 +173,7 @@
:else :else
(let [file-id (:current-file-id @st/state)] (let [file-id (:current-file-id @st/state)]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(->> (dwm/upload-media-url name file-id url) (->> (dwm/upload-media-url name file-id url)
(rx/take 1) (rx/take 1)
@ -184,7 +183,7 @@
(uploadMediaData (uploadMediaData
[_ name data mime-type] [_ name data mime-type]
(let [file-id (:current-file-id @st/state)] (let [file-id (:current-file-id @st/state)]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(->> (dwm/process-blobs (->> (dwm/process-blobs
{:file-id file-id {:file-id file-id

View file

@ -19,13 +19,12 @@
[app.plugins.shape :as shape] [app.plugins.shape :as shape]
[app.plugins.user :as user] [app.plugins.user :as user]
[app.plugins.utils :as u] [app.plugins.utils :as u]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]))
[promesa.core :as p]))
(deftype CommentProxy [$plugin $file $page $thread $id] (deftype CommentProxy [$plugin $file $page $thread $id]
Object Object
(remove [_] (remove [_]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(cond (cond
(not (r/check-permission $plugin "comment:write")) (not (r/check-permission $plugin "comment:write"))
@ -79,7 +78,7 @@
Object Object
(findComments (findComments
[_] [_]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(cond (cond
(not (r/check-permission $plugin "comment:read")) (not (r/check-permission $plugin "comment:read"))
@ -106,7 +105,7 @@
(u/display-not-valid :reply "Not valid") (u/display-not-valid :reply "Not valid")
:else :else
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(->> (rp/cmd! :create-comment {:thread-id $id :content content}) (->> (rp/cmd! :create-comment {:thread-id $id :content content})
(rx/subs! #(resolve (comment-proxy $plugin $file $page $id $users %)) reject)))))) (rx/subs! #(resolve (comment-proxy $plugin $file $page $id $users %)) reject))))))
@ -121,9 +120,9 @@
(u/display-not-valid :remove "Cannot change content from another user's comments") (u/display-not-valid :remove "Cannot change content from another user's comments")
:else :else
(p/create (js/Promise.
(fn [resolve] (fn [resolve]
(p/create (js/Promise.
(st/emit! (dc/delete-comment-thread-on-workspace {:id $id} #(resolve)))))))))) (st/emit! (dc/delete-comment-thread-on-workspace {:id $id} #(resolve))))))))))
(defn comment-thread-proxy? [p] (defn comment-thread-proxy? [p]

View file

@ -21,8 +21,7 @@
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.http :as http] [app.util.http :as http]
[app.util.object :as obj] [app.util.object :as obj]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]))
[promesa.core :as p]))
(deftype FileProxy [$plugin $id] (deftype FileProxy [$plugin $id]
Object Object
@ -133,7 +132,7 @@
:binfile-v3 :binfile-v3
:binfile-v1) :binfile-v1)
"zip" :legacy-zip)] "zip" :legacy-zip)]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(->> (uw/ask-many! (->> (uw/ask-many!
{:cmd :export-files {:cmd :export-files

View file

@ -30,8 +30,7 @@
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj] [app.util.object :as obj]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[potok.v2.core :as ptk] [potok.v2.core :as ptk]))
[promesa.core :as p]))
(declare lib-color-proxy) (declare lib-color-proxy)
(declare lib-typography-proxy) (declare lib-typography-proxy)
@ -915,7 +914,7 @@
(availableLibraries (availableLibraries
[_] [_]
(let [team-id (:current-team-id @st/state)] (let [team-id (:current-team-id @st/state)]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(let [current-libs (into #{} (map first) (get @st/state :workspace-libraries))] (let [current-libs (into #{} (map first) (get @st/state :workspace-libraries))]
(->> (rp/cmd! :get-team-shared-files {:team-id team-id}) (->> (rp/cmd! :get-team-shared-files {:team-id team-id})
@ -939,7 +938,7 @@
(u/display-not-valid :connectLibrary "Plugin doesn't have 'library:write' permission") (u/display-not-valid :connectLibrary "Plugin doesn't have 'library:write' permission")
:else :else
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(cond (cond
(not (string? library-id)) (not (string? library-id))

View file

@ -29,8 +29,7 @@
[app.plugins.utils :as u] [app.plugins.utils :as u]
[app.util.object :as obj] [app.util.object :as obj]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]))
[promesa.core :as p]))
(deftype FlowProxy [$plugin $file $page $id] (deftype FlowProxy [$plugin $file $page $id]
Object Object
@ -288,7 +287,7 @@
(some? board) (some? board)
(-> (update :x - (:x board)) (-> (update :x - (:x board))
(update :y - (:y board))))] (update :y - (:y board))))]
(p/create (js/Promise.
(fn [resolve] (fn [resolve]
(st/emit! (st/emit!
(dc/create-thread-on-workspace (dc/create-thread-on-workspace
@ -315,10 +314,10 @@
(u/display-not-valid :removeCommentThread "Plugin doesn't have 'content:write' permission") (u/display-not-valid :removeCommentThread "Plugin doesn't have 'content:write' permission")
:else :else
(p/create (js/Promise.
(fn [resolve] (fn [resolve]
(let [thread-id (obj/get thread "$id")] (let [thread-id (obj/get thread "$id")]
(p/create (js/Promise.
(st/emit! (dc/delete-comment-thread-on-workspace {:id thread-id} #(resolve))))))))) (st/emit! (dc/delete-comment-thread-on-workspace {:id thread-id} #(resolve)))))))))
(findCommentThreads (findCommentThreads
@ -326,7 +325,7 @@
(let [only-yours (boolean (obj/get criteria "onlyYours" false)) (let [only-yours (boolean (obj/get criteria "onlyYours" false))
show-resolved (boolean (obj/get criteria "showResolved" true)) show-resolved (boolean (obj/get criteria "showResolved" true))
user-id (-> @st/state :profile :id)] user-id (-> @st/state :profile :id)]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(cond (cond
(not (r/check-permission $plugin "comment:read")) (not (r/check-permission $plugin "comment:read"))

View file

@ -52,8 +52,7 @@
[app.util.object :as obj] [app.util.object :as obj]
[app.util.path.format :as upf] [app.util.path.format :as upf]
[beicon.v2.core :as rx] [beicon.v2.core :as rx]
[cuerdas.core :as str] [cuerdas.core :as str]))
[promesa.core :as p]))
(declare shape-proxy) (declare shape-proxy)
(declare shape-proxy?) (declare shape-proxy?)
@ -542,7 +541,7 @@
:type (:type value :png) :type (:type value :png)
:suffix (:suffix value "") :suffix (:suffix value "")
:scale (:scale value 1)}]}] :scale (:scale value 1)}]}]
(p/create (js/Promise.
(fn [resolve reject] (fn [resolve reject]
(->> (rp/cmd! :export payload) (->> (rp/cmd! :export payload)
(rx/mapcat #(rp/cmd! :export {:cmd :get-resource :wait true :id (:id %) :blob? true})) (rx/mapcat #(rp/cmd! :export {:cmd :get-resource :wait true :id (:id %) :blob? true}))
@ -952,7 +951,7 @@
;; Geometry properties ;; Geometry properties
{:name "x" {:name "x"
:get #(-> % u/proxy->shape :x) :get #(-> % u/proxy->shape :points grc/points->rect :x)
:set :set
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
@ -967,7 +966,7 @@
(st/emit! (dw/update-position id {:x value})))))} (st/emit! (dw/update-position id {:x value})))))}
{:name "y" {:name "y"
:get #(-> % u/proxy->shape :y) :get #(-> % u/proxy->shape :points grc/points->rect :y)
:set :set
(fn [self value] (fn [self value]
(let [id (obj/get self "$id")] (let [id (obj/get self "$id")]
@ -991,9 +990,10 @@
{:name "parentX" {:name "parentX"
:get (fn [self] :get (fn [self]
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
shape-x (-> shape :points grc/points->rect :x)
parent-id (:parent-id shape) parent-id (:parent-id shape)
parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id)] parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id)]
(- (:x shape) (:x parent)))) (- shape-x (:x parent))))
:set :set
(fn [self value] (fn [self value]
(cond (cond
@ -1013,10 +1013,11 @@
{:name "parentY" {:name "parentY"
:get (fn [self] :get (fn [self]
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
shape-y (-> shape :points grc/points->rect :y)
parent-id (:parent-id shape) parent-id (:parent-id shape)
parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id) parent (u/locate-shape (obj/get self "$file") (obj/get self "$page") parent-id)
parent-y (:y parent)] parent-y (:y parent)]
(- (:y shape) parent-y))) (- shape-y parent-y)))
:set :set
(fn [self value] (fn [self value]
(cond (cond
@ -1036,10 +1037,11 @@
{:name "boardX" {:name "boardX"
:get (fn [self] :get (fn [self]
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
shape-x (-> shape :points grc/points->rect :x)
frame-id (:parent-id shape) frame-id (:parent-id shape)
frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id) frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id)
frame-x (:x frame)] frame-x (:x frame)]
(- (:x shape) frame-x))) (- shape-x frame-x)))
:set :set
(fn [self value] (fn [self value]
(cond (cond
@ -1059,10 +1061,11 @@
{:name "boardY" {:name "boardY"
:get (fn [self] :get (fn [self]
(let [shape (u/proxy->shape self) (let [shape (u/proxy->shape self)
shape-y (-> shape :points grc/points->rect :y)
frame-id (:parent-id shape) frame-id (:parent-id shape)
frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id) frame (u/locate-shape (obj/get self "$file") (obj/get self "$page") frame-id)
frame-y (:y frame)] frame-y (:y frame)]
(- (:y shape) frame-y))) (- shape-y frame-y)))
:set :set
(fn [self value] (fn [self value]
(cond (cond
@ -1080,10 +1083,10 @@
(st/emit! (dw/update-position id {:y (+ frame-y value)})))))} (st/emit! (dw/update-position id {:y (+ frame-y value)})))))}
{:name "width" {:name "width"
:get #(-> % u/proxy->shape :width)} :get #(-> % u/proxy->shape :selrect :width)}
{:name "height" {:name "height"
:get #(-> % u/proxy->shape :height)} :get #(-> % u/proxy->shape :selrect :height)}
{:name "bounds" {:name "bounds"
:get #(-> % u/proxy->shape :points grc/points->rect format/format-bounds)} :get #(-> % u/proxy->shape :points grc/points->rect format/format-bounds)}

View file

@ -12,8 +12,7 @@
[app.common.types.container :as ctn] [app.common.types.container :as ctn]
[app.common.types.file :as ctf] [app.common.types.file :as ctf]
[app.main.store :as st] [app.main.store :as st]
[app.util.object :as obj] [app.util.object :as obj]))
[promesa.core :as p]))
(defn locate-file (defn locate-file
[id] [id]
@ -175,7 +174,7 @@
[] []
(let [ret-v (atom nil) (let [ret-v (atom nil)
ret-p ret-p
(p/create (js/Promise.
(fn [resolve _] (fn [resolve _]
(add-watch (add-watch
ret-v ret-v

View file

@ -177,13 +177,59 @@ function build-exporter-bundle {
rm -rf $bundle_dir; rm -rf $bundle_dir;
mv ./exporter/target $bundle_dir; mv ./exporter/target $bundle_dir;
echo $version > $bundle_dir/version.txt echo $version > $bundle_dir/version.txt
put-license-file $bundle_dir; put-license-file $bundle_dir;
echo ">> bundle exporter end"; echo ">> bundle exporter end";
} }
function build-docs-bundle {
echo ">> bundle docs start";
mkdir -p ./bundles
local version=$(print-current-version);
local bundle_dir="./bundles/docs";
build "docs";
rm -rf $bundle_dir;
mv ./docs/_dist $bundle_dir;
echo $version > $bundle_dir/version.txt;
put-license-file $bundle_dir;
echo ">> bundle docs end";
}
function build-frontend-docker-images {
rsync -avr --delete ./bundles/frontend/ ./docker/images/bundle-frontend/;
pushd ./docker/images;
docker build -t penpotapp/frontend:$CURRENT_BRANCH -t penpotapp/frontend:latest -f Dockerfile.frontend .;
popd;
}
function build-backend-docker-images {
rsync -avr --delete ./bundles/backend/ ./docker/images/bundle-backend/;
pushd ./docker/images;
docker build -t penpotapp/backend:$CURRENT_BRANCH -t penpotapp/backend:latest -f Dockerfile.backend .;
popd;
}
function build-exporter-docker-images {
rsync -avr --delete ./bundles/exporter/ ./docker/images/bundle-exporter/;
pushd ./docker/images;
docker build -t penpotapp/exporter:$CURRENT_BRANCH -t penpotapp/exporter:latest -f Dockerfile.exporter .;
popd;
}
function usage {
echo "PENPOT build & release manager"
echo "USAGE: $0 OPTION"
echo "Options:"
echo "- pull-devenv Pulls docker development oriented image"
echo "- build-devenv Build docker development oriented image"
echo "- build-devenv-local Build a local docker development oriented image"
echo "- create-devenv Create the development oriented docker compose service."
echo "- start-devenv Start the development oriented docker compose service."
function build-frontend-docker-images { function build-frontend-docker-images {
rsync -avr --delete ./bundles/frontend/ ./docker/images/bundle-frontend/; rsync -avr --delete ./bundles/frontend/ ./docker/images/bundle-frontend/;
pushd ./docker/images; pushd ./docker/images;
@ -224,6 +270,7 @@ function usage {
echo "- build-frontend-bundle Build frontend bundle" echo "- build-frontend-bundle Build frontend bundle"
echo "- build-backend-bundle Build backend bundle." echo "- build-backend-bundle Build backend bundle."
echo "- build-exporter-bundle Build exporter bundle." echo "- build-exporter-bundle Build exporter bundle."
echo "- build-docs-bundle Build docs bundle."
echo "" echo ""
echo "- build-docker-images Build all docker images (frontend, backend and exporter)." echo "- build-docker-images Build all docker images (frontend, backend and exporter)."
echo "- build-frontend-docker-images Build frontend docker images." echo "- build-frontend-docker-images Build frontend docker images."
@ -293,6 +340,10 @@ case $1 in
build-exporter-bundle; build-exporter-bundle;
;; ;;
build-docs-bundle)
build-docs-bundle;
;;
build-docker-images) build-docker-images)
build-frontend-docker-images build-frontend-docker-images
build-backend-docker-images build-backend-docker-images