use crossterm::event::KeyEvent;
use ratatui::Frame;
use ratatui::layout::Rect;
use super::theme::ViewContext;
use crate::policy::match_tree::PolicyManifest;
pub enum Action {
None,
Quit,
Abort,
Modified,
RunForm(FormRequest),
Flash(String),
}
pub enum FormRequest {
AddRule,
AddSandbox,
AddSandboxRule { sandbox_name: String },
AddInclude,
EditCondition { path: Vec<usize> },
EditDecision { path: Vec<usize> },
EditRule { path: Vec<usize> },
AddChild { parent_path: Vec<usize> },
EditSandbox { sandbox_name: String },
EditSandboxRule {
sandbox_name: String,
rule_index: usize,
},
}
pub trait Component {
type Msg;
fn handle_key(&self, key: KeyEvent) -> Option<Self::Msg>;
fn update(&mut self, msg: Self::Msg, manifest: &mut PolicyManifest) -> Action;
fn view(&self, frame: &mut Frame, area: Rect, ctx: &ViewContext);
}