Lines
96.88 %
Functions
50 %
Branches
100 %
//! The script keys of the Scripts tab.
use crate::app::App;
use crate::form::Form;
use crate::modal::Modal;
use crate::tabs::scripts::ScriptsTab;
use crate::view::Tab;
/// What a script key asks for.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ScriptKey {
/// Switch the selected script on or off.
Toggle,
}
pub(super) fn apply_tab(app: &mut App, key: ScriptKey) {
if !app.front_is(Tab::Scripts) {
return;
match key {
ScriptKey::Toggle => toggle_selected(app),
pub(super) fn open_create(app: &mut App) {
app.open_dialog_for(Tab::Scripts, Modal::Form(Form::script_create()));
/// Loads the selected script into the edit form; says why when none is selected.
pub(super) fn open_edit_for_selected(app: &mut App) {
match app
.front::<ScriptsTab>()
.and_then(|tab| tab.selected_key().map(str::to_string))
{
Some(id) => app.open_script_edit_async(&id),
None => app.set_status("no script selected"),
/// Confirms deleting the selected script; says why when none is selected.
pub(super) fn confirm_delete_selected(app: &mut App) {
.and_then(|tab| tab.selected_row().cloned())
Some(row) => app.confirm_delete_script(row),
fn toggle_selected(app: &mut App) {
Some(row) => app.toggle_script(&row),