Merge remote-tracking branch 'origin/staging' into develop

This commit is contained in:
Andrey Antukh 2025-02-19 10:46:55 +01:00
commit 44acd79081
8 changed files with 60 additions and 57 deletions

View file

@ -51,15 +51,12 @@
[:label :string]
[:callback ::sm/fn]]]]])
(def ^:private valid-notification?
(sm/validator schema:notification))
(def ^:private check-notification
(sm/check-fn schema:notification))
(defn show
[data]
(dm/assert!
"expected valid notification map"
(valid-notification? data))
(assert (check-notification data) "expected valid notification map")
(ptk/reify ::show
ptk/UpdateEvent
@ -68,12 +65,16 @@
(assoc state :notification notification)))
ptk/WatchEvent
(watch [_ _ stream]
(watch [_ state stream]
(rx/merge
(let [stopper (rx/filter (ptk/type? ::hide) stream)]
(let [stopper (rx/filter (ptk/type? ::hide) stream)
route-id (dm/get-in state [:route :data :name])]
(->> stream
(rx/filter (ptk/type? :app.main.router/navigate))
(rx/map (fn [_] (hide)))
(rx/map deref)
(rx/filter #(not= route-id (:id %)))
(rx/map hide)
(rx/take-until stopper)))
(when (:timeout data)
(let [stopper (rx/filter (ptk/type? ::show) stream)]

View file

@ -188,8 +188,8 @@
libraries)]
(when needs-check?
(rx/concat (rx/timer 1000)
(rx/of (dwl/notify-sync-file file-id))))))))
(->> (rx/of (dwl/notify-sync-file file-id))
(rx/delay 1000)))))))
(defn- fetch-libraries
[file-id]

View file

@ -715,8 +715,10 @@
(defn go-to-component-file
[file-id component]
(dm/assert! (uuid? file-id))
(dm/assert! (some? component))
(assert (uuid? file-id) "expected an uuid for `file-id`")
(assert (ctk/check-component component) "expected a valid component")
(ptk/reify ::nav-to-component-file
ptk/WatchEvent
(watch [_ state _]
@ -724,8 +726,7 @@
(assoc :file-id file-id)
(assoc :page-id (:main-instance-page component))
(assoc :component-id (:id component)))]
(rx/of (rt/nav :workspace params :new-window? true))))))
(rx/of (rt/nav :workspace params ::rt/new-window true))))))
(defn go-to-local-component
[& {:keys [id] :as options}]
@ -1192,12 +1193,11 @@
(ptk/reify ::notify-sync-file
ptk/WatchEvent
(watch [_ state _]
(let [file (dm/get-in state [:files file-id])
(let [file (dsh/lookup-file state file-id)
file-data (get file :data)
ignore-until (get file :ignore-sync-until)
;; FIXME: syntax of this can be improved
libraries-need-sync
(filter #(seq (assets-need-sync % file-data ignore-until))
(vals (get state :files)))
@ -1213,8 +1213,7 @@
(st/emit! (ntf/hide)))
do-dismiss
#(do (st/emit! ignore-sync)
(st/emit! (ntf/hide)))]
#(st/emit! ignore-sync (ntf/hide))]
(when (seq libraries-need-sync)
(rx/of (ntf/dialog

View file

@ -17,34 +17,37 @@
[:class {:optional true} :string]
[:variant {:optional true}
[:maybe [:enum "default" "error"]]]
[:acceptLabel {:optional true} :string]
[:cancelLabel {:optional true} :string]
[:onAccept {:optional true} [:fn fn?]]
[:onCancel {:optional true} [:fn fn?]]])
[:accept-label {:optional true} :string]
[:cancel-label {:optional true} :string]
[:on-accept {:optional true} [:fn fn?]]
[:on-cancel {:optional true} [:fn fn?]]])
(mf/defc actionable*
{::mf/props :obj
::mf/schema schema:actionable}
[{:keys [class variant acceptLabel cancelLabel children onAccept onCancel] :rest props}]
{::mf/schema schema:actionable}
[{:keys [class variant accept-label cancel-label children on-accept on-cancel] :rest props}]
(let [variant (or variant "default")
class (d/append-class class (stl/css :notification))
props (mf/spread-props props {:class class :data-testid "actionable"})
(let [variant (d/nilv variant "default")
class (d/append-class class (stl/css :notification))
props (mf/spread-props props
{:class class
:data-testid "actionable"})
handle-accept
on-accept
(mf/use-fn
(fn [e]
(when onAccept (onAccept e))))
(when (fn? on-accept)
(on-accept e))))
handle-cancel
on-cancel
(mf/use-fn
(fn [e]
(when onCancel (onCancel e))))]
(when on-cancel (on-cancel e))))]
[:> "aside" props
[:div {:class (stl/css :notification-message)}
children]
[:> :aside props
[:div {:class (stl/css :notification-message)} children]
[:> button* {:variant "secondary"
:on-click handle-cancel} cancelLabel]
:on-click on-cancel}
cancel-label]
[:> button* {:variant (if (= variant "default") "primary" "destructive")
:on-click handle-accept} acceptLabel]]))
:on-click on-accept}
accept-label]]))

View file

@ -21,10 +21,10 @@
[{:keys [content accept cancel links] :as props}]
[:> actionable* {:class (stl/css :new-inline)
:cancelLabel (:label cancel)
:onCancel (:callback cancel)
:acceptLabel (:label accept)
:onAccept (:callback accept)}
:cancel-label (:label cancel)
:on-cancel (:callback cancel)
:accept-label (:label accept)
:on-accept (:callback accept)}
content
(when (some? links)

View file

@ -463,14 +463,13 @@
(let [type (:type data)
path (:path route)
query-params (:query-params route)
path-params (:path-params route)
params (:query-params route)
workspace? (str/includes? path "workspace")
dashboard? (str/includes? path "dashboard")
view? (str/includes? path "view")
;; We stora the request access info int this state
;; We store the request access info int this state
info* (mf/use-state nil)
info (deref info*)
@ -478,22 +477,22 @@
request-access?
(and
(or (= (:type data) :not-found) (= (:type data) :authentication))
(or (= (:type data) :not-found)
(= (:type data) :authentication))
(or workspace? dashboard? view?)
(or (:file-id info)
(:team-id info)))]
(mf/with-effect [type path query-params path-params]
(let [query-params (u/map->query-string query-params)
event-params {::ev/name "exception-page"
:type type
:path path
:query-params query-params}]
(st/emit! (ptk/event ::ev/event event-params))))
(mf/with-effect [type path params]
(st/emit! (ptk/data-event ::ev/event
{::ev/name "exception-page"
:type type
:path path
:params (u/map->query-string params)})))
(mf/with-effect [path-params info]
(mf/with-effect [params info]
(when-not (:loaded info)
(->> (load-info path-params)
(->> (load-info params)
(rx/subs! (partial reset! info*)))))
(when loaded?