mirror of
https://github.com/penpot/penpot.git
synced 2025-05-17 13:56:10 +02:00
commit
2ca8ff4db1
30 changed files with 1766 additions and 376 deletions
|
@ -400,6 +400,13 @@
|
|||
},
|
||||
"used-in" : [ "src/app/main/ui/settings/profile.cljs" ]
|
||||
},
|
||||
"dashboard.copy-suffix" : {
|
||||
"translations" : {
|
||||
"en" : "(copy)",
|
||||
"es" : "(copia)"
|
||||
},
|
||||
"used-in" : [ "src/app/main/data/dashboard.cljs" ]
|
||||
},
|
||||
"dashboard.create-new-team" : {
|
||||
"translations" : {
|
||||
"ca" : "+ Crear un nou equip",
|
||||
|
@ -441,6 +448,13 @@
|
|||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/files.cljs" ]
|
||||
},
|
||||
"dashboard.duplicate" : {
|
||||
"translations" : {
|
||||
"en" : "Duplicate",
|
||||
"es" : "Duplicar"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.empty-files" : {
|
||||
"translations" : {
|
||||
"ca" : "Encara no hi ha cap arxiu aquí",
|
||||
|
@ -493,6 +507,20 @@
|
|||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/grid.cljs" ]
|
||||
},
|
||||
"dashboard.move-to" : {
|
||||
"translations" : {
|
||||
"en" : "Move to",
|
||||
"es" : "Mover a"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.move-to-other-team" : {
|
||||
"translations" : {
|
||||
"en" : "Move to other team",
|
||||
"es" : "Mover a otro equipo"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.new-file" : {
|
||||
"translations" : {
|
||||
"ca" : "+ Nou Arxiu",
|
||||
|
@ -579,6 +607,13 @@
|
|||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/team.cljs" ]
|
||||
},
|
||||
"dashboard.open-in-new-tab" : {
|
||||
"translations" : {
|
||||
"en" : "Open file in a new tab",
|
||||
"es" : "Abrir en una pestaña nueva"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.password-change" : {
|
||||
"translations" : {
|
||||
"ca" : "Canvia la contrasenya",
|
||||
|
@ -590,6 +625,13 @@
|
|||
},
|
||||
"used-in" : [ "src/app/main/ui/settings/password.cljs" ]
|
||||
},
|
||||
"dashboard.pin-unpin" : {
|
||||
"translations" : {
|
||||
"en" : "Pin/Unpin",
|
||||
"es" : "Fijar/Desfijar"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/project_menu.cljs" ]
|
||||
},
|
||||
"dashboard.projects-title" : {
|
||||
"translations" : {
|
||||
"ca" : "Projectes",
|
||||
|
@ -687,6 +729,48 @@
|
|||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/grid.cljs" ]
|
||||
},
|
||||
"dashboard.success-delete-project" : {
|
||||
"translations" : {
|
||||
"en" : "Your project has been deleted successfully",
|
||||
"es" : "Tu proyecto ha sido borrado con éxito"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/project_menu.cljs" ]
|
||||
},
|
||||
"dashboard.success-delete-file" : {
|
||||
"translations" : {
|
||||
"en" : "Your file has been deleted successfully",
|
||||
"es" : "Tu archivo ha sido borrado con éxito"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.success-duplicate-project" : {
|
||||
"translations" : {
|
||||
"en" : "Your project has been duplicated successfully",
|
||||
"es" : "Tu proyecto ha sido duplicado con éxito"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/project_menu.cljs" ]
|
||||
},
|
||||
"dashboard.success-duplicate-file" : {
|
||||
"translations" : {
|
||||
"en" : "Your file has been duplicated successfully",
|
||||
"es" : "Tu archivo ha sido duplicado con éxito"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.success-move-project" : {
|
||||
"translations" : {
|
||||
"en" : "Your project has been moved successfully",
|
||||
"es" : "Tu proyecto ha sido movido con éxito"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/project_menu.cljs" ]
|
||||
},
|
||||
"dashboard.success-move-file" : {
|
||||
"translations" : {
|
||||
"en" : "Your file has been moved successfully",
|
||||
"es" : "Tu archivo ha sido movido con éxito"
|
||||
},
|
||||
"used-in" : [ "src/app/main/ui/dashboard/file_menu.cljs" ]
|
||||
},
|
||||
"dashboard.switch-team" : {
|
||||
"translations" : {
|
||||
"ca" : "Cambiar d'equip",
|
||||
|
@ -964,7 +1048,7 @@
|
|||
"translations" : {
|
||||
"ca" : "Sembla que el contingut de la imatge no coincideix amb l'extensió del arxiu",
|
||||
"en" : "Seems that the contents of the image does not match the file extension.",
|
||||
"es" : "Parece que el contenido de la imagen no coincide con la etensión del archivo.",
|
||||
"es" : "Parece que el contenido de la imagen no coincide con la extensión del archivo.",
|
||||
"fr" : "Il semble que le contenu de l’image ne correspond pas à l’extension de fichier.",
|
||||
"ru" : "",
|
||||
"zh_cn" : "图片内容好像与文档扩展名不匹配。"
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
visibility: visible;
|
||||
}
|
||||
|
||||
.context-menu.fixed {
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.context-menu-items {
|
||||
background: $color-white;
|
||||
border-radius: $br-small;
|
||||
|
@ -31,6 +35,12 @@
|
|||
overflow: auto;
|
||||
position: absolute;
|
||||
top: $size-3;
|
||||
|
||||
& .separator {
|
||||
border-top: 1px solid $color-gray-10;
|
||||
padding: 0px;
|
||||
margin: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.context-menu-action {
|
||||
|
@ -45,6 +55,34 @@
|
|||
color: $color-black;
|
||||
background-color: $color-primary-lighter;
|
||||
}
|
||||
|
||||
&.submenu {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
|
||||
& span {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
& svg {
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
&.submenu-back {
|
||||
color: $color-gray-30;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
& svg {
|
||||
height: 10px;
|
||||
width: 10px;
|
||||
transform: rotate(180deg);
|
||||
margin-right: $small;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.context-menu.is-selectable {
|
||||
|
|
|
@ -195,13 +195,6 @@
|
|||
width: 15px;
|
||||
height: 30px;
|
||||
|
||||
svg {
|
||||
fill: $color-gray-20;
|
||||
height: 18px;
|
||||
margin-right: $x-small;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
span {
|
||||
color: $color-black;
|
||||
}
|
||||
|
@ -218,13 +211,15 @@
|
|||
align-items: flex-end;
|
||||
flex-direction: column;
|
||||
|
||||
svg {
|
||||
> svg {
|
||||
fill: $color-gray-60;
|
||||
margin-right: 0;
|
||||
height: 18px;
|
||||
width: 18px;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
svg {
|
||||
> svg {
|
||||
fill: $color-primary-dark;
|
||||
}
|
||||
|
||||
|
@ -237,7 +232,7 @@
|
|||
}
|
||||
|
||||
.project-th-actions.force-display {
|
||||
display: flex;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -105,4 +105,14 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.pin-icon {
|
||||
svg {
|
||||
fill: $color-gray-20;
|
||||
}
|
||||
|
||||
&.active {
|
||||
svg { fill: $color-gray-50; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@
|
|||
overflow: unset;
|
||||
}
|
||||
|
||||
li {
|
||||
& > li {
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
|
|
|
@ -49,6 +49,10 @@
|
|||
margin-right: $medium;
|
||||
}
|
||||
|
||||
.edit-wrapper {
|
||||
margin-right: $medium;
|
||||
}
|
||||
|
||||
.info {
|
||||
font-size: 15px;
|
||||
line-height: 1rem;
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
[app.common.uuid :as uuid]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.data.users :as du]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[app.util.time :as dt]
|
||||
[app.util.timers :as ts]
|
||||
|
@ -347,6 +348,43 @@
|
|||
(rx/map #(partial created %))
|
||||
(rx/catch on-error)))))))
|
||||
|
||||
(defn duplicate-project
|
||||
[{:keys [id name] :as params}]
|
||||
(us/assert ::us/uuid id)
|
||||
(letfn [(duplicated [project state]
|
||||
(-> state
|
||||
(assoc-in [:projects (:team-id project) (:id project)] project)))]
|
||||
(ptk/reify ::duplicate-project
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error identity}} (meta params)
|
||||
|
||||
new-name (str name " " (tr "dashboard.copy-suffix"))]
|
||||
|
||||
(->> (rp/mutation! :duplicate-project {:project-id id
|
||||
:name new-name})
|
||||
(rx/tap on-success)
|
||||
(rx/map #(partial duplicated %))
|
||||
(rx/catch on-error)))))))
|
||||
|
||||
(defn move-project
|
||||
[{:keys [id team-id] :as params}]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::us/uuid team-id)
|
||||
(ptk/reify ::move-project
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error identity}} (meta params)]
|
||||
|
||||
(->> (rp/mutation! :move-project {:project-id id
|
||||
:team-id team-id})
|
||||
(rx/tap on-success)
|
||||
(rx/catch on-error))))))
|
||||
|
||||
(def clear-project-for-edit
|
||||
(ptk/reify ::clear-project-for-edit
|
||||
ptk/UpdateEvent
|
||||
|
@ -494,3 +532,43 @@
|
|||
(-> state
|
||||
(assoc-in [:files project-id id] file)
|
||||
(update-in [:recent-files project-id] (fnil conj #{}) id)))))
|
||||
|
||||
;; --- Duplicate File
|
||||
|
||||
(defn duplicate-file
|
||||
[{:keys [id name] :as params}]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::name name)
|
||||
(ptk/reify ::duplicate-file
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error identity}} (meta params)
|
||||
|
||||
new-name (str name " " (tr "dashboard.copy-suffix"))]
|
||||
|
||||
(->> (rp/mutation! :duplicate-file {:file-id id
|
||||
:name new-name})
|
||||
(rx/tap on-success)
|
||||
(rx/map file-created)
|
||||
(rx/catch on-error))))))
|
||||
|
||||
;; --- Move File
|
||||
|
||||
(defn move-file
|
||||
[{:keys [id project-id] :as params}]
|
||||
(us/assert ::us/uuid id)
|
||||
(us/assert ::us/uuid project-id)
|
||||
(ptk/reify ::move-file
|
||||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [{:keys [on-success on-error]
|
||||
:or {on-success identity
|
||||
on-error identity}} (meta params)]
|
||||
|
||||
(->> (rp/mutation! :move-files {:ids #{id}
|
||||
:project-id project-id})
|
||||
(rx/tap on-success)
|
||||
(rx/catch on-error))))))
|
||||
|
||||
|
|
|
@ -12,9 +12,11 @@
|
|||
[rumext.alpha :as mf]
|
||||
[goog.object :as gobj]
|
||||
[app.main.ui.components.dropdown :refer [dropdown']]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.util.data :refer [classnames]]
|
||||
[app.util.dom :as dom]))
|
||||
[app.util.dom :as dom]
|
||||
[app.util.object :as obj]))
|
||||
|
||||
(mf/defc context-menu
|
||||
{::mf/wrap-props false}
|
||||
|
@ -24,37 +26,92 @@
|
|||
(assert (vector? (gobj/get props "options")) "missing `options` prop")
|
||||
|
||||
(let [open? (gobj/get props "show")
|
||||
on-close (gobj/get props "on-close")
|
||||
options (gobj/get props "options")
|
||||
is-selectable (gobj/get props "selectable")
|
||||
selected (gobj/get props "selected")
|
||||
top (gobj/get props "top")
|
||||
left (gobj/get props "left")
|
||||
top (gobj/get props "top" 0)
|
||||
left (gobj/get props "left" 0)
|
||||
fixed? (gobj/get props "fixed?" false)
|
||||
|
||||
offset (mf/use-state 0)
|
||||
local (mf/use-state {:offset 0
|
||||
:levels nil})
|
||||
|
||||
on-local-close
|
||||
(mf/use-callback
|
||||
(fn []
|
||||
(swap! local assoc :levels [{:parent-option nil
|
||||
:options options}])
|
||||
(on-close)))
|
||||
|
||||
check-menu-offscreen
|
||||
(mf/use-callback
|
||||
(mf/deps top @offset)
|
||||
(mf/deps top (:offset @local))
|
||||
(fn [node]
|
||||
(when node
|
||||
(when (and node (not fixed?))
|
||||
(let [{node-height :height} (dom/get-bounding-rect node)
|
||||
{window-height :height} (dom/get-window-size)
|
||||
target-offset (if (> (+ top node-height) window-height)
|
||||
(- node-height)
|
||||
0)]
|
||||
|
||||
(if (not= target-offset @offset)
|
||||
(reset! offset target-offset))))))]
|
||||
(if (not= target-offset (:offset @local))
|
||||
(swap! local assoc :offset target-offset))))))
|
||||
|
||||
(when open?
|
||||
enter-submenu
|
||||
(mf/use-callback
|
||||
(mf/deps options)
|
||||
(fn [option-name sub-options]
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(swap! local update :levels
|
||||
conj {:parent-option option-name
|
||||
:options sub-options}))))
|
||||
|
||||
exit-submenu
|
||||
(mf/use-callback
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(swap! local update :levels pop)))
|
||||
|
||||
props (obj/merge props #js {:on-close on-local-close})]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps options)
|
||||
#(swap! local assoc :levels [{:parent-option nil
|
||||
:options options}]))
|
||||
|
||||
(when (and open? (some? (:levels @local)))
|
||||
[:> dropdown' props
|
||||
[:div.context-menu {:class (classnames :is-open open?
|
||||
:fixed fixed?
|
||||
:is-selectable is-selectable)
|
||||
:style {:top (+ top @offset)
|
||||
:style {:top (+ top (:offset @local))
|
||||
:left left}}
|
||||
[:ul.context-menu-items {:ref check-menu-offscreen}
|
||||
(for [[action-name action-handler] options]
|
||||
[:li.context-menu-item {:class (classnames :is-selected (and selected (= action-name selected)))
|
||||
:key action-name}
|
||||
[:a.context-menu-action {:on-click action-handler}
|
||||
action-name]])]]])))
|
||||
(let [level (-> @local :levels peek)]
|
||||
[:ul.context-menu-items {:ref check-menu-offscreen}
|
||||
(when-let [parent-option (:parent-option level)]
|
||||
[:*
|
||||
[:li.context-menu-item
|
||||
[:a.context-menu-action.submenu-back
|
||||
{:data-no-close true
|
||||
:on-click exit-submenu}
|
||||
[:span i/arrow-slide]
|
||||
parent-option]]
|
||||
[:li.separator]])
|
||||
(for [[option-name option-handler sub-options] (:options level)]
|
||||
(when option-name
|
||||
(if (= option-name :separator)
|
||||
[:li.separator]
|
||||
[:li.context-menu-item
|
||||
{:class (classnames :is-selected (and selected
|
||||
(= option-name selected)))
|
||||
:key option-name}
|
||||
(if-not sub-options
|
||||
[:a.context-menu-action {:on-click option-handler}
|
||||
option-name]
|
||||
[:a.context-menu-action.submenu
|
||||
{:data-no-close true
|
||||
:on-click (enter-submenu option-name sub-options)}
|
||||
option-name
|
||||
[:span i/arrow-slide]])])))])]])))
|
||||
|
|
|
@ -17,12 +17,13 @@
|
|||
|
||||
on-click
|
||||
(fn [event]
|
||||
(if ref
|
||||
(let [target (dom/get-target event)
|
||||
parent (mf/ref-val ref)]
|
||||
(when-not (or (not parent) (.contains parent target))
|
||||
(on-close)))
|
||||
(on-close)))
|
||||
(let [target (dom/get-target event)]
|
||||
(when-not (.-data-no-close ^js target)
|
||||
(if ref
|
||||
(let [parent (mf/ref-val ref)]
|
||||
(when-not (or (not parent) (.contains parent target))
|
||||
(on-close)))
|
||||
(on-close)))))
|
||||
|
||||
on-keyup
|
||||
(fn [event]
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
[app.main.data.modal :as modal]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.dashboard.files :refer [files-section]]
|
||||
[app.main.ui.dashboard.libraries :refer [libraries-page]]
|
||||
[app.main.ui.dashboard.projects :refer [projects-section]]
|
||||
|
@ -105,18 +106,23 @@
|
|||
(mf/deps team-id)
|
||||
(st/emitf (dd/fetch-bundle {:id team-id})))
|
||||
|
||||
[:section.dashboard-layout
|
||||
[:& sidebar {:team team
|
||||
:projects projects
|
||||
:project project
|
||||
:profile profile
|
||||
:section section
|
||||
:search-term search-term}]
|
||||
(when (and team (seq projects))
|
||||
[:& dashboard-content {:projects projects
|
||||
:profile profile
|
||||
:project project
|
||||
:section section
|
||||
:search-term search-term
|
||||
:team team}])]))
|
||||
[:& (mf/provider ctx/current-file-id) {:value nil}
|
||||
[:& (mf/provider ctx/current-team-id) {:value team-id}
|
||||
[:& (mf/provider ctx/current-project-id) {:value project-id}
|
||||
[:& (mf/provider ctx/current-page-id) {:value nil}
|
||||
|
||||
[:section.dashboard-layout
|
||||
[:& sidebar {:team team
|
||||
:projects projects
|
||||
:project project
|
||||
:profile profile
|
||||
:section section
|
||||
:search-term search-term}]
|
||||
(when (and team (seq projects))
|
||||
[:& dashboard-content {:projects projects
|
||||
:profile profile
|
||||
:project project
|
||||
:section section
|
||||
:search-term search-term
|
||||
:team team}])]]]]]))
|
||||
|
||||
|
|
183
frontend/src/app/main/ui/dashboard/file_menu.cljs
Normal file
183
frontend/src/app/main/ui/dashboard/file_menu.cljs
Normal file
|
@ -0,0 +1,183 @@
|
|||
;; 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/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2021 UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.dashboard.file-menu
|
||||
(:require
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.components.context-menu :refer [context-menu]]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[beicon.core :as rx]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc file-menu
|
||||
[{:keys [file show? on-edit on-menu-close top left] :as props}]
|
||||
(assert (some? file) "missing `file` 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")
|
||||
(let [top (or top 0)
|
||||
left (or left 0)
|
||||
|
||||
current-team-id (mf/use-ctx ctx/current-team-id)
|
||||
teams (mf/use-state nil)
|
||||
current-team (get @teams current-team-id)
|
||||
other-teams (remove #(= (:id %) current-team-id)
|
||||
(vals @teams))
|
||||
current-projects (remove #(= (:id %) (:project-id file))
|
||||
(:projects current-team))
|
||||
|
||||
project-name (fn [project]
|
||||
(if (:is-default project)
|
||||
(tr "labels.drafts")
|
||||
(:name project)))
|
||||
|
||||
on-new-tab
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(let [pparams {:project-id (:project-id file)
|
||||
:file-id (:id file)}
|
||||
qparams {:page-id (first (get-in file [:data :pages]))}]
|
||||
(st/emit! (rt/nav-new-window :workspace pparams qparams)))))
|
||||
|
||||
on-duplicate
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dm/success (tr "dashboard.success-duplicate-file"))
|
||||
(dd/duplicate-file file)))
|
||||
|
||||
delete-fn
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dm/success (tr "dashboard.success-delete-file"))
|
||||
(dd/delete-file file)))
|
||||
|
||||
on-delete
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(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
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [team-id project-id]
|
||||
(let [data {:id (:id file)
|
||||
:project-id project-id}
|
||||
|
||||
mdata {:on-success
|
||||
(st/emitf (dm/success (tr "dashboard.success-move-file"))
|
||||
(rt/nav :dashboard-files
|
||||
{:team-id team-id
|
||||
:project-id project-id}))}]
|
||||
|
||||
(st/emitf (dd/move-file (with-meta data mdata))))))
|
||||
|
||||
add-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dd/set-file-shared (assoc file :is-shared true))))
|
||||
|
||||
del-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dd/set-file-shared (assoc file :is-shared false))))
|
||||
|
||||
on-add-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(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}))))
|
||||
|
||||
on-del-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(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}))))]
|
||||
|
||||
(mf/use-layout-effect
|
||||
(mf/deps show?)
|
||||
(fn []
|
||||
(let [group-by-team (fn [projects]
|
||||
(reduce
|
||||
(fn [teams project]
|
||||
(update teams (:team-id project)
|
||||
#(if (nil? %)
|
||||
{:id (:team-id project)
|
||||
:name (:team-name project)
|
||||
:projects [project]}
|
||||
(update % :projects conj project))))
|
||||
{}
|
||||
projects))]
|
||||
(if show?
|
||||
(->> (rp/query! :all-projects)
|
||||
(rx/map group-by-team)
|
||||
(rx/subs #(reset! teams %)))
|
||||
(reset! teams [])))))
|
||||
|
||||
(when current-team
|
||||
[:& context-menu {:on-close on-menu-close
|
||||
:show show?
|
||||
:fixed? (or (not= top 0) (not= left 0))
|
||||
:top top
|
||||
:left left
|
||||
:options [[(tr "dashboard.open-in-new-tab") on-new-tab]
|
||||
[(tr "labels.rename") on-edit]
|
||||
[(tr "dashboard.duplicate") on-duplicate]
|
||||
(when (or (seq current-projects) (seq other-teams))
|
||||
[(tr "dashboard.move-to") nil
|
||||
(conj (vec (for [project current-projects]
|
||||
[(project-name project)
|
||||
(on-move (:id current-team)
|
||||
(:id project))]))
|
||||
(when (seq other-teams)
|
||||
[(tr "dashboard.move-to-other-team") nil
|
||||
(for [team other-teams]
|
||||
[(:name team) nil
|
||||
(for [sub-project (:projects team)]
|
||||
[(project-name sub-project)
|
||||
(on-move (:id team)
|
||||
(:id sub-project))])])]))])
|
||||
(if (:is-shared file)
|
||||
[(tr "dashboard.remove-shared") on-del-shared]
|
||||
[(tr "dashboard.add-shared") on-add-shared])
|
||||
[:separator]
|
||||
[(tr "labels.delete") on-delete]]}])))
|
||||
|
|
@ -15,6 +15,7 @@
|
|||
[app.main.ui.components.context-menu :refer [context-menu]]
|
||||
[app.main.ui.dashboard.grid :refer [grid]]
|
||||
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
|
||||
[app.main.ui.dashboard.project-menu :refer [project-menu]]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [t]]
|
||||
|
@ -40,23 +41,10 @@
|
|||
on-edit
|
||||
(mf/use-callback #(swap! local assoc :edition true :menu-open false))
|
||||
|
||||
|
||||
delete-fn
|
||||
toggle-pin
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn [event]
|
||||
(st/emit! (dd/delete-project project)
|
||||
(rt/nav :dashboard-projects {:team-id (:id team)}))))
|
||||
|
||||
on-delete
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(st/emitf (modal/show
|
||||
{:type :confirm
|
||||
:title (t locale "modals.delete-project-confirm.title")
|
||||
:message (t locale "modals.delete-project-confirm.message")
|
||||
:accept-label (t locale "modals.delete-project-confirm.accept")
|
||||
:on-accept delete-fn})))
|
||||
(st/emitf (dd/toggle-project-pin project)))
|
||||
|
||||
on-create-clicked
|
||||
(mf/use-callback
|
||||
|
@ -77,12 +65,18 @@
|
|||
(st/emit! (dd/rename-project (assoc project :name name)))
|
||||
(swap! local assoc :edition false))}]
|
||||
[:div.dashboard-title
|
||||
[:h1 (:name project)]
|
||||
[:div.icon {:on-click on-menu-click} i/actions]
|
||||
[:& context-menu {:on-close on-menu-close
|
||||
:show (:menu-open @local)
|
||||
:options [[(t locale "labels.rename") on-edit]
|
||||
[(t locale "labels.delete") on-delete]]}]]))
|
||||
[:h1 {:on-double-click on-edit}
|
||||
(:name project)]
|
||||
[:div.icon {:on-click on-menu-click}
|
||||
i/actions]
|
||||
[:& project-menu {:project project
|
||||
:show? (:menu-open @local)
|
||||
:on-edit on-edit
|
||||
:on-menu-close on-menu-close}]
|
||||
[:div.icon.pin-icon
|
||||
{:class (when (:is-pinned project) "active")
|
||||
:on-click toggle-pin}
|
||||
i/pin]]))
|
||||
[:a.btn-secondary.btn-small {:on-click on-create-clicked}
|
||||
(t locale "dashboard.new-file")]]))
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
[app.main.fonts :as fonts]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.components.context-menu :refer [context-menu]]
|
||||
[app.main.ui.dashboard.file-menu :refer [file-menu]]
|
||||
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.main.worker :as wrk]
|
||||
|
@ -61,84 +62,36 @@
|
|||
(mf/defc grid-item
|
||||
{:wrap [mf/memo]}
|
||||
[{:keys [id file] :as props}]
|
||||
(let [local (mf/use-state {:menu-open false :edition false})
|
||||
(let [local (mf/use-state {:menu-open false
|
||||
:menu-pos nil
|
||||
:edition false})
|
||||
locale (mf/deref i18n/locale)
|
||||
on-close (mf/use-callback #(swap! local assoc :menu-open false))
|
||||
menu-ref (mf/use-ref)
|
||||
|
||||
delete-fn
|
||||
on-menu-close
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dd/delete-file file)))
|
||||
|
||||
on-delete
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (modal/show
|
||||
{:type :confirm
|
||||
:title (t locale "modals.delete-file-confirm.title")
|
||||
:message (t locale "modals.delete-file-confirm.message")
|
||||
:accept-label (t locale "modals.delete-file-confirm.accept")
|
||||
:on-accept delete-fn}))))
|
||||
#(swap! local assoc :menu-open false))
|
||||
|
||||
on-navigate
|
||||
(mf/use-callback
|
||||
(mf/deps id)
|
||||
(fn []
|
||||
(let [pparams {:project-id (:project-id file)
|
||||
:file-id (:id file)}
|
||||
qparams {:page-id (first (get-in file [:data :pages]))}]
|
||||
(st/emit! (rt/nav :workspace pparams qparams)))))
|
||||
|
||||
|
||||
add-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dd/set-file-shared (assoc file :is-shared true))))
|
||||
|
||||
del-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(st/emitf (dd/set-file-shared (assoc file :is-shared false))))
|
||||
|
||||
on-add-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (modal/show
|
||||
{:type :confirm
|
||||
:message ""
|
||||
:title (t locale "modals.add-shared-confirm.message" (:name file))
|
||||
:hint (t locale "modals.add-shared-confirm.hint")
|
||||
:cancel-label :omit
|
||||
:accept-label (t locale "modals.add-shared-confirm.accept")
|
||||
:accept-style :primary
|
||||
:on-accept add-shared}))))
|
||||
|
||||
on-del-shared
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(st/emit! (modal/show
|
||||
{:type :confirm
|
||||
:message ""
|
||||
:title (t locale "modals.remove-shared-confirm.message" (:name file))
|
||||
:hint (t locale "modals.remove-shared-confirm.hint")
|
||||
:cancel-label :omit
|
||||
:accept-label (t locale "modals.remove-shared-confirm.accept")
|
||||
:on-accept del-shared}))))
|
||||
(let [menu-icon (mf/ref-val menu-ref)
|
||||
target (dom/get-target event)]
|
||||
(when-not (dom/child? target menu-icon)
|
||||
(let [pparams {:project-id (:project-id file)
|
||||
:file-id (:id file)}
|
||||
qparams {:page-id (first (get-in file [:data :pages]))}]
|
||||
(st/emit! (rt/nav :workspace pparams qparams)))))))
|
||||
|
||||
on-menu-click
|
||||
(mf/use-callback
|
||||
(mf/deps file)
|
||||
(fn [event]
|
||||
(dom/prevent-default event)
|
||||
(dom/stop-propagation event)
|
||||
(swap! local assoc :menu-open true)))
|
||||
(let [position (dom/get-client-position event)]
|
||||
(swap! local assoc :menu-open true
|
||||
:menu-pos position))))
|
||||
|
||||
edit
|
||||
(mf/use-callback
|
||||
|
@ -154,10 +107,10 @@
|
|||
(dom/stop-propagation event)
|
||||
(swap! local assoc
|
||||
:edition true
|
||||
:menu-open false)))
|
||||
:menu-open false)))]
|
||||
|
||||
]
|
||||
[:div.grid-item.project-th {:on-click on-navigate}
|
||||
[:div.grid-item.project-th {:on-click on-navigate
|
||||
:on-context-menu on-menu-click}
|
||||
[:div.overlay]
|
||||
[:& grid-item-thumbnail {:file file}]
|
||||
(when (:is-shared file)
|
||||
|
@ -171,15 +124,15 @@
|
|||
[:div.project-th-actions {:class (dom/classnames
|
||||
:force-display (:menu-open @local))}
|
||||
[:div.project-th-icon.menu
|
||||
{:on-click on-menu-click}
|
||||
i/actions]
|
||||
[:& context-menu {:on-close on-close
|
||||
:show (:menu-open @local)
|
||||
:options [[(t locale "labels.rename") on-edit]
|
||||
[(t locale "labels.delete") on-delete]
|
||||
(if (:is-shared file)
|
||||
[(t locale "dashboard.remove-shared") on-del-shared]
|
||||
[(t locale "dashboard.add-shared") on-add-shared])]}]]]))
|
||||
{:ref menu-ref
|
||||
:on-click on-menu-click}
|
||||
i/actions
|
||||
[:& file-menu {:file file
|
||||
:show? (:menu-open @local)
|
||||
:left (:x (:menu-pos @local))
|
||||
:top (:y (:menu-pos @local))
|
||||
:on-edit on-edit
|
||||
:on-menu-close on-menu-close}]]]]))
|
||||
|
||||
(mf/defc empty-placeholder
|
||||
[]
|
||||
|
|
110
frontend/src/app/main/ui/dashboard/project_menu.cljs
Normal file
110
frontend/src/app/main/ui/dashboard/project_menu.cljs
Normal file
|
@ -0,0 +1,110 @@
|
|||
;; 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/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) 2021 UXBOX Labs SL
|
||||
|
||||
(ns app.main.ui.dashboard.project-menu
|
||||
(:require
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.repo :as rp]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
[app.main.ui.components.context-menu :refer [context-menu]]
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.router :as rt]
|
||||
[beicon.core :as rx]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(mf/defc project-menu
|
||||
[{:keys [project show? on-edit on-menu-close top left] :as props}]
|
||||
(assert (some? project) "missing `project` 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")
|
||||
(let [top (or top 0)
|
||||
left (or left 0)
|
||||
|
||||
current-team-id (mf/use-ctx ctx/current-team-id)
|
||||
teams (mf/use-state nil)
|
||||
|
||||
on-duplicate
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
#(let [on-success
|
||||
(fn [new-project]
|
||||
(st/emit! (dm/success (tr "dashboard.success-duplicate-project"))
|
||||
(rt/nav :dashboard-files
|
||||
{:team-id (:team-id new-project)
|
||||
:project-id (:id new-project)})))]
|
||||
(st/emit! (dd/duplicate-project
|
||||
(with-meta project {:on-success on-success})))))
|
||||
|
||||
toggle-pin
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(st/emitf (dd/toggle-project-pin project)))
|
||||
|
||||
on-move
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn [team-id]
|
||||
(let [data {:id (:id project)
|
||||
:team-id team-id}
|
||||
|
||||
mdata {:on-success
|
||||
(st/emitf (rt/nav :dashboard-projects
|
||||
{:team-id team-id}))}]
|
||||
|
||||
(st/emitf (dm/success (tr "dashboard.success-move-project"))
|
||||
(dd/move-project (with-meta data mdata))))))
|
||||
|
||||
delete-fn
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn [event]
|
||||
(st/emit! (dm/success (tr "dashboard.success-delete-project"))
|
||||
(dd/delete-project project)
|
||||
(rt/nav :dashboard-projects {:team-id (:team-id project)}))))
|
||||
|
||||
on-delete
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(st/emitf (modal/show
|
||||
{:type :confirm
|
||||
:title (tr "modals.delete-project-confirm.title")
|
||||
:message (tr "modals.delete-project-confirm.message")
|
||||
:accept-label (tr "modals.delete-project-confirm.accept")
|
||||
:on-accept delete-fn})))]
|
||||
|
||||
(mf/use-layout-effect
|
||||
(mf/deps show?)
|
||||
(fn []
|
||||
(if show?
|
||||
(->> (rp/query! :teams)
|
||||
(rx/map (fn [teams]
|
||||
(remove #(= (:id %) current-team-id) teams)))
|
||||
(rx/subs #(reset! teams %)))
|
||||
(reset! teams []))))
|
||||
|
||||
(when @teams
|
||||
[:& context-menu {:on-close on-menu-close
|
||||
:show show?
|
||||
:fixed? (or (not= top 0) (not= left 0))
|
||||
:top top
|
||||
:left left
|
||||
:options [[(tr "labels.rename") on-edit]
|
||||
[(tr "dashboard.duplicate") on-duplicate]
|
||||
[(tr "dashboard.pin-unpin") toggle-pin]
|
||||
(when (seq @teams)
|
||||
[(tr "dashboard.move-to") nil
|
||||
(for [team @teams]
|
||||
[(:name team) (on-move (:id team))])])
|
||||
[:separator]
|
||||
[(tr "labels.delete") on-delete]]}])))
|
||||
|
|
@ -15,6 +15,8 @@
|
|||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.dashboard.grid :refer [line-grid]]
|
||||
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
|
||||
[app.main.ui.dashboard.project-menu :refer [project-menu]]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.dom :as dom]
|
||||
[app.util.i18n :as i18n :refer [t tr]]
|
||||
|
@ -60,16 +62,43 @@
|
|||
team-id (:team-id project)
|
||||
file-count (or (:count project) 0)
|
||||
|
||||
dstate (mf/deref refs/dashboard-local)
|
||||
edit-id (:project-for-edit dstate)
|
||||
local (mf/use-state {:menu-open false
|
||||
:menu-pos nil
|
||||
:edition? (= (:id project) edit-id)})
|
||||
|
||||
on-nav
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(st/emitf (rt/nav :dashboard-files {:team-id (:team-id project)
|
||||
:project-id (:id project)})))
|
||||
|
||||
toggle-pin
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(st/emitf (dd/toggle-project-pin project)))
|
||||
|
||||
on-menu-click
|
||||
(mf/use-callback (fn [event]
|
||||
(let [position (dom/get-client-position event)]
|
||||
(dom/prevent-default event)
|
||||
(swap! local assoc :menu-open true
|
||||
:menu-pos position))))
|
||||
|
||||
on-menu-close
|
||||
(mf/use-callback #(swap! local assoc :menu-open false))
|
||||
|
||||
on-edit-open
|
||||
(mf/use-callback #(swap! local assoc :edition? true))
|
||||
|
||||
on-edit
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
(fn [name]
|
||||
(st/emit! (dd/rename-project (assoc project :name name)))
|
||||
(swap! local assoc :edition? false)))
|
||||
|
||||
on-file-created
|
||||
(mf/use-callback
|
||||
(mf/deps project)
|
||||
|
@ -88,7 +117,6 @@
|
|||
params {:project-id (:id project)}]
|
||||
(st/emit! (dd/create-file (with-meta params mdata))))))]
|
||||
|
||||
|
||||
[:div.dashboard-project-row {:class (when first? "first")}
|
||||
[:div.project
|
||||
(when-not (:is-default project)
|
||||
|
@ -96,7 +124,18 @@
|
|||
{:class (when (:is-pinned project) "active")
|
||||
:on-click toggle-pin}
|
||||
i/pin])
|
||||
[:h2 {:on-click on-nav} (:name project)]
|
||||
(if (:edition? @local)
|
||||
[:& inline-edition {:content (:name project)
|
||||
:on-end on-edit}]
|
||||
[:h2 {:on-click on-nav
|
||||
:on-context-menu on-menu-click}
|
||||
(:name project)])
|
||||
[:& project-menu {:project project
|
||||
:show? (:menu-open @local)
|
||||
:left (:x (:menu-pos @local))
|
||||
:top (:y (:menu-pos @local))
|
||||
:on-edit on-edit-open
|
||||
:on-menu-close on-menu-close}]
|
||||
[:span.info (str file-count " files")]
|
||||
(when (> file-count 0)
|
||||
(let [time (-> (:modified-at project)
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
[app.main.ui.components.forms :as fm]
|
||||
[app.main.ui.dashboard.comments :refer [comments-section]]
|
||||
[app.main.ui.dashboard.inline-edition :refer [inline-edition]]
|
||||
[app.main.ui.dashboard.project-menu :refer [project-menu]]
|
||||
[app.main.ui.dashboard.team-form]
|
||||
[app.main.ui.icons :as i]
|
||||
[app.util.avatars :as avatars]
|
||||
|
@ -42,10 +43,12 @@
|
|||
|
||||
(mf/defc sidebar-project
|
||||
[{:keys [item selected?] :as props}]
|
||||
(let [dstate (mf/deref refs/dashboard-local)
|
||||
edit-id (:project-for-edit dstate)
|
||||
(let [dstate (mf/deref refs/dashboard-local)
|
||||
edit-id (:project-for-edit dstate)
|
||||
|
||||
edition? (mf/use-state (= (:id item) edit-id))
|
||||
local (mf/use-state {:menu-open false
|
||||
:menu-pos nil
|
||||
:edition? (= (:id item) edit-id)})
|
||||
|
||||
on-click
|
||||
(mf/use-callback
|
||||
|
@ -54,23 +57,41 @@
|
|||
(st/emit! (rt/nav :dashboard-files {:team-id (:team-id item)
|
||||
:project-id (:id item)}))))
|
||||
|
||||
on-dbl-click
|
||||
(mf/use-callback #(reset! edition? true))
|
||||
on-menu-click
|
||||
(mf/use-callback (fn [event]
|
||||
(let [position (dom/get-client-position event)]
|
||||
(dom/prevent-default event)
|
||||
(swap! local assoc :menu-open true
|
||||
:menu-pos position))))
|
||||
|
||||
on-menu-close
|
||||
(mf/use-callback #(swap! local assoc :menu-open false))
|
||||
|
||||
on-edit-open
|
||||
(mf/use-callback #(swap! local assoc :edition? true))
|
||||
|
||||
on-edit
|
||||
(mf/use-callback
|
||||
(mf/deps item)
|
||||
(fn [name]
|
||||
(st/emit! (dd/rename-project (assoc item :name name)))
|
||||
(reset! edition? false)))]
|
||||
(swap! local assoc :edition? false)))]
|
||||
|
||||
[:li {:on-click on-click
|
||||
:on-double-click on-dbl-click
|
||||
:class (when selected? "current")}
|
||||
(if @edition?
|
||||
[:& inline-edition {:content (:name item)
|
||||
:on-end on-edit}]
|
||||
[:span.element-title (:name item)])]))
|
||||
[:*
|
||||
[:li {:on-click on-click
|
||||
:on-double-click on-edit-open
|
||||
:on-context-menu on-menu-click
|
||||
:class (when selected? "current")}
|
||||
(if (:edition? @local)
|
||||
[:& inline-edition {:content (:name item)
|
||||
:on-end on-edit}]
|
||||
[:span.element-title (:name item)])]
|
||||
[:& project-menu {:project item
|
||||
:show? (:menu-open @local)
|
||||
:left (:x (:menu-pos @local))
|
||||
:top (:y (:menu-pos @local))
|
||||
:on-edit on-edit-open
|
||||
:on-menu-close on-menu-close}]]))
|
||||
|
||||
(mf/defc sidebar-search
|
||||
[{:keys [search-term team-id locale] :as props}]
|
||||
|
|
|
@ -249,6 +249,9 @@
|
|||
(let [class-list (.-classList ^js node)]
|
||||
(.contains ^js class-list class-name)))
|
||||
|
||||
(defn child? [node1 node2]
|
||||
(.contains ^js node2 ^js node1))
|
||||
|
||||
(defn get-user-agent []
|
||||
(.-userAgent globals/navigator))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue