mirror of
https://github.com/penpot/penpot.git
synced 2025-02-15 03:28:25 -05:00
✨ Add info in modal
This commit is contained in:
parent
a5bf1c03e7
commit
c108974ad2
19 changed files with 327 additions and 58 deletions
|
@ -384,7 +384,7 @@
|
||||||
|
|
||||||
(s/def ::file-data-for-thumbnail
|
(s/def ::file-data-for-thumbnail
|
||||||
(s/keys :req-un [::profile-id ::file-id]
|
(s/keys :req-un [::profile-id ::file-id]
|
||||||
:opt-in [::components-v2]))
|
:opt-un [::components-v2]))
|
||||||
|
|
||||||
(sv/defmethod ::file-data-for-thumbnail
|
(sv/defmethod ::file-data-for-thumbnail
|
||||||
"Retrieves the data for generate the thumbnail of the file. Used
|
"Retrieves the data for generate the thumbnail of the file. Used
|
||||||
|
@ -464,6 +464,24 @@
|
||||||
(check-read-permissions! pool profile-id file-id)
|
(check-read-permissions! pool profile-id file-id)
|
||||||
(retrieve-file-libraries cfg false file-id))
|
(retrieve-file-libraries cfg false file-id))
|
||||||
|
|
||||||
|
|
||||||
|
;; --- Query: Files that use this File library
|
||||||
|
|
||||||
|
(def ^:private sql:library-using-files
|
||||||
|
"SELECT f.id,
|
||||||
|
f.name
|
||||||
|
FROM file_library_rel AS flr
|
||||||
|
INNER JOIN file AS f ON f.id = flr.file_id
|
||||||
|
WHERE flr.library_file_id = ?;")
|
||||||
|
|
||||||
|
(s/def ::library-using-files
|
||||||
|
(s/keys :req-un [::profile-id ::file-id]))
|
||||||
|
|
||||||
|
(sv/defmethod ::library-using-files
|
||||||
|
[{:keys [pool] :as cfg} {:keys [profile-id file-id] :as params}]
|
||||||
|
(check-read-permissions! pool profile-id file-id)
|
||||||
|
(db/exec! pool [sql:library-using-files file-id]))
|
||||||
|
|
||||||
;; --- QUERY: team-recent-files
|
;; --- QUERY: team-recent-files
|
||||||
|
|
||||||
(def sql:team-recent-files
|
(def sql:team-recent-files
|
||||||
|
|
|
@ -15,14 +15,7 @@
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.pages :as cp]
|
[app.common.pages :as cp]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.component :as ctk]
|
|
||||||
[app.common.types.components-list :as ctkl]
|
|
||||||
[app.common.types.container :as ctn]
|
|
||||||
[app.common.types.file :as ctf]
|
|
||||||
[app.common.types.page :as ctp]
|
|
||||||
[app.common.types.pages-list :as ctpl]
|
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.types.shape-tree :as ctst]
|
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) UXBOX Labs SL
|
;; Copyright (c) UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.common.types.colors-list
|
(ns app.common.types.colors-list)
|
||||||
(:require
|
|
||||||
[app.common.data :as d]))
|
|
||||||
|
|
||||||
(defn colors-seq
|
(defn colors-seq
|
||||||
[file-data]
|
[file-data]
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
[app.common.types.page :as ctp]
|
[app.common.types.page :as ctp]
|
||||||
[app.common.types.pages-list :as ctpl]
|
[app.common.types.pages-list :as ctpl]
|
||||||
[app.common.types.shape-tree :as ctst]
|
[app.common.types.shape-tree :as ctst]
|
||||||
[app.common.types.typography :as cty]
|
|
||||||
[app.common.types.typographies-list :as ctyl]
|
[app.common.types.typographies-list :as ctyl]
|
||||||
|
[app.common.types.typography :as cty]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[clojure.spec.alpha :as s]
|
[clojure.spec.alpha :as s]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
@ -155,11 +155,11 @@
|
||||||
[[container instances]])))
|
[[container instances]])))
|
||||||
|
|
||||||
find-asset-usages
|
find-asset-usages
|
||||||
(fn [file-data library-id asset-type asset]
|
(fn [file-data asset]
|
||||||
(mapcat #(find-usages-in-container % asset) (containers-seq file-data)))]
|
(mapcat #(find-usages-in-container % asset) (containers-seq file-data)))]
|
||||||
|
|
||||||
(mapcat (fn [asset]
|
(mapcat (fn [asset]
|
||||||
(let [instances (find-asset-usages file-data (:id library-data) asset-type asset)]
|
(let [instances (find-asset-usages file-data asset)]
|
||||||
(when (d/not-empty? instances)
|
(when (d/not-empty? instances)
|
||||||
[[asset instances]])))
|
[[asset instances]])))
|
||||||
assets-seq)))
|
assets-seq)))
|
||||||
|
@ -252,7 +252,7 @@
|
||||||
(assoc-in [:options :components-v2] true))))))
|
(assoc-in [:options :components-v2] true))))))
|
||||||
|
|
||||||
(defn- absorb-components
|
(defn- absorb-components
|
||||||
[file-data library-data used-components]
|
[file-data used-components]
|
||||||
(let [grid-gap 50
|
(let [grid-gap 50
|
||||||
|
|
||||||
; Search for the library page. If not exists, create it.
|
; Search for the library page. If not exists, create it.
|
||||||
|
@ -336,7 +336,7 @@
|
||||||
(add-component-grid file-data (sort-by #(:name (first %)) used-components))))
|
(add-component-grid file-data (sort-by #(:name (first %)) used-components))))
|
||||||
|
|
||||||
(defn- absorb-colors
|
(defn- absorb-colors
|
||||||
[file-data library-data used-colors]
|
[file-data used-colors]
|
||||||
(let [absorb-color
|
(let [absorb-color
|
||||||
(fn [file-data [color usages]]
|
(fn [file-data [color usages]]
|
||||||
(let [remap-shape #(ctc/remap-colors % (:id file-data) color)
|
(let [remap-shape #(ctc/remap-colors % (:id file-data) color)
|
||||||
|
@ -360,7 +360,7 @@
|
||||||
used-colors)))
|
used-colors)))
|
||||||
|
|
||||||
(defn- absorb-typographies
|
(defn- absorb-typographies
|
||||||
[file-data library-data used-typographies]
|
[file-data used-typographies]
|
||||||
(let [absorb-typography
|
(let [absorb-typography
|
||||||
(fn [file-data [typography usages]]
|
(fn [file-data [typography usages]]
|
||||||
(let [remap-shape #(cty/remap-typographies % (:id file-data) typography)
|
(let [remap-shape #(cty/remap-typographies % (:id file-data) typography)
|
||||||
|
@ -393,13 +393,13 @@
|
||||||
|
|
||||||
(cond-> file-data
|
(cond-> file-data
|
||||||
(d/not-empty? used-components)
|
(d/not-empty? used-components)
|
||||||
(absorb-components library-data used-components)
|
(absorb-components used-components)
|
||||||
|
|
||||||
(d/not-empty? used-colors)
|
(d/not-empty? used-colors)
|
||||||
(absorb-colors library-data used-colors)
|
(absorb-colors used-colors)
|
||||||
|
|
||||||
(d/not-empty? used-typographies)
|
(d/not-empty? used-typographies)
|
||||||
(absorb-typographies library-data used-typographies))))
|
(absorb-typographies used-typographies))))
|
||||||
|
|
||||||
|
|
||||||
;; Debug helpers
|
;; Debug helpers
|
||||||
|
|
|
@ -4,9 +4,7 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) UXBOX Labs SL
|
;; Copyright (c) UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.common.types.typographies-list
|
(ns app.common.types.typographies-list)
|
||||||
(:require
|
|
||||||
[app.common.data :as d]))
|
|
||||||
|
|
||||||
(defn typographies-seq
|
(defn typographies-seq
|
||||||
[file-data]
|
[file-data]
|
||||||
|
|
|
@ -134,6 +134,12 @@
|
||||||
font-size: $fs16;
|
font-size: $fs16;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
&.delete-shared {
|
||||||
|
padding: 15px 32px;
|
||||||
|
.modal-item-element {
|
||||||
|
font-size: $fs16;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal-footer {
|
.modal-footer {
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
[app.main.ui :as ui]
|
[app.main.ui :as ui]
|
||||||
[app.main.ui.alert]
|
[app.main.ui.alert]
|
||||||
[app.main.ui.confirm]
|
[app.main.ui.confirm]
|
||||||
|
[app.main.ui.delete-shared]
|
||||||
[app.main.ui.modal :refer [modal]]
|
[app.main.ui.modal :refer [modal]]
|
||||||
[app.main.ui.routes :as rt]
|
[app.main.ui.routes :as rt]
|
||||||
[app.main.worker :as worker]
|
[app.main.worker :as worker]
|
||||||
|
|
|
@ -247,6 +247,32 @@
|
||||||
(->> (rp/query :team-shared-files {:team-id team-id})
|
(->> (rp/query :team-shared-files {:team-id team-id})
|
||||||
(rx/map shared-files-fetched))))))
|
(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
|
;; --- EVENT: recent-files
|
||||||
|
|
||||||
(defn recent-files-fetched
|
(defn recent-files-fetched
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
[app.common.math :as mth]
|
[app.common.math :as mth]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.main.data.workspace.common :as dwc]
|
|
||||||
[app.main.data.workspace.shapes :as dwsh]
|
[app.main.data.workspace.shapes :as dwsh]
|
||||||
[app.main.data.workspace.state-helpers :as wsh]
|
[app.main.data.workspace.state-helpers :as wsh]
|
||||||
[app.main.data.workspace.undo :as dwu]
|
[app.main.data.workspace.undo :as dwu]
|
||||||
|
|
|
@ -686,7 +686,7 @@
|
||||||
:library-id library-id})))
|
:library-id library-id})))
|
||||||
(when (and (seq (:redo-changes library-changes))
|
(when (and (seq (:redo-changes library-changes))
|
||||||
sync-components?)
|
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
|
(defn- sync-file-2nd-stage
|
||||||
"If some components have been modified, we need to launch another synchronization
|
"If some components have been modified, we need to launch another synchronization
|
||||||
|
|
|
@ -9,14 +9,13 @@
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.geom.proportions :as gpr]
|
[app.common.geom.proportions :as gpr]
|
||||||
[app.common.pages :as cp]
|
|
||||||
[app.common.pages.changes-builder :as pcb]
|
[app.common.pages.changes-builder :as pcb]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.spec :as us]
|
[app.common.spec :as us]
|
||||||
[app.common.types.page :as ctp]
|
[app.common.types.page :as ctp]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
[app.common.types.shape.interactions :as ctsi]
|
|
||||||
[app.common.types.shape-tree :as ctst]
|
[app.common.types.shape-tree :as ctst]
|
||||||
|
[app.common.types.shape.interactions :as ctsi]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.workspace.changes :as dch]
|
[app.main.data.workspace.changes :as dch]
|
||||||
[app.main.data.workspace.edition :as dwe]
|
[app.main.data.workspace.edition :as dwe]
|
||||||
|
|
|
@ -92,6 +92,13 @@
|
||||||
on-delete
|
on-delete
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation 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?
|
(if multi?
|
||||||
(st/emit! (modal/show
|
(st/emit! (modal/show
|
||||||
{:type :confirm
|
{:type :confirm
|
||||||
|
@ -104,7 +111,7 @@
|
||||||
:title (tr "modals.delete-file-confirm.title")
|
:title (tr "modals.delete-file-confirm.title")
|
||||||
:message (tr "modals.delete-file-confirm.message")
|
:message (tr "modals.delete-file-confirm.message")
|
||||||
:accept-label (tr "modals.delete-file-confirm.accept")
|
:accept-label (tr "modals.delete-file-confirm.accept")
|
||||||
:on-accept delete-fn}))))
|
:on-accept delete-fn})))))
|
||||||
|
|
||||||
on-move-success
|
on-move-success
|
||||||
(fn [team-id project-id]
|
(fn [team-id project-id]
|
||||||
|
@ -148,13 +155,10 @@
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
|
(st/emit! (dd/fetch-library-using-files file))
|
||||||
(st/emit! (modal/show
|
(st/emit! (modal/show
|
||||||
{:type :confirm
|
{:type :delete-shared
|
||||||
:message ""
|
:origin :unpublish
|
||||||
: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})))
|
:on-accept del-shared})))
|
||||||
|
|
||||||
on-export-files
|
on-export-files
|
||||||
|
@ -233,7 +237,7 @@
|
||||||
(when (or (seq current-projects) (seq other-teams))
|
(when (or (seq current-projects) (seq other-teams))
|
||||||
[(tr "dashboard.move-to") nil sub-options "file-move-to"])
|
[(tr "dashboard.move-to") nil sub-options "file-move-to"])
|
||||||
(if (:is-shared file)
|
(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"])
|
[(tr "dashboard.add-shared") on-add-shared nil "file-add-shared"])
|
||||||
[:separator]
|
[:separator]
|
||||||
[(tr "dashboard.download-binary-file") on-export-binary-files nil "download-binary-file"]
|
[(tr "dashboard.download-binary-file") on-export-binary-files nil "download-binary-file"]
|
||||||
|
|
|
@ -127,5 +127,6 @@
|
||||||
[:section.dashboard-container
|
[:section.dashboard-container
|
||||||
[:& grid {:project project
|
[:& grid {:project project
|
||||||
:files files
|
:files files
|
||||||
:on-create-clicked on-create-clicked}]]]))
|
:on-create-clicked on-create-clicked
|
||||||
|
:origin :files}]]]))
|
||||||
|
|
||||||
|
|
|
@ -75,12 +75,13 @@
|
||||||
|
|
||||||
(mf/defc grid-item
|
(mf/defc grid-item
|
||||||
{:wrap [mf/memo]}
|
{:wrap [mf/memo]}
|
||||||
[{:keys [file navigate?] :as props}]
|
[{:keys [file navigate? origin] :as props}]
|
||||||
(let [file-id (:id file)
|
(let [file-id (:id file)
|
||||||
local (mf/use-state {:menu-open false
|
local (mf/use-state {:menu-open false
|
||||||
:menu-pos nil
|
:menu-pos nil
|
||||||
:edition false})
|
:edition false})
|
||||||
selected-files (mf/deref refs/dashboard-selected-files)
|
selected-files (mf/deref refs/dashboard-selected-files)
|
||||||
|
dashboard-local (mf/deref refs/dashboard-local)
|
||||||
item-ref (mf/use-ref)
|
item-ref (mf/use-ref)
|
||||||
menu-ref (mf/use-ref)
|
menu-ref (mf/use-ref)
|
||||||
selected? (contains? selected-files file-id)
|
selected? (contains? selected-files file-id)
|
||||||
|
@ -205,10 +206,12 @@
|
||||||
:top (:y (:menu-pos @local))
|
:top (:y (:menu-pos @local))
|
||||||
:navigate? navigate?
|
:navigate? navigate?
|
||||||
:on-edit on-edit
|
: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
|
(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)
|
(let [dragging? (mf/use-state false)
|
||||||
project-id (:id project)
|
project-id (:id project)
|
||||||
|
|
||||||
|
@ -268,7 +271,8 @@
|
||||||
[:& grid-item
|
[:& grid-item
|
||||||
{:file item
|
{:file item
|
||||||
:key (:id item)
|
:key (:id item)
|
||||||
:navigate? true}])]
|
:navigate? true
|
||||||
|
:origin origin}])]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:& empty-placeholder {:default? (:is-default project)
|
[:& empty-placeholder {:default? (:is-default project)
|
||||||
|
@ -276,7 +280,7 @@
|
||||||
:project project}])]))
|
:project project}])]))
|
||||||
|
|
||||||
(mf/defc line-grid-row
|
(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)
|
(let [rowref (mf/use-ref)
|
||||||
|
|
||||||
width (mf/use-state nil)
|
width (mf/use-state nil)
|
||||||
|
@ -322,7 +326,8 @@
|
||||||
:file item
|
:file item
|
||||||
:selected-files selected-files
|
:selected-files selected-files
|
||||||
:key (:id item)
|
:key (:id item)
|
||||||
:navigate? false}])
|
:navigate? false
|
||||||
|
:origin origin}])
|
||||||
(when (and (> limit 0)
|
(when (and (> limit 0)
|
||||||
(> (count files) limit))
|
(> (count files) limit))
|
||||||
[:div.grid-item.placeholder {:on-click on-load-more}
|
[:div.grid-item.placeholder {:on-click on-load-more}
|
||||||
|
@ -331,7 +336,7 @@
|
||||||
(tr "dashboard.show-all-files")]])]))
|
(tr "dashboard.show-all-files")]])]))
|
||||||
|
|
||||||
(mf/defc line-grid
|
(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)
|
(let [dragging? (mf/use-state false)
|
||||||
project-id (:id project)
|
project-id (:id project)
|
||||||
team-id (:id team)
|
team-id (:id team)
|
||||||
|
@ -415,7 +420,8 @@
|
||||||
:team-id team-id
|
:team-id team-id
|
||||||
:selected-files selected-files
|
:selected-files selected-files
|
||||||
:on-load-more on-load-more
|
:on-load-more on-load-more
|
||||||
:dragging? @dragging?}]
|
:dragging? @dragging?
|
||||||
|
:origin origin}]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:& empty-placeholder {:dragging? @dragging?
|
[:& empty-placeholder {:dragging? @dragging?
|
||||||
|
|
|
@ -42,5 +42,6 @@
|
||||||
[:h1 (tr "dashboard.libraries-title")]]]
|
[:h1 (tr "dashboard.libraries-title")]]]
|
||||||
[:section.dashboard-container
|
[:section.dashboard-container
|
||||||
[:& grid {:files files
|
[:& grid {:files files
|
||||||
:project default-project}]]]))
|
:project default-project
|
||||||
|
:origin :libraries}]]]))
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,8 @@
|
||||||
:team team
|
:team team
|
||||||
:on-load-more on-nav
|
:on-load-more on-nav
|
||||||
:files files
|
: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
|
(def recent-files-ref
|
||||||
(l/derived :dashboard-recent-files st/state))
|
(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}]]]]]))
|
|
@ -539,6 +539,10 @@ msgstr "Want to remove your account?"
|
||||||
msgid "dashboard.remove-shared"
|
msgid "dashboard.remove-shared"
|
||||||
msgstr "Remove as Shared Library"
|
msgstr "Remove as Shared Library"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "dashboard.unpublish-shared"
|
||||||
|
msgstr "Unpublish Library"
|
||||||
|
|
||||||
#: src/app/main/ui/settings/profile.cljs
|
#: src/app/main/ui/settings/profile.cljs
|
||||||
msgid "dashboard.save-settings"
|
msgid "dashboard.save-settings"
|
||||||
msgstr "Save settings"
|
msgstr "Save settings"
|
||||||
|
@ -1775,6 +1779,49 @@ msgstr ""
|
||||||
msgid "modals.remove-shared-confirm.message"
|
msgid "modals.remove-shared-confirm.message"
|
||||||
msgstr "Remove “%s” as Shared Library"
|
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"
|
||||||
|
|
||||||
|
#: 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?"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.unpublish-shared-confirm.scd-message"
|
||||||
|
msgid_plural "modals.unpublish-shared-confirm.scd-message"
|
||||||
|
msgstr[0] "It's in use in this file:"
|
||||||
|
msgstr[1] "It's in use in these files:"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.unpublish-shared-confirm.hint"
|
||||||
|
msgid_plural "modals.unpublish-shared-confirm.hint"
|
||||||
|
msgstr[0] "If you unpublish it, the assets in it became a library of this file."
|
||||||
|
msgstr[1] "If you unpublish it, the assets in it became a library of these files."
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.unpublish-shared-confirm.accept"
|
||||||
|
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"
|
||||||
|
|
||||||
|
#: 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?"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.delete-shared-confirm.scd-message"
|
||||||
|
msgid_plural "modals.delete-shared-confirm.scd-message"
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/nudge.cljs
|
#: src/app/main/ui/workspace/nudge.cljs
|
||||||
msgid "modals.small-nudge"
|
msgid "modals.small-nudge"
|
||||||
msgstr "Small nudge"
|
msgstr "Small nudge"
|
||||||
|
@ -1807,6 +1854,10 @@ msgstr ""
|
||||||
msgid "modals.update-remote-component.message"
|
msgid "modals.update-remote-component.message"
|
||||||
msgstr "Update a component in a shared library"
|
msgstr "Update a component in a shared library"
|
||||||
|
|
||||||
|
#: src/app/main/ui/delete_shared.cljs
|
||||||
|
msgid "modals.delete-shared.title"
|
||||||
|
msgstr "Deleting file"
|
||||||
|
|
||||||
#: src/app/main/ui/dashboard/team.cljs
|
#: src/app/main/ui/dashboard/team.cljs
|
||||||
msgid "notifications.invitation-email-sent"
|
msgid "notifications.invitation-email-sent"
|
||||||
msgstr "Invitation sent successfully"
|
msgstr "Invitation sent successfully"
|
||||||
|
|
|
@ -551,6 +551,10 @@ msgstr "¿Quieres borrar tu cuenta?"
|
||||||
msgid "dashboard.remove-shared"
|
msgid "dashboard.remove-shared"
|
||||||
msgstr "Eliminar como Biblioteca Compartida"
|
msgstr "Eliminar como Biblioteca Compartida"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "dashboard.unpublish-shared"
|
||||||
|
msgstr "Despublicar Biblioteca"
|
||||||
|
|
||||||
#: src/app/main/ui/settings/profile.cljs
|
#: src/app/main/ui/settings/profile.cljs
|
||||||
msgid "dashboard.save-settings"
|
msgid "dashboard.save-settings"
|
||||||
msgstr "Guardar opciones"
|
msgstr "Guardar opciones"
|
||||||
|
@ -1849,6 +1853,48 @@ msgstr ""
|
||||||
msgid "modals.remove-shared-confirm.message"
|
msgid "modals.remove-shared-confirm.message"
|
||||||
msgstr "Añadir “%s” como Biblioteca Compartida"
|
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"
|
||||||
|
|
||||||
|
#: 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?"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.unpublish-shared-confirm.scd-message"
|
||||||
|
msgid_plural "modals.unpublish-shared-confirm.scd-message"
|
||||||
|
msgstr[0] "Está siendo usada en este archivo:"
|
||||||
|
msgstr[1] "Está siendo usada en estos archivos:"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.unpublish-shared-confirm.hint"
|
||||||
|
msgid_plural "modals.unpublish-shared-confirm.hint"
|
||||||
|
msgstr[0] "Si la despublicas, los elementos pasarán a formar parte de la biblioteca del archivo."
|
||||||
|
msgstr[1] "Si la despublicas, los elementos pasarán a formar parte de la biblioteca de los archivos."
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.unpublish-shared-confirm.accept"
|
||||||
|
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"
|
||||||
|
|
||||||
|
#: 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?"
|
||||||
|
|
||||||
|
#: src/app/main/ui/workspace/header.cljs, src/app/main/ui/dashboard/file_menu.cljs
|
||||||
|
msgid "modals.delete-shared-confirm.scd-message"
|
||||||
|
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.accept"
|
||||||
|
msgstr "Borrar archivo"
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/nudge.cljs
|
#: src/app/main/ui/workspace/nudge.cljs
|
||||||
msgid "modals.small-nudge"
|
msgid "modals.small-nudge"
|
||||||
msgstr "Mínimo"
|
msgstr "Mínimo"
|
||||||
|
@ -1887,6 +1933,10 @@ msgstr ""
|
||||||
msgid "modals.update-remote-component.message"
|
msgid "modals.update-remote-component.message"
|
||||||
msgstr "Actualizar un componente en librería"
|
msgstr "Actualizar un componente en librería"
|
||||||
|
|
||||||
|
#: src/app/main/ui/delete_shared.cljs
|
||||||
|
msgid "modals.delete-shared.title"
|
||||||
|
msgstr "Borrar archivo"
|
||||||
|
|
||||||
#: src/app/main/ui/dashboard/team.cljs
|
#: src/app/main/ui/dashboard/team.cljs
|
||||||
msgid "notifications.invitation-email-sent"
|
msgid "notifications.invitation-email-sent"
|
||||||
msgstr "Invitación enviada con éxito"
|
msgstr "Invitación enviada con éxito"
|
||||||
|
|
Loading…
Add table
Reference in a new issue