mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 04:56:11 +02:00
♻️ Refactor naming and location of flash notifications
This commit is contained in:
parent
3917215952
commit
f187012469
40 changed files with 258 additions and 275 deletions
|
@ -9,8 +9,8 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.types.components-list :as ctkl]
|
[app.common.types.components-list :as ctkl]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
|
|
||||||
(defn hide-notifications!
|
(defn hide-notifications!
|
||||||
[]
|
[]
|
||||||
(st/emit! msg/hide))
|
(st/emit! (ntf/hide)))
|
||||||
|
|
||||||
(defn handle-notification
|
(defn handle-notification
|
||||||
[{:keys [message code level] :as params}]
|
[{:keys [message code level] :as params}]
|
||||||
|
@ -72,7 +72,7 @@
|
||||||
:upgrade-version
|
:upgrade-version
|
||||||
(when (or (not= (:version params) (:full cf/version))
|
(when (or (not= (:version params) (:full cf/version))
|
||||||
(true? (:force params)))
|
(true? (:force params)))
|
||||||
(rx/of (msg/dialog
|
(rx/of (ntf/dialog
|
||||||
:content (tr "notifications.by-code.upgrade-version")
|
:content (tr "notifications.by-code.upgrade-version")
|
||||||
:controls :inline-actions
|
:controls :inline-actions
|
||||||
:notification-type :inline
|
:notification-type :inline
|
||||||
|
@ -81,7 +81,7 @@
|
||||||
:tag :notification)))
|
:tag :notification)))
|
||||||
|
|
||||||
:maintenance
|
:maintenance
|
||||||
(rx/of (msg/dialog
|
(rx/of (ntf/dialog
|
||||||
:content (tr "notifications.by-code.maintenance")
|
:content (tr "notifications.by-code.maintenance")
|
||||||
:controls :inline-actions
|
:controls :inline-actions
|
||||||
:type level
|
:type level
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
:callback hide-notifications!}]
|
:callback hide-notifications!}]
|
||||||
:tag :notification))
|
:tag :notification))
|
||||||
|
|
||||||
(rx/of (msg/dialog
|
(rx/of (ntf/dialog
|
||||||
:content message
|
:content message
|
||||||
:controls :close
|
:controls :close
|
||||||
:type level
|
:type level
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
[app.common.media :as cm]
|
[app.common.media :as cm]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.fonts :as fonts]
|
[app.main.fonts :as fonts]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -183,7 +183,7 @@
|
||||||
#(when
|
#(when
|
||||||
(not-empty %)
|
(not-empty %)
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(msg/error
|
(ntf/error
|
||||||
(if (> (count %) 1)
|
(if (> (count %) 1)
|
||||||
(tr "errors.bad-font-plural" (str/join ", " %))
|
(tr "errors.bad-font-plural" (str/join ", " %))
|
||||||
(tr "errors.bad-font" (first %)))))))
|
(tr "errors.bad-font" (first %)))))))
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.media :as cm]
|
[app.common.media :as cm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.i18n :refer [tr]]
|
[app.util.i18n :refer [tr]]
|
||||||
[beicon.v2.core :as rx]
|
[beicon.v2.core :as rx]
|
||||||
|
@ -46,14 +46,14 @@
|
||||||
|
|
||||||
(defn notify-start-loading
|
(defn notify-start-loading
|
||||||
[]
|
[]
|
||||||
(st/emit! (msg/show {:content (tr "media.loading")
|
(st/emit! (ntf/show {:content (tr "media.loading")
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :info
|
:type :info
|
||||||
:timeout nil})))
|
:timeout nil})))
|
||||||
|
|
||||||
(defn notify-finished-loading
|
(defn notify-finished-loading
|
||||||
[]
|
[]
|
||||||
(st/emit! msg/hide))
|
(st/emit! (ntf/hide)))
|
||||||
|
|
||||||
(defn process-error
|
(defn process-error
|
||||||
[error]
|
[error]
|
||||||
|
@ -69,4 +69,4 @@
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(tr "errors.unexpected-error"))]
|
(tr "errors.unexpected-error"))]
|
||||||
(rx/of (msg/error msg))))
|
(rx/of (ntf/error msg))))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) KALEIDOS INC
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
(ns app.main.data.messages
|
(ns app.main.data.notifications
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
|
@ -17,14 +17,14 @@
|
||||||
|
|
||||||
(def default-timeout 7000)
|
(def default-timeout 7000)
|
||||||
|
|
||||||
(def ^:private schema:message
|
(def ^:private schema:notification
|
||||||
[:map {:title "Message"}
|
[:map {:title "Notification"}
|
||||||
[:type [::sm/one-of #{:success :error :info :warning}]]
|
[:level [::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}
|
||||||
[::sm/one-of #{:fixed :floating :inline}]]
|
[::sm/one-of #{:fixed :floating :inline}]]
|
||||||
[:notification-type {:optional true}
|
[:type {:optional true}
|
||||||
[::sm/one-of #{:inline :context :toast}]]
|
[::sm/one-of #{:inline :context :toast}]]
|
||||||
[:controls {:optional true}
|
[:controls {:optional true}
|
||||||
[::sm/one-of #{:none :close :inline-actions :bottom-actions}]]
|
[::sm/one-of #{:none :close :inline-actions :bottom-actions}]]
|
||||||
|
@ -43,20 +43,21 @@
|
||||||
[:label :string]
|
[:label :string]
|
||||||
[:callback ::sm/fn]]]]])
|
[:callback ::sm/fn]]]]])
|
||||||
|
|
||||||
(def ^:private valid-message?
|
(def ^:private valid-notification?
|
||||||
(sm/validator schema:message))
|
(sm/validator schema:notification))
|
||||||
|
|
||||||
(defn show
|
(defn show
|
||||||
[data]
|
[data]
|
||||||
|
|
||||||
(dm/assert!
|
(dm/assert!
|
||||||
"expected valid message map"
|
"expected valid notification map"
|
||||||
(valid-message? data))
|
(valid-notification? data))
|
||||||
|
|
||||||
(ptk/reify ::show
|
(ptk/reify ::show
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [message (assoc data :status :visible)]
|
(let [notification (assoc data :status :visible)]
|
||||||
(assoc state :message message)))
|
(assoc state :notification notification)))
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ stream]
|
(watch [_ _ stream]
|
||||||
|
@ -64,42 +65,39 @@
|
||||||
(let [stopper (rx/filter (ptk/type? ::hide) stream)]
|
(let [stopper (rx/filter (ptk/type? ::hide) stream)]
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/filter (ptk/type? :app.util.router/navigate))
|
(rx/filter (ptk/type? :app.util.router/navigate))
|
||||||
(rx/map (constantly hide))
|
(rx/map (fn [_] (hide)))
|
||||||
(rx/take-until stopper)))
|
(rx/take-until stopper)))
|
||||||
(when (:timeout data)
|
(when (:timeout data)
|
||||||
(let [stopper (rx/filter (ptk/type? ::show) stream)]
|
(let [stopper (rx/filter (ptk/type? ::show) stream)]
|
||||||
(->> (rx/of hide)
|
(->> (rx/of (hide))
|
||||||
(rx/delay (:timeout data))
|
(rx/delay (:timeout data))
|
||||||
(rx/take-until stopper))))))))
|
(rx/take-until stopper))))))))
|
||||||
|
|
||||||
(def hide
|
(defn hide
|
||||||
|
[& {:keys [tag]}]
|
||||||
(ptk/reify ::hide
|
(ptk/reify ::hide
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(dissoc state :message))))
|
(if (some? tag)
|
||||||
|
(let [notification (get state :notification)]
|
||||||
(defn hide-tag
|
(if (= tag (:tag notification))
|
||||||
[tag]
|
(dissoc state :notification)
|
||||||
(ptk/reify ::hide-tag
|
state))
|
||||||
ptk/WatchEvent
|
(dissoc state :notification)))))
|
||||||
(watch [_ state _]
|
|
||||||
(let [message (get state :message)]
|
|
||||||
(when (= (:tag message) tag)
|
|
||||||
(rx/of hide))))))
|
|
||||||
|
|
||||||
(defn error
|
(defn error
|
||||||
([content]
|
([content]
|
||||||
(show {:content content
|
(show {:content content
|
||||||
:type :error
|
:level :error
|
||||||
:notification-type :toast
|
:type :toast
|
||||||
:position :fixed})))
|
:position :fixed})))
|
||||||
|
|
||||||
(defn info
|
(defn info
|
||||||
([content] (info content {}))
|
([content] (info content {}))
|
||||||
([content {:keys [timeout] :or {timeout default-timeout}}]
|
([content {:keys [timeout] :or {timeout default-timeout}}]
|
||||||
(show {:content content
|
(show {:content content
|
||||||
:type :info
|
:level :info
|
||||||
:notification-type :toast
|
:type :toast
|
||||||
:position :fixed
|
:position :fixed
|
||||||
:timeout timeout})))
|
:timeout timeout})))
|
||||||
|
|
||||||
|
@ -107,8 +105,8 @@
|
||||||
([content] (success content {}))
|
([content] (success content {}))
|
||||||
([content {:keys [timeout] :or {timeout default-timeout}}]
|
([content {:keys [timeout] :or {timeout default-timeout}}]
|
||||||
(show {:content content
|
(show {:content content
|
||||||
:type :success
|
:level :success
|
||||||
:notification-type :toast
|
:type :toast
|
||||||
:position :fixed
|
:position :fixed
|
||||||
:timeout timeout})))
|
:timeout timeout})))
|
||||||
|
|
||||||
|
@ -116,31 +114,19 @@
|
||||||
([content] (warn content {}))
|
([content] (warn content {}))
|
||||||
([content {:keys [timeout] :or {timeout default-timeout}}]
|
([content {:keys [timeout] :or {timeout default-timeout}}]
|
||||||
(show {:content content
|
(show {:content content
|
||||||
:type :warning
|
:level :warning
|
||||||
:notification-type :toast
|
:type :toast
|
||||||
:position :fixed
|
:position :fixed
|
||||||
:timeout timeout})))
|
:timeout timeout})))
|
||||||
|
|
||||||
(defn dialog
|
(defn dialog
|
||||||
[& {:keys [content controls actions position tag type]
|
[& {:keys [content controls actions position tag level links]
|
||||||
:or {controls :none position :floating type :info}}]
|
:or {controls :none position :floating level :info}}]
|
||||||
(show (d/without-nils
|
(show (d/without-nils
|
||||||
{:content content
|
{:content content
|
||||||
:type type
|
:level level
|
||||||
|
:links links
|
||||||
:position position
|
:position position
|
||||||
:controls controls
|
:controls controls
|
||||||
:actions actions
|
:actions actions
|
||||||
:tag tag})))
|
:tag tag})))
|
||||||
|
|
||||||
(defn info-dialog
|
|
||||||
[& {:keys [content controls links actions tag]
|
|
||||||
:or {controls :none links nil tag nil}}]
|
|
||||||
(show (d/without-nils
|
|
||||||
{:content content
|
|
||||||
:type :info
|
|
||||||
:position :floating
|
|
||||||
:notification-type :inline
|
|
||||||
:controls controls
|
|
||||||
:links links
|
|
||||||
:actions actions
|
|
||||||
:tag tag})))
|
|
|
@ -15,7 +15,7 @@
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.media :as di]
|
[app.main.data.media :as di]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.websocket :as ws]
|
[app.main.data.websocket :as ws]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
|
@ -711,4 +711,4 @@
|
||||||
|
|
||||||
(tr "errors.generic"))]
|
(tr "errors.generic"))]
|
||||||
|
|
||||||
(rx/of (msg/warn hint))))))
|
(rx/of (ntf/warn hint))))))
|
||||||
|
|
|
@ -39,8 +39,8 @@
|
||||||
[app.main.data.comments :as dcm]
|
[app.main.data.comments :as dcm]
|
||||||
[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.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.persistence :as dps]
|
[app.main.data.persistence :as dps]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.data.workspace.bool :as dwb]
|
[app.main.data.workspace.bool :as dwb]
|
||||||
|
@ -347,7 +347,7 @@
|
||||||
(log/debug :hint "initialize-file" :file-id file-id)
|
(log/debug :hint "initialize-file" :file-id file-id)
|
||||||
(let [stoper-s (rx/filter (ptk/type? ::finalize-file) stream)]
|
(let [stoper-s (rx/filter (ptk/type? ::finalize-file) stream)]
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of msg/hide
|
(rx/of (ntf/hide)
|
||||||
(features/initialize)
|
(features/initialize)
|
||||||
(dcm/retrieve-comment-threads file-id)
|
(dcm/retrieve-comment-threads file-id)
|
||||||
(fetch-bundle project-id file-id))
|
(fetch-bundle project-id file-id))
|
||||||
|
@ -1595,7 +1595,7 @@
|
||||||
(on-error [cause]
|
(on-error [cause]
|
||||||
(let [data (ex-data cause)]
|
(let [data (ex-data cause)]
|
||||||
(if (:not-implemented data)
|
(if (:not-implemented data)
|
||||||
(rx/of (msg/warn (tr "errors.clipboard-not-implemented")))
|
(rx/of (ntf/warn (tr "errors.clipboard-not-implemented")))
|
||||||
(js/console.error "Clipboard error:" cause))
|
(js/console.error "Clipboard error:" cause))
|
||||||
(rx/empty)))]
|
(rx/empty)))]
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@
|
||||||
[app.main.data.changes :as dch]
|
[app.main.data.changes :as dch]
|
||||||
[app.main.data.comments :as dc]
|
[app.main.data.comments :as dc]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.workspace :as-alias dw]
|
[app.main.data.workspace :as-alias dw]
|
||||||
[app.main.data.workspace.groups :as dwg]
|
[app.main.data.workspace.groups :as dwg]
|
||||||
[app.main.data.workspace.notifications :as-alias dwn]
|
[app.main.data.workspace.notifications :as-alias dwn]
|
||||||
|
@ -1016,7 +1016,7 @@
|
||||||
file))
|
file))
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (set-updating-library false)
|
(rx/of (set-updating-library false)
|
||||||
(msg/hide-tag :sync-dialog))
|
(ntf/hide {:tag :sync-dialog}))
|
||||||
(when (seq (:redo-changes changes))
|
(when (seq (:redo-changes changes))
|
||||||
(rx/of (dch/commit-changes changes)))
|
(rx/of (dch/commit-changes changes)))
|
||||||
(when-not (empty? updated-frames)
|
(when-not (empty? updated-frames)
|
||||||
|
@ -1084,12 +1084,12 @@
|
||||||
(sync-file (:current-file-id state)
|
(sync-file (:current-file-id state)
|
||||||
(:id library)))
|
(:id library)))
|
||||||
libraries-need-sync))
|
libraries-need-sync))
|
||||||
(st/emit! msg/hide))
|
(st/emit! (ntf/hide)))
|
||||||
do-dismiss #(do (st/emit! ignore-sync)
|
do-dismiss #(do (st/emit! ignore-sync)
|
||||||
(st/emit! msg/hide))]
|
(st/emit! (ntf/hide)))]
|
||||||
|
|
||||||
(when (seq libraries-need-sync)
|
(when (seq libraries-need-sync)
|
||||||
(rx/of (msg/info-dialog
|
(rx/of (ntf/dialog
|
||||||
:content (tr "workspace.updates.there-are-updates")
|
:content (tr "workspace.updates.there-are-updates")
|
||||||
:controls :inline-actions
|
:controls :inline-actions
|
||||||
:links [{:label (tr "workspace.updates.more-info")
|
:links [{:label (tr "workspace.updates.more-info")
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.changes :as dch]
|
[app.main.data.changes :as dch]
|
||||||
[app.main.data.media :as dmm]
|
[app.main.data.media :as dmm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.workspace.libraries :as dwl]
|
[app.main.data.workspace.libraries :as dwl]
|
||||||
[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]
|
||||||
|
@ -169,25 +169,25 @@
|
||||||
(handle-media-error (ex-data error) on-error)
|
(handle-media-error (ex-data error) on-error)
|
||||||
(cond
|
(cond
|
||||||
(= (:code error) :invalid-svg-file)
|
(= (:code error) :invalid-svg-file)
|
||||||
(rx/of (msg/error (tr "errors.media-type-not-allowed")))
|
(rx/of (ntf/error (tr "errors.media-type-not-allowed")))
|
||||||
|
|
||||||
(= (:code error) :media-type-not-allowed)
|
(= (:code error) :media-type-not-allowed)
|
||||||
(rx/of (msg/error (tr "errors.media-type-not-allowed")))
|
(rx/of (ntf/error (tr "errors.media-type-not-allowed")))
|
||||||
|
|
||||||
(= (:code error) :unable-to-access-to-url)
|
(= (:code error) :unable-to-access-to-url)
|
||||||
(rx/of (msg/error (tr "errors.media-type-not-allowed")))
|
(rx/of (ntf/error (tr "errors.media-type-not-allowed")))
|
||||||
|
|
||||||
(= (:code error) :invalid-image)
|
(= (:code error) :invalid-image)
|
||||||
(rx/of (msg/error (tr "errors.media-type-not-allowed")))
|
(rx/of (ntf/error (tr "errors.media-type-not-allowed")))
|
||||||
|
|
||||||
(= (:code error) :media-max-file-size-reached)
|
(= (:code error) :media-max-file-size-reached)
|
||||||
(rx/of (msg/error (tr "errors.media-too-large")))
|
(rx/of (ntf/error (tr "errors.media-too-large")))
|
||||||
|
|
||||||
(= (:code error) :media-type-mismatch)
|
(= (:code error) :media-type-mismatch)
|
||||||
(rx/of (msg/error (tr "errors.media-type-mismatch")))
|
(rx/of (ntf/error (tr "errors.media-type-mismatch")))
|
||||||
|
|
||||||
(= (:code error) :unable-to-optimize)
|
(= (:code error) :unable-to-optimize)
|
||||||
(rx/of (msg/error (:hint error)))
|
(rx/of (ntf/error (:hint error)))
|
||||||
|
|
||||||
(fn? on-error)
|
(fn? on-error)
|
||||||
(on-error error)
|
(on-error error)
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
:else
|
:else
|
||||||
(do
|
(do
|
||||||
(.error js/console "ERROR" error)
|
(.error js/console "ERROR" error)
|
||||||
(rx/of (msg/error (tr "errors.cannot-upload")))))))
|
(rx/of (ntf/error (tr "errors.cannot-upload")))))))
|
||||||
|
|
||||||
|
|
||||||
(def ^:private
|
(def ^:private
|
||||||
|
@ -220,7 +220,7 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (msg/show {:content (tr "media.loading")
|
(rx/of (ntf/show {:content (tr "media.loading")
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :info
|
:type :info
|
||||||
:timeout nil
|
:timeout nil
|
||||||
|
@ -234,7 +234,7 @@
|
||||||
;; Every stream has its own sideeffect. We need to ignore the result
|
;; Every stream has its own sideeffect. We need to ignore the result
|
||||||
(rx/ignore)
|
(rx/ignore)
|
||||||
(rx/catch #(handle-media-error % on-error))
|
(rx/catch #(handle-media-error % on-error))
|
||||||
(rx/finalize #(st/emit! (msg/hide-tag :media-loading))))))))
|
(rx/finalize #(st/emit! (ntf/hide :tag :media-loading))))))))
|
||||||
|
|
||||||
;; Deprecated in components-v2
|
;; Deprecated in components-v2
|
||||||
(defn upload-media-asset
|
(defn upload-media-asset
|
||||||
|
@ -254,8 +254,6 @@
|
||||||
:on-svg #(st/emit! (svg-uploaded % file-id position)))]
|
:on-svg #(st/emit! (svg-uploaded % file-id position)))]
|
||||||
(process-media-objects params)))
|
(process-media-objects params)))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn upload-fill-image
|
(defn upload-fill-image
|
||||||
[file on-success]
|
[file on-success]
|
||||||
(dm/assert!
|
(dm/assert!
|
||||||
|
@ -450,7 +448,7 @@
|
||||||
:id object-id}]
|
:id object-id}]
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (msg/show {:content (tr "media.loading")
|
(rx/of (ntf/show {:content (tr "media.loading")
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :info
|
:type :info
|
||||||
:timeout nil
|
:timeout nil
|
||||||
|
@ -458,7 +456,7 @@
|
||||||
(->> (rp/cmd! :clone-file-media-object params)
|
(->> (rp/cmd! :clone-file-media-object params)
|
||||||
(rx/tap on-success)
|
(rx/tap on-success)
|
||||||
(rx/catch on-error)
|
(rx/catch on-error)
|
||||||
(rx/finalize #(st/emit! (msg/hide-tag :media-loading)))))))))
|
(rx/finalize #(st/emit! (ntf/hide :tag :media-loading)))))))))
|
||||||
|
|
||||||
(defn create-svg-shape
|
(defn create-svg-shape
|
||||||
[id name svg-string position]
|
[id name svg-string position]
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
[clojure.set :as set]
|
[clojure.set :as set]
|
||||||
[potok.v2.core :as ptk]))
|
[potok.v2.core :as ptk]))
|
||||||
|
|
||||||
|
;; FIXME: this ns should be renamed to something different
|
||||||
|
|
||||||
(declare process-message)
|
(declare process-message)
|
||||||
(declare handle-presence)
|
(declare handle-presence)
|
||||||
(declare handle-pointer-update)
|
(declare handle-pointer-update)
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[app.common.exceptions :as ex]
|
[app.common.exceptions :as ex]
|
||||||
[app.common.pprint :as pp]
|
[app.common.pprint :as pp]
|
||||||
[app.common.schema :as-alias sm]
|
[app.common.schema :as-alias sm]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.util.globals :as glob]
|
[app.util.globals :as glob]
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
(let [msg (tr "errors.auth.unable-to-login")
|
(let [msg (tr "errors.auth.unable-to-login")
|
||||||
uri (. (. js/document -location) -href)]
|
uri (. (. js/document -location) -href)]
|
||||||
(st/emit! (du/logout {:capture-redirect true}))
|
(st/emit! (du/logout {:capture-redirect true}))
|
||||||
(ts/schedule 500 #(st/emit! (msg/warn msg)))
|
(ts/schedule 500 #(st/emit! (ntf/warn msg)))
|
||||||
(ts/schedule 1000 #(swap! storage assoc :redirect-url uri))))
|
(ts/schedule 1000 #(swap! storage assoc :redirect-url uri))))
|
||||||
|
|
||||||
;; Error that happens on an active business model validation does not
|
;; Error that happens on an active business model validation does not
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
(= code :invalid-paste-data)
|
(= code :invalid-paste-data)
|
||||||
(let [message (tr "errors.paste-data-validation")]
|
(let [message (tr "errors.paste-data-validation")]
|
||||||
(st/async-emit!
|
(st/async-emit!
|
||||||
(msg/show {:content message
|
(ntf/show {:content message
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :error
|
:type :error
|
||||||
:timeout 3000})))
|
:timeout 3000})))
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
(defmethod ptk/handle-error :assertion
|
(defmethod ptk/handle-error :assertion
|
||||||
[error]
|
[error]
|
||||||
(ts/schedule
|
(ts/schedule
|
||||||
#(st/emit! (msg/show {:content "Internal Assertion Error"
|
#(st/emit! (ntf/show {:content "Internal Assertion Error"
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :error
|
:type :error
|
||||||
:timeout 3000})))
|
:timeout 3000})))
|
||||||
|
@ -154,7 +154,7 @@
|
||||||
[error]
|
[error]
|
||||||
(ts/schedule
|
(ts/schedule
|
||||||
#(st/emit!
|
#(st/emit!
|
||||||
(msg/show {:content "Something wrong has happened (on worker)."
|
(ntf/show {:content "Something wrong has happened (on worker)."
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :error
|
:type :error
|
||||||
:timeout 3000})))
|
:timeout 3000})))
|
||||||
|
@ -168,7 +168,7 @@
|
||||||
(defmethod ptk/handle-error :svg-parser
|
(defmethod ptk/handle-error :svg-parser
|
||||||
[_]
|
[_]
|
||||||
(ts/schedule
|
(ts/schedule
|
||||||
#(st/emit! (msg/show {:content "SVG is invalid or malformed"
|
#(st/emit! (ntf/show {:content "SVG is invalid or malformed"
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :error
|
:type :error
|
||||||
:timeout 3000}))))
|
:timeout 3000}))))
|
||||||
|
@ -177,7 +177,7 @@
|
||||||
(defmethod ptk/handle-error :comment-error
|
(defmethod ptk/handle-error :comment-error
|
||||||
[_]
|
[_]
|
||||||
(ts/schedule
|
(ts/schedule
|
||||||
#(st/emit! (msg/show {:content "There was an error with the comment"
|
#(st/emit! (ntf/show {:content "There was an error with the comment"
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:type :error
|
:type :error
|
||||||
:timeout 3000}))))
|
:timeout 3000}))))
|
||||||
|
|
|
@ -24,9 +24,6 @@
|
||||||
(def router
|
(def router
|
||||||
(l/derived :router st/state))
|
(l/derived :router st/state))
|
||||||
|
|
||||||
(def message
|
|
||||||
(l/derived :message st/state))
|
|
||||||
|
|
||||||
(def profile
|
(def profile
|
||||||
(l/derived :profile st/state))
|
(l/derived :profile st/state))
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
[app.main.ui.debug.icons-preview :refer [icons-preview]]
|
[app.main.ui.debug.icons-preview :refer [icons-preview]]
|
||||||
[app.main.ui.frame-preview :as frame-preview]
|
[app.main.ui.frame-preview :as frame-preview]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
[app.main.ui.messages :as msgs]
|
[app.main.ui.notifications :as notifications]
|
||||||
[app.main.ui.onboarding.newsletter :refer [onboarding-newsletter]]
|
[app.main.ui.onboarding.newsletter :refer [onboarding-newsletter]]
|
||||||
[app.main.ui.onboarding.questions :refer [questions-modal]]
|
[app.main.ui.onboarding.questions :refer [questions-modal]]
|
||||||
[app.main.ui.onboarding.team-choice :refer [onboarding-team-modal]]
|
[app.main.ui.onboarding.team-choice :refer [onboarding-team-modal]]
|
||||||
|
@ -194,6 +194,6 @@
|
||||||
(if edata
|
(if edata
|
||||||
[:& static/exception-page {:data edata :route route}]
|
[:& static/exception-page {:data edata :route route}]
|
||||||
[:*
|
[:*
|
||||||
[:& msgs/notifications-hub]
|
[:& notifications/current-notification]
|
||||||
(when route
|
(when route
|
||||||
[:& main-page {:route route :profile profile}])])]]))
|
[:& main-page {:route route :profile profile}])])]]))
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
[app.common.logging :as log]
|
[app.common.logging :as log]
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
[]
|
[]
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type :warning
|
{:level :warning
|
||||||
:content (tr "auth.demo-warning")}])
|
:content (tr "auth.demo-warning")}])
|
||||||
|
|
||||||
(defn create-demo-profile
|
(defn create-demo-profile
|
||||||
|
@ -57,10 +57,10 @@
|
||||||
(cond
|
(cond
|
||||||
(and (= type :restriction)
|
(and (= type :restriction)
|
||||||
(= code :provider-not-configured))
|
(= code :provider-not-configured))
|
||||||
(st/emit! (msg/error (tr "errors.auth-provider-not-configured")))
|
(st/emit! (ntf/error (tr "errors.auth-provider-not-configured")))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(st/emit! (msg/error (tr "errors.generic"))))))))
|
(st/emit! (ntf/error (tr "errors.generic"))))))))
|
||||||
|
|
||||||
(def ^:private schema:login-form
|
(def ^:private schema:login-form
|
||||||
[:map {:title "LoginForm"}
|
[:map {:title "LoginForm"}
|
||||||
|
@ -86,7 +86,7 @@
|
||||||
|
|
||||||
(and (= :restriction (:type cause))
|
(and (= :restriction (:type cause))
|
||||||
(= :ldap-not-initialized (:code cause)))
|
(= :ldap-not-initialized (:code cause)))
|
||||||
(st/emit! (msg/error (tr "errors.ldap-disabled")))
|
(st/emit! (ntf/error (tr "errors.ldap-disabled")))
|
||||||
|
|
||||||
(and (= :restriction (:type cause))
|
(and (= :restriction (:type cause))
|
||||||
(= :admin-only-profile (:code cause)))
|
(= :admin-only-profile (:code cause)))
|
||||||
|
@ -145,9 +145,8 @@
|
||||||
[:*
|
[:*
|
||||||
(when-let [message @error]
|
(when-let [message @error]
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type :error
|
{:level :error
|
||||||
:content message
|
:content message
|
||||||
:data-testid "login-banner"
|
|
||||||
:role "alert"}])
|
:role "alert"}])
|
||||||
|
|
||||||
[:& fm/form {:on-submit on-submit
|
[:& fm/form {:on-submit on-submit
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
|
@ -29,11 +29,11 @@
|
||||||
|
|
||||||
(defn- on-error
|
(defn- on-error
|
||||||
[_form _error]
|
[_form _error]
|
||||||
(st/emit! (msg/error (tr "errors.invalid-recovery-token"))))
|
(st/emit! (ntf/error (tr "errors.invalid-recovery-token"))))
|
||||||
|
|
||||||
(defn- on-success
|
(defn- on-success
|
||||||
[_]
|
[_]
|
||||||
(st/emit! (msg/info (tr "auth.notifications.password-changed-successfully"))
|
(st/emit! (ntf/info (tr "auth.notifications.password-changed-successfully"))
|
||||||
(rt/nav :auth-login)))
|
(rt/nav :auth-login)))
|
||||||
|
|
||||||
(defn- on-submit
|
(defn- on-submit
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
default-success-finish
|
default-success-finish
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
#(st/emit! (msg/info (tr "auth.notifications.recovery-token-sent"))))
|
#(st/emit! (ntf/info (tr "auth.notifications.recovery-token-sent"))))
|
||||||
|
|
||||||
on-success
|
on-success
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -47,14 +47,14 @@
|
||||||
(let [code (-> cause ex-data :code)]
|
(let [code (-> cause ex-data :code)]
|
||||||
(case code
|
(case code
|
||||||
:profile-not-verified
|
:profile-not-verified
|
||||||
(rx/of (msg/error (tr "auth.notifications.profile-not-verified")))
|
(rx/of (ntf/error (tr "auth.notifications.profile-not-verified")))
|
||||||
|
|
||||||
:profile-is-muted
|
:profile-is-muted
|
||||||
(rx/of (msg/error (tr "errors.profile-is-muted")))
|
(rx/of (ntf/error (tr "errors.profile-is-muted")))
|
||||||
|
|
||||||
(:email-has-permanent-bounces
|
(:email-has-permanent-bounces
|
||||||
:email-has-complaints)
|
:email-has-complaints)
|
||||||
(rx/of (msg/error (tr "errors.email-has-permanent-bounces" (:email data))))
|
(rx/of (ntf/error (tr "errors.email-has-permanent-bounces" (:email data))))
|
||||||
|
|
||||||
(rx/throw cause)))))
|
(rx/throw cause)))))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -46,22 +46,22 @@
|
||||||
(let [{:keys [type code] :as edata} (ex-data cause)]
|
(let [{:keys [type code] :as edata} (ex-data cause)]
|
||||||
(condp = [type code]
|
(condp = [type code]
|
||||||
[:restriction :registration-disabled]
|
[:restriction :registration-disabled]
|
||||||
(st/emit! (msg/error (tr "errors.registration-disabled")))
|
(st/emit! (ntf/error (tr "errors.registration-disabled")))
|
||||||
|
|
||||||
[:restriction :email-domain-is-not-allowed]
|
[:restriction :email-domain-is-not-allowed]
|
||||||
(st/emit! (msg/error (tr "errors.email-domain-not-allowed")))
|
(st/emit! (ntf/error (tr "errors.email-domain-not-allowed")))
|
||||||
|
|
||||||
[:restriction :email-has-permanent-bounces]
|
[:restriction :email-has-permanent-bounces]
|
||||||
(st/emit! (msg/error (tr "errors.email-has-permanent-bounces" (:email edata))))
|
(st/emit! (ntf/error (tr "errors.email-has-permanent-bounces" (:email edata))))
|
||||||
|
|
||||||
[:restriction :email-has-complaints]
|
[:restriction :email-has-complaints]
|
||||||
(st/emit! (msg/error (tr "errors.email-has-permanent-bounces" (:email edata))))
|
(st/emit! (ntf/error (tr "errors.email-has-permanent-bounces" (:email edata))))
|
||||||
|
|
||||||
[:validation :email-as-password]
|
[:validation :email-as-password]
|
||||||
(swap! form assoc-in [:errors :password]
|
(swap! form assoc-in [:errors :password]
|
||||||
{:code "errors.email-as-password"})
|
{:code "errors.email-as-password"})
|
||||||
|
|
||||||
(st/emit! (msg/error (tr "errors.generic")))))))
|
(st/emit! (ntf/error (tr "errors.generic")))))))
|
||||||
|
|
||||||
on-submit
|
on-submit
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
on-error
|
on-error
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(st/emit! (msg/error (tr "errors.generic")))))
|
(st/emit! (ntf/error (tr "errors.generic")))))
|
||||||
|
|
||||||
on-submit
|
on-submit
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
(ns app.main.ui.auth.verify-token
|
(ns app.main.ui.auth.verify-token
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -24,13 +24,13 @@
|
||||||
(defmethod handle-token :verify-email
|
(defmethod handle-token :verify-email
|
||||||
[data]
|
[data]
|
||||||
(let [msg (tr "dashboard.notifications.email-verified-successfully")]
|
(let [msg (tr "dashboard.notifications.email-verified-successfully")]
|
||||||
(ts/schedule 1000 #(st/emit! (msg/success msg)))
|
(ts/schedule 1000 #(st/emit! (ntf/success msg)))
|
||||||
(st/emit! (du/login-from-token data))))
|
(st/emit! (du/login-from-token data))))
|
||||||
|
|
||||||
(defmethod handle-token :change-email
|
(defmethod handle-token :change-email
|
||||||
[_data]
|
[_data]
|
||||||
(let [msg (tr "dashboard.notifications.email-changed-successfully")]
|
(let [msg (tr "dashboard.notifications.email-changed-successfully")]
|
||||||
(ts/schedule 100 #(st/emit! (msg/success msg)))
|
(ts/schedule 100 #(st/emit! (ntf/success msg)))
|
||||||
(st/emit! (rt/nav :settings-profile)
|
(st/emit! (rt/nav :settings-profile)
|
||||||
(du/fetch-profile))))
|
(du/fetch-profile))))
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
(case (:state tdata)
|
(case (:state tdata)
|
||||||
:created
|
:created
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(msg/success (tr "auth.notifications.team-invitation-accepted"))
|
(ntf/success (tr "auth.notifications.team-invitation-accepted"))
|
||||||
(du/fetch-profile)
|
(du/fetch-profile)
|
||||||
(rt/nav :dashboard-projects {:team-id (:team-id tdata)}))
|
(rt/nav :dashboard-projects {:team-id (:team-id tdata)}))
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
[_tdata]
|
[_tdata]
|
||||||
(st/emit!
|
(st/emit!
|
||||||
(rt/nav :auth-login)
|
(rt/nav :auth-login)
|
||||||
(msg/warn (tr "errors.unexpected-token"))))
|
(ntf/warn (tr "errors.unexpected-token"))))
|
||||||
|
|
||||||
(mf/defc verify-token
|
(mf/defc verify-token
|
||||||
[{:keys [route] :as props}]
|
[{:keys [route] :as props}]
|
||||||
|
@ -79,17 +79,17 @@
|
||||||
|
|
||||||
(= :email-already-exists code)
|
(= :email-already-exists code)
|
||||||
(let [msg (tr "errors.email-already-exists")]
|
(let [msg (tr "errors.email-already-exists")]
|
||||||
(ts/schedule 100 #(st/emit! (msg/error msg)))
|
(ts/schedule 100 #(st/emit! (ntf/error msg)))
|
||||||
(st/emit! (rt/nav :auth-login)))
|
(st/emit! (rt/nav :auth-login)))
|
||||||
|
|
||||||
(= :email-already-validated code)
|
(= :email-already-validated code)
|
||||||
(let [msg (tr "errors.email-already-validated")]
|
(let [msg (tr "errors.email-already-validated")]
|
||||||
(ts/schedule 100 #(st/emit! (msg/warn msg)))
|
(ts/schedule 100 #(st/emit! (ntf/warn msg)))
|
||||||
(st/emit! (rt/nav :auth-login)))
|
(st/emit! (rt/nav :auth-login)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [msg (tr "errors.generic")]
|
(let [msg (tr "errors.generic")]
|
||||||
(ts/schedule 100 #(st/emit! (msg/error msg)))
|
(ts/schedule 100 #(st/emit! (ntf/error msg)))
|
||||||
(st/emit! (rt/nav :auth-login)))))))))
|
(st/emit! (rt/nav :auth-login)))))))))
|
||||||
|
|
||||||
(if @bad-token
|
(if @bad-token
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
[app.main.data.common :as dcm]
|
[app.main.data.common :as dcm]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.context-menu-a11y :refer [context-menu-a11y]]
|
[app.main.ui.components.context-menu-a11y :refer [context-menu-a11y]]
|
||||||
|
@ -88,12 +88,12 @@
|
||||||
on-duplicate
|
on-duplicate
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(apply st/emit! (map dd/duplicate-file files))
|
(apply st/emit! (map dd/duplicate-file files))
|
||||||
(st/emit! (msg/success (tr "dashboard.success-duplicate-file" (i18n/c (count files))))))
|
(st/emit! (ntf/success (tr "dashboard.success-duplicate-file" (i18n/c (count files))))))
|
||||||
|
|
||||||
on-delete-accept
|
on-delete-accept
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(apply st/emit! (map dd/delete-file files))
|
(apply st/emit! (map dd/delete-file files))
|
||||||
(st/emit! (msg/success (tr "dashboard.success-delete-file" (i18n/c (count files))))
|
(st/emit! (ntf/success (tr "dashboard.success-delete-file" (i18n/c (count files))))
|
||||||
(dd/clear-selected-files)))
|
(dd/clear-selected-files)))
|
||||||
|
|
||||||
on-delete
|
on-delete
|
||||||
|
@ -126,8 +126,8 @@
|
||||||
on-move-success
|
on-move-success
|
||||||
(fn [team-id project-id]
|
(fn [team-id project-id]
|
||||||
(if multi?
|
(if multi?
|
||||||
(st/emit! (msg/success (tr "dashboard.success-move-files")))
|
(st/emit! (ntf/success (tr "dashboard.success-move-files")))
|
||||||
(st/emit! (msg/success (tr "dashboard.success-move-file"))))
|
(st/emit! (ntf/success (tr "dashboard.success-move-file"))))
|
||||||
(if (or navigate? (not= team-id current-team-id))
|
(if (or navigate? (not= team-id current-team-id))
|
||||||
(st/emit! (dd/go-to-files team-id project-id))
|
(st/emit! (dd/go-to-files team-id project-id))
|
||||||
(st/emit! (dd/fetch-recent-files team-id)
|
(st/emit! (dd/fetch-recent-files team-id)
|
||||||
|
|
|
@ -180,12 +180,12 @@
|
||||||
:on-selected on-selected}]]
|
:on-selected on-selected}]]
|
||||||
|
|
||||||
[:& context-notification {:content (tr "dashboard.fonts.hero-text2")
|
[:& context-notification {:content (tr "dashboard.fonts.hero-text2")
|
||||||
:type :default
|
:level :default
|
||||||
:is-html true}]
|
:is-html true}]
|
||||||
|
|
||||||
(when problematic-fonts?
|
(when problematic-fonts?
|
||||||
[:& context-notification {:content (tr "dashboard.fonts.warning-text")
|
[:& context-notification {:content (tr "dashboard.fonts.warning-text")
|
||||||
:type :warning
|
:level :warning
|
||||||
:is-html true}])]]
|
:is-html true}])]]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
[app.common.logging :as log]
|
[app.common.logging :as log]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.fonts :as fonts]
|
[app.main.fonts :as fonts]
|
||||||
[app.main.rasterizer :as thr]
|
[app.main.rasterizer :as thr]
|
||||||
|
@ -560,7 +560,7 @@
|
||||||
|
|
||||||
on-drop-success
|
on-drop-success
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (msg/success (tr "dashboard.success-move-file"))
|
(st/emit! (ntf/success (tr "dashboard.success-move-file"))
|
||||||
(dd/fetch-recent-files (:id team))
|
(dd/fetch-recent-files (:id team))
|
||||||
(dd/clear-selected-files)))
|
(dd/clear-selected-files)))
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
[app.common.logging :as log]
|
[app.common.logging :as log]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.errors :as errors]
|
[app.main.errors :as errors]
|
||||||
[app.main.features :as features]
|
[app.main.features :as features]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -366,7 +366,7 @@
|
||||||
(reset! template-finished* true)
|
(reset! template-finished* true)
|
||||||
(errors/print-error! cause)
|
(errors/print-error! cause)
|
||||||
(rx/of (modal/hide)
|
(rx/of (modal/hide)
|
||||||
(msg/error (tr "dashboard.libraries-and-templates.import-error")))))
|
(ntf/error (tr "dashboard.libraries-and-templates.import-error")))))
|
||||||
|
|
||||||
continue-entries
|
continue-entries
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
@ -481,19 +481,19 @@
|
||||||
[:div {:class (stl/css :modal-content)}
|
[:div {:class (stl/css :modal-content)}
|
||||||
(when (and (= :analyzing status) errors?)
|
(when (and (= :analyzing status) errors?)
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type :warning
|
{:level :warning
|
||||||
:content (tr "dashboard.import.import-warning")}])
|
:content (tr "dashboard.import.import-warning")}])
|
||||||
|
|
||||||
(when (and (= :importing status) (not ^boolean pending-import?))
|
(when (and (= :importing status) (not ^boolean pending-import?))
|
||||||
(cond
|
(cond
|
||||||
errors?
|
errors?
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type :warning
|
{:level :warning
|
||||||
:content (tr "dashboard.import.import-warning")}]
|
:content (tr "dashboard.import.import-warning")}]
|
||||||
|
|
||||||
:else
|
:else
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type (if (zero? success-num) :warning :success)
|
{:level (if (zero? success-num) :warning :success)
|
||||||
:content (tr "dashboard.import.import-message" (i18n/c success-num))}]))
|
:content (tr "dashboard.import.import-message" (i18n/c success-num))}]))
|
||||||
|
|
||||||
(for [entry entries]
|
(for [entry entries]
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
(ns app.main.ui.dashboard.project-menu
|
(ns app.main.ui.dashboard.project-menu
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.context-menu-a11y :refer [context-menu-a11y]]
|
[app.main.ui.components.context-menu-a11y :refer [context-menu-a11y]]
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
on-duplicate-success
|
on-duplicate-success
|
||||||
(fn [new-project]
|
(fn [new-project]
|
||||||
(st/emit! (msg/success (tr "dashboard.success-duplicate-project"))
|
(st/emit! (ntf/success (tr "dashboard.success-duplicate-project"))
|
||||||
(rt/nav :dashboard-files
|
(rt/nav :dashboard-files
|
||||||
{:team-id (:team-id new-project)
|
{:team-id (:team-id new-project)
|
||||||
:project-id (:id new-project)})))
|
:project-id (:id new-project)})))
|
||||||
|
@ -51,12 +51,12 @@
|
||||||
(fn [team-id]
|
(fn [team-id]
|
||||||
(let [data {:id (:id project) :team-id team-id}
|
(let [data {:id (:id project) :team-id team-id}
|
||||||
mdata {:on-success #(on-move-success team-id)}]
|
mdata {:on-success #(on-move-success team-id)}]
|
||||||
#(st/emit! (msg/success (tr "dashboard.success-move-project"))
|
#(st/emit! (ntf/success (tr "dashboard.success-move-project"))
|
||||||
(dd/move-project (with-meta data mdata)))))
|
(dd/move-project (with-meta data mdata)))))
|
||||||
|
|
||||||
delete-fn
|
delete-fn
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(st/emit! (msg/success (tr "dashboard.success-delete-project"))
|
(st/emit! (ntf/success (tr "dashboard.success-delete-project"))
|
||||||
(dd/delete-project project)
|
(dd/delete-project project)
|
||||||
(dd/go-to-projects (:team-id project))))
|
(dd/go-to-projects (:team-id project))))
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -149,7 +149,7 @@
|
||||||
on-drop-success
|
on-drop-success
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps (:id item))
|
(mf/deps (:id item))
|
||||||
#(st/emit! (msg/success (tr "dashboard.success-move-file"))
|
#(st/emit! (ntf/success (tr "dashboard.success-move-file"))
|
||||||
(dd/go-to-files (:id item))))
|
(dd/go-to-files (:id item))))
|
||||||
|
|
||||||
on-drop
|
on-drop
|
||||||
|
@ -362,13 +362,13 @@
|
||||||
(fn [{:keys [code] :as error}]
|
(fn [{:keys [code] :as error}]
|
||||||
(condp = code
|
(condp = code
|
||||||
:no-enough-members-for-leave
|
:no-enough-members-for-leave
|
||||||
(rx/of (msg/error (tr "errors.team-leave.insufficient-members")))
|
(rx/of (ntf/error (tr "errors.team-leave.insufficient-members")))
|
||||||
|
|
||||||
:member-does-not-exist
|
:member-does-not-exist
|
||||||
(rx/of (msg/error (tr "errors.team-leave.member-does-not-exists")))
|
(rx/of (ntf/error (tr "errors.team-leave.member-does-not-exists")))
|
||||||
|
|
||||||
:owner-cant-leave-team
|
:owner-cant-leave-team
|
||||||
(rx/of (msg/error (tr "errors.team-leave.owner-cant-leave")))
|
(rx/of (ntf/error (tr "errors.team-leave.owner-cant-leave")))
|
||||||
|
|
||||||
(rx/throw error)))
|
(rx/throw error)))
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
[app.config :as cfg]
|
[app.config :as cfg]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -162,7 +162,7 @@
|
||||||
on-success
|
on-success
|
||||||
(fn [_form {:keys [total]}]
|
(fn [_form {:keys [total]}]
|
||||||
(when (pos? total)
|
(when (pos? total)
|
||||||
(st/emit! (msg/success (tr "notifications.invitation-email-sent"))))
|
(st/emit! (ntf/success (tr "notifications.invitation-email-sent"))))
|
||||||
|
|
||||||
(st/emit! (modal/hide)
|
(st/emit! (modal/hide)
|
||||||
(dd/fetch-team-invitations)))
|
(dd/fetch-team-invitations)))
|
||||||
|
@ -173,7 +173,7 @@
|
||||||
(cond
|
(cond
|
||||||
(and (= :validation type)
|
(and (= :validation type)
|
||||||
(= :profile-is-muted code))
|
(= :profile-is-muted code))
|
||||||
(st/emit! (msg/error (tr "errors.profile-is-muted"))
|
(st/emit! (ntf/error (tr "errors.profile-is-muted"))
|
||||||
(modal/hide))
|
(modal/hide))
|
||||||
|
|
||||||
(or (= :member-is-muted code)
|
(or (= :member-is-muted code)
|
||||||
|
@ -182,7 +182,7 @@
|
||||||
(swap! error-text (tr "errors.email-spam-or-permanent-bounces" (:email error)))
|
(swap! error-text (tr "errors.email-spam-or-permanent-bounces" (:email error)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(st/emit! (msg/error (tr "errors.generic"))
|
(st/emit! (ntf/error (tr "errors.generic"))
|
||||||
(modal/hide)))))
|
(modal/hide)))))
|
||||||
|
|
||||||
on-submit
|
on-submit
|
||||||
|
@ -203,11 +203,11 @@
|
||||||
|
|
||||||
(when-not (= "" @error-text)
|
(when-not (= "" @error-text)
|
||||||
[:& context-notification {:content @error-text
|
[:& context-notification {:content @error-text
|
||||||
:type :error}])
|
:level :error}])
|
||||||
|
|
||||||
(when (some current-data-emails current-members-emails)
|
(when (some current-data-emails current-members-emails)
|
||||||
[:& context-notification {:content (tr "modals.invite-member.repeated-invitation")
|
[:& context-notification {:content (tr "modals.invite-member.repeated-invitation")
|
||||||
:type :warning}])
|
:level :warning}])
|
||||||
|
|
||||||
[:div {:class (stl/css :role-select)}
|
[:div {:class (stl/css :role-select)}
|
||||||
[:p {:class (stl/css :role-title)}
|
[:p {:class (stl/css :role-title)}
|
||||||
|
@ -368,13 +368,13 @@
|
||||||
(condp = code
|
(condp = code
|
||||||
|
|
||||||
:no-enough-members-for-leave
|
:no-enough-members-for-leave
|
||||||
(rx/of (msg/error (tr "errors.team-leave.insufficient-members")))
|
(rx/of (ntf/error (tr "errors.team-leave.insufficient-members")))
|
||||||
|
|
||||||
:member-does-not-exist
|
:member-does-not-exist
|
||||||
(rx/of (msg/error (tr "errors.team-leave.member-does-not-exists")))
|
(rx/of (ntf/error (tr "errors.team-leave.member-does-not-exists")))
|
||||||
|
|
||||||
:owner-cant-leave-team
|
:owner-cant-leave-team
|
||||||
(rx/of (msg/error (tr "errors.team-leave.owner-cant-leave")))
|
(rx/of (ntf/error (tr "errors.team-leave.owner-cant-leave")))
|
||||||
|
|
||||||
(rx/throw error))))
|
(rx/throw error))))
|
||||||
|
|
||||||
|
@ -580,16 +580,16 @@
|
||||||
(cond
|
(cond
|
||||||
(and (= :validation type)
|
(and (= :validation type)
|
||||||
(= :profile-is-muted code))
|
(= :profile-is-muted code))
|
||||||
(rx/of (msg/error (tr "errors.profile-is-muted")))
|
(rx/of (ntf/error (tr "errors.profile-is-muted")))
|
||||||
|
|
||||||
(and (= :validation type)
|
(and (= :validation type)
|
||||||
(= :member-is-muted code))
|
(= :member-is-muted code))
|
||||||
(rx/of (msg/error (tr "errors.member-is-muted")))
|
(rx/of (ntf/error (tr "errors.member-is-muted")))
|
||||||
|
|
||||||
(and (= :restriction type)
|
(and (= :restriction type)
|
||||||
(or (= :email-has-permanent-bounces code)
|
(or (= :email-has-permanent-bounces code)
|
||||||
(= :email-has-complaints code)))
|
(= :email-has-complaints code)))
|
||||||
(rx/of (msg/error (tr "errors.email-has-permanent-bounces" email)))
|
(rx/of (ntf/error (tr "errors.email-has-permanent-bounces" email)))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(rx/throw cause)))))
|
(rx/throw cause)))))
|
||||||
|
@ -605,7 +605,7 @@
|
||||||
on-resend-success
|
on-resend-success
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (msg/success (tr "notifications.invitation-email-sent"))
|
(st/emit! (ntf/success (tr "notifications.invitation-email-sent"))
|
||||||
(modal/hide)
|
(modal/hide)
|
||||||
(dd/fetch-team-invitations))))
|
(dd/fetch-team-invitations))))
|
||||||
|
|
||||||
|
@ -626,7 +626,7 @@
|
||||||
on-copy-success
|
on-copy-success
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (msg/success (tr "notifications.invitation-link-copied"))
|
(st/emit! (ntf/success (tr "notifications.invitation-link-copied"))
|
||||||
(modal/hide))))
|
(modal/hide))))
|
||||||
|
|
||||||
on-copy
|
on-copy
|
||||||
|
@ -788,7 +788,7 @@
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(let [message (tr "dashboard.webhooks.create.success")]
|
(let [message (tr "dashboard.webhooks.create.success")]
|
||||||
(st/emit! (dd/fetch-team-webhooks)
|
(st/emit! (dd/fetch-team-webhooks)
|
||||||
(msg/success message)
|
(ntf/success message)
|
||||||
(modal/hide)))))
|
(modal/hide)))))
|
||||||
|
|
||||||
on-error
|
on-error
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
|
@ -29,22 +29,22 @@
|
||||||
(defn- on-create-success
|
(defn- on-create-success
|
||||||
[_form response]
|
[_form response]
|
||||||
(let [msg "Team created successfully"]
|
(let [msg "Team created successfully"]
|
||||||
(st/emit! (msg/success msg)
|
(st/emit! (ntf/success msg)
|
||||||
(modal/hide)
|
(modal/hide)
|
||||||
(rt/nav :dashboard-projects {:team-id (:id response)}))))
|
(rt/nav :dashboard-projects {:team-id (:id response)}))))
|
||||||
|
|
||||||
(defn- on-update-success
|
(defn- on-update-success
|
||||||
[_form _response]
|
[_form _response]
|
||||||
(let [msg "Team created successfully"]
|
(let [msg "Team created successfully"]
|
||||||
(st/emit! (msg/success msg)
|
(st/emit! (ntf/success msg)
|
||||||
(modal/hide))))
|
(modal/hide))))
|
||||||
|
|
||||||
(defn- on-error
|
(defn- on-error
|
||||||
[form _response]
|
[form _response]
|
||||||
(let [id (get-in @form [:clean-data :id])]
|
(let [id (get-in @form [:clean-data :id])]
|
||||||
(if id
|
(if id
|
||||||
(rx/of (msg/error "Error on updating team."))
|
(rx/of (ntf/error "Error on updating team."))
|
||||||
(rx/of (msg/error "Error on creating team.")))))
|
(rx/of (ntf/error "Error on creating team.")))))
|
||||||
|
|
||||||
(defn- on-create-submit
|
(defn- on-create-submit
|
||||||
[form]
|
[form]
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
;; 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) KALEIDOS INC
|
|
||||||
|
|
||||||
(ns app.main.ui.messages
|
|
||||||
(:require
|
|
||||||
[app.main.data.messages :as dmsg]
|
|
||||||
[app.main.refs :as refs]
|
|
||||||
[app.main.store :as st]
|
|
||||||
[app.main.ui.notifications.context-notification :refer [context-notification]]
|
|
||||||
[app.main.ui.notifications.inline-notification :refer [inline-notification]]
|
|
||||||
[app.main.ui.notifications.toast-notification :refer [toast-notification]]
|
|
||||||
[rumext.v2 :as mf]))
|
|
||||||
|
|
||||||
(mf/defc notifications-hub
|
|
||||||
[]
|
|
||||||
(let [message (mf/deref refs/message)
|
|
||||||
on-close (mf/use-fn #(st/emit! dmsg/hide))
|
|
||||||
context? (and (nil? (:timeout message))
|
|
||||||
(nil? (:actions message)))
|
|
||||||
inline? (or (= :inline (:notification-type message))
|
|
||||||
(= :floating (:position message)))
|
|
||||||
toast? (or (= :toast (:notification-type message))
|
|
||||||
(some? (:timeout message)))]
|
|
||||||
|
|
||||||
(when message
|
|
||||||
(cond
|
|
||||||
toast?
|
|
||||||
[:& toast-notification
|
|
||||||
{:type (or (:type message) :info)
|
|
||||||
:links (:links message)
|
|
||||||
:on-close on-close
|
|
||||||
:content (:content message)}]
|
|
||||||
|
|
||||||
inline?
|
|
||||||
[:& inline-notification
|
|
||||||
{:actions (:actions message)
|
|
||||||
:links (:links message)
|
|
||||||
:content (:content message)}]
|
|
||||||
|
|
||||||
context?
|
|
||||||
[:& context-notification
|
|
||||||
{:type (or (:type message) :info)
|
|
||||||
:links (:links message)
|
|
||||||
:content (:content message)}]
|
|
||||||
|
|
||||||
:else
|
|
||||||
[:& toast-notification
|
|
||||||
{:type (or (:type message) :info)
|
|
||||||
:links (:links message)
|
|
||||||
:on-close on-close
|
|
||||||
:content (:content message)}]))))
|
|
57
frontend/src/app/main/ui/notifications.cljs
Normal file
57
frontend/src/app/main/ui/notifications.cljs
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
;; 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) KALEIDOS INC
|
||||||
|
|
||||||
|
(ns app.main.ui.notifications
|
||||||
|
(:require
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
|
[app.main.store :as st]
|
||||||
|
[app.main.ui.notifications.context-notification :refer [context-notification]]
|
||||||
|
[app.main.ui.notifications.inline-notification :refer [inline-notification]]
|
||||||
|
[app.main.ui.notifications.toast-notification :refer [toast-notification]]
|
||||||
|
[okulary.core :as l]
|
||||||
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
|
(def ref:notification
|
||||||
|
(l/derived :notification st/state))
|
||||||
|
|
||||||
|
(mf/defc current-notification
|
||||||
|
[]
|
||||||
|
(let [notification (mf/deref ref:notification)
|
||||||
|
on-close (mf/use-fn #(st/emit! (ntf/hide)))
|
||||||
|
context? (and (nil? (:timeout notification))
|
||||||
|
(nil? (:actions notification)))
|
||||||
|
inline? (or (= :inline (:type notification))
|
||||||
|
(= :floating (:position notification)))
|
||||||
|
toast? (or (= :toast (:type notification))
|
||||||
|
(some? (:timeout notification)))]
|
||||||
|
|
||||||
|
(when notification
|
||||||
|
(cond
|
||||||
|
toast?
|
||||||
|
[:& toast-notification
|
||||||
|
{:level (or (:level notification) :info)
|
||||||
|
:links (:links notification)
|
||||||
|
:on-close on-close
|
||||||
|
:content (:content notification)}]
|
||||||
|
|
||||||
|
inline?
|
||||||
|
[:& inline-notification
|
||||||
|
{:actions (:actions notification)
|
||||||
|
:links (:links notification)
|
||||||
|
:content (:content notification)}]
|
||||||
|
|
||||||
|
context?
|
||||||
|
[:& context-notification
|
||||||
|
{:level (or (:level notification) :info)
|
||||||
|
:links (:links notification)
|
||||||
|
:content (:content notification)}]
|
||||||
|
|
||||||
|
:else
|
||||||
|
[:& toast-notification
|
||||||
|
{:level (or (:level notification) :info)
|
||||||
|
:links (:links notification)
|
||||||
|
:on-close on-close
|
||||||
|
:content (:content notification)}]))))
|
|
@ -25,9 +25,9 @@
|
||||||
(def ^:private info-icon
|
(def ^:private info-icon
|
||||||
(i/icon-xref :help (stl/css :icon)))
|
(i/icon-xref :help (stl/css :icon)))
|
||||||
|
|
||||||
(defn get-icon-by-type
|
(defn get-icon-by-level
|
||||||
[type]
|
[level]
|
||||||
(case type
|
(case level
|
||||||
:warning neutral-icon
|
:warning neutral-icon
|
||||||
:error error-icon
|
:error error-icon
|
||||||
:success success-icon
|
:success success-icon
|
||||||
|
@ -36,19 +36,17 @@
|
||||||
|
|
||||||
(mf/defc context-notification
|
(mf/defc context-notification
|
||||||
"They are persistent, informative and non-actionable.
|
"They are persistent, informative and non-actionable.
|
||||||
They are contextual messages in specific areas off the app"
|
They are contextual messages in specific areas off the app"
|
||||||
|
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
[{:keys [type content links is-html] :as props}]
|
[{:keys [level content links is-html] :as props}]
|
||||||
|
|
||||||
[:aside {:class (stl/css-case :context-notification true
|
[:aside {:class (stl/css-case :context-notification true
|
||||||
:contain-html is-html
|
:contain-html is-html
|
||||||
:warning (= type :warning)
|
:warning (= level :warning)
|
||||||
:error (= type :error)
|
:error (= level :error)
|
||||||
:success (= type :success)
|
:success (= level :success)
|
||||||
:info (= type :info))}
|
:info (= level :info))}
|
||||||
|
|
||||||
(get-icon-by-type type)
|
(get-icon-by-level level)
|
||||||
|
|
||||||
;; The content can arrive in markdown format, in these cases
|
;; The content can arrive in markdown format, in these cases
|
||||||
;; we will use the prop is-html to true to indicate it and
|
;; we will use the prop is-html to true to indicate it and
|
||||||
|
|
|
@ -28,9 +28,9 @@
|
||||||
(def ^:private close-icon
|
(def ^:private close-icon
|
||||||
(i/icon-xref :close (stl/css :close-icon)))
|
(i/icon-xref :close (stl/css :close-icon)))
|
||||||
|
|
||||||
(defn get-icon-by-type
|
(defn get-icon-by-level
|
||||||
[type]
|
[level]
|
||||||
(case type
|
(case level
|
||||||
:warning neutral-icon
|
:warning neutral-icon
|
||||||
:error error-icon
|
:error error-icon
|
||||||
:success success-icon
|
:success success-icon
|
||||||
|
@ -44,15 +44,15 @@
|
||||||
error messages that require user interaction."
|
error messages that require user interaction."
|
||||||
|
|
||||||
{::mf/props :obj}
|
{::mf/props :obj}
|
||||||
[{:keys [type content on-close links] :as props}]
|
[{:keys [level content on-close links] :as props}]
|
||||||
|
|
||||||
[:aside {:class (stl/css-case :toast-notification true
|
[:aside {:class (stl/css-case :toast-notification true
|
||||||
:warning (= type :warning)
|
:warning (= level :warning)
|
||||||
:error (= type :error)
|
:error (= level :error)
|
||||||
:success (= type :success)
|
:success (= level :success)
|
||||||
:info (= type :info))}
|
:info (= level :info))}
|
||||||
|
|
||||||
(get-icon-by-type type)
|
(get-icon-by-level level)
|
||||||
|
|
||||||
[:div {:class (stl/css :text)}
|
[:div {:class (stl/css :text)}
|
||||||
content
|
content
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.events :as-alias ev]
|
[app.main.data.events :as-alias ev]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
(fn []
|
(fn []
|
||||||
(when (or (:newsletter-updates state)
|
(when (or (:newsletter-updates state)
|
||||||
(:newsletter-news state))
|
(:newsletter-news state))
|
||||||
(st/emit! (msg/success (tr "onboarding.newsletter.acceptance-message"))))
|
(st/emit! (ntf/success (tr "onboarding.newsletter.acceptance-message"))))
|
||||||
|
|
||||||
(let [params (-> state
|
(let [params (-> state
|
||||||
(assoc ::ev/name "onboarding-step")
|
(assoc ::ev/name "onboarding-step")
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
|
@ -90,7 +90,7 @@
|
||||||
on-error
|
on-error
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(st/emit! (msg/error (tr "errors.generic")))))
|
(st/emit! (ntf/error (tr "errors.generic")))))
|
||||||
|
|
||||||
on-invite-later
|
on-invite-later
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.context-menu-a11y :refer [context-menu-a11y]]
|
[app.main.ui.components.context-menu-a11y :refer [context-menu-a11y]]
|
||||||
|
@ -64,7 +64,7 @@
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(let [message (tr "dashboard.access-tokens.create.success")]
|
(let [message (tr "dashboard.access-tokens.create.success")]
|
||||||
(st/emit! (du/fetch-access-tokens)
|
(st/emit! (du/fetch-access-tokens)
|
||||||
(msg/success message)
|
(ntf/success message)
|
||||||
(reset! created? true)))))
|
(reset! created? true)))))
|
||||||
|
|
||||||
on-close
|
on-close
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
on-error
|
on-error
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(st/emit! (msg/error (tr "errors.generic"))
|
(st/emit! (ntf/error (tr "errors.generic"))
|
||||||
(modal/hide))))
|
(modal/hide))))
|
||||||
|
|
||||||
on-submit
|
on-submit
|
||||||
|
@ -99,7 +99,7 @@
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/prevent-default event)
|
(dom/prevent-default event)
|
||||||
(wapi/write-to-clipboard (:token created))
|
(wapi/write-to-clipboard (:token created))
|
||||||
(st/emit! (msg/show {:type :info
|
(st/emit! (ntf/show {:type :info
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:content (tr "dashboard.access-tokens.copied-success")
|
:content (tr "dashboard.access-tokens.copied-success")
|
||||||
:timeout 7000}))))]
|
:timeout 7000}))))]
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -30,11 +30,11 @@
|
||||||
(assoc-in data [:errors :email-1] error))))
|
(assoc-in data [:errors :email-1] error))))
|
||||||
|
|
||||||
:profile-is-muted
|
:profile-is-muted
|
||||||
(rx/of (msg/error (tr "errors.profile-is-muted")))
|
(rx/of (ntf/error (tr "errors.profile-is-muted")))
|
||||||
|
|
||||||
(:email-has-permanent-bounces
|
(:email-has-permanent-bounces
|
||||||
:email-has-complaints)
|
:email-has-complaints)
|
||||||
(rx/of (msg/error (tr "errors.email-has-permanent-bounces" (:email error))))
|
(rx/of (ntf/error (tr "errors.email-has-permanent-bounces" (:email error))))
|
||||||
|
|
||||||
(rx/throw cause))))
|
(rx/throw cause))))
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
(st/emit! (du/fetch-profile)
|
(st/emit! (du/fetch-profile)
|
||||||
(modal/hide))
|
(modal/hide))
|
||||||
(let [message (tr "notifications.validation-email-sent" (:email profile))]
|
(let [message (tr "notifications.validation-email-sent" (:email profile))]
|
||||||
(st/emit! (msg/info message)
|
(st/emit! (ntf/info message)
|
||||||
(modal/hide)))))
|
(modal/hide)))))
|
||||||
|
|
||||||
(defn- on-submit
|
(defn- on-submit
|
||||||
|
@ -95,7 +95,7 @@
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-content)}
|
[:div {:class (stl/css :modal-content)}
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type :info
|
{:level :info
|
||||||
:content (tr "modals.change-email.info" (:email profile))}]
|
:content (tr "modals.change-email.info" (:email profile))}]
|
||||||
|
|
||||||
[:div {:class (stl/css :fields-row)}
|
[:div {:class (stl/css :fields-row)}
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
(ns app.main.ui.settings.delete-account
|
(ns app.main.ui.settings.delete-account
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.icons :as i]
|
[app.main.ui.icons :as i]
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
(let [code (-> cause ex-data :code)]
|
(let [code (-> cause ex-data :code)]
|
||||||
(if (= :owner-teams-with-people code)
|
(if (= :owner-teams-with-people code)
|
||||||
(let [msg (tr "notifications.profile-deletion-not-allowed")]
|
(let [msg (tr "notifications.profile-deletion-not-allowed")]
|
||||||
(rx/of (msg/error msg)))
|
(rx/of (ntf/error msg)))
|
||||||
(rx/throw cause))))
|
(rx/throw cause))))
|
||||||
|
|
||||||
(mf/defc delete-account-modal
|
(mf/defc delete-account-modal
|
||||||
|
@ -49,7 +49,7 @@
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-content)}
|
[:div {:class (stl/css :modal-content)}
|
||||||
[:& context-notification
|
[:& context-notification
|
||||||
{:type :warning
|
{:level :warning
|
||||||
:content (tr "modals.delete-account.info")}]]
|
:content (tr "modals.delete-account.info")}]]
|
||||||
|
|
||||||
[:div {:class (stl/css :modal-footer)}
|
[:div {:class (stl/css :modal-footer)}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.repo :as rp]
|
[app.main.repo :as rp]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
(mf/deps profile)
|
(mf/deps profile)
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(reset! loading false)
|
(reset! loading false)
|
||||||
(st/emit! (msg/success (tr "labels.feedback-sent")))
|
(st/emit! (ntf/success (tr "labels.feedback-sent")))
|
||||||
(swap! form assoc :data {} :touched {} :errors {})))
|
(swap! form assoc :data {} :touched {} :errors {})))
|
||||||
|
|
||||||
on-error
|
on-error
|
||||||
|
@ -45,8 +45,8 @@
|
||||||
(fn [{:keys [code] :as error}]
|
(fn [{:keys [code] :as error}]
|
||||||
(reset! loading false)
|
(reset! loading false)
|
||||||
(if (= code :feedback-disabled)
|
(if (= code :feedback-disabled)
|
||||||
(st/emit! (msg/error (tr "labels.feedback-disabled")))
|
(st/emit! (ntf/error (tr "labels.feedback-disabled")))
|
||||||
(st/emit! (msg/error (tr "errors.generic"))))))
|
(st/emit! (ntf/error (tr "errors.generic"))))))
|
||||||
|
|
||||||
on-submit
|
on-submit
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
(ns app.main.ui.settings.options
|
(ns app.main.ui.settings.options
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
(defn- on-success
|
(defn- on-success
|
||||||
[profile]
|
[profile]
|
||||||
(st/emit! (msg/success (tr "notifications.profile-saved"))
|
(st/emit! (ntf/success (tr "notifications.profile-saved"))
|
||||||
(du/profile-fetched profile)))
|
(du/profile-fetched profile)))
|
||||||
|
|
||||||
(defn- on-submit
|
(defn- on-submit
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.main.data.messages :as msg]
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as udu]
|
[app.main.data.users :as udu]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.forms :as fm]
|
[app.main.ui.components.forms :as fm]
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
{:code "errors.email-as-password"})
|
{:code "errors.email-as-password"})
|
||||||
|
|
||||||
(let [msg (tr "generic.error")]
|
(let [msg (tr "generic.error")]
|
||||||
(st/emit! (msg/error msg)))))
|
(st/emit! (ntf/error msg)))))
|
||||||
|
|
||||||
(defn- on-success
|
(defn- on-success
|
||||||
[form]
|
[form]
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
msg (tr "dashboard.notifications.password-saved")]
|
msg (tr "dashboard.notifications.password-saved")]
|
||||||
(dom/clean-value! password-old-node)
|
(dom/clean-value! password-old-node)
|
||||||
(dom/focus! password-old-node)
|
(dom/focus! password-old-node)
|
||||||
(st/emit! (msg/success msg))))
|
(st/emit! (ntf/success msg))))
|
||||||
|
|
||||||
(defn- on-submit
|
(defn- on-submit
|
||||||
[form event]
|
[form event]
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.users :as du]
|
[app.main.data.users :as du]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
(let [data (:clean-data @form)]
|
(let [data (:clean-data @form)]
|
||||||
(st/emit! (du/update-profile data)
|
(st/emit! (du/update-profile data)
|
||||||
(du/persist-profile)
|
(du/persist-profile)
|
||||||
(msg/success (tr "notifications.profile-saved")))))
|
(ntf/success (tr "notifications.profile-saved")))))
|
||||||
|
|
||||||
;; --- Profile Form
|
;; --- Profile Form
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
[app.config :as cf]
|
[app.config :as cf]
|
||||||
[app.main.data.common :as dc]
|
[app.main.data.common :as dc]
|
||||||
[app.main.data.events :as ev]
|
[app.main.data.events :as ev]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.select :refer [select]]
|
[app.main.ui.components.select :refer [select]]
|
||||||
|
@ -134,7 +134,7 @@
|
||||||
copy-link
|
copy-link
|
||||||
(fn [_]
|
(fn [_]
|
||||||
(wapi/write-to-clipboard current-link)
|
(wapi/write-to-clipboard current-link)
|
||||||
(st/emit! (msg/show {:type :info
|
(st/emit! (ntf/show {:type :info
|
||||||
:notification-type :toast
|
:notification-type :toast
|
||||||
:content (tr "common.share-link.link-copied-success")
|
:content (tr "common.share-link.link-copied-success")
|
||||||
:timeout 1000})))
|
:timeout 1000})))
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.main.data.messages :as msg]
|
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
[app.main.data.notifications :as ntf]
|
||||||
[app.main.data.persistence :as dps]
|
[app.main.data.persistence :as dps]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.data.workspace.colors :as dc]
|
[app.main.data.workspace.colors :as dc]
|
||||||
|
@ -195,7 +195,7 @@
|
||||||
(st/emit! ::dps/force-persist
|
(st/emit! ::dps/force-persist
|
||||||
(dc/stop-picker)
|
(dc/stop-picker)
|
||||||
(modal/hide)
|
(modal/hide)
|
||||||
msg/hide
|
(ntf/hide)
|
||||||
(dw/finalize-file project-id file-id))))
|
(dw/finalize-file project-id file-id))))
|
||||||
|
|
||||||
[:& (mf/provider ctx/current-file-id) {:value file-id}
|
[:& (mf/provider ctx/current-file-id) {:value file-id}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue