mirror of
https://github.com/penpot/penpot.git
synced 2025-07-03 00:07:17 +02:00
✨ Add info in modal
This commit is contained in:
parent
a5bf1c03e7
commit
c108974ad2
19 changed files with 327 additions and 58 deletions
|
@ -18,6 +18,7 @@
|
|||
[app.main.ui :as ui]
|
||||
[app.main.ui.alert]
|
||||
[app.main.ui.confirm]
|
||||
[app.main.ui.delete-shared]
|
||||
[app.main.ui.modal :refer [modal]]
|
||||
[app.main.ui.routes :as rt]
|
||||
[app.main.worker :as worker]
|
||||
|
|
|
@ -247,6 +247,32 @@
|
|||
(->> (rp/query :team-shared-files {:team-id team-id})
|
||||
(rx/map shared-files-fetched))))))
|
||||
|
||||
;; --- EVENT: Get files that use this shared-file
|
||||
|
||||
(defn clean-temp-shared
|
||||
[]
|
||||
(ptk/reify ::clean-temp-shared
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:dashboard-local :files-with-shared] nil))))
|
||||
|
||||
(defn library-using-files-fetched
|
||||
[files]
|
||||
(ptk/reify ::library-using-files-fetched
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [files (d/index-by :id files)]
|
||||
(assoc-in state [:dashboard-local :files-with-shared] files)))))
|
||||
|
||||
(defn fetch-library-using-files
|
||||
[file]
|
||||
(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))))))
|
||||
|
||||
;; --- EVENT: recent-files
|
||||
|
||||
(defn recent-files-fetched
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
[app.common.math :as mth]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.main.data.workspace.common :as dwc]
|
||||
[app.main.data.workspace.shapes :as dwsh]
|
||||
[app.main.data.workspace.state-helpers :as wsh]
|
||||
[app.main.data.workspace.undo :as dwu]
|
||||
|
|
|
@ -686,7 +686,7 @@
|
|||
:library-id library-id})))
|
||||
(when (and (seq (:redo-changes library-changes))
|
||||
sync-components?)
|
||||
(rx/of (sync-file-2nd-stage file-id library-id))))))))))
|
||||
(rx/of (sync-file-2nd-stage file-id library-id asset-id))))))))))
|
||||
|
||||
(defn- sync-file-2nd-stage
|
||||
"If some components have been modified, we need to launch another synchronization
|
||||
|
|
|
@ -9,14 +9,13 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.geom.proportions :as gpr]
|
||||
[app.common.pages :as cp]
|
||||
[app.common.pages.changes-builder :as pcb]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.spec :as us]
|
||||
[app.common.types.page :as ctp]
|
||||
[app.common.types.shape :as cts]
|
||||
[app.common.types.shape.interactions :as ctsi]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.types.shape.interactions :as ctsi]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.main.data.workspace.changes :as dch]
|
||||
[app.main.data.workspace.edition :as dwe]
|
||||
|
|
|
@ -92,19 +92,26 @@
|
|||
on-delete
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(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}))))
|
||||
(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})))))
|
||||
|
||||
on-move-success
|
||||
(fn [team-id project-id]
|
||||
|
@ -148,13 +155,10 @@
|
|||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (dd/fetch-library-using-files 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")
|
||||
{:type :delete-shared
|
||||
:origin :unpublish
|
||||
:on-accept del-shared})))
|
||||
|
||||
on-export-files
|
||||
|
@ -233,7 +237,7 @@
|
|||
(when (or (seq current-projects) (seq other-teams))
|
||||
[(tr "dashboard.move-to") nil sub-options "file-move-to"])
|
||||
(if (:is-shared file)
|
||||
[(tr "dashboard.remove-shared") on-del-shared nil "file-del-shared"]
|
||||
[(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"]
|
||||
|
|
|
@ -127,5 +127,6 @@
|
|||
[:section.dashboard-container
|
||||
[:& grid {:project project
|
||||
:files files
|
||||
:on-create-clicked on-create-clicked}]]]))
|
||||
:on-create-clicked on-create-clicked
|
||||
:origin :files}]]]))
|
||||
|
||||
|
|
|
@ -75,12 +75,13 @@
|
|||
|
||||
(mf/defc grid-item
|
||||
{:wrap [mf/memo]}
|
||||
[{:keys [file navigate?] :as props}]
|
||||
[{:keys [file navigate? origin] :as props}]
|
||||
(let [file-id (:id file)
|
||||
local (mf/use-state {:menu-open false
|
||||
:menu-pos nil
|
||||
:edition false})
|
||||
selected-files (mf/deref refs/dashboard-selected-files)
|
||||
dashboard-local (mf/deref refs/dashboard-local)
|
||||
item-ref (mf/use-ref)
|
||||
menu-ref (mf/use-ref)
|
||||
selected? (contains? selected-files file-id)
|
||||
|
@ -205,10 +206,12 @@
|
|||
:top (:y (:menu-pos @local))
|
||||
:navigate? navigate?
|
||||
:on-edit on-edit
|
||||
:on-menu-close on-menu-close}])]]]))
|
||||
:on-menu-close on-menu-close
|
||||
:origin origin
|
||||
:dashboard-local dashboard-local}])]]]))
|
||||
|
||||
(mf/defc grid
|
||||
[{:keys [files project on-create-clicked] :as props}]
|
||||
[{:keys [files project on-create-clicked origin] :as props}]
|
||||
(let [dragging? (mf/use-state false)
|
||||
project-id (:id project)
|
||||
|
||||
|
@ -268,7 +271,8 @@
|
|||
[:& grid-item
|
||||
{:file item
|
||||
:key (:id item)
|
||||
:navigate? true}])]
|
||||
:navigate? true
|
||||
:origin origin}])]
|
||||
|
||||
:else
|
||||
[:& empty-placeholder {:default? (:is-default project)
|
||||
|
@ -276,7 +280,7 @@
|
|||
:project project}])]))
|
||||
|
||||
(mf/defc line-grid-row
|
||||
[{:keys [files selected-files on-load-more dragging?] :as props}]
|
||||
[{:keys [files selected-files on-load-more dragging? origin] :as props}]
|
||||
(let [rowref (mf/use-ref)
|
||||
|
||||
width (mf/use-state nil)
|
||||
|
@ -322,7 +326,8 @@
|
|||
:file item
|
||||
:selected-files selected-files
|
||||
:key (:id item)
|
||||
:navigate? false}])
|
||||
:navigate? false
|
||||
:origin origin}])
|
||||
(when (and (> limit 0)
|
||||
(> (count files) limit))
|
||||
[:div.grid-item.placeholder {:on-click on-load-more}
|
||||
|
@ -331,7 +336,7 @@
|
|||
(tr "dashboard.show-all-files")]])]))
|
||||
|
||||
(mf/defc line-grid
|
||||
[{:keys [project team files on-load-more on-create-clicked] :as props}]
|
||||
[{:keys [project team files on-load-more on-create-clicked origin] :as props}]
|
||||
(let [dragging? (mf/use-state false)
|
||||
project-id (:id project)
|
||||
team-id (:id team)
|
||||
|
@ -415,7 +420,8 @@
|
|||
:team-id team-id
|
||||
:selected-files selected-files
|
||||
:on-load-more on-load-more
|
||||
:dragging? @dragging?}]
|
||||
:dragging? @dragging?
|
||||
:origin origin}]
|
||||
|
||||
:else
|
||||
[:& empty-placeholder {:dragging? @dragging?
|
||||
|
|
|
@ -42,5 +42,6 @@
|
|||
[:h1 (tr "dashboard.libraries-title")]]]
|
||||
[:section.dashboard-container
|
||||
[:& grid {:files files
|
||||
:project default-project}]]]))
|
||||
:project default-project
|
||||
:origin :libraries}]]]))
|
||||
|
||||
|
|
|
@ -153,7 +153,8 @@
|
|||
:team team
|
||||
:on-load-more on-nav
|
||||
:files files
|
||||
:on-create-clicked (partial create-file "dashboard:empty-folder-placeholder")}]]))
|
||||
:on-create-clicked (partial create-file "dashboard:empty-folder-placeholder")
|
||||
:origin :project}]]))
|
||||
|
||||
(def recent-files-ref
|
||||
(l/derived :dashboard-recent-files st/state))
|
||||
|
|
117
frontend/src/app/main/ui/delete_shared.cljs
Normal file
117
frontend/src/app/main/ui/delete_shared.cljs
Normal file
|
@ -0,0 +1,117 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.delete-shared
|
||||
(:require
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.keyboard :as k]
|
||||
[goog.events :as events]
|
||||
[rumext.alpha :as mf])
|
||||
(:import goog.events.EventType))
|
||||
|
||||
(mf/defc delete-shared-dialog
|
||||
{::mf/register modal/components
|
||||
::mf/register-as :delete-shared}
|
||||
[{:keys [on-accept
|
||||
on-cancel
|
||||
accept-style
|
||||
origin] :as props}]
|
||||
(let [on-accept (or on-accept identity)
|
||||
on-cancel (or on-cancel identity)
|
||||
cancel-label (tr "labels.cancel")
|
||||
accept-style (or accept-style :danger)
|
||||
is-delete? (= origin :delete)
|
||||
dashboard-local (mf/deref refs/dashboard-local)
|
||||
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"))
|
||||
message (if is-delete?
|
||||
(tr "modals.delete-shared-confirm.message")
|
||||
(tr "modals.unpublish-shared-confirm.message"))
|
||||
|
||||
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)))
|
||||
hint (if is-delete?
|
||||
""
|
||||
(tr "modals.unpublish-shared-confirm.hint" (i18n/c count-files)))
|
||||
|
||||
accept-fn
|
||||
(mf/use-callback
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(st/emit! (modal/hide))
|
||||
(on-accept props)))
|
||||
|
||||
cancel-fn
|
||||
(mf/use-callback
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(st/emit! (modal/hide))
|
||||
(on-cancel props)))]
|
||||
|
||||
(mf/with-effect
|
||||
(letfn [(on-keydown [event]
|
||||
(when (k/enter? event)
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (modal/hide))
|
||||
(on-accept props)))]
|
||||
(->> (events/listen js/document EventType.KEYDOWN on-keydown)
|
||||
(partial events/unlistenByKey)))
|
||||
#(st/emit! (dd/clean-temp-shared)))
|
||||
|
||||
[:div.modal-overlay
|
||||
[:div.modal-container.confirm-dialog
|
||||
[:div.modal-header
|
||||
[:div.modal-header-title
|
||||
[:h2 title]]
|
||||
[:div.modal-close-button
|
||||
{:on-click cancel-fn} i/close]]
|
||||
|
||||
[: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])])]
|
||||
|
||||
[:div.modal-footer
|
||||
[:div.action-buttons
|
||||
(when-not (= cancel-label :omit)
|
||||
[:input.cancel-button
|
||||
{:type "button"
|
||||
:value cancel-label
|
||||
:on-click cancel-fn}])
|
||||
|
||||
[:input.accept-button
|
||||
{:class (dom/classnames
|
||||
:danger (= accept-style :danger)
|
||||
:primary (= accept-style :primary))
|
||||
:type "button"
|
||||
:value accept-label
|
||||
:on-click accept-fn}]]]]]))
|
Loading…
Add table
Add a link
Reference in a new issue