🐛 Fix backend notification dialogs

This commit is contained in:
Andrey Antukh 2025-04-03 11:07:35 +02:00
parent 8f600f334f
commit 1d69941882
5 changed files with 10 additions and 20 deletions

View file

@ -73,7 +73,7 @@
(st/emit! (ntf/hide))) (st/emit! (ntf/hide)))
(defn handle-notification (defn handle-notification
[{:keys [message code level] :as params}] [{:keys [message code] :as params}]
(ptk/reify ::show-notification (ptk/reify ::show-notification
ptk/WatchEvent ptk/WatchEvent
(watch [_ _ _] (watch [_ _ _]
@ -81,9 +81,6 @@
:upgrade-version :upgrade-version
(rx/of (ntf/dialog (rx/of (ntf/dialog
:content (tr "notifications.by-code.upgrade-version") :content (tr "notifications.by-code.upgrade-version")
:controls :inline-actions
:type :inline
:level level
:accept {:label (tr "labels.refresh") :accept {:label (tr "labels.refresh")
:callback force-reload!} :callback force-reload!}
:tag :notification)) :tag :notification))
@ -91,16 +88,14 @@
:maintenance :maintenance
(rx/of (ntf/dialog (rx/of (ntf/dialog
:content (tr "notifications.by-code.maintenance") :content (tr "notifications.by-code.maintenance")
:controls :inline-actions
:type level
:accept {:label (tr "labels.accept") :accept {:label (tr "labels.accept")
:callback hide-notifications!} :callback hide-notifications!}
:tag :notification)) :tag :notification))
(rx/of (ntf/dialog (rx/of (ntf/dialog
:content message :content message
:controls :close :accept {:label (tr "labels.close")
:type level :callback hide-notifications!}
:tag :notification)))))) :tag :notification))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -19,7 +19,7 @@
(def ^:private schema:notification (def ^:private schema:notification
[:map {:title "Notification"} [:map {:title "Notification"}
[:level [::sm/one-of #{:success :error :info :warning}]] [:level {:optional true} [::sm/one-of #{:success :error :info :warning}]]
[:status {:optional true} [:status {:optional true}
[::sm/one-of #{:visible :hide}]] [::sm/one-of #{:visible :hide}]]
[:position {:optional true} [:position {:optional true}
@ -129,15 +129,11 @@
:timeout timeout}))) :timeout timeout})))
(defn dialog (defn dialog
[& {:keys [content controls actions accept cancel position tag level links] [& {:keys [content accept cancel tag links]}]
:or {controls :none position :floating level :info}}]
(show (d/without-nils (show (d/without-nils
{:content content {:content content
:level level :type :inline
:links links
:position position
:controls controls
:actions actions
:accept accept :accept accept
:cancel cancel :cancel cancel
:links links
:tag tag}))) :tag tag})))

View file

@ -65,7 +65,6 @@
(->> (rx/from initmsg) (->> (rx/from initmsg)
(rx/map dws/send)) (rx/map dws/send))
;; Subscribe to notifications of the subscription ;; Subscribe to notifications of the subscription
(->> stream (->> stream
(rx/filter (ptk/type? ::dws/message)) (rx/filter (ptk/type? ::dws/message))

View file

@ -370,6 +370,6 @@
(if edata (if edata
[:> static/exception-page* {:data edata :route route}] [:> static/exception-page* {:data edata :route route}]
[:> error-boundary* {:fallback static/internal-error*} [:> error-boundary* {:fallback static/internal-error*}
[:& notifications/current-notification] [:> notifications/current-notification*]
(when route (when route
[:> page* {:route route :profile profile}])])]])) [:> page* {:route route :profile profile}])])]]))

View file

@ -14,10 +14,10 @@
[okulary.core :as l] [okulary.core :as l]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
(def ref:notification (def ^:private ref:notification
(l/derived :notification st/state)) (l/derived :notification st/state))
(mf/defc current-notification (mf/defc current-notification*
[] []
(let [notification (mf/deref ref:notification) (let [notification (mf/deref ref:notification)
on-close (mf/use-fn #(st/emit! (ntf/hide))) on-close (mf/use-fn #(st/emit! (ntf/hide)))