From caf558f8dda253ebf534060ac214d42c3ab19489 Mon Sep 17 00:00:00 2001 From: Alonso Torres Date: Thu, 10 Apr 2025 14:46:50 +0200 Subject: [PATCH] :bug: Fix import error messages (#6265) --- CHANGES.md | 1 + .../src/app/main/ui/dashboard/import.cljs | 43 ++++++++++++++----- .../src/app/main/ui/dashboard/import.scss | 17 ++++++++ .../notifications/context_notification.cljs | 17 +++++--- frontend/translations/en.po | 11 +++++ frontend/translations/es.po | 12 ++++++ 6 files changed, 83 insertions(+), 18 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index e2ac773f4..b840f6d17 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -20,6 +20,7 @@ - Fix problem with error detail in toast [Taiga #10519](https://tree.taiga.io/project/penpot/issue/10519) - Fix view mode error when an external user tries to export something from a prototype using a shared link [Taiga #10251](https://tree.taiga.io/project/penpot/issue/10251) - Fix merge path nodes with only one node selected [Taiga #9626](https://tree.taiga.io/project/penpot/issue/9626) +- Fix problem with import errors [Taiga #10040](https://tree.taiga.io/project/penpot/issue/10040) ## 2.6.1 diff --git a/frontend/src/app/main/ui/dashboard/import.cljs b/frontend/src/app/main/ui/dashboard/import.cljs index dc0afa8ca..e515ea93a 100644 --- a/frontend/src/app/main/ui/dashboard/import.cljs +++ b/frontend/src/app/main/ui/dashboard/import.cljs @@ -291,7 +291,7 @@ import-error? [:div {:class (stl/css :error-message)} - (tr "dashboard.import.import-error")] + (tr "labels.error")] (and (not import-success?) (some? progress)) [:div {:class (stl/css :progress-message)} (parse-progress-message progress)]) @@ -443,7 +443,12 @@ (and (seq entries) (every? #(= :import-success (:status %)) entries)) - (reset! status* :import-success))) + (reset! status* :import-success) + + (and (seq entries) + (and (every? #(not= :import-ready (:status %)) entries) + (some #(= :import-error (:status %)) entries))) + (reset! status* :import-error))) ;; Run analyze operation on component mount (mf/with-effect [] @@ -469,15 +474,30 @@ {:level (if (zero? import-success-total) :warning :success) :content (tr "dashboard.import.import-message" (i18n/c import-success-total))}]) - (for [entry entries] - [:> import-entry* {:edition edition - :key (dm/str (:uri entry) "/" (:file-id entry)) - :entry entry - :entries entries - :on-edit on-edit - :on-change on-entry-change - :on-delete on-entry-delete - :can-be-deleted (> (count entries) 1)}]) + (when (= :import-error status) + [:& context-notification + {:level :error + :class (stl/css :context-notification-error) + :content (tr "dashboard.import.import-error.disclaimer")}]) + + (if (= :import-error status) + [:div {:class (stl/css :import-error-disclaimer)} + [:div (tr "dashboard.import.import-error.message1")] + [:ul {:class (stl/css :import-error-list)} + (for [entry entries] + (when (= :import-error (:status entry)) + [:li {:class (stl/css :import-error-list-enry)} (:name entry)]))] + [:div (tr "dashboard.import.import-error.message2")]] + + (for [entry entries] + [:> import-entry* {:edition edition + :key (dm/str (:uri entry) "/" (:file-id entry)) + :entry entry + :entries entries + :on-edit on-edit + :on-change on-entry-change + :on-delete on-entry-delete + :can-be-deleted (> (count entries) 1)}])) (when (some? template) [:> import-entry* {:entry (assoc template :status status) @@ -499,6 +519,7 @@ :on-click on-continue}]) (when (or (= :import-success status) + (= :import-error status) (= :import-progress status)) [:input {:class (stl/css :accept-btn) :type "button" diff --git a/frontend/src/app/main/ui/dashboard/import.scss b/frontend/src/app/main/ui/dashboard/import.scss index 257134dc4..34bb378fa 100644 --- a/frontend/src/app/main/ui/dashboard/import.scss +++ b/frontend/src/app/main/ui/dashboard/import.scss @@ -192,3 +192,20 @@ } } } + +.context-notification-error { + --context-notification-bg-color: var(--modal-background-color); +} + +.import-error-disclaimer { + color: var(--color-foreground-primary); +} + +.import-error-list { + padding: 0 var(--sp-l); + list-style: disc; +} + +.import-error-list-enry { + padding: var(--sp-xs) 0; +} diff --git a/frontend/src/app/main/ui/notifications/context_notification.cljs b/frontend/src/app/main/ui/notifications/context_notification.cljs index f79219c00..d1bb0dbfc 100644 --- a/frontend/src/app/main/ui/notifications/context_notification.cljs +++ b/frontend/src/app/main/ui/notifications/context_notification.cljs @@ -38,13 +38,16 @@ "They are persistent, informative and non-actionable. They are contextual messages in specific areas off the app" {::mf/props :obj} - [{:keys [level content links is-html] :as props}] - [:aside {:class (stl/css-case :context-notification true - :contain-html is-html - :warning (= level :warning) - :error (= level :error) - :success (= level :success) - :info (= level :info))} + [{:keys [level content links is-html class] :as props}] + [:aside {:class (dm/str + class + " " + (stl/css-case :context-notification true + :contain-html is-html + :warning (= level :warning) + :error (= level :error) + :success (= level :success) + :info (= level :info)))} (get-icon-by-level level) diff --git a/frontend/translations/en.po b/frontend/translations/en.po index 8e585a453..72945e641 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -1932,6 +1932,9 @@ msgstr "Drafts" msgid "labels.edit" msgstr "Edit" +msgid "labels.error" +msgstr "Error" + #, unused msgid "labels.edit-file" msgstr "Edit file" @@ -7276,3 +7279,11 @@ msgstr "Click to close the path" msgid "workspace.notification-pill.detail" msgstr "Details" +msgid "dashboard.import.import-error.disclaimer" +msgstr "Not all files have been imported" + +msgid "dashboard.import.import-error.message1" +msgstr "The following files have errors:" + +msgid "dashboard.import.import-error.message2" +msgstr "Files with errors will not be uploaded." diff --git a/frontend/translations/es.po b/frontend/translations/es.po index 2e39ff01a..0bfc1e64a 100644 --- a/frontend/translations/es.po +++ b/frontend/translations/es.po @@ -1955,6 +1955,9 @@ msgstr "Borradores" msgid "labels.edit" msgstr "Editar" +msgid "labels.error" +msgstr "Error" + #, unused msgid "labels.edit-file" msgstr "Editar archivo" @@ -7251,3 +7254,12 @@ msgstr "Pulsar para cerrar la ruta" msgid "workspace.notification-pill.detail" msgstr "Detalles" + +msgid "dashboard.import.import-error.disclaimer" +msgstr "No todos los ficheros han sido importados" + +msgid "dashboard.import.import-error.message1" +msgstr "Estos ficheros tienen errores:" + +msgid "dashboard.import.import-error.message2" +msgstr "Los ficheros con error no serĂ¡n importados."