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

This commit is contained in:
Andrey Antukh 2026-11-18 13:15:27 +01:00
commit dad4479b9c
4 changed files with 25 additions and 5 deletions

View File

@ -359,7 +359,7 @@
(modal/show :file-restored
{:fullname (restorer-fullname state profile-id session-id)
:label label
:created-at created-at
:date created-at
;; Made on the replaced version, so the reload drops them
:unsaved (boolean (seq (dps/pending-file-changes state file)))}))
(rx/empty))))))

View File

@ -36,7 +36,9 @@
which was reloaded, and whether their edits not saved yet were lost."
{::mf/register modal/components
::mf/register-as :file-restored}
[{:keys [fullname label created-at unsaved]}]
;; The modal wrapper passes the props map without camelCasing its keys,
;; so every prop of this component must be a one-word name.
[{:keys [fullname label date unsaved]}]
(let [on-close (mf/use-fn #(st/emit! (modal/hide)))]
[:div {:class (stl/css :modal-overlay)}
[:div {:class (stl/css :modal-dialog)
@ -49,7 +51,7 @@
:class (stl/css :modal-title)}
(tr "workspace.file-restored.title")]
[:> text* {:as "p" :typography t/body-large}
(restored-message fullname label created-at)]
(restored-message fullname label date)]
(when unsaved
[:> text* {:as "p" :typography t/body-large}
(tr "workspace.file-restored.unsaved-changes")])

View File

@ -140,7 +140,7 @@
props (:props (shown-modal events))]
(t/is (= "Ada" (:fullname props)))
(t/is (= "Hand-off v2" (:label props)))
(t/is (= created-at (:created-at props)))
(t/is (= created-at (:date props)))
(t/is (true? (:unsaved props)))))
;; Scenario: the restoring session left before its message arrived, so it

View File

@ -6,10 +6,14 @@
(ns frontend-tests.ui.file-restored-modal-test
(:require
["react-dom/server" :as rds]
[app.common.time :as ct]
[app.main.data.modal :as modal]
[app.main.ui.workspace.file-restored-modal :as frm]
[app.util.i18n :as i18n]
[cljs.test :as t :include-macros true]))
[cljs.test :as t :include-macros true]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
(defn- message
"The translation key and arguments of the restore message."
@ -32,3 +36,17 @@
(message "Ada" nil nil)))
(t/is (= ["workspace.file-restored.message-anonymous"]
(message nil nil nil)))))
(defn- render-modal
"Markup of the registered `:file-restored` modal for the `props` map,
rendered the way the modal wrapper does it (`mf/element` with the map)."
[props]
(with-redefs [i18n/tr (fn ([key] key) ([key & args] (str/join "|" (into [key] args))))]
(rds/renderToStaticMarkup
(mf/element (get @modal/components :file-restored) props))))
(t/deftest the-modal-shows-the-date-of-an-unnamed-version
(let [created-at (ct/now)
markup (render-modal {:fullname "Ada" :date created-at :unsaved false})]
(t/is (str/includes? markup (str "workspace.file-restored.message-date|Ada|"
(ct/format-inst created-at "PPp"))))))