0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Include features info in exported zipfiles

This commit is contained in:
Andrés Moya 2022-12-01 14:19:27 +01:00
parent 1b8e4dfdfa
commit 94cdd4a481
4 changed files with 14 additions and 14 deletions

View file

@ -72,7 +72,7 @@
manifest-stream
(->> files-stream
(rx/map #(e/create-manifest (uuid/next) (:id file) :all %))
(rx/map #(e/create-manifest (uuid/next) (:id file) :all % false))
(rx/map (fn [a]
(vector "manifest.json" a))))

View file

@ -13,7 +13,6 @@
[app.main.data.events :as ev]
[app.main.data.messages :as msg]
[app.main.data.modal :as modal]
[app.main.features :as features]
[app.main.store :as st]
[app.main.ui.components.file-uploader :refer [file-uploader]]
[app.main.ui.icons :as i]
@ -248,8 +247,6 @@
:files (->> files
(mapv #(assoc % :status :analyzing)))})
components-v2 (features/use-feature :components-v2)
analyze-import
(mf/use-callback
(fn [files]
@ -271,7 +268,6 @@
:num-files (count files)}))
(->> (uw/ask-many!
{:cmd :import-files
:components-v2 components-v2
:project-id project-id
:files files})
(rx/subs

View file

@ -24,7 +24,7 @@
(defn create-manifest
"Creates a manifest entry for the given files"
[team-id file-id export-type files]
[team-id file-id export-type files components-v2]
(letfn [(format-page [manifest page]
(-> manifest
(assoc (str (:id page))
@ -37,10 +37,14 @@
(mapv str))
index (->> (get-in file [:data :pages-index])
(vals)
(reduce format-page {}))]
(reduce format-page {}))
features (cond-> []
components-v2
(conj "components/v2"))]
(-> manifest
(assoc (str (:id file))
{:name name
:features features
:shared is-shared
:pages pages
:pagesIndex index
@ -395,7 +399,7 @@
manifest-stream
(->> files-stream
(rx/map #(create-manifest team-id file-id export-type %))
(rx/map #(create-manifest team-id file-id export-type % components-v2))
(rx/map #(vector "manifest.json" %)))
render-stream

View file

@ -126,10 +126,10 @@
(defn create-file
"Create a new file on the back-end"
[context components-v2]
[context]
(let [resolve-fn (:resolve context)
file-id (resolve-fn (:file-id context))
features (cond-> #{} components-v2 (conj "components/v2"))]
features (into #{} (:features context))]
(rp/cmd! :create-temp-file
{:id file-id
:name (:name context)
@ -563,14 +563,14 @@
(rx/tap #(rx/end! progress-str)))]))
(defn create-files
[context files components-v2]
[context files]
(let [data (group-by :file-id files)]
(rx/concat
(->> (rx/from files)
(rx/map #(merge context %))
(rx/flat-map (fn [context]
(->> (create-file context components-v2)
(->> (create-file context)
(rx/map #(vector % (first (get data (:file-id context)))))))))
(->> (rx/from files)
@ -629,7 +629,7 @@
(rx/of {:uri (:uri file) :error error}))))))))))
(defmethod impl/handler :import-files
[{:keys [project-id files components-v2]}]
[{:keys [project-id files]}]
(let [context {:project-id project-id
:resolve (resolve-factory)}
@ -637,7 +637,7 @@
binary-files (filter #(= "application/octet-stream" (:type %)) files)]
(->> (rx/merge
(->> (create-files context zip-files components-v2)
(->> (create-files context zip-files)
(rx/flat-map
(fn [[file data]]
(->> (uz/load-from-url (:uri data))