mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 06:56:37 +02:00
🎉 Add unpublish option on context menu
This commit is contained in:
parent
8f325e4303
commit
2375f9ab83
17 changed files with 200 additions and 400 deletions
|
@ -49,13 +49,14 @@
|
|||
projects))
|
||||
|
||||
(mf/defc file-menu
|
||||
[{:keys [files show? on-edit on-menu-close top left navigate?] :as props}]
|
||||
[{:keys [files show? on-edit on-menu-close top left navigate? origin] :as props}]
|
||||
(assert (seq files) "missing `files` prop")
|
||||
(assert (boolean? show?) "missing `show?` prop")
|
||||
(assert (fn? on-edit) "missing `on-edit` prop")
|
||||
(assert (fn? on-menu-close) "missing `on-menu-close` prop")
|
||||
(assert (boolean? navigate?) "missing `navigate?` prop")
|
||||
(let [top (or top 0)
|
||||
(let [is-lib-page? (= :libraries origin)
|
||||
top (or top 0)
|
||||
left (or left 0)
|
||||
|
||||
file (first files)
|
||||
|
@ -92,15 +93,15 @@
|
|||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
|
||||
(let [has-shared? (filter #(:is-shared %) files)]
|
||||
(let [num-shared (filter #(:is-shared %) files)]
|
||||
|
||||
(if has-shared?
|
||||
(if (< 0 (count num-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?)})))
|
||||
:count-libraries (count num-shared)})))
|
||||
|
||||
(if multi?
|
||||
(st/emit! (modal/show
|
||||
|
@ -158,12 +159,12 @@
|
|||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dd/fetch-libraries-using-files [file]))
|
||||
(st/emit! (dd/fetch-libraries-using-files files))
|
||||
(st/emit! (modal/show
|
||||
{:type :delete-shared
|
||||
:origin :unpublish
|
||||
:on-accept del-shared
|
||||
:count-libraries 1})))
|
||||
:count-libraries file-count})))
|
||||
|
||||
on-export-files
|
||||
(fn [event-name binary?]
|
||||
|
@ -232,27 +233,31 @@
|
|||
[(tr "dashboard.move-to-multi" file-count) nil sub-options "move-to-multi"])
|
||||
[(tr "dashboard.export-binary-multi" file-count) on-export-binary-files]
|
||||
[(tr "dashboard.export-standard-multi" file-count) on-export-standard-files]
|
||||
[:separator]
|
||||
[(tr "labels.delete-multi-files" file-count) on-delete nil "delete-multi-files"]]
|
||||
(when (:is-shared file)
|
||||
[(tr "labels.unpublish-multi-files" file-count) on-del-shared nil "file-del-shared"])
|
||||
(when (not is-lib-page?)
|
||||
[:separator]
|
||||
[(tr "labels.delete-multi-files" file-count) on-delete nil "delete-multi-files"])]
|
||||
|
||||
[[(tr "dashboard.open-in-new-tab") on-new-tab]
|
||||
[(tr "labels.rename") on-edit nil "file-rename"]
|
||||
[(tr "dashboard.duplicate") on-duplicate nil "file-duplicate"]
|
||||
(when (or (seq current-projects) (seq other-teams))
|
||||
[(tr "dashboard.move-to") nil sub-options "file-move-to"])
|
||||
(when (and (not is-lib-page?) (or (seq current-projects) (seq other-teams)))
|
||||
[(tr "dashboard.move-to") nil sub-options "file-move-to"])
|
||||
(if (:is-shared file)
|
||||
[(tr "dashboard.unpublish-shared") on-del-shared nil "file-del-shared"]
|
||||
[(tr "dashboard.add-shared") on-add-shared nil "file-add-shared"])
|
||||
[:separator]
|
||||
[(tr "dashboard.download-binary-file") on-export-binary-files nil "download-binary-file"]
|
||||
[(tr "dashboard.download-standard-file") on-export-standard-files nil "download-standard-file"]
|
||||
[:separator]
|
||||
[(tr "labels.delete") on-delete nil "file-delete"]])]
|
||||
(when (not is-lib-page?)
|
||||
[:separator]
|
||||
[(tr "labels.delete") on-delete nil "file-delete"])])]
|
||||
|
||||
[:& context-menu {:on-close on-menu-close
|
||||
:show show?
|
||||
:fixed? (or (not= top 0) (not= left 0))
|
||||
:min-width? true
|
||||
:top top
|
||||
:left left
|
||||
:options options}]))))
|
||||
[:& context-menu {:on-close on-menu-close
|
||||
:show show?
|
||||
:fixed? (or (not= top 0) (not= left 0))
|
||||
:min-width? true
|
||||
:top top
|
||||
:left left
|
||||
:options options}]))))
|
||||
|
|
|
@ -43,17 +43,26 @@
|
|||
accept-label (if is-delete?
|
||||
(tr "modals.delete-shared-confirm.accept" (i18n/c count-libraries))
|
||||
(tr "modals.unpublish-shared-confirm.accept"))
|
||||
scd-message (if is-delete?
|
||||
|
||||
no-files-message (if is-delete?
|
||||
(tr "modals.delete-shared-confirm.no-files-message" (i18n/c count-libraries))
|
||||
(tr "modals.unpublish-shared-confirm.no-files-message" (i18n/c count-libraries))
|
||||
)
|
||||
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))
|
||||
(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)))
|
||||
)
|
||||
(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)))
|
||||
(if (> count-libraries 1)
|
||||
(tr "modals.delete-shared-confirm.hint-plural" (i18n/c count-files))
|
||||
(tr "modals.delete-shared-confirm.hint" (i18n/c count-files)))
|
||||
(if (> count-libraries 1)
|
||||
(tr "modals.unpublish-shared-confirm.hint-plural" (i18n/c count-files))
|
||||
(tr "modals.unpublish-shared-confirm.hint" (i18n/c count-files))))
|
||||
|
||||
accept-fn
|
||||
(mf/use-callback
|
||||
|
@ -91,19 +100,21 @@
|
|||
[:div.modal-content.delete-shared
|
||||
(when (and (string? message) (not= message ""))
|
||||
[:h3 message])
|
||||
|
||||
(when (> (count files->shared) 0)
|
||||
[:*
|
||||
[:div
|
||||
(when (and (string? scd-message) (not= scd-message ""))
|
||||
[:h3 scd-message])
|
||||
[:ul.file-list
|
||||
(for [[id file] files->shared]
|
||||
[:li.modal-item-element
|
||||
{:key id}
|
||||
[:span "- " (:name file)]])]]
|
||||
(when (and (string? hint) (not= hint ""))
|
||||
[:h3 hint])])]
|
||||
(when (not= 0 count-libraries)
|
||||
(if (> (count files->shared) 0)
|
||||
[:*
|
||||
[:div
|
||||
(when (and (string? scd-message) (not= scd-message ""))
|
||||
[:h3 scd-message])
|
||||
[:ul.file-list
|
||||
(for [[id file] files->shared]
|
||||
[:li.modal-item-element
|
||||
{:key id}
|
||||
[:span "- " (:name file)]])]]
|
||||
(when (and (string? hint) (not= hint ""))
|
||||
[:h3 hint])]
|
||||
[:*
|
||||
[:h3 no-files-message]]))]
|
||||
|
||||
[:div.modal-footer
|
||||
[:div.action-buttons
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
[app.common.pages.helpers :as cph]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.events :as ev]
|
||||
[app.main.data.exports :as de]
|
||||
[app.main.data.modal :as modal]
|
||||
|
@ -116,8 +117,8 @@
|
|||
add-shared-fn
|
||||
#(st/emit! (dwl/set-file-shared (:id file) true))
|
||||
|
||||
del-shared-fn
|
||||
#(st/emit! (dwl/set-file-shared (:id file) false))
|
||||
|
||||
|
||||
|
||||
on-add-shared
|
||||
(mf/use-fn
|
||||
|
@ -135,14 +136,15 @@
|
|||
on-remove-shared
|
||||
(mf/use-fn
|
||||
(mf/deps file)
|
||||
#(st/emit! (modal/show
|
||||
{:type :confirm
|
||||
:message ""
|
||||
:title (tr "modals.remove-shared-confirm.message" (:name file))
|
||||
:hint (tr "modals.remove-shared-confirm.hint")
|
||||
:cancel-label :omit
|
||||
:accept-label (tr "modals.remove-shared-confirm.accept")
|
||||
:on-accept del-shared-fn})))
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dd/fetch-libraries-using-files [file]))
|
||||
(st/emit! (modal/show
|
||||
{:type :delete-shared
|
||||
:origin :unpublish
|
||||
:on-accept #(st/emit! (dwl/set-file-shared (:id file) false))
|
||||
:count-libraries 1}))))
|
||||
|
||||
handle-blur (fn [_]
|
||||
(let [value (-> edit-input-ref mf/ref-val dom/get-value)]
|
||||
|
@ -281,7 +283,7 @@
|
|||
[:ul.sub-menu.file
|
||||
(if (:is-shared file)
|
||||
[:li {:on-click on-remove-shared}
|
||||
[:span (tr "dashboard.remove-shared")]]
|
||||
[:span (tr "dashboard.unpublish-shared")]]
|
||||
[:li {:on-click on-add-shared}
|
||||
[:span (tr "dashboard.add-shared")]])
|
||||
[:li.export-file {:on-click on-export-shapes}
|
||||
|
|
|
@ -192,7 +192,7 @@
|
|||
(when @open?
|
||||
[:div.advanced-ops-body
|
||||
[:div.layout-row
|
||||
[:div.direction-wrap.row-title "Align"] ;; TODO tradus
|
||||
[:div.direction-wrap.row-title "Align"]
|
||||
[:div.btn-wrapper
|
||||
[:& align-self-row {:is-col? is-col?
|
||||
:align-self align-self
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue