diff --git a/CHANGES.md b/CHANGES.md index 6c2f5e038..22a8037b5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -18,6 +18,7 @@ - Fix some texts and a typo [Taiga #4215](https://tree.taiga.io/project/penpot/issue/4215) - Fix twitter support account link [Taiga #4279](https://tree.taiga.io/project/penpot/issue/4279) - Fix lang autodetect issue [Taiga #4277](https://tree.taiga.io/project/penpot/issue/4277) +- Fix adding an extra page on import [Taiga #4543](https://tree.taiga.io/project/penpot/task/4543) ### :arrow_up: Deps updates ### :heart: Community contributions by (Thank you!) diff --git a/backend/src/app/rpc/commands/files/create.clj b/backend/src/app/rpc/commands/files/create.clj index 4a7c5d600..eb5ebe675 100644 --- a/backend/src/app/rpc/commands/files/create.clj +++ b/backend/src/app/rpc/commands/files/create.clj @@ -31,9 +31,9 @@ (defn create-file [conn {:keys [id name project-id is-shared data revn - modified-at deleted-at + modified-at deleted-at create-page ignore-sync-until features] - :or {is-shared false revn 0} + :or {is-shared false revn 0 create-page true} :as params}] (let [id (or id (:id data) (uuid/next)) features (-> (into files/default-features features) @@ -43,7 +43,9 @@ (binding [ffeat/*current* features ffeat/*wrap-with-objects-map-fn* (if (features "storate/objects-map") omap/wrap identity) ffeat/*wrap-with-pointer-map-fn* (if (features "storage/pointer-map") pmap/wrap identity)] - (ctf/make-file-data id))) + (if create-page + (ctf/make-file-data id) + (ctf/make-file-data id nil)))) features (db/create-array conn "text" features) file (db/insert! conn :file diff --git a/backend/src/app/rpc/commands/files/temp.clj b/backend/src/app/rpc/commands/files/temp.clj index 350ddb23c..3dbee423d 100644 --- a/backend/src/app/rpc/commands/files/temp.clj +++ b/backend/src/app/rpc/commands/files/temp.clj @@ -8,6 +8,7 @@ (:require [app.common.exceptions :as ex] [app.common.pages :as cp] + [app.common.spec :as us] [app.common.uuid :as uuid] [app.db :as db] [app.rpc.commands.files :as files] @@ -22,7 +23,16 @@ ;; --- MUTATION COMMAND: create-temp-file -(s/def ::create-temp-file ::files.create/create-file) +(s/def ::create-page ::us/boolean) + +(s/def ::create-temp-file + (s/keys :req-un [::files/profile-id + ::files/name + ::files/project-id] + :opt-un [::files/id + ::files/is-shared + ::files/features + ::create-page])) (sv/defmethod ::create-temp-file {::doc/added "1.17"} diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index a4b7b26ba..d2143101b 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -72,10 +72,13 @@ (make-file-data file-id (uuid/next))) ([file-id page-id] - (let [page (ctp/make-empty-page page-id "Page-1")] + (let [page (when (some? page-id) + (ctp/make-empty-page page-id "Page-1"))] (cond-> (-> empty-file-data - (assoc :id file-id) - (ctpl/add-page page)) + (assoc :id file-id)) + + (some? page-id) + (ctpl/add-page page) (contains? ffeat/*current* "components/v2") (assoc-in [:options :components-v2] true))))) diff --git a/frontend/src/app/worker/import.cljs b/frontend/src/app/worker/import.cljs index cdccc632e..5936bc6cd 100644 --- a/frontend/src/app/worker/import.cljs +++ b/frontend/src/app/worker/import.cljs @@ -135,6 +135,7 @@ :name (:name context) :is-shared (:shared context) :project-id (:project-id context) + :create-page false :features features}))) (defn link-file-libraries