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

🎉 Add plurals to delete or unpublish lib modal

This commit is contained in:
Eva 2022-08-01 13:51:27 +02:00
parent 18970cb233
commit ae20a06e97
5 changed files with 90 additions and 48 deletions

View file

@ -264,14 +264,15 @@
(let [files (d/index-by :id files)]
(assoc-in state [:dashboard-local :files-with-shared] files)))))
(defn fetch-library-using-files
[file]
(defn fetch-libraries-using-files
[files]
(ptk/reify ::fetch-library-using-files
ptk/WatchEvent
(watch [_ _ _]
(let [file-id (:id file)]
(->> (rp/query :library-using-files {:file-id file-id})
(rx/map library-using-files-fetched))))))
(->> (rx/from files)
(rx/mapcat (fn [file] (rp/query :library-using-files {:file-id (:id file)})))
(rx/reduce into [])
(rx/map library-using-files-fetched)))))
;; --- EVENT: recent-files

View file

@ -92,26 +92,30 @@
on-delete
(fn [event]
(dom/stop-propagation event)
(if (:is-shared file)
(do (st/emit! (dd/fetch-library-using-files file))
(st/emit! (modal/show
{:type :delete-shared
:origin :delete
:on-accept delete-fn})))
(if multi?
(st/emit! (modal/show
{:type :confirm
:title (tr "modals.delete-file-multi-confirm.title" file-count)
:message (tr "modals.delete-file-multi-confirm.message" file-count)
:accept-label (tr "modals.delete-file-multi-confirm.accept" file-count)
:on-accept delete-fn}))
(st/emit! (modal/show
{:type :confirm
:title (tr "modals.delete-file-confirm.title")
:message (tr "modals.delete-file-confirm.message")
:accept-label (tr "modals.delete-file-confirm.accept")
:on-accept delete-fn})))))
(let [has-shared? (filter #(:is-shared %) files)]
(if has-shared?
(do (st/emit! (dd/fetch-libraries-using-files files))
(st/emit! (modal/show
{:type :delete-shared
:origin :delete
:on-accept delete-fn
:count-libraries (count has-shared?)})))
(if multi?
(st/emit! (modal/show
{:type :confirm
:title (tr "modals.delete-file-multi-confirm.title" file-count)
:message (tr "modals.delete-file-multi-confirm.message" file-count)
:accept-label (tr "modals.delete-file-multi-confirm.accept" file-count)
:on-accept delete-fn}))
(st/emit! (modal/show
{:type :confirm
:title (tr "modals.delete-file-confirm.title")
:message (tr "modals.delete-file-confirm.message")
:accept-label (tr "modals.delete-file-confirm.accept")
:on-accept delete-fn}))))))
on-move-success
(fn [team-id project-id]
@ -155,11 +159,12 @@
(fn [event]
(dom/prevent-default event)
(dom/stop-propagation event)
(st/emit! (dd/fetch-library-using-files file))
(st/emit! (dd/fetch-libraries-using-files [file]))
(st/emit! (modal/show
{:type :delete-shared
:origin :unpublish
:on-accept del-shared})))
:on-accept del-shared
:count-libraries 1})))
on-export-files
(fn [event-name binary?]

View file

@ -24,7 +24,8 @@
[{:keys [on-accept
on-cancel
accept-style
origin] :as props}]
origin
count-libraries] :as props}]
(let [on-accept (or on-accept identity)
on-cancel (or on-cancel identity)
cancel-label (tr "labels.cancel")
@ -34,18 +35,22 @@
files->shared (:files-with-shared dashboard-local)
count-files (count (keys files->shared))
title (if is-delete?
(tr "modals.delete-shared-confirm.title")
(tr "modals.unpublish-shared-confirm.title"))
(tr "modals.delete-shared-confirm.title" (i18n/c count-libraries))
(tr "modals.unpublish-shared-confirm.title" (i18n/c count-libraries)))
message (if is-delete?
(tr "modals.delete-shared-confirm.message")
(tr "modals.unpublish-shared-confirm.message"))
(tr "modals.delete-shared-confirm.message" (i18n/c count-libraries))
(tr "modals.unpublish-shared-confirm.message" (i18n/c count-libraries)))
accept-label (if is-delete?
(tr "modals.delete-shared-confirm.accept")
(tr "modals.unpublish-shared-confirm.accept"))
scd-message (if is-delete?
(tr "modals.delete-shared-confirm.scd-message" (i18n/c count-files))
(tr "modals.unpublish-shared-confirm.scd-message" (i18n/c count-files)))
(tr "modals.delete-shared-confirm.accept" (i18n/c count-libraries))
(tr "modals.unpublish-shared-confirm.accept"))
scd-message (if is-delete?
(if (> count-libraries 1)
(tr "modals.delete-shared-confirm.scd-message-plural" (i18n/c count-files))
(tr "modals.delete-shared-confirm.scd-message" (i18n/c count-files)))
(if (> count-libraries 1)
(tr "modals.unpublish-shared-confirm.scd-message-plural" (i18n/c count-files))
(tr "modals.unpublish-shared-confirm.scd-message" (i18n/c count-files)))
)
hint (if is-delete?
""
(tr "modals.unpublish-shared-confirm.hint" (i18n/c count-files)))

View file

@ -1781,11 +1781,15 @@ msgstr "Remove “%s” as Shared Library"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.unpublish-shared-confirm.title"
msgstr "Unpublish library"
msgid_plural "modals.unpublish-shared-confirm.title"
msgstr[0] "Unpublish library"
msgstr[1] "Unpublish libraries"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.unpublish-shared-confirm.message"
msgstr "Are you sure you want to unpublish this library?"
msgid_plural "modals.unpublish-shared-confirm.message"
msgstr[0] "Are you sure you want to unpublish this library?"
msgstr[1] "Are you sure you want to unpublish these libraries?"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.unpublish-shared-confirm.scd-message"
@ -1805,11 +1809,15 @@ msgstr "Unpublish"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.title"
msgstr "Deleting file"
msgid_plural "modals.delete-shared-confirm.title"
msgstr[0] "Deleting file"
msgstr[1] "Deleting files"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.message"
msgstr "Are you sure you want to delete this file?"
msgid_plural "modals.delete-shared-confirm.message"
msgstr[0] "Are you sure you want to delete this file?"
msgstr[1] "Are you sure you want to delete these files?"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.scd-message"
@ -1818,9 +1826,16 @@ msgstr[0] "This file has libraries that are being used in this file:"
msgstr[1] "This file has libraries that are being used in these files:"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.accept"
msgstr "Delete file"
msgid "modals.delete-shared-confirm.scd-message-plural"
msgid_plural "modals.delete-shared-confirm.scd-message-plural"
msgstr[0] "These files have libraries that are being used in this file:"
msgstr[1] "These files have libraries that are being used in these files:"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.accept"
msgid_plural "modals.delete-shared-confirm.accept"
msgstr[0] "Delete file"
msgstr[1] "Delete files"
#: src/app/main/ui/workspace/nudge.cljs
msgid "modals.small-nudge"

View file

@ -1855,11 +1855,15 @@ msgstr "Añadir “%s” como Biblioteca Compartida"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.unpublish-shared-confirm.title"
msgstr "Despublicar biblioteca"
msgid_plural "modals.unpublish-shared-confirm.title"
msgstr[0] "Despublicar biblioteca"
msgstr[1] "Despublicar bibliotecas"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.unpublish-shared-confirm.message"
msgstr "¿Seguro que quieres despublicar esta biblioteca?"
msgid_plural "modals.unpublish-shared-confirm.message"
msgstr[0] "¿Seguro que quieres despublicar esta biblioteca?"
msgstr[1] "¿Seguro que quieres despublicar estas bibliotecas?"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.unpublish-shared-confirm.scd-message"
@ -1879,11 +1883,15 @@ msgstr "Despublicar"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.title"
msgstr "Borrar archivo"
msgid_plural "modals.delete-shared-confirm.title"
msgstr[0] "Borrar archivo"
msgstr[1] "Borrar archivos"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.message"
msgstr "¿Seguro que quieres borrar este archivo?"
msgid_plural "modals.delete-shared-confirm.message"
msgstr[0] "¿Seguro que quieres borrar este archivo?"
msgstr[1] "¿Seguro que quieres borrar estos archivos?"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.scd-message"
@ -1891,9 +1899,17 @@ msgid_plural "modals.delete-shared-confirm.scd-message"
msgstr[0] "El archivo que quieres borrar tiene una librería que se está usando en este archivo:"
msgstr[1] "El archivo que quieres borrar tiene una librería que se está usando en estos archivos:"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.scd-message-plural"
msgid_plural "modals.delete-shared-confirm.scd-message-plural"
msgstr[0] "Los archivos que quieres borrar tienen una librería que se está usando en este archivo:"
msgstr[1] "Los archivos que quieres borrar tienen una librería que se está usando en estos archivos:"
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
msgid "modals.delete-shared-confirm.accept"
msgstr "Borrar archivo"
msgid_plural "modals.delete-shared-confirm.accept"
msgstr[0] "Borrar archivo"
msgstr[1] "Borrar archivos"
#: src/app/main/ui/workspace/nudge.cljs
msgid "modals.small-nudge"