clin-rs 0.8.19

Encrypted terminal note-taking app inspired by Obsidian
use super::Action;
use crate::app::App;
use anyhow::Result;
use std::borrow::Cow;

pub struct OpenContentTreeAction;

impl Action for OpenContentTreeAction {
    fn id(&self) -> Cow<'static, str> {
        Cow::Borrowed("content_tree.open")
    }

    fn name(&self) -> Cow<'static, str> {
        Cow::Borrowed("Content Tree")
    }

    fn description(&self) -> Cow<'static, str> {
        Cow::Borrowed("Show the selected note's headers and content as a navigable tree")
    }
    fn category(&self) -> super::ActionCategory {
        super::ActionCategory::Notes
    }

    fn glyph(&self) -> &'static str {
        "\u{f1bb}"
    }

    fn execute(&self, app: &mut App, _context_note_id: Option<&str>) -> Result<()> {
        if app.get_selected_note_id().is_none() {
            app.set_temporary_status_static("Select a note first");
            return Ok(());
        }
        app.open_content_tree_view();
        Ok(())
    }
}