0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-13 10:38:13 -05:00

Close menus and modals on role change

This commit is contained in:
Pablo Alba 2024-10-15 13:31:29 +02:00
parent 043c4105db
commit 6fb65de100
4 changed files with 42 additions and 15 deletions

View file

@ -20,6 +20,7 @@
[app.main.data.events :as ev]
[app.main.data.fonts :as df]
[app.main.data.media :as di]
[app.main.data.modal :as modal]
[app.main.data.users :as du]
[app.main.data.websocket :as dws]
[app.main.features :as features]
@ -1210,10 +1211,19 @@
;; 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
[{:keys [type] :as msg}]
(case type
: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)
nil))

View file

@ -13,6 +13,7 @@
[app.common.uuid :as uuid]
[app.main.data.changes :as dch]
[app.main.data.common :as dc]
[app.main.data.modal :as modal]
[app.main.data.websocket :as dws]
[app.main.data.workspace.common :as dwc]
[app.main.data.workspace.edition :as dwe]
@ -112,7 +113,8 @@
;; Delay so anything that launched :interrupt can finish
(rx/delay 100))
(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))))))))

View file

@ -313,22 +313,24 @@
on-show (mf/use-fn #(reset! show? true))
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)
:on-click on-show}
menu-icon])
menu-icon]
[:& dropdown {:show @show? :on-close on-hide}
[:ul {:class (stl/css :actions-dropdown)}
(when is-you?
[:li {:on-click on-leave
:class (stl/css :action-dropdown-item)
:key "is-you-option"} (tr "dashboard.leave-team")])
(when (and can-delete? (not is-you?) (not (and is-owner? (not owner?))))
[:li {:on-click on-delete
:class (stl/css :action-dropdown-item)
:key "is-not-you-option"} (tr "labels.remove-member")])]]]))
[:& dropdown {:show @show? :on-close on-hide}
[:ul {:class (stl/css :actions-dropdown)}
(when is-you?
[:li {:on-click on-leave
:class (stl/css :action-dropdown-item)
:key "is-you-option"} (tr "dashboard.leave-team")])
(when (and can-delete? (not is-you?) (not (and is-owner? (not owner?))))
[:li {:on-click on-delete
:class (stl/css :action-dropdown-item)
:key "is-not-you-option"} (tr "labels.remove-member")])]]])))
(defn- set-role! [member-id role]
(let [params {:member-id member-id :role role}]

View file

@ -35,6 +35,7 @@
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[app.util.router :as rt]
[beicon.v2.core :as rx]
[potok.v2.core :as ptk]
[rumext.v2 :as mf]))
@ -678,6 +679,12 @@
(dom/stop-propagation event)
(reset! sub-menu* nil)))
close-all-menus
(mf/use-fn
(fn []
(reset! show-menu* false)
(reset! sub-menu* nil)))
on-menu-click
(mf/use-fn
(fn [event]
@ -716,6 +723,12 @@
(ptk/event ::ev/event {::ev/name "open-plugins-manager" ::ev/origin "workspace:menu"})
(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