From 2c264d6460b7421a11d6379b85b7d349eedd800f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Tue, 10 Oct 2023 12:41:27 +0200 Subject: [PATCH] :wrench: Add migration to set root shapes as valid objects --- common/src/app/common/files/defaults.cljc | 2 +- common/src/app/common/files/migrations.cljc | 16 ++++++++++++++++ common/src/app/common/files/validate.cljc | 1 + frontend/src/app/main/ui/dashboard/import.cljs | 1 - 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index 44590ae88..14480bc46 100644 --- a/common/src/app/common/files/defaults.cljc +++ b/common/src/app/common/files/defaults.cljc @@ -6,4 +6,4 @@ (ns app.common.files.defaults) -(def version 32) +(def version 33) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 7154e3df5..35a8b366d 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -608,3 +608,19 @@ (-> data (update :pages-index update-vals update-container) (update :components update-vals update-container)))) + +(defmethod migrate 33 + [data] + (letfn [(update-object [object] + ; Ensure all root objects are well formed shapes. + (if (= (:id object) uuid/zero) + (-> object + (assoc :parent-id uuid/zero + :frame-id uuid/zero) + (cts/setup-shape)) + object)) + + (update-container [container] + (update container :objects update-vals update-object))] + (-> data + (update :pages-index update-vals update-container)))) diff --git a/common/src/app/common/files/validate.cljc b/common/src/app/common/files/validate.cljc index 4eb9315a9..f9faea548 100644 --- a/common/src/app/common/files/validate.cljc +++ b/common/src/app/common/files/validate.cljc @@ -394,6 +394,7 @@ (binding [*throw-on-error* throw? *errors* (volatile! [])] (->> (ctpl/pages-seq (:data file)) + (filter #(some? (:id %))) (run! #(validate-shape uuid/zero file % libraries :throw? throw?))) (deref *errors*))) diff --git a/frontend/src/app/main/ui/dashboard/import.cljs b/frontend/src/app/main/ui/dashboard/import.cljs index bb26e8d0a..57aba1b11 100644 --- a/frontend/src/app/main/ui/dashboard/import.cljs +++ b/frontend/src/app/main/ui/dashboard/import.cljs @@ -343,7 +343,6 @@ (->> files (filter #(= (:status %) :importing)) count) (:importing-templates @state)) - warning-files (->> files (filter #(and (= (:status %) :import-finish) (d/not-empty? (:errors %)))) count) success-files (->> files (filter #(and (= (:status %) :import-finish) (empty? (:errors %)))) count) pending-analysis? (> (->> files (filter #(= (:status %) :analyzing)) count) 0)