Format: the update dialog, toast and feedback tests pass cargo fmt
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
44a7debfb6
commit
81d0f5f5dd
3 files changed
+24
-5
No files matched your search
@@ -149,9 +149,19 @@ fn the_owner_reads_what_is_shown(cx: &mut TestAppContext) {
|
|||||||
push(&view, Toast::new("Denied").severity(Severity::Danger), cx);
|
push(&view, Toast::new("Denied").severity(Severity::Danger), cx);
|
||||||
let toaster = view.read_with(cx, |desk, _| desk.toaster.clone());
|
let toaster = view.read_with(cx, |desk, _| desk.toaster.clone());
|
||||||
let shown = |cx: &mut VisualTestContext| toaster.read_with(cx, |toaster, _| toaster.shown());
|
let shown = |cx: &mut VisualTestContext| toaster.read_with(cx, |toaster, _| toaster.shown());
|
||||||
assert_eq!(shown(cx), [("Saved".into(), None), ("Denied".into(), Some(Severity::Danger))]);
|
assert_eq!(
|
||||||
|
shown(cx),
|
||||||
|
[
|
||||||
|
("Saved".into(), None),
|
||||||
|
("Denied".into(), Some(Severity::Danger))
|
||||||
|
]
|
||||||
|
);
|
||||||
toaster.update(cx, |toaster, cx| toaster.dismiss(first, cx));
|
toaster.update(cx, |toaster, cx| toaster.dismiss(first, cx));
|
||||||
assert_eq!(shown(cx), [("Denied".into(), Some(Severity::Danger))], "a leaving toast is not shown");
|
assert_eq!(
|
||||||
|
shown(cx),
|
||||||
|
[("Denied".into(), Some(Severity::Danger))],
|
||||||
|
"a leaving toast is not shown"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
|
|||||||
@@ -128,7 +128,9 @@ impl Toaster {
|
|||||||
/// The titles and severities on show, oldest first.
|
/// The titles and severities on show, oldest first.
|
||||||
pub fn shown(&self) -> Vec<(SharedString, Option<Severity>)> {
|
pub fn shown(&self) -> Vec<(SharedString, Option<Severity>)> {
|
||||||
let staying = self.live.iter().filter(|live| !live.leaving);
|
let staying = self.live.iter().filter(|live| !live.leaving);
|
||||||
staying.map(|live| (live.toast.title.clone(), live.toast.severity)).collect()
|
staying
|
||||||
|
.map(|live| (live.toast.title.clone(), live.toast.severity))
|
||||||
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sends a toast away: it fades and folds, then leaves the stack.
|
/// Sends a toast away: it fades and folds, then leaves the stack.
|
||||||
|
|||||||
+9
-2
@@ -124,7 +124,11 @@ impl RenderOnce for UpdateBanner {
|
|||||||
UpdateState::Available => text(cx, "update.available", &[("version", version)]),
|
UpdateState::Available => text(cx, "update.available", &[("version", version)]),
|
||||||
UpdateState::Downloading(value) => {
|
UpdateState::Downloading(value) => {
|
||||||
let percent = (value * 100.0).round().to_string();
|
let percent = (value * 100.0).round().to_string();
|
||||||
text(cx, "update.downloading", &[("version", version), ("percent", &percent)])
|
text(
|
||||||
|
cx,
|
||||||
|
"update.downloading",
|
||||||
|
&[("version", version), ("percent", &percent)],
|
||||||
|
)
|
||||||
}
|
}
|
||||||
UpdateState::Ready => text(cx, "update.ready", &[("version", version)]),
|
UpdateState::Ready => text(cx, "update.ready", &[("version", version)]),
|
||||||
};
|
};
|
||||||
@@ -220,7 +224,10 @@ impl UpdateDialog {
|
|||||||
|
|
||||||
impl RenderOnce for UpdateDialog {
|
impl RenderOnce for UpdateDialog {
|
||||||
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
fn render(self, _: &mut Window, cx: &mut App) -> impl IntoElement {
|
||||||
let args = [("name", self.name.as_ref()), ("version", self.version.as_ref())];
|
let args = [
|
||||||
|
("name", self.name.as_ref()),
|
||||||
|
("version", self.version.as_ref()),
|
||||||
|
];
|
||||||
let headline = match self.state {
|
let headline = match self.state {
|
||||||
UpdateState::Ready => text(cx, "update.headline.ready", &args),
|
UpdateState::Ready => text(cx, "update.headline.ready", &args),
|
||||||
_ => text(cx, "update.headline.available", &args),
|
_ => text(cx, "update.headline.available", &args),
|
||||||
|
|||||||
Reference in new issue
Block a user