Menu clippy on wasm32, header-menu and edit-menu stories

The wasm32 clippy step of the Menu job: craft-atomic drops files that have no drop glue there, the crash-log clock helper is native only, and one lint expectation holds on 64-bit targets only. Table and AltTextField declare their overlay and get a story that opens it.
This commit is contained in:
aiongg
2026-11-14 05:25:25 +00:00
parent 2b5de84828
commit 31e032d5df
5 changed files with 37 additions and 2 deletions
+8
View File
@@ -390,6 +390,10 @@ fn stage(
.map_err(|e| permissions_error(e, path))
})
.and_then(|()| fs.sync(&file).map_err(|e| write_error(e, path, dir, existed)));
#[allow(
clippy::drop_non_drop,
reason = "File has no drop glue on wasm32-unknown-unknown; on other targets the drop closes it before the next step"
)]
drop(file);
if written.is_err() {
let _ = fs.remove(&tmp);
@@ -489,6 +493,10 @@ fn copy_new(fs: &dyn AtomicFs, tmp: &Path, target: &Path, permissions: NewFilePe
}
fs.sync(&to)
});
#[allow(
clippy::drop_non_drop,
reason = "File has no drop glue on wasm32-unknown-unknown; on other targets the drop closes it before the next step"
)]
drop(to);
if copied.is_err() {
let _ = fs.remove(target);
+1
View File
@@ -41,6 +41,7 @@ fn payload_message(payload: &(dyn std::any::Any + Send)) -> String {
payload.downcast_ref::<&str>().map(|s| (*s).to_owned()).or_else(|| payload.downcast_ref::<String>().cloned()).unwrap_or_else(|| "panic".into())
}
#[cfg(not(target_arch = "wasm32"))]
fn unix_secs() -> u64 {
(crate::clock::unix_ms() / 1000.0) as u64
}
+1 -1
View File
@@ -34,7 +34,7 @@ impl Outcome for NavigateBarOutput {
}
/// The members of one tool's bar.
#[expect(clippy::large_enum_variant, reason = "built once per frame and matched at once; boxing the Zoom variant would allocate every frame")]
#[allow(clippy::large_enum_variant, reason = "built once per frame and matched at once; boxing the Zoom variant would allocate every frame")]
enum Members<'a> {
Zoom { view: Bind<'a, CanvasView>, target: ViewTarget, options: &'a mut NavigationOptions, out: Bind<'a, bool> },
RotateView { view: Bind<'a, CanvasView> },
+14 -1
View File
@@ -3,7 +3,8 @@
use super::{Table, sort_rows};
use crate::contract::{Bind, CollectionEvent, ColumnEvent, ColumnKind, ColumnSort, ColumnSpec, ShowCollection as _, ToggleColumn};
use crate::list::{ListRow, ToggleCell};
use crate::testing::{Drive, StoryData, StoryOutput, story};
use crate::testing::pointer::{moved, secondary};
use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story};
use craft_behavior::{ColumnKey, ColumnWidth, DisplayOrder, ItemSource, Selection};
use craft_i18n::{AgeStyle, FileSize, SizeUnit};
use egui::Ui;
@@ -149,6 +150,18 @@ fn table_many(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
table(ui, data, files(40), Some(ColumnSort::ascending(NAME)), false, true, Selection::single(0))
}
/// A secondary click on the Name header, which opens the header menu.
fn open_header_menu(fixture: &mut Fixture) {
let at = fixture.by_label("Name").expect("the header cell").center();
fixture.frame(vec![moved(at), secondary(at, true)]);
fixture.frame(vec![secondary(at, false)]).settle();
}
#[story(Table<'static, usize>, covers = [Open], drive = Drive::Custom(open_header_menu))]
fn table_header_menu(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
table(ui, data, files(12), Some(ColumnSort::ascending(NAME)), true, false, Selection::default())
}
#[story(Table<'static, usize>, covers = [One], drive = Drive::Never)]
fn table_one(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
table(ui, data, files(1), None, false, false, Selection::default())
@@ -3,6 +3,7 @@
use super::{AltText, AltTextField};
use crate::contract::{Bind, Show as _, Validity};
use crate::runtime::env::Message;
use crate::testing::pointer::{moved, secondary};
use crate::testing::{Drive, Fixture, StoryData, StoryOutput, story};
use craft_behavior::Mixed;
use egui::{Key, Modifiers, Ui};
@@ -23,6 +24,18 @@ fn alt_text_field(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
AltTextField::new(PROMPT, Bind::bound(data.value("alt", AltText::new("A red kite")))).show(ui).into()
}
/// A secondary click on the description box, which opens the edit menu.
fn open_edit_menu(fixture: &mut Fixture) {
let at = fixture.by_label(PROMPT).expect("the description box").center();
fixture.frame(vec![moved(at), secondary(at, true)]);
fixture.frame(vec![secondary(at, false)]).settle();
}
#[story(AltTextField<'static>, covers = [Open], drive = Drive::Custom(open_edit_menu))]
fn alt_text_field_edit_menu(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
AltTextField::new(PROMPT, Bind::bound(data.value("menu", AltText::new("A red kite")))).show(ui).into()
}
#[story(AltTextField<'static>, covers = [LongText], drive = Drive::Never)]
fn alt_text_field_long(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
AltTextField::new(PROMPT, Bind::bound(data.value("long", AltText::new(LONG)))).show(ui).into()