mirror of
https://github.com/penpot/penpot.git
synced 2025-07-18 22:17:23 +02:00
✨ Close menus and modals on role change
This commit is contained in:
parent
043c4105db
commit
6fb65de100
4 changed files with 42 additions and 15 deletions
|
@ -20,6 +20,7 @@
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.fonts :as df]
|
[app.main.data.fonts :as df]
|
||||||
[app.main.data.media :as di]
|
[app.main.data.media :as di]
|
||||||
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.data.websocket :as dws]
|
[app.main.data.websocket :as dws]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
|
@ -1210,10 +1211,19 @@
|
||||||
;; Notifications
|
;; Notifications
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
|
||||||
|
(defn- handle-change-team-permissions-dashboard
|
||||||
|
[msg]
|
||||||
|
(ptk/reify ::handle-change-team-permissions-dashboard
|
||||||
|
ptk/WatchEvent
|
||||||
|
(watch [_ _ _]
|
||||||
|
(rx/of (dc/change-team-permissions (assoc msg :workspace? false))
|
||||||
|
(modal/hide)))))
|
||||||
|
|
||||||
(defn- process-message
|
(defn- process-message
|
||||||
[{:keys [type] :as msg}]
|
[{:keys [type] :as msg}]
|
||||||
(case type
|
(case type
|
||||||
:notification (dc/handle-notification msg)
|
:notification (dc/handle-notification msg)
|
||||||
:team-permissions-change (dc/change-team-permissions (assoc msg :workspace? false))
|
:team-permissions-change (handle-change-team-permissions-dashboard msg)
|
||||||
:removed-from-team (dc/removed-from-team msg)
|
:removed-from-team (dc/removed-from-team msg)
|
||||||
nil))
|
nil))
|
|
@ -13,6 +13,7 @@
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.changes :as dch]
|
[app.main.data.changes :as dch]
|
||||||
[app.main.data.common :as dc]
|
[app.main.data.common :as dc]
|
||||||
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.websocket :as dws]
|
[app.main.data.websocket :as dws]
|
||||||
[app.main.data.workspace.common :as dwc]
|
[app.main.data.workspace.common :as dwc]
|
||||||
[app.main.data.workspace.edition :as dwe]
|
[app.main.data.workspace.edition :as dwe]
|
||||||
|
@ -112,7 +113,8 @@
|
||||||
;; Delay so anything that launched :interrupt can finish
|
;; Delay so anything that launched :interrupt can finish
|
||||||
(rx/delay 100))
|
(rx/delay 100))
|
||||||
(if viewer?
|
(if viewer?
|
||||||
(rx/of (dwly/set-options-mode :inspect))
|
(rx/of (modal/hide)
|
||||||
|
(dwly/set-options-mode :inspect))
|
||||||
(rx/of (dwly/set-options-mode :design))))))))
|
(rx/of (dwly/set-options-mode :design))))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -313,22 +313,24 @@
|
||||||
on-show (mf/use-fn #(reset! show? true))
|
on-show (mf/use-fn #(reset! show? true))
|
||||||
on-hide (mf/use-fn #(reset! show? false))]
|
on-hide (mf/use-fn #(reset! show? false))]
|
||||||
|
|
||||||
[:*
|
|
||||||
(when (or is-you? (and can-delete? (not (and is-owner? (not owner?)))))
|
(when (or is-you? (and can-delete? (not (and is-owner? (not owner?)))))
|
||||||
|
[:*
|
||||||
[:button {:class (stl/css :menu-btn)
|
[:button {:class (stl/css :menu-btn)
|
||||||
:on-click on-show}
|
:on-click on-show}
|
||||||
menu-icon])
|
menu-icon]
|
||||||
|
|
||||||
[:& dropdown {:show @show? :on-close on-hide}
|
|
||||||
[:ul {:class (stl/css :actions-dropdown)}
|
[:& dropdown {:show @show? :on-close on-hide}
|
||||||
(when is-you?
|
[:ul {:class (stl/css :actions-dropdown)}
|
||||||
[:li {:on-click on-leave
|
(when is-you?
|
||||||
:class (stl/css :action-dropdown-item)
|
[:li {:on-click on-leave
|
||||||
:key "is-you-option"} (tr "dashboard.leave-team")])
|
:class (stl/css :action-dropdown-item)
|
||||||
(when (and can-delete? (not is-you?) (not (and is-owner? (not owner?))))
|
:key "is-you-option"} (tr "dashboard.leave-team")])
|
||||||
[:li {:on-click on-delete
|
(when (and can-delete? (not is-you?) (not (and is-owner? (not owner?))))
|
||||||
:class (stl/css :action-dropdown-item)
|
[:li {:on-click on-delete
|
||||||
:key "is-not-you-option"} (tr "labels.remove-member")])]]]))
|
:class (stl/css :action-dropdown-item)
|
||||||
|
:key "is-not-you-option"} (tr "labels.remove-member")])]]])))
|
||||||
|
|
||||||
(defn- set-role! [member-id role]
|
(defn- set-role! [member-id role]
|
||||||
(let [params {:member-id member-id :role role}]
|
(let [params {:member-id member-id :role role}]
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
[app.util.router :as rt]
|
[app.util.router :as rt]
|
||||||
|
[beicon.v2.core :as rx]
|
||||||
[potok.v2.core :as ptk]
|
[potok.v2.core :as ptk]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
@ -678,6 +679,12 @@
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
(reset! sub-menu* nil)))
|
(reset! sub-menu* nil)))
|
||||||
|
|
||||||
|
close-all-menus
|
||||||
|
(mf/use-fn
|
||||||
|
(fn []
|
||||||
|
(reset! show-menu* false)
|
||||||
|
(reset! sub-menu* nil)))
|
||||||
|
|
||||||
on-menu-click
|
on-menu-click
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [event]
|
(fn [event]
|
||||||
|
@ -716,6 +723,12 @@
|
||||||
(ptk/event ::ev/event {::ev/name "open-plugins-manager" ::ev/origin "workspace:menu"})
|
(ptk/event ::ev/event {::ev/name "open-plugins-manager" ::ev/origin "workspace:menu"})
|
||||||
(modal/show :plugin-management {}))))]
|
(modal/show :plugin-management {}))))]
|
||||||
|
|
||||||
|
(mf/with-effect []
|
||||||
|
(let [disposable (->> st/stream
|
||||||
|
(rx/filter #(= :interrupt %))
|
||||||
|
(rx/subs! close-all-menus))]
|
||||||
|
(partial rx/dispose! disposable)))
|
||||||
|
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
[:div {:on-click open-menu
|
[:div {:on-click open-menu
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue