mirror of
https://github.com/penpot/penpot.git
synced 2025-02-23 23:35:58 -05:00
🎉 Warn about empty libraries on the share library dialog
This commit is contained in:
parent
175072f546
commit
d615fbb282
9 changed files with 78 additions and 31 deletions
|
@ -749,6 +749,23 @@
|
|||
(teams/check-read-permissions! conn profile-id team-id)
|
||||
(get-team-recent-files conn team-id)))
|
||||
|
||||
|
||||
;; --- COMMAND QUERY: get-file-summary
|
||||
|
||||
(sv/defmethod ::get-file-summary
|
||||
"Retrieve a file summary by its ID. Only authenticated users."
|
||||
{::doc/added "1.20"
|
||||
::sm/params schema:get-file}
|
||||
[{:keys [::db/pool] :as cfg} {:keys [::rpc/profile-id id features project-id] :as params}]
|
||||
(db/with-atomic [conn pool]
|
||||
(check-read-permissions! conn profile-id id)
|
||||
(let [file (get-file conn id features project-id)]
|
||||
{:name (:name file)
|
||||
:components-count (count (ctkl/components-seq (:data file)))
|
||||
:graphics-count (count (get-in file [:data :media] []))
|
||||
:colors-count (count (get-in file [:data :colors] []))
|
||||
:typography-count (count (get-in file [:data :typographies] []))})))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; MUTATION COMMANDS
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
|
@ -7,8 +7,12 @@
|
|||
(ns app.main.data.common
|
||||
"A general purpose events."
|
||||
(:require
|
||||
[app.common.files.features :as ffeat]
|
||||
[app.common.types.components-list :as ctkl]
|
||||
[app.config :as cf]
|
||||
[app.main.data.messages :as msg]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.features :as features]
|
||||
[app.main.repo :as rp]
|
||||
[app.util.i18n :refer [tr]]
|
||||
[beicon.core :as rx]
|
||||
|
@ -76,3 +80,39 @@
|
|||
:controls :close
|
||||
:type level
|
||||
:tag :notification))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SHARED LIBRARY
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(defn show-shared-dialog
|
||||
[file-id add-shared]
|
||||
(ptk/reify ::show-shared-dialog
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [features (cond-> ffeat/enabled
|
||||
(features/active-feature? state :components-v2)
|
||||
(conj "components/v2"))
|
||||
data (:workspace-data state)
|
||||
file (:workspace-file state)]
|
||||
(->> (if (and data file)
|
||||
(rx/of {:name (:name file)
|
||||
:components-count (count (ctkl/components-seq data))
|
||||
:graphics-count (count (:media data))
|
||||
:colors-count (count (:colors data))
|
||||
:typography-count (count (:typographies data))})
|
||||
(rp/cmd! :get-file-summary {:id file-id :features features}))
|
||||
(rx/map (fn [summary]
|
||||
(let [count (+ (:components-count summary)
|
||||
(:graphics-count summary)
|
||||
(:colors-count summary)
|
||||
(:typography-count summary))]
|
||||
(modal/show
|
||||
{:type :confirm
|
||||
:message ""
|
||||
:title (tr "modals.add-shared-confirm.message" (:name summary))
|
||||
:hint (if (zero? count) (tr "modals.add-shared-confirm-empty.hint") (tr "modals.add-shared-confirm.hint"))
|
||||
:cancel-label (if (zero? count) (tr "labels.cancel") :omit)
|
||||
:accept-label (tr "modals.add-shared-confirm.accept")
|
||||
:accept-style :primary
|
||||
:on-accept add-shared})))))))))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.ui.dashboard.file-menu
|
||||
(:require
|
||||
[app.main.data.common :refer [show-shared-dialog]]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.messages :as dm]
|
||||
|
@ -151,15 +152,7 @@
|
|||
on-add-shared
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (modal/show
|
||||
{:type :confirm
|
||||
:message ""
|
||||
:title (tr "modals.add-shared-confirm.message" (:name file))
|
||||
:hint (tr "modals.add-shared-confirm.hint")
|
||||
:cancel-label :omit
|
||||
:accept-label (tr "modals.add-shared-confirm.accept")
|
||||
:accept-style :primary
|
||||
:on-accept add-shared})))
|
||||
(st/emit! (show-shared-dialog (:id file) add-shared)))
|
||||
|
||||
on-del-shared
|
||||
(fn [event]
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.common :refer [show-shared-dialog]]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.exports :as de]
|
||||
[app.main.data.modal :as modal]
|
||||
|
@ -347,7 +348,6 @@
|
|||
{::mf/wrap-props false}
|
||||
[{:keys [on-close file team-id]}]
|
||||
(let [file-id (:id file)
|
||||
file-name (:name file)
|
||||
shared? (:is-shared file)
|
||||
|
||||
objects (mf/deref refs/workspace-page-objects)
|
||||
|
@ -361,15 +361,8 @@
|
|||
|
||||
on-add-shared
|
||||
(mf/use-fn
|
||||
(mf/deps file-name add-shared-fn)
|
||||
#(modal/show! {:type :confirm
|
||||
:message ""
|
||||
:title (tr "modals.add-shared-confirm.message" file-name)
|
||||
:hint (tr "modals.add-shared-confirm.hint")
|
||||
:cancel-label :omit
|
||||
:accept-label (tr "modals.add-shared-confirm.accept")
|
||||
:accept-style :primary
|
||||
:on-accept add-shared-fn}))
|
||||
(mf/deps file-id add-shared-fn)
|
||||
#(st/emit! (show-shared-dialog file-id add-shared-fn)))
|
||||
|
||||
on-remove-shared
|
||||
(mf/use-fn
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.common :refer [show-shared-dialog]]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.exports :as de]
|
||||
[app.main.data.modal :as modal]
|
||||
|
@ -462,7 +463,6 @@
|
|||
{::mf/wrap-props false}
|
||||
[{:keys [on-close file team-id]}]
|
||||
(let [file-id (:id file)
|
||||
file-name (:name file)
|
||||
shared? (:is-shared file)
|
||||
|
||||
objects (mf/deref refs/workspace-page-objects)
|
||||
|
@ -476,15 +476,8 @@
|
|||
|
||||
on-add-shared
|
||||
(mf/use-fn
|
||||
(mf/deps file-name add-shared-fn)
|
||||
#(modal/show! {:type :confirm
|
||||
:message ""
|
||||
:title (tr "modals.add-shared-confirm.message" file-name)
|
||||
:hint (tr "modals.add-shared-confirm.hint")
|
||||
:cancel-label :omit
|
||||
:accept-label (tr "modals.add-shared-confirm.accept")
|
||||
:accept-style :primary
|
||||
:on-accept add-shared-fn}))
|
||||
(mf/deps file-id add-shared-fn)
|
||||
#(st/emit! (show-shared-dialog file-id add-shared-fn)))
|
||||
|
||||
on-remove-shared
|
||||
(mf/use-fn (mf/deps file-id)
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
{"button-primary":"sidebar_sitemap_button-primary_Z-bKW","button-secondary":"sidebar_sitemap_button-secondary_a56LZ","button-tertiary":"sidebar_sitemap_button-tertiary_E2hzd","sitemap":"sidebar_sitemap_sitemap_kvKKx","add-page":"sidebar_sitemap_add-page_r8Ibb","button-radio":"sidebar_sitemap_button-radio_BxzRJ","button-warning":"sidebar_sitemap_button-warning_qADPu","button-disabled":"sidebar_sitemap_button-disabled_IU-S6","button-tag":"sidebar_sitemap_button-tag_u1NAz","button-icon":"sidebar_sitemap_button-icon_MkibT","button-icon-small":"sidebar_sitemap_button-icon-small_Mhipv","tool-window-content":"sidebar_sitemap_tool-window-content_G-Nut","pages-list":"sidebar_sitemap_pages-list_cb1Mx","page-element":"sidebar_sitemap_page-element_iR9wf","element-list-body":"sidebar_sitemap_element-list-body_OIVac","page-actions":"sidebar_sitemap_page-actions_QTuKw","page-icon":"sidebar_sitemap_page-icon_ujSjM","link":"sidebar_sitemap_link_WvD4-","asset-element":"sidebar_sitemap_asset-element_I1-m4","input-element":"sidebar_sitemap_input-element_YAbpV","new-scrollbar":"sidebar_sitemap_new-scrollbar_Pb1-Y","menu-dropdown":"sidebar_sitemap_menu-dropdown_jAZ-g","menu-item":"sidebar_sitemap_menu-item_cQrV2","shortcut":"sidebar_sitemap_shortcut_Oywax","shortcut-key":"sidebar_sitemap_shortcut-key_IIYlf","user-icon":"sidebar_sitemap_user-icon_l-DH7","title-bar":"sidebar_sitemap_title-bar_tIJtT","title":"sidebar_sitemap_title_HmFc4","view-only-mode":"sidebar_sitemap_view-only-mode_JrsYg","resize-area":"sidebar_sitemap_resize-area_JgdjZ","dnd-over-top":"sidebar_sitemap_dnd-over-top_kGfcb","dnd-over-bot":"sidebar_sitemap_dnd-over-bot_352W2","dnd-over":"sidebar_sitemap_dnd-over_Sf5e2","page-name":"sidebar_sitemap_page-name_601Ii","element-name":"sidebar_sitemap_element-name_iMex0","on-drag":"sidebar_sitemap_on-drag_v3GM8","selected":"sidebar_sitemap_selected_mCOlT","hidden":"sidebar_sitemap_hidden_viFSn","title-spacing-sitemap":"sidebar_sitemap_title-spacing-sitemap_pDMgN","spin-animation":"sidebar_sitemap_spin-animation_SVOeo"}
|
|
@ -1 +1 @@
|
|||
{"grid-track-marker":"viewport_grid_layout_editor_grid-track-marker_HABEp","marker-shape":"viewport_grid_layout_editor_marker-shape_FZTUQ","marker-text":"viewport_grid_layout_editor_marker-text_5xM8J","grid-editor-label":"viewport_grid_layout_editor_grid-editor-label_2NbYe","grid-frame":"viewport_grid_layout_editor_grid-frame_CzMnU","grid-plus-button":"viewport_grid_layout_editor_grid-plus-button_brOge","grid-plus-shape":"viewport_grid_layout_editor_grid-plus-shape_jtOU9","grid-plus-icon":"viewport_grid_layout_editor_grid-plus-icon_Zolso","grid-cell-outline":"viewport_grid_layout_editor_grid-cell-outline_1-cRq","hover":"viewport_grid_layout_editor_hover_Rn-tv","selected":"viewport_grid_layout_editor_selected_nhyhL"}
|
||||
{"grid-track-marker":"viewport_grid_layout_editor_grid-track-marker_HABEp","marker-shape":"viewport_grid_layout_editor_marker-shape_FZTUQ","marker-text":"viewport_grid_layout_editor_marker-text_5xM8J","grid-editor-wrapper":"viewport_grid_layout_editor_grid-editor-wrapper_Uyk2S","grid-editor-label":"viewport_grid_layout_editor_grid-editor-label_2NbYe","grid-editor-button":"viewport_grid_layout_editor_grid-editor-button_N6Gmu","grid-frame":"viewport_grid_layout_editor_grid-frame_CzMnU","grid-plus-button":"viewport_grid_layout_editor_grid-plus-button_brOge","grid-plus-shape":"viewport_grid_layout_editor_grid-plus-shape_jtOU9","grid-plus-icon":"viewport_grid_layout_editor_grid-plus-icon_Zolso","grid-cell-outline":"viewport_grid_layout_editor_grid-cell-outline_1-cRq","hover":"viewport_grid_layout_editor_hover_Rn-tv","selected":"viewport_grid_layout_editor_selected_nhyhL"}
|
|
@ -1720,6 +1720,12 @@ msgstr ""
|
|||
"Once added as Shared Library, the assets of this file library will be "
|
||||
"available to be used among the rest of your files."
|
||||
|
||||
msgid "modals.add-shared-confirm-empty.hint"
|
||||
msgstr ""
|
||||
"Your library is empty. Once added as Shared Library, the assets you create will be "
|
||||
"available to be used among the rest of your files. "
|
||||
"Are you sure you want to publish it?"
|
||||
|
||||
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||
msgid "modals.add-shared-confirm.message"
|
||||
msgstr "Add “%s” as Shared Library"
|
||||
|
|
|
@ -1775,6 +1775,12 @@ msgstr ""
|
|||
"Una vez añadido como Biblioteca Compartida, los recursos de este archivo "
|
||||
"estarán disponibles para ser usado por el resto de tus archivos."
|
||||
|
||||
msgid "modals.add-shared-confirm.hint-empty"
|
||||
msgstr ""
|
||||
"Esta biblioteca está vacía. Una vez añadido como Biblioteca Compartida, los recursos "
|
||||
"que crees en este archivo estarán disponibles para ser usado por el resto de tus archivos. "
|
||||
"¿Seguro que quieres publicarla?"
|
||||
|
||||
#: src/app/main/ui/workspace/header.cljs,
|
||||
#: src/app/main/ui/dashboard/file_menu.cljs
|
||||
msgid "modals.add-shared-confirm.message"
|
||||
|
|
Loading…
Add table
Reference in a new issue