fix: expose configuration save in fader editor
Rust CI fader_master passed its selected CI mode.
MadGobblins/fader_master/pipeline/head This commit looks good
Details
Rust CI fader_master passed its selected CI mode.
MadGobblins/fader_master/pipeline/head This commit looks good
Details
Test: cargo test -p tui --all-targets --all-features --locked Test: cargo clippy -p tui --all-targets --all-features --locked -- -D warnings Test: cargo fmt --all -- --check
This commit is contained in:
parent
a464735f54
commit
51b23b8b25
|
|
@ -968,6 +968,7 @@ enum FaderEditorRow {
|
|||
Density {
|
||||
density: FaderDensity,
|
||||
},
|
||||
Save,
|
||||
}
|
||||
|
||||
enum MixerRow<'a> {
|
||||
|
|
@ -1746,6 +1747,9 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
.unwrap_or((false, FaderDensity::Standard));
|
||||
rows.push(FaderEditorRow::Density { density });
|
||||
rows.push(FaderEditorRow::Visibility { hidden });
|
||||
if self.snapshot.configuration.dirty {
|
||||
rows.push(FaderEditorRow::Save);
|
||||
}
|
||||
rows
|
||||
}
|
||||
|
||||
|
|
@ -1907,6 +1911,12 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
density: density.next(),
|
||||
});
|
||||
}
|
||||
FaderEditorRow::Save => {
|
||||
self.save_configuration();
|
||||
if !self.snapshot.configuration.dirty {
|
||||
self.fader_editor = None;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -2660,6 +2670,9 @@ impl<C: MixerClient> LiveTui<C> {
|
|||
FaderEditorRow::Density { density } => {
|
||||
format!("{marker} Size {} [Enter to cycle]", density.label())
|
||||
}
|
||||
FaderEditorRow::Save => {
|
||||
format!("{marker} Save changes [Enter to activate]")
|
||||
}
|
||||
};
|
||||
Line::from(text).style(if index == editor.selected {
|
||||
Style::default().fg(theme.accent).bold()
|
||||
|
|
@ -3792,6 +3805,12 @@ mod tests {
|
|||
self.snapshot.configuration.learning = None;
|
||||
Ok(self.snapshot.clone())
|
||||
}
|
||||
|
||||
fn save_configuration(&mut self, expected_revision: u64) -> io::Result<MixerSnapshot> {
|
||||
self.snapshot.configuration.dirty = false;
|
||||
self.snapshot.configuration.applied_revision = expected_revision;
|
||||
Ok(self.snapshot.clone())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -4451,6 +4470,44 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dirty_fader_editor_exposes_save_and_activates_the_draft() {
|
||||
let mut snapshot = DemoClient::default().view();
|
||||
snapshot.items[0].id.id = "music".into();
|
||||
snapshot.configuration.faders = vec![ConfiguredFader {
|
||||
id: "music-fader".into(),
|
||||
target: snapshot.items[0].id.clone(),
|
||||
pickup: true,
|
||||
pickup_tolerance: 0.02,
|
||||
}];
|
||||
snapshot.configuration.mixer_layout = vec![MixerLayoutEntry::Fader {
|
||||
fader: "music-fader".into(),
|
||||
hidden: false,
|
||||
density: FaderDensity::Standard,
|
||||
}];
|
||||
snapshot.configuration.dirty = true;
|
||||
snapshot.configuration.revision = 4;
|
||||
let edits = Arc::new(Mutex::new(Vec::new()));
|
||||
let mut app = LiveTui::new(LayoutClient { snapshot, edits }).unwrap();
|
||||
|
||||
app.handle_key_event(press(KeyCode::Char('e')));
|
||||
let area = Rect::new(0, 0, 100, 22);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
(&app).render(area, &mut buffer);
|
||||
let rendered = buffer
|
||||
.content
|
||||
.iter()
|
||||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(rendered.contains("Save changes"));
|
||||
|
||||
app.fader_editor.as_mut().unwrap().selected = app.fader_editor_rows().len() - 1;
|
||||
app.handle_key_event(press(KeyCode::Enter));
|
||||
|
||||
assert!(!app.snapshot.configuration.dirty);
|
||||
assert_eq!(app.snapshot.configuration.applied_revision, 4);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fader_density_cycles_and_compact_rows_render_at_their_exact_heights() {
|
||||
assert_eq!(FaderDensity::Slim.next(), FaderDensity::BorderedSlim);
|
||||
|
|
|
|||
Loading…
Reference in New Issue