mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 06:31:39 +02:00
🐛 Fix broken grids defaults on comp-v2 migration
This commit is contained in:
parent
dba10ffd9b
commit
9eb902c682
1 changed files with 25 additions and 0 deletions
|
@ -31,6 +31,7 @@
|
||||||
[app.common.types.components-list :as ctkl]
|
[app.common.types.components-list :as ctkl]
|
||||||
[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.common.types.grid :as ctg]
|
||||||
[app.common.types.page :as ctp]
|
[app.common.types.page :as ctp]
|
||||||
[app.common.types.pages-list :as ctpl]
|
[app.common.types.pages-list :as ctpl]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
|
@ -138,6 +139,13 @@
|
||||||
(def valid-image-attrs?
|
(def valid-image-attrs?
|
||||||
(sm/lazy-validator ::cts/image-attrs))
|
(sm/lazy-validator ::cts/image-attrs))
|
||||||
|
|
||||||
|
(def valid-column-grid-params?
|
||||||
|
(sm/lazy-validator ::ctg/column-params))
|
||||||
|
|
||||||
|
(def valid-square-grid-params?
|
||||||
|
(sm/lazy-validator ::ctg/square-params))
|
||||||
|
|
||||||
|
|
||||||
(defn- prepare-file-data
|
(defn- prepare-file-data
|
||||||
"Apply some specific migrations or fixes to things that are allowed in v1 but not in v2,
|
"Apply some specific migrations or fixes to things that are allowed in v1 but not in v2,
|
||||||
or that are the result of old bugs."
|
or that are the result of old bugs."
|
||||||
|
@ -221,11 +229,28 @@
|
||||||
(dissoc options :background)
|
(dissoc options :background)
|
||||||
options))
|
options))
|
||||||
|
|
||||||
|
(fix-saved-grids [options]
|
||||||
|
(d/update-when options :saved-grids
|
||||||
|
(fn [grids]
|
||||||
|
(cond-> grids
|
||||||
|
(and (contains? grids :column)
|
||||||
|
(not (valid-column-grid-params? (:column grids))))
|
||||||
|
(dissoc :column)
|
||||||
|
|
||||||
|
(and (contains? grids :row)
|
||||||
|
(not (valid-column-grid-params? (:row grids))))
|
||||||
|
(dissoc :row)
|
||||||
|
|
||||||
|
(and (contains? grids :square)
|
||||||
|
(not (valid-square-grid-params? (:square grids))))
|
||||||
|
(dissoc :square)))))
|
||||||
|
|
||||||
(fix-options [options]
|
(fix-options [options]
|
||||||
(-> options
|
(-> options
|
||||||
;; Some pages has invalid data on flows, we proceed just to
|
;; Some pages has invalid data on flows, we proceed just to
|
||||||
;; delete them.
|
;; delete them.
|
||||||
(d/update-when :flows #(filterv valid-flow? %))
|
(d/update-when :flows #(filterv valid-flow? %))
|
||||||
|
(fix-saved-grids)
|
||||||
(fix-background)))]
|
(fix-background)))]
|
||||||
|
|
||||||
(update file-data :pages-index update-vals update-page)))
|
(update file-data :pages-index update-vals update-page)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue