0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 16:00:19 -05:00

🐛 Fix export multiple images when only one of them has export settings

This commit is contained in:
Alejandro Alonso 2023-07-24 12:53:58 +02:00 committed by Eva
parent 1b31a02c14
commit db7c4a9265
2 changed files with 30 additions and 12 deletions

View file

@ -87,6 +87,7 @@
- Fix absolute positioned layouts not showing flex properties [Taiga #5630](https://tree.taiga.io/project/penpot/issue/5630) - Fix absolute positioned layouts not showing flex properties [Taiga #5630](https://tree.taiga.io/project/penpot/issue/5630)
- Fix text gradient handlers [Taiga #4047](https://tree.taiga.io/project/penpot/issue/4047) - Fix text gradient handlers [Taiga #4047](https://tree.taiga.io/project/penpot/issue/4047)
- Fix when user deletes one file during import it is impossible to finish importing of second file [Taiga #5656](https://tree.taiga.io/project/penpot/issue/5656) - Fix when user deletes one file during import it is impossible to finish importing of second file [Taiga #5656](https://tree.taiga.io/project/penpot/issue/5656)
- Fix export multiple images when only one of them has export settings [Taiga #5649](https://tree.taiga.io/project/penpot/issue/5649)
### :arrow_up: Deps updates ### :arrow_up: Deps updates

View file

@ -26,18 +26,20 @@
(mf/defc exports-menu (mf/defc exports-menu
{::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type" "page-id" "file-id"]))]} {::mf/wrap [#(mf/memo' % (mf/check-props ["ids" "values" "type" "page-id" "file-id"]))]}
[{:keys [ids type values page-id file-id] :as props}] [{:keys [ids type values page-id file-id] :as props}]
(let [exports (:exports values []) (let [exports (:exports values [])
state (mf/deref refs/export) state (mf/deref refs/export)
in-progress? (:in-progress state) in-progress? (:in-progress state)
sname (when (seqable? exports) shapes-with-exports (->> (wsh/lookup-shapes @st/state ids)
(let [shapes (wsh/lookup-shapes @st/state ids) (filter #(pos? (count (:exports %)))))
sname (-> shapes first :name)
suffix (-> exports first :suffix)] sname (when (seqable? exports)
(cond-> sname (let [sname (-> shapes-with-exports first :name)
(and (= 1 (count exports)) (some? suffix)) suffix (-> exports first :suffix)]
(str suffix)))) (cond-> sname
(and (= 1 (count exports)) (some? suffix))
(str suffix))))
scale-enabled? scale-enabled?
(mf/use-callback (mf/use-callback
@ -50,7 +52,22 @@
(fn [event] (fn [event]
(dom/prevent-default event) (dom/prevent-default event)
(if (= :multiple type) (if (= :multiple type)
(st/emit! (de/show-workspace-export-dialog {:selected (reverse ids)})) ;; I can select multiple shapes all of them with no export settings and one of them with only one
;; In that situation we must export it directly
(if (and (= 1 (count shapes-with-exports)) (= 1 (-> shapes-with-exports first :exports count)))
(let [shape (-> shapes-with-exports first)
export (-> shape :exports first)
sname (:name shape)
suffix (:suffix export)
defaults {:page-id page-id
:file-id file-id
:name sname
:object-id (:id (first shapes-with-exports))}]
(cond-> sname
(some? suffix)
(str suffix))
(st/emit! (de/request-simple-export {:export (merge export defaults)})))
(st/emit! (de/show-workspace-export-dialog {:selected (reverse ids)})))
;; In other all cases we only allowed to have a single ;; In other all cases we only allowed to have a single
;; shape-id because multiple shape-ids are handled ;; shape-id because multiple shape-ids are handled
@ -182,4 +199,4 @@
:disabled in-progress?} :disabled in-progress?}
(if in-progress? (if in-progress?
(tr "workspace.options.exporting-object") (tr "workspace.options.exporting-object")
(tr "workspace.options.export-object" (c (count ids))))])])) (tr "workspace.options.export-object" (c (count shapes-with-exports))))])]))