mirror of
https://github.com/penpot/penpot.git
synced 2025-05-12 14:26:38 +02:00
🐛 Fix get name from file when importing
This commit is contained in:
parent
50774bebb3
commit
c8593b1c18
2 changed files with 12 additions and 4 deletions
|
@ -728,10 +728,11 @@
|
||||||
|
|
||||||
|
|
||||||
(defmethod read-section :v1/files
|
(defmethod read-section :v1/files
|
||||||
[{:keys [::db/conn ::input ::project-id ::enabled-features ::timestamp ::overwrite?] :as system}]
|
[{:keys [::db/conn ::input ::project-id ::enabled-features ::timestamp ::overwrite? ::name] :as system}]
|
||||||
|
|
||||||
(doseq [expected-file-id (-> *state* deref :files)]
|
(doseq [[idx expected-file-id] (d/enumerate (-> *state* deref :files))]
|
||||||
(let [file (read-obj! input)
|
(let [file (read-obj! input)
|
||||||
|
|
||||||
media (read-obj! input)
|
media (read-obj! input)
|
||||||
|
|
||||||
file-id (:id file)
|
file-id (:id file)
|
||||||
|
@ -770,6 +771,8 @@
|
||||||
|
|
||||||
(let [file (-> file
|
(let [file (-> file
|
||||||
(assoc :id file-id')
|
(assoc :id file-id')
|
||||||
|
(cond-> (and (= idx 0) (some? name))
|
||||||
|
(assoc :name name))
|
||||||
(process-file))
|
(process-file))
|
||||||
|
|
||||||
;; All features that are enabled and requires explicit migration are
|
;; All features that are enabled and requires explicit migration are
|
||||||
|
@ -1105,6 +1108,7 @@
|
||||||
schema:import-binfile
|
schema:import-binfile
|
||||||
(sm/define
|
(sm/define
|
||||||
[:map {:title "import-binfile"}
|
[:map {:title "import-binfile"}
|
||||||
|
[:name :string]
|
||||||
[:project-id ::sm/uuid]
|
[:project-id ::sm/uuid]
|
||||||
[:file ::media/upload]]))
|
[:file ::media/upload]]))
|
||||||
|
|
||||||
|
@ -1116,12 +1120,13 @@
|
||||||
::webhooks/event? true
|
::webhooks/event? true
|
||||||
::sse/stream? true
|
::sse/stream? true
|
||||||
::sm/params schema:import-binfile}
|
::sm/params schema:import-binfile}
|
||||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id project-id file] :as params}]
|
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id name project-id file] :as params}]
|
||||||
(projects/check-read-permissions! pool profile-id project-id)
|
(projects/check-read-permissions! pool profile-id project-id)
|
||||||
(let [params (-> cfg
|
(let [params (-> cfg
|
||||||
(assoc ::input (:path file))
|
(assoc ::input (:path file))
|
||||||
(assoc ::project-id project-id)
|
(assoc ::project-id project-id)
|
||||||
(assoc ::profile-id profile-id)
|
(assoc ::profile-id profile-id)
|
||||||
|
(assoc ::name name)
|
||||||
(assoc ::ignore-index-errors? true))]
|
(assoc ::ignore-index-errors? true))]
|
||||||
(with-meta
|
(with-meta
|
||||||
(sse/response #(import-binfile params))
|
(sse/response #(import-binfile params))
|
||||||
|
|
|
@ -728,7 +728,10 @@
|
||||||
:method :get})
|
:method :get})
|
||||||
(rx/map :body)
|
(rx/map :body)
|
||||||
(rx/mapcat (fn [file]
|
(rx/mapcat (fn [file]
|
||||||
(->> (rp/cmd! ::sse/import-binfile {:file file :project-id project-id})
|
(->> (rp/cmd! ::sse/import-binfile
|
||||||
|
{:name (str/replace (:name data) #".penpot$" "")
|
||||||
|
:file file
|
||||||
|
:project-id project-id})
|
||||||
(rx/tap (fn [event]
|
(rx/tap (fn [event]
|
||||||
(let [payload (sse/get-payload event)
|
(let [payload (sse/get-payload event)
|
||||||
type (sse/get-type event)]
|
type (sse/get-type event)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue