0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 01:21:21 -05:00

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

This commit is contained in:
Alejandro Alonso 2024-11-25 11:18:47 +01:00
commit 61e19ae3a8
15 changed files with 77 additions and 72 deletions

View file

@ -39,11 +39,12 @@
### :sparkles: New features ### :sparkles: New features
- Viewer role for team members [Taiga #1056 & #6590](https://tree.taiga.io/project/penpot/us/1056 & https://tree.taiga.io/project/penpot/us/6590) - Viewer role for team members [Taiga #1056 & #6590](https://tree.taiga.io/project/penpot/us/1056 & https://tree.taiga.io/project/penpot/us/6590)
- File history versions management [Taiga](https://tree.taiga.io/project/penpot/us/187?milestone=411120) - File history versions management [Taiga #187](https://tree.taiga.io/project/penpot/us/187?milestone=411120)
- Rename selected layer via keyboard shortcut and context menu option [Taiga #8882](https://tree.taiga.io/project/penpot/us/8882) - Rename selected layer via keyboard shortcut and context menu option [Taiga #8882](https://tree.taiga.io/project/penpot/us/8882)
### :bug: Bugs fixed ### :bug: Bugs fixed
- Fix problem with some texts desynchronization [Taiga #9379](https://tree.taiga.io/project/penpot/issue/9379)
## 2.3.3 ## 2.3.3

View file

@ -50,8 +50,7 @@
" where file_id=? and tag=? and deleted_at is null") " where file_id=? and tag=? and deleted_at is null")
res (db/exec! conn [sql file-id tag])] res (db/exec! conn [sql file-id tag])]
(->> res (->> res
(d/index-by :object-id (fn [row] (d/index-by :object-id :media-id)
(files/resolve-public-uri (:media-id row))))
(d/without-nils)))) (d/without-nils))))
(defn- get-object-thumbnails (defn- get-object-thumbnails
@ -62,8 +61,7 @@
" where file_id=? and deleted_at is null") " where file_id=? and deleted_at is null")
res (db/exec! conn [sql file-id])] res (db/exec! conn [sql file-id])]
(->> res (->> res
(d/index-by :object-id (fn [row] (d/index-by :object-id :media-id)
(files/resolve-public-uri (:media-id row))))
(d/without-nils)))) (d/without-nils))))
([conn file-id object-ids] ([conn file-id object-ids]
@ -75,8 +73,7 @@
res (db/exec! conn [sql file-id ids])] res (db/exec! conn [sql file-id ids])]
(->> res (->> res
(d/index-by :object-id (fn [row] (d/index-by :object-id :media-id)
(files/resolve-public-uri (:media-id row))))
(d/without-nils))))) (d/without-nils)))))
(sv/defmethod ::get-file-object-thumbnails (sv/defmethod ::get-file-object-thumbnails
@ -127,8 +124,11 @@
(if-let [frame (-> frames first)] (if-let [frame (-> frames first)]
(let [frame-id (:id frame) (let [frame-id (:id frame)
object-id (thc/fmt-object-id (:id file) page-id frame-id "frame") object-id (thc/fmt-object-id (:id file) page-id frame-id "frame")
frame (if-let [thumb (get thumbnails object-id)]
(assoc frame :thumbnail thumb :shapes []) frame (if-let [media-id (get thumbnails object-id)]
(-> frame
(assoc :thumbnail-id media-id)
(assoc :shapes []))
(dissoc frame :thumbnail)) (dissoc frame :thumbnail))
children-ids children-ids

View file

@ -1090,8 +1090,7 @@
(t/is (contains? result :file-id)) (t/is (contains? result :file-id))
(t/is (= (:id file) (:file-id result))) (t/is (= (:id file) (:file-id result)))
(t/is (str/starts-with? (get-in result [:page :objects frame1-id :thumbnail]) (t/is (uuid? (get-in result [:page :objects frame1-id :thumbnail-id])))
"http://localhost:3449/assets/by-id/"))
(t/is (= [] (get-in result [:page :objects frame1-id :shapes])))) (t/is (= [] (get-in result [:page :objects frame1-id :shapes]))))
;; Delete thumbnail data ;; Delete thumbnail data

View file

@ -58,10 +58,11 @@ test("Save and restore version", async ({ page }) => {
await page.getByRole("textbox").press("Enter"); await page.getByRole("textbox").press("Enter");
await page await page
.locator("li") .getByLabel("History", { exact: true })
.filter({ hasText: "INIT" }) .locator("div")
.getByRole("button") .nth(3)
.click(); .hover();
await page.getByRole("button", { name: "Open version menu" }).click();
await page.getByRole("button", { name: "Restore" }).click(); await page.getByRole("button", { name: "Restore" }).click();
await workspacePage.mockRPC( await workspacePage.mockRPC(

View file

@ -237,13 +237,18 @@ async function renderTemplate(path, context = {}, partials = {}) {
return mustache.render(content, context, partials); return mustache.render(content, context, partials);
} }
const renderer = { const extension = {
link(href, title, text) { useNewRenderer: true,
return `<a href="${href}" target="_blank">${text}</a>`; renderer: {
link(token) {
const href = token.href;
const text = token.text;
return `<a href="${href}" target="_blank">${text}</a>`;
},
}, },
}; };
marked.use({ renderer }); marked.use(extension);
async function readTranslations() { async function readTranslations() {
const langs = [ const langs = [

View file

@ -12,7 +12,6 @@
[app.common.schema :as sm] [app.common.schema :as sm]
[app.common.types.components-list :as ctkl] [app.common.types.components-list :as ctkl]
[app.common.types.team :as ctt] [app.common.types.team :as ctt]
[app.config :as cf]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.data.notifications :as ntf] [app.main.data.notifications :as ntf]
[app.main.features :as features] [app.main.features :as features]
@ -75,15 +74,13 @@
(watch [_ _ _] (watch [_ _ _]
(case code (case code
:upgrade-version :upgrade-version
(when (or (not= (:version params) (:full cf/version)) (rx/of (ntf/dialog
(true? (:force params))) :content (tr "notifications.by-code.upgrade-version")
(rx/of (ntf/dialog :controls :inline-actions
:content (tr "notifications.by-code.upgrade-version") :type :inline
:controls :inline-actions :level level
:type :inline :actions [{:label "Refresh" :callback force-reload!}]
:level level :tag :notification))
:actions [{:label "Refresh" :callback force-reload!}]
:tag :notification)))
:maintenance :maintenance
(rx/of (ntf/dialog (rx/of (ntf/dialog

View file

@ -199,18 +199,21 @@
;; Load libraries ;; Load libraries
(->> (rp/cmd! :get-file-libraries {:file-id file-id}) (->> (rp/cmd! :get-file-libraries {:file-id file-id})
(rx/mapcat identity) (rx/mapcat (fn [libraries]
(rx/merge-map (rx/merge
(fn [{:keys [id synced-at]}] (->> (rx/from libraries)
(->> (rp/cmd! :get-file {:id id :features features}) (rx/merge-map
(rx/map #(assoc % :synced-at synced-at))))) (fn [{:keys [id synced-at]}]
(rx/merge-map fpmap/resolve-file) (->> (rp/cmd! :get-file {:id id :features features})
(rx/merge-map (rx/map #(assoc % :synced-at synced-at)))))
(fn [{:keys [id] :as file}] (rx/merge-map fpmap/resolve-file)
(->> (rp/cmd! :get-file-object-thumbnails {:file-id id :tag "component"}) (rx/reduce conj [])
(rx/map #(assoc file :thumbnails %))))) (rx/map libraries-fetched))
(rx/reduce conj []) (->> (rx/from libraries)
(rx/map libraries-fetched))) (rx/map :id)
(rx/mapcat (fn [file-id]
(rp/cmd! :get-file-object-thumbnails {:file-id file-id :tag "component"})))
(rx/map dwl/library-thumbnails-fetched)))))))
(rx/of (with-meta (workspace-initialized) (rx/of (with-meta (workspace-initialized)
{:file-id file-id}))) {:file-id file-id})))

View file

@ -881,11 +881,9 @@
(rx/of (rx/of
(dwu/start-undo-transaction undo-id) (dwu/start-undo-transaction undo-id)
(update-component shape-id undo-group) (update-component shape-id undo-group)
(sync-file current-file-id file-id :components (:component-id shape) undo-group) (sync-file current-file-id file-id :components component-id undo-group)
(update-component-thumbnail-sync state component-id file-id "frame")
(update-component-thumbnail-sync state component-id file-id "component")
(when (not current-file?) (when (not current-file?)
(sync-file file-id file-id :components (:component-id shape) undo-group)) (sync-file file-id file-id :components component-id undo-group))
(dwu/commit-undo-transaction undo-id))))))) (dwu/commit-undo-transaction undo-id)))))))
(defn launch-component-sync (defn launch-component-sync
@ -937,9 +935,9 @@
;; in the grid creating new rows/columns to make space ;; in the grid creating new rows/columns to make space
(let [file (wsh/get-file state file-id) (let [file (wsh/get-file state file-id)
libraries (wsh/get-libraries state) libraries (wsh/get-libraries state)
page (wsh/lookup-page state) page (wsh/lookup-page state)
objects (wsh/lookup-page-objects state) objects (wsh/lookup-page-objects state)
parent (get objects (:parent-id shape)) parent (get objects (:parent-id shape))
;; If the target parent is a grid layout we need to pass the target cell ;; If the target parent is a grid layout we need to pass the target cell
target-cell (when (ctl/grid-layout? parent) target-cell (when (ctl/grid-layout? parent)

View file

@ -168,7 +168,7 @@
(.error js/console cause) (.error js/console cause)
(rx/empty))) (rx/empty)))
(rx/tap #(l/trc :hint "thumbnail updated" :elapsed (dm/str (tp) "ms"))) (rx/tap #(l/dbg :hint "thumbnail updated" :elapsed (dm/str (tp) "ms")))
;; We cancel all the stream if user starts editing while ;; We cancel all the stream if user starts editing while
;; thumbnail is generating ;; thumbnail is generating

View file

@ -13,6 +13,7 @@
[app.common.types.shape-tree :as ctt] [app.common.types.shape-tree :as ctt]
[app.common.types.shape.layout :as ctl] [app.common.types.shape.layout :as ctl]
[app.common.types.tokens-lib :as ctob] [app.common.types.tokens-lib :as ctob]
[app.config :as cf]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[app.main.store :as st] [app.main.store :as st]
[app.main.ui.workspace.tokens.token-set :as wtts] [app.main.ui.workspace.tokens.token-set :as wtts]
@ -588,7 +589,8 @@
[object-id] [object-id]
(l/derived (l/derived
(fn [state] (fn [state]
(dm/get-in state [:workspace-thumbnails object-id])) (some-> (dm/get-in state [:workspace-thumbnails object-id])
(cf/resolve-media)))
st/state)) st/state))
(def workspace-text-modifier (def workspace-text-modifier

View file

@ -135,7 +135,7 @@
bounds (mf/with-memo [bounds points] bounds (mf/with-memo [bounds points]
(or bounds (gsb/get-frame-bounds shape))) (or bounds (gsb/get-frame-bounds shape)))
thumb (:thumbnail shape) thumb (cf/resolve-media (:thumbnail-id shape))
debug? (dbg/enabled? :thumbnails) debug? (dbg/enabled? :thumbnails)
safari? (cf/check-browser? :safari) safari? (cf/check-browser? :safari)
@ -171,7 +171,7 @@
{::mf/wrap-props false} {::mf/wrap-props false}
[props] [props]
(let [shape (unchecked-get props "shape")] (let [shape (unchecked-get props "shape")]
(when ^boolean (:thumbnail shape) (when ^boolean (:thumbnail-id shape)
[:> frame-container props [:> frame-container props
[:> frame-thumbnail-image props]]))) [:> frame-thumbnail-image props]])))

View file

@ -49,11 +49,16 @@
(defn generate-paragraph-styles (defn generate-paragraph-styles
[_shape data] [_shape data]
(let [line-height (:line-height data 1.2) (let [line-height (:line-height data)
line-height
(if (and (some? line-height) (not= "" line-height))
line-height
(:line-height txt/default-text-attrs))
text-align (:text-align data "start") text-align (:text-align data "start")
base #js {;; Fix a problem when exporting HTML base #js {;; Fix a problem when exporting HTML
:fontSize 0 ;;(str (:font-size data (:font-size txt/default-text-attrs)) "px") :fontSize 0 ;;(str (:font-size data (:font-size txt/default-text-attrs)) "px")
:lineHeight (:line-height data (:line-height txt/default-text-attrs)) :lineHeight line-height
:margin 0}] :margin 0}]
(cond-> base (cond-> base

View file

@ -269,17 +269,19 @@
(mf/defc component-item-thumbnail (mf/defc component-item-thumbnail
"Component that renders the thumbnail image or the original SVG." "Component that renders the thumbnail image or the original SVG."
{::mf/wrap-props false} {::mf/props :obj}
[{:keys [file-id root-shape component container class]}] [{:keys [file-id root-shape component container class]}]
(let [page-id (:main-instance-page component) (let [page-id (:main-instance-page component)
root-id (:main-instance-id component) root-id (:main-instance-id component)
retry (mf/use-state 0)
retry (mf/use-state 0) thumbnail-uri*
(mf/with-memo [file-id page-id root-id]
(let [object-id (thc/fmt-object-id file-id page-id root-id "component")]
(refs/workspace-thumbnail-by-id object-id)))
thumbnail-uri* (mf/with-memo [file-id page-id root-id] thumbnail-uri
(let [object-id (thc/fmt-object-id file-id page-id root-id "component")] (mf/deref thumbnail-uri*)
(refs/workspace-thumbnail-by-id object-id)))
thumbnail-uri (mf/deref thumbnail-uri*)
on-error on-error
(mf/use-fn (mf/use-fn

View file

@ -57,15 +57,6 @@
component)] component)]
[root-shape container]))) [root-shape container])))
;; NOTE: We don't schedule the thumbnail generation on idle right now
;; until we can queue and handle thumbnail batching properly.
#_(mf/with-effect []
(when-not (some? thumbnail-uri)
(tm/schedule-on-idle
#(st/emit! (dwl/update-component-thumbnail (:id component) file-id)))))
(mf/defc components-item (mf/defc components-item
{::mf/wrap-props false} {::mf/wrap-props false}
[{:keys [component renaming listing-thumbs? selected [{:keys [component renaming listing-thumbs? selected

View file

@ -134,7 +134,8 @@
time (dt/timeago (:created-at entry) {:locale locale})] time (dt/timeago (:created-at entry) {:locale locale})]
[:span {:class (stl/css :date)} time])]] [:span {:class (stl/css :date)} time])]]
[:> icon-button* {:variant "ghost" [:> icon-button* {:class (stl/css :version-entry-options)
:variant "ghost"
:aria-label (tr "workspace.versions.version-menu") :aria-label (tr "workspace.versions.version-menu")
:on-click handle-open-menu :on-click handle-open-menu
:icon "menu"}]] :icon "menu"}]]