From 3c32e9a35fd76df0d0f416cc197b90ef93085678 Mon Sep 17 00:00:00 2001 From: Erik Kundt Date: Thu, 4 Apr 2024 14:41:45 +0200 Subject: [PATCH] patch: Remove legacy tui-realm commands --- bin/commands/patch.rs | 42 +-- bin/commands/patch/flux.rs | 2 - bin/commands/patch/realm.rs | 6 - bin/commands/patch/realm/common.rs | 2 - bin/commands/patch/realm/common/ui.rs | 179 ----------- bin/commands/patch/realm/select.rs | 173 ----------- bin/commands/patch/realm/select/event.rs | 182 ----------- bin/commands/patch/realm/select/page.rs | 177 ----------- bin/commands/patch/realm/select/ui.rs | 156 ---------- bin/commands/patch/realm/suite.rs | 289 ----------------- bin/commands/patch/realm/suite/event.rs | 140 --------- bin/commands/patch/realm/suite/page.rs | 346 --------------------- bin/commands/patch/realm/suite/ui.rs | 171 ---------- bin/commands/patch/{flux => }/select.rs | 2 +- bin/commands/patch/{flux => }/select/ui.rs | 0 15 files changed, 5 insertions(+), 1862 deletions(-) delete mode 100644 bin/commands/patch/flux.rs delete mode 100644 bin/commands/patch/realm.rs delete mode 100644 bin/commands/patch/realm/common.rs delete mode 100644 bin/commands/patch/realm/common/ui.rs delete mode 100644 bin/commands/patch/realm/select.rs delete mode 100644 bin/commands/patch/realm/select/event.rs delete mode 100644 bin/commands/patch/realm/select/page.rs delete mode 100644 bin/commands/patch/realm/select/ui.rs delete mode 100644 bin/commands/patch/realm/suite.rs delete mode 100644 bin/commands/patch/realm/suite/event.rs delete mode 100644 bin/commands/patch/realm/suite/page.rs delete mode 100644 bin/commands/patch/realm/suite/ui.rs rename bin/commands/patch/{flux => }/select.rs (99%) rename bin/commands/patch/{flux => }/select/ui.rs (100%) diff --git a/bin/commands/patch.rs b/bin/commands/patch.rs index b779e74c..d0df7697 100644 --- a/bin/commands/patch.rs +++ b/bin/commands/patch.rs @@ -1,11 +1,7 @@ #[path = "patch/common.rs"] mod common; -#[cfg(feature = "flux")] -#[path = "patch/flux.rs"] -mod flux; -#[cfg(feature = "realm")] -#[path = "patch/realm.rs"] -mod realm; +#[path = "patch/select.rs"] +mod select; use std::ffi::OsString; @@ -148,36 +144,6 @@ impl Args for Options { } } -#[cfg(feature = "realm")] -pub fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> { - use tui::common::context; - use tui::realm::Window; - - pub const FPS: u64 = 60; - let (_, id) = radicle::rad::cwd() - .map_err(|_| anyhow!("this command must be run in the context of a project"))?; - - match options.op { - Operation::Select { ref opts } => { - let profile = terminal::profile()?; - let context = context::Context::new(profile, id)?.with_patches(); - - log::enable(context.profile(), "patch", "select")?; - - let mut app = realm::select::App::new(context, opts.mode.clone(), opts.filter.clone()); - let output = Window::default().run(&mut app, 1000 / FPS)?; - - let output = output - .map(|o| serde_json::to_string(&o).unwrap_or_default()) - .unwrap_or_default(); - - eprint!("{output}"); - } - } - - Ok(()) -} - #[cfg(feature = "flux")] #[tokio::main] pub async fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Result<()> { @@ -194,13 +160,13 @@ pub async fn run(options: Options, _ctx: impl terminal::Context) -> anyhow::Resu log::enable(&profile, "patch", "select")?; - let context = flux::select::Context { + let context = select::Context { profile, repository, mode: opts.mode, filter: opts.filter.clone(), }; - let output = flux::select::App::new(context).run().await?; + let output = select::App::new(context).run().await?; let output = output .map(|o| serde_json::to_string(&o).unwrap_or_default()) diff --git a/bin/commands/patch/flux.rs b/bin/commands/patch/flux.rs deleted file mode 100644 index ffc8d2d0..00000000 --- a/bin/commands/patch/flux.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[path = "flux/select.rs"] -pub mod select; diff --git a/bin/commands/patch/realm.rs b/bin/commands/patch/realm.rs deleted file mode 100644 index 31f9ee56..00000000 --- a/bin/commands/patch/realm.rs +++ /dev/null @@ -1,6 +0,0 @@ -#[path = "realm/common.rs"] -pub mod common; -#[path = "realm/select.rs"] -pub mod select; -#[path = "realm/suite.rs"] -pub mod suite; diff --git a/bin/commands/patch/realm/common.rs b/bin/commands/patch/realm/common.rs deleted file mode 100644 index 6c6eb76c..00000000 --- a/bin/commands/patch/realm/common.rs +++ /dev/null @@ -1,2 +0,0 @@ -#[path = "common/ui.rs"] -pub mod ui; diff --git a/bin/commands/patch/realm/common/ui.rs b/bin/commands/patch/realm/common/ui.rs deleted file mode 100644 index ec43cd6f..00000000 --- a/bin/commands/patch/realm/common/ui.rs +++ /dev/null @@ -1,179 +0,0 @@ -use radicle::cob::patch::{Patch, PatchId}; - -use tuirealm::command::{Cmd, CmdResult}; -use tuirealm::tui::layout::Rect; -use tuirealm::{AttrValue, Attribute, Frame, MockComponent, Props, State}; - -use radicle_tui as tui; - -use tui::common::cob::patch::Filter; -use tui::common::context::Context; -use tui::realm::ui::cob::PatchItem; -use tui::realm::ui::theme::{style, Theme}; -use tui::realm::ui::widget::context::{ContextBar, Progress}; -use tui::realm::ui::widget::label::{self}; -use tui::realm::ui::widget::list::{ColumnWidth, Table}; -use tui::realm::ui::widget::{Widget, WidgetComponent}; - -pub struct PatchBrowser { - items: Vec, - table: Widget>, -} - -impl PatchBrowser { - pub fn new( - theme: &Theme, - context: &Context, - filter: Filter, - selected: Option<(PatchId, Patch)>, - ) -> Self { - let header = [ - label::header(" ● "), - label::header("ID"), - label::header("Title"), - label::header("Author"), - label::header("Head"), - label::header("+"), - label::header("-"), - label::header("Updated"), - ]; - - let widths = [ - ColumnWidth::Fixed(3), - ColumnWidth::Fixed(7), - ColumnWidth::Grow, - ColumnWidth::Fixed(21), - ColumnWidth::Fixed(7), - ColumnWidth::Fixed(4), - ColumnWidth::Fixed(4), - ColumnWidth::Fixed(18), - ]; - - let repo = context.repository(); - let patches = context - .patches() - .as_ref() - .unwrap() - .iter() - .filter(|(_, patch)| filter.matches(context.profile(), patch)); - - let mut items = vec![]; - for (id, patch) in patches { - if let Ok(item) = PatchItem::try_from((context.profile(), repo, *id, patch.clone())) { - items.push(item); - } - } - - items.sort_by(|a, b| b.timestamp().cmp(a.timestamp())); - items.sort_by(|a, b| a.state().cmp(b.state())); - - let selected = match selected { - Some((id, patch)) => { - Some(PatchItem::try_from((context.profile(), repo, id, patch)).unwrap()) - } - _ => items.first().cloned(), - }; - - let table = Widget::new(Table::new(&items, selected, header, widths, theme.clone())); - - Self { items, table } - } - - pub fn items(&self) -> &Vec { - &self.items - } -} - -impl WidgetComponent for PatchBrowser { - fn view(&mut self, properties: &Props, frame: &mut Frame, area: Rect) { - let focus = properties - .get_or(Attribute::Focus, AttrValue::Flag(false)) - .unwrap_flag(); - - self.table.attr(Attribute::Focus, AttrValue::Flag(focus)); - self.table.view(frame, area); - } - - fn state(&self) -> State { - self.table.state() - } - - fn perform(&mut self, _properties: &Props, cmd: Cmd) -> CmdResult { - self.table.perform(cmd) - } -} - -pub fn browse_context( - context: &Context, - _theme: &Theme, - filter: Filter, - progress: Progress, -) -> Widget { - use radicle::cob::patch::State; - - let mut draft = 0; - let mut open = 0; - let mut archived = 0; - let mut merged = 0; - - let patches = context - .patches() - .as_ref() - .unwrap() - .iter() - .filter(|(_, patch)| filter.matches(context.profile(), patch)); - - for (_, patch) in patches { - match patch.state() { - State::Draft => draft += 1, - State::Open { conflicts: _ } => open += 1, - State::Archived => archived += 1, - State::Merged { - commit: _, - revision: _, - } => merged += 1, - } - } - - let context = label::reversable("/").style(style::magenta_reversed()); - let filter = label::default(&filter.to_string()).style(style::magenta_dim()); - - let draft_n = label::default(&format!("{draft}")).style(style::gray_dim()); - let draft = label::default(" Draft"); - - let open_n = label::default(&format!("{open}")).style(style::green()); - let open = label::default(" Open"); - - let archived_n = label::default(&format!("{archived}")).style(style::yellow()); - let archived = label::default(" Archived"); - - let merged_n = label::default(&format!("{merged}")).style(style::cyan()); - let merged = label::default(" Merged "); - - let progress = label::reversable(&progress.to_string()).style(style::magenta_reversed()); - - let spacer = label::default(""); - let divider = label::default(" | "); - - let context_bar = ContextBar::new( - label::group(&[context]), - label::group(&[filter]), - label::group(&[spacer]), - label::group(&[ - draft_n, - draft, - divider.clone(), - open_n, - open, - divider.clone(), - archived_n, - archived, - divider, - merged_n, - merged, - ]), - label::group(&[progress]), - ); - - Widget::new(context_bar).height(1) -} diff --git a/bin/commands/patch/realm/select.rs b/bin/commands/patch/realm/select.rs deleted file mode 100644 index 38be400c..00000000 --- a/bin/commands/patch/realm/select.rs +++ /dev/null @@ -1,173 +0,0 @@ -#[path = "select/event.rs"] -mod event; -#[path = "select/page.rs"] -mod page; -#[path = "select/ui.rs"] -mod ui; - -use std::hash::Hash; - -use anyhow::Result; -use radicle::patch::PatchId; - -use tuirealm::application::PollStrategy; -use tuirealm::event::Key; -use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause}; - -use radicle_tui as tui; - -use tui::common::cob::patch::Filter; -use tui::common::context::Context; - -use tui::realm::ui::subscription; -use tui::realm::ui::theme::Theme; -use tui::realm::{PageStack, Tui}; -use tui::Exit; - -use page::ListView; - -use super::super::common::Mode; - -type Selection = tui::Selection; - -#[derive(Debug, Eq, PartialEq, Clone, Hash)] -pub enum ListCid { - Header, - PatchBrowser, - Context, - Shortcuts, -} - -/// All component ids known to this application. -#[derive(Debug, Default, Eq, PartialEq, Clone, Hash)] -pub enum Cid { - List(ListCid), - #[default] - GlobalListener, -} - -#[derive(Clone, Default, Debug, Eq, PartialEq)] -pub enum Message { - #[default] - Tick, - Quit(Option), - Batch(Vec), -} - -pub struct App { - context: Context, - pages: PageStack, - theme: Theme, - quit: bool, - mode: Mode, - filter: Filter, - output: Option, -} - -/// Creates a new application using a tui-realm-application, mounts all -/// components and sets focus to a default one. -impl App { - pub fn new(context: Context, mode: Mode, filter: Filter) -> Self { - Self { - context, - pages: PageStack::default(), - theme: Theme::default(), - quit: false, - mode, - filter, - output: None, - } - } - - fn view_list( - &mut self, - app: &mut Application, - theme: &Theme, - ) -> Result<()> { - let home = Box::new(ListView::new(self.mode.clone(), self.filter.clone())); - self.pages.push(home, app, &self.context, theme)?; - - Ok(()) - } - - fn process( - &mut self, - app: &mut Application, - message: Message, - ) -> Result> { - let theme = Theme::default(); - match message { - Message::Batch(messages) => { - let mut results = vec![]; - for message in messages { - if let Some(result) = self.process(app, message)? { - results.push(result); - } - } - match results.len() { - 0 => Ok(None), - 1 => Ok(Some(results[0].to_owned())), - _ => Ok(Some(Message::Batch(results))), - } - } - Message::Quit(output) => { - self.quit = true; - self.output = output; - Ok(None) - } - _ => self - .pages - .peek_mut()? - .update(app, &self.context, &theme, message), - } - } -} - -impl Tui for App { - fn init(&mut self, app: &mut Application) -> Result<()> { - self.view_list(app, &self.theme.clone())?; - - // Add global key listener and subscribe to key events - let global = tui::realm::ui::global_listener().to_boxed(); - app.mount( - Cid::GlobalListener, - global, - vec![Sub::new( - subscription::quit_clause(Key::Char('q')), - SubClause::Always, - )], - )?; - - Ok(()) - } - - fn view(&mut self, app: &mut Application, frame: &mut Frame) { - if let Ok(page) = self.pages.peek_mut() { - page.view(app, frame); - } - } - - fn update(&mut self, app: &mut Application) -> Result { - match app.tick(PollStrategy::Once) { - Ok(messages) if !messages.is_empty() => { - for message in messages { - let mut msg = Some(message); - while msg.is_some() { - msg = self.process(app, msg.unwrap())?; - } - } - Ok(true) - } - _ => Ok(false), - } - } - - fn exit(&self) -> Option> { - if self.quit { - return Some(Exit { - value: self.output.clone(), - }); - } - None - } -} diff --git a/bin/commands/patch/realm/select/event.rs b/bin/commands/patch/realm/select/event.rs deleted file mode 100644 index c3a3bed8..00000000 --- a/bin/commands/patch/realm/select/event.rs +++ /dev/null @@ -1,182 +0,0 @@ -use radicle::patch::PatchId; -use tuirealm::command::{Cmd, CmdResult, Direction as MoveDirection}; -use tuirealm::event::{Event, Key, KeyEvent}; -use tuirealm::{MockComponent, NoUserEvent}; - -use radicle_tui as tui; - -use tui::realm::ui::state::ItemState; -use tui::realm::ui::widget::container::{AppHeader, GlobalListener, LabeledContainer}; -use tui::realm::ui::widget::context::{ContextBar, Shortcuts}; -use tui::realm::ui::widget::list::PropertyList; -use tui::realm::ui::widget::Widget; - -use crate::tui_patch::common::PatchOperation; - -use super::ui::{IdSelect, OperationSelect}; -use super::Message; - -type Selection = tui::Selection; - -/// Since the framework does not know the type of messages that are being -/// passed around in the app, the following handlers need to be implemented for -/// each component used. -/// -/// TODO: should handle `Event::WindowResize`, which is not emitted by `termion`. -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { - code: Key::Char('q'), - .. - }) => Some(Message::Quit(None)), - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - let mut submit = || -> Option { - match self.perform(Cmd::Submit) { - CmdResult::Submit(state) => { - let selected = ItemState::try_from(state).ok()?.selected()?; - let item = self.items().get(selected)?; - Some(item.id().to_owned()) - } - _ => None, - } - }; - - match event { - Event::Keyboard(KeyEvent { code: Key::Up, .. }) - | Event::Keyboard(KeyEvent { - code: Key::Char('k'), - .. - }) => { - self.perform(Cmd::Move(MoveDirection::Up)); - Some(Message::Tick) - } - Event::Keyboard(KeyEvent { - code: Key::Down, .. - }) - | Event::Keyboard(KeyEvent { - code: Key::Char('j'), - .. - }) => { - self.perform(Cmd::Move(MoveDirection::Down)); - Some(Message::Tick) - } - Event::Keyboard(KeyEvent { - code: Key::Enter, .. - }) => submit().map(|id| { - let selection = Selection { - operation: None, - ids: vec![id], - args: vec![], - }; - Message::Quit(Some(selection)) - }), - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - let mut submit = || -> Option { - match self.perform(Cmd::Submit) { - CmdResult::Submit(state) => { - let selected = ItemState::try_from(state).ok()?.selected()?; - let item = self.items().get(selected)?; - Some(item.id().to_owned()) - } - _ => None, - } - }; - - match event { - Event::Keyboard(KeyEvent { code: Key::Up, .. }) - | Event::Keyboard(KeyEvent { - code: Key::Char('k'), - .. - }) => { - self.perform(Cmd::Move(MoveDirection::Up)); - Some(Message::Tick) - } - Event::Keyboard(KeyEvent { - code: Key::Down, .. - }) - | Event::Keyboard(KeyEvent { - code: Key::Char('j'), - .. - }) => { - self.perform(Cmd::Move(MoveDirection::Down)); - Some(Message::Tick) - } - Event::Keyboard(KeyEvent { - code: Key::Enter, .. - }) => submit().map(|id| { - let selection = Selection { - operation: Some(PatchOperation::Show.to_string()), - ids: vec![id], - args: vec![], - }; - Message::Quit(Some(selection)) - }), - Event::Keyboard(KeyEvent { - code: Key::Char('c'), - .. - }) => submit().map(|id| { - let selection = Selection { - operation: Some(PatchOperation::Checkout.to_string()), - ids: vec![id], - args: vec![], - }; - Message::Quit(Some(selection)) - }), - Event::Keyboard(KeyEvent { - code: Key::Char('d'), - .. - }) => submit().map(|id| { - let selection = Selection { - operation: Some(PatchOperation::Diff.to_string()), - ids: vec![id], - args: vec![], - }; - Message::Quit(Some(selection)) - }), - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} diff --git a/bin/commands/patch/realm/select/page.rs b/bin/commands/patch/realm/select/page.rs deleted file mode 100644 index 2624f487..00000000 --- a/bin/commands/patch/realm/select/page.rs +++ /dev/null @@ -1,177 +0,0 @@ -use std::collections::HashMap; - -use anyhow::Result; - -use tuirealm::{AttrValue, Attribute, Frame, NoUserEvent, Sub, SubClause}; - -use radicle_tui as tui; - -use tui::common::cob::patch::Filter; -use tui::common::context::Context; -use tui::realm::ui::state::ItemState; -use tui::realm::ui::theme::Theme; -use tui::realm::ui::widget::context::{Progress, Shortcuts}; -use tui::realm::ui::widget::Widget; -use tui::realm::ui::{layout, subscription}; -use tui::realm::ViewPage; - -use super::super::common; -use super::{ui, Application, Cid, ListCid, Message, Mode}; - -/// -/// Home -/// -pub struct ListView { - active_component: ListCid, - subject: Mode, - filter: Filter, - shortcuts: HashMap>, -} - -impl ListView { - pub fn new(subject: Mode, filter: Filter) -> Self { - Self { - active_component: ListCid::PatchBrowser, - subject, - filter, - shortcuts: HashMap::default(), - } - } - - fn update_context( - &self, - app: &mut Application, - context: &Context, - theme: &Theme, - ) -> Result<()> { - let state = app.state(&Cid::List(ListCid::PatchBrowser))?; - let progress = match ItemState::try_from(state) { - Ok(state) => Progress::Step( - state - .selected() - .map(|s| s.saturating_add(1)) - .unwrap_or_default(), - state.len(), - ), - Err(_) => Progress::None, - }; - - let context = common::ui::browse_context(context, theme, self.filter.clone(), progress); - - app.remount(Cid::List(ListCid::Context), context.to_boxed(), vec![])?; - - Ok(()) - } - - fn update_shortcuts( - &self, - app: &mut Application, - cid: ListCid, - ) -> Result<()> { - if let Some(shortcuts) = self.shortcuts.get(&cid) { - app.remount( - Cid::List(ListCid::Shortcuts), - shortcuts.clone().to_boxed(), - vec![], - )?; - } - - Ok(()) - } -} - -impl ViewPage for ListView { - fn mount( - &mut self, - app: &mut Application, - context: &Context, - theme: &Theme, - ) -> Result<()> { - let navigation = ui::list_navigation(theme); - let header = tui::realm::ui::app_header(context, theme, Some(navigation)).to_boxed(); - - app.remount(Cid::List(ListCid::Header), header, vec![])?; - - match self.subject { - Mode::Id => { - let patch_browser = - ui::id_select(theme, context, self.filter.clone(), None).to_boxed(); - self.shortcuts = patch_browser.as_ref().shortcuts(); - - app.remount(Cid::List(ListCid::PatchBrowser), patch_browser, vec![])?; - } - Mode::Operation => { - let patch_browser = - ui::operation_select(theme, context, self.filter.clone(), None).to_boxed(); - self.shortcuts = patch_browser.as_ref().shortcuts(); - - app.remount(Cid::List(ListCid::PatchBrowser), patch_browser, vec![])?; - } - }; - - app.active(&Cid::List(self.active_component.clone()))?; - self.update_shortcuts(app, self.active_component.clone())?; - self.update_context(app, context, theme)?; - - Ok(()) - } - - fn unmount(&self, app: &mut Application) -> Result<()> { - app.umount(&Cid::List(ListCid::Header))?; - app.umount(&Cid::List(ListCid::PatchBrowser))?; - app.umount(&Cid::List(ListCid::Context))?; - app.umount(&Cid::List(ListCid::Shortcuts))?; - Ok(()) - } - - fn update( - &mut self, - app: &mut Application, - context: &Context, - theme: &Theme, - _message: Message, - ) -> Result> { - self.update_context(app, context, theme)?; - - Ok(None) - } - - fn view(&mut self, app: &mut Application, frame: &mut Frame) { - let area = frame.size(); - let context_h = app - .query(&Cid::List(ListCid::Context), Attribute::Height) - .unwrap_or_default() - .unwrap_or(AttrValue::Size(0)) - .unwrap_size(); - let shortcuts_h = 1u16; - - let layout = layout::default_page(area, context_h, shortcuts_h); - - app.view( - &Cid::List(self.active_component.clone()), - frame, - layout.component, - ); - - app.view(&Cid::List(ListCid::Context), frame, layout.context); - app.view(&Cid::List(ListCid::Shortcuts), frame, layout.shortcuts); - } - - fn subscribe(&self, app: &mut Application) -> Result<()> { - app.subscribe( - &Cid::List(ListCid::Header), - Sub::new(subscription::navigation_clause(), SubClause::Always), - )?; - - Ok(()) - } - - fn unsubscribe(&self, app: &mut Application) -> Result<()> { - app.unsubscribe( - &Cid::List(ListCid::Header), - subscription::navigation_clause(), - )?; - - Ok(()) - } -} diff --git a/bin/commands/patch/realm/select/ui.rs b/bin/commands/patch/realm/select/ui.rs deleted file mode 100644 index 491ae787..00000000 --- a/bin/commands/patch/realm/select/ui.rs +++ /dev/null @@ -1,156 +0,0 @@ -use std::collections::HashMap; - -use radicle::cob::patch::{Patch, PatchId}; - -use radicle_tui as tui; - -use tui::common::cob::patch::Filter; -use tui::common::context::Context; -use tui::realm::ui::cob::PatchItem; -use tui::realm::ui::theme::{style, Theme}; -use tui::realm::ui::widget::context::Shortcuts; -use tui::realm::ui::widget::{Widget, WidgetComponent}; - -use tui::realm::ui::widget::container::Tabs; -use tui::realm::ui::widget::label::{self}; -use tuirealm::command::{Cmd, CmdResult}; -use tuirealm::tui::layout::Rect; -use tuirealm::{AttrValue, Attribute, Frame, MockComponent, Props, State}; - -use super::super::common; -use super::ListCid; - -pub struct IdSelect { - theme: Theme, - browser: Widget, -} - -impl IdSelect { - pub fn new(theme: Theme, browser: Widget) -> Self { - Self { theme, browser } - } - - pub fn items(&self) -> &Vec { - self.browser.items() - } - - pub fn shortcuts(&self) -> HashMap> { - [( - ListCid::PatchBrowser, - tui::realm::ui::shortcuts( - &self.theme, - vec![ - tui::realm::ui::shortcut(&self.theme, "enter", "select"), - tui::realm::ui::shortcut(&self.theme, "q", "quit"), - ], - ), - )] - .iter() - .cloned() - .collect() - } -} - -impl WidgetComponent for IdSelect { - fn view(&mut self, properties: &Props, frame: &mut Frame, area: Rect) { - let focus = properties - .get_or(Attribute::Focus, AttrValue::Flag(false)) - .unwrap_flag(); - - self.browser.attr(Attribute::Focus, AttrValue::Flag(focus)); - self.browser.view(frame, area); - } - - fn state(&self) -> State { - self.browser.state() - } - - fn perform(&mut self, _properties: &Props, cmd: Cmd) -> CmdResult { - self.browser.perform(cmd) - } -} - -pub struct OperationSelect { - theme: Theme, - browser: Widget, -} - -impl OperationSelect { - pub fn new(theme: Theme, browser: Widget) -> Self { - Self { theme, browser } - } - - pub fn items(&self) -> &Vec { - self.browser.items() - } - - pub fn shortcuts(&self) -> HashMap> { - [( - ListCid::PatchBrowser, - tui::realm::ui::shortcuts( - &self.theme, - vec![ - tui::realm::ui::shortcut(&self.theme, "enter", "show"), - tui::realm::ui::shortcut(&self.theme, "c", "checkout"), - tui::realm::ui::shortcut(&self.theme, "d", "diff"), - tui::realm::ui::shortcut(&self.theme, "q", "quit"), - ], - ), - )] - .iter() - .cloned() - .collect() - } -} - -impl WidgetComponent for OperationSelect { - fn view(&mut self, properties: &Props, frame: &mut Frame, area: Rect) { - let focus = properties - .get_or(Attribute::Focus, AttrValue::Flag(false)) - .unwrap_flag(); - - self.browser.attr(Attribute::Focus, AttrValue::Flag(focus)); - self.browser.view(frame, area); - } - - fn state(&self) -> State { - self.browser.state() - } - - fn perform(&mut self, _properties: &Props, cmd: Cmd) -> CmdResult { - self.browser.perform(cmd) - } -} - -pub fn list_navigation(theme: &Theme) -> Widget { - tui::realm::ui::tabs( - theme, - vec![label::reversable("Patches").style(style::cyan())], - ) -} - -pub fn id_select( - theme: &Theme, - context: &Context, - filter: Filter, - selected: Option<(PatchId, Patch)>, -) -> Widget { - let browser = Widget::new(common::ui::PatchBrowser::new( - theme, context, filter, selected, - )); - - Widget::new(IdSelect::new(theme.clone(), browser)) -} - -pub fn operation_select( - theme: &Theme, - context: &Context, - filter: Filter, - selected: Option<(PatchId, Patch)>, -) -> Widget { - let browser = Widget::new(common::ui::PatchBrowser::new( - theme, context, filter, selected, - )); - - Widget::new(OperationSelect::new(theme.clone(), browser)) -} diff --git a/bin/commands/patch/realm/suite.rs b/bin/commands/patch/realm/suite.rs deleted file mode 100644 index f0c6dbc8..00000000 --- a/bin/commands/patch/realm/suite.rs +++ /dev/null @@ -1,289 +0,0 @@ -#[path = "suite/event.rs"] -mod event; -#[path = "suite/page.rs"] -mod page; -#[path = "suite/ui.rs"] -mod ui; - -use std::hash::Hash; - -use anyhow::Result; - -use radicle::cob::patch::PatchId; - -use tuirealm::application::PollStrategy; -use tuirealm::event::Key; -use tuirealm::{Application, Frame, NoUserEvent, Sub, SubClause}; - -use radicle_tui as tui; - -use tui::common::cob; -use tui::common::cob::patch::Filter; -use tui::common::context::Context; -use tui::realm::ui::subscription; -use tui::realm::ui::theme::Theme; -use tui::realm::{PageStack, Tui}; -use tui::Exit; - -use page::{ListView, PatchView}; - -#[derive(Debug, Eq, PartialEq, Clone, Hash)] -pub enum ListCid { - Header, - PatchBrowser, - Context, - Shortcuts, -} - -#[derive(Debug, Eq, PartialEq, Clone, Hash)] -pub enum PatchCid { - Header, - Activity, - Files, - Context, - Shortcuts, -} - -/// All component ids known to this application. -#[derive(Debug, Default, Eq, PartialEq, Clone, Hash)] -pub enum Cid { - List(ListCid), - Patch(PatchCid), - #[default] - GlobalListener, - Popup, -} - -#[derive(Clone, Debug, Eq, PartialEq)] -pub enum PatchMessage { - Show(PatchId), - Leave, -} - -#[derive(Clone, Debug, Eq, PartialEq)] -pub enum PopupMessage { - Info(String), - Warning(String), - Error(String), - Hide, -} - -#[derive(Clone, Default, Debug, Eq, PartialEq)] -pub enum Message { - Patch(PatchMessage), - NavigationChanged(u16), - FormSubmitted(String), - Popup(PopupMessage), - #[default] - Tick, - Quit, - Batch(Vec), -} - -#[allow(dead_code)] -pub struct App { - context: Context, - pages: PageStack, - theme: Theme, - filter: Filter, - quit: bool, -} - -/// Creates a new application using a tui-realm-application, mounts all -/// components and sets focus to a default one. -#[allow(dead_code)] -impl App { - pub fn new(context: Context, filter: Filter) -> Self { - Self { - context, - pages: PageStack::default(), - theme: Theme::default(), - filter, - quit: false, - } - } - - fn view_list( - &mut self, - app: &mut Application, - theme: &Theme, - ) -> Result<()> { - let home = Box::new(ListView::new(theme.clone(), self.filter.clone())); - self.pages.push(home, app, &self.context, theme)?; - - Ok(()) - } - - fn view_patch( - &mut self, - app: &mut Application, - id: PatchId, - theme: &Theme, - ) -> Result<()> { - let profile = self.context.profile(); - let repo = self.context.repository(); - - if let Some(patch) = cob::patch::find(profile, repo, &id)? { - let view = Box::new(PatchView::new(theme.clone(), (id, patch))); - self.pages.push(view, app, &self.context, theme)?; - - Ok(()) - } else { - Err(anyhow::anyhow!( - "Could not mount 'page::PatchView'. Patch not found." - )) - } - } - - fn process( - &mut self, - app: &mut Application, - message: Message, - ) -> Result> { - let theme = Theme::default(); - match message { - Message::Batch(messages) => { - let mut results = vec![]; - for message in messages { - if let Some(result) = self.process(app, message)? { - results.push(result); - } - } - match results.len() { - 0 => Ok(None), - 1 => Ok(Some(results[0].to_owned())), - _ => Ok(Some(Message::Batch(results))), - } - } - Message::Patch(PatchMessage::Show(id)) => { - self.view_patch(app, id, &theme)?; - Ok(None) - } - Message::Patch(PatchMessage::Leave) => { - self.pages.pop(app)?; - Ok(None) - } - Message::Popup(PopupMessage::Info(info)) => { - self.show_info_popup(app, &theme, &info)?; - Ok(None) - } - Message::Popup(PopupMessage::Warning(warning)) => { - self.show_warning_popup(app, &theme, &warning)?; - Ok(None) - } - Message::Popup(PopupMessage::Error(error)) => { - self.show_error_popup(app, &theme, &error)?; - Ok(None) - } - Message::Popup(PopupMessage::Hide) => { - self.hide_popup(app)?; - Ok(None) - } - Message::Quit => { - self.quit = true; - Ok(None) - } - _ => self - .pages - .peek_mut()? - .update(app, &self.context, &theme, message), - } - } - - fn show_info_popup( - &mut self, - app: &mut Application, - theme: &Theme, - message: &str, - ) -> Result<()> { - let popup = tui::realm::ui::info(theme, message); - app.remount(Cid::Popup, popup.to_boxed(), vec![])?; - app.active(&Cid::Popup)?; - - Ok(()) - } - - fn show_warning_popup( - &mut self, - app: &mut Application, - theme: &Theme, - message: &str, - ) -> Result<()> { - let popup = tui::realm::ui::warning(theme, message); - app.remount(Cid::Popup, popup.to_boxed(), vec![])?; - app.active(&Cid::Popup)?; - - Ok(()) - } - - fn show_error_popup( - &mut self, - app: &mut Application, - theme: &Theme, - message: &str, - ) -> Result<()> { - let popup = tui::realm::ui::error(theme, message); - app.remount(Cid::Popup, popup.to_boxed(), vec![])?; - app.active(&Cid::Popup)?; - - Ok(()) - } - - fn hide_popup(&mut self, app: &mut Application) -> Result<()> { - app.blur()?; - app.umount(&Cid::Popup)?; - - Ok(()) - } -} - -impl Tui for App { - fn init(&mut self, app: &mut Application) -> Result<()> { - self.view_list(app, &self.theme.clone())?; - - // Add global key listener and subscribe to key events - let global = tui::realm::ui::global_listener().to_boxed(); - app.mount( - Cid::GlobalListener, - global, - vec![Sub::new( - subscription::quit_clause(Key::Char('q')), - SubClause::Always, - )], - )?; - - Ok(()) - } - - fn view(&mut self, app: &mut Application, frame: &mut Frame) { - if let Ok(page) = self.pages.peek_mut() { - page.view(app, frame); - } - - if app.mounted(&Cid::Popup) { - app.view(&Cid::Popup, frame, frame.size()); - } - } - - fn update(&mut self, app: &mut Application) -> Result { - match app.tick(PollStrategy::Once) { - Ok(messages) if !messages.is_empty() => { - for message in messages { - let mut msg = Some(message); - while msg.is_some() { - msg = self.process(app, msg.unwrap())?; - } - } - Ok(true) - } - _ => Ok(false), - } - } - - fn exit(&self) -> Option> { - if self.quit { - return Some(Exit { value: None }); - } - None - } -} diff --git a/bin/commands/patch/realm/suite/event.rs b/bin/commands/patch/realm/suite/event.rs deleted file mode 100644 index 0603068c..00000000 --- a/bin/commands/patch/realm/suite/event.rs +++ /dev/null @@ -1,140 +0,0 @@ -use tuirealm::command::{Cmd, CmdResult, Direction as MoveDirection}; -use tuirealm::event::{Event, Key, KeyEvent}; -use tuirealm::{MockComponent, NoUserEvent, State, StateValue}; - -use radicle_tui::realm::ui::state::ItemState; -use radicle_tui::realm::ui::widget::container::{ - AppHeader, GlobalListener, LabeledContainer, Popup, -}; -use radicle_tui::realm::ui::widget::context::{ContextBar, Shortcuts}; -use radicle_tui::realm::ui::widget::list::PropertyList; -use radicle_tui::realm::ui::widget::Widget; - -use super::super::common; -use super::{ui, Message, PatchMessage, PopupMessage}; - -/// Since the framework does not know the type of messages that are being -/// passed around in the app, the following handlers need to be implemented for -/// each component used. -/// -/// TODO: should handle `Event::WindowResize`, which is not emitted by `termion`. -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { - code: Key::Char('q'), - .. - }) => Some(Message::Quit), - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { code: Key::Tab, .. }) => { - match self.perform(Cmd::Move(MoveDirection::Right)) { - CmdResult::Changed(State::One(StateValue::U16(index))) => { - Some(Message::NavigationChanged(index)) - } - _ => None, - } - } - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { code: Key::Up, .. }) - | Event::Keyboard(KeyEvent { - code: Key::Char('k'), - .. - }) => { - self.perform(Cmd::Move(MoveDirection::Up)); - Some(Message::Tick) - } - Event::Keyboard(KeyEvent { - code: Key::Down, .. - }) - | Event::Keyboard(KeyEvent { - code: Key::Char('j'), - .. - }) => { - self.perform(Cmd::Move(MoveDirection::Down)); - Some(Message::Tick) - } - Event::Keyboard(KeyEvent { - code: Key::Enter, .. - }) => match self.perform(Cmd::Submit) { - CmdResult::Submit(state) => { - let selected = ItemState::try_from(state).ok()?.selected()?; - let item = self.items().get(selected)?; - Some(Message::Patch(PatchMessage::Show(item.id().to_owned()))) - } - _ => None, - }, - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => { - Some(Message::Patch(PatchMessage::Leave)) - } - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => { - Some(Message::Patch(PatchMessage::Leave)) - } - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, event: Event) -> Option { - match event { - Event::Keyboard(KeyEvent { code: Key::Esc, .. }) => { - Some(Message::Popup(PopupMessage::Hide)) - } - _ => None, - } - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} - -impl tuirealm::Component for Widget { - fn on(&mut self, _event: Event) -> Option { - None - } -} diff --git a/bin/commands/patch/realm/suite/page.rs b/bin/commands/patch/realm/suite/page.rs deleted file mode 100644 index 83d8f153..00000000 --- a/bin/commands/patch/realm/suite/page.rs +++ /dev/null @@ -1,346 +0,0 @@ -use std::collections::HashMap; - -use anyhow::Result; - -use radicle::cob::patch::{Patch, PatchId}; - -use tuirealm::{AttrValue, Attribute, Frame, NoUserEvent, Sub, SubClause}; - -use radicle_tui as tui; - -use tui::common::cob::patch::Filter; -use tui::common::context::Context; -use tui::realm::ui::state::ItemState; -use tui::realm::ui::theme::Theme; -use tui::realm::ui::widget::context::{Progress, Shortcuts}; -use tui::realm::ui::widget::Widget; -use tui::realm::ui::{layout, subscription}; -use tui::realm::ViewPage; - -use super::{ui, Application, Cid, ListCid, Message, PatchCid}; - -/// -/// Home -/// -pub struct ListView { - active_component: ListCid, - shortcuts: HashMap>, - filter: Filter, -} - -impl ListView { - pub fn new(theme: Theme, filter: Filter) -> Self { - let shortcuts = Self::build_shortcuts(&theme); - Self { - active_component: ListCid::PatchBrowser, - shortcuts, - filter, - } - } - - fn build_shortcuts(theme: &Theme) -> HashMap> { - [( - ListCid::PatchBrowser, - tui::realm::ui::shortcuts( - theme, - vec![ - tui::realm::ui::shortcut(theme, "tab", "section"), - tui::realm::ui::shortcut(theme, "↑/↓", "navigate"), - tui::realm::ui::shortcut(theme, "enter", "show"), - tui::realm::ui::shortcut(theme, "q", "quit"), - ], - ), - )] - .iter() - .cloned() - .collect() - } - - fn update_context( - &self, - app: &mut Application, - context: &Context, - theme: &Theme, - ) -> Result<()> { - let state = app.state(&Cid::List(ListCid::PatchBrowser))?; - let progress = match ItemState::try_from(state) { - Ok(state) => Progress::Step( - state - .selected() - .map(|s| s.saturating_add(1)) - .unwrap_or_default(), - state.len(), - ), - Err(_) => Progress::None, - }; - let context = ui::browse_context(context, theme, progress); - - app.remount(Cid::List(ListCid::Context), context.to_boxed(), vec![])?; - - Ok(()) - } - - fn update_shortcuts( - &self, - app: &mut Application, - cid: ListCid, - ) -> Result<()> { - if let Some(shortcuts) = self.shortcuts.get(&cid) { - app.remount( - Cid::List(ListCid::Shortcuts), - shortcuts.clone().to_boxed(), - vec![], - )?; - } - Ok(()) - } -} - -impl ViewPage for ListView { - fn mount( - &mut self, - app: &mut Application, - context: &Context, - theme: &Theme, - ) -> Result<()> { - let navigation = ui::list_navigation(theme); - let header = tui::realm::ui::app_header(context, theme, Some(navigation)).to_boxed(); - let patch_browser = ui::patches(theme, context, self.filter.clone(), None).to_boxed(); - - app.remount(Cid::List(ListCid::Header), header, vec![])?; - app.remount(Cid::List(ListCid::PatchBrowser), patch_browser, vec![])?; - - app.active(&Cid::List(self.active_component.clone()))?; - self.update_shortcuts(app, self.active_component.clone())?; - self.update_context(app, context, theme)?; - - Ok(()) - } - - fn unmount(&self, app: &mut Application) -> Result<()> { - app.umount(&Cid::List(ListCid::Header))?; - app.umount(&Cid::List(ListCid::PatchBrowser))?; - app.umount(&Cid::List(ListCid::Context))?; - app.umount(&Cid::List(ListCid::Shortcuts))?; - Ok(()) - } - - fn update( - &mut self, - app: &mut Application, - context: &Context, - theme: &Theme, - _message: Message, - ) -> Result> { - self.update_context(app, context, theme)?; - - Ok(None) - } - - fn view(&mut self, app: &mut Application, frame: &mut Frame) { - let area = frame.size(); - let context_h = app - .query(&Cid::List(ListCid::Context), Attribute::Height) - .unwrap_or_default() - .unwrap_or(AttrValue::Size(0)) - .unwrap_size(); - let shortcuts_h = 1u16; - - let layout = layout::full_page(area, context_h, shortcuts_h); - - app.view(&Cid::List(ListCid::Header), frame, layout.navigation); - app.view( - &Cid::List(self.active_component.clone()), - frame, - layout.component, - ); - - app.view(&Cid::List(ListCid::Context), frame, layout.context); - app.view(&Cid::List(ListCid::Shortcuts), frame, layout.shortcuts); - } - - fn subscribe(&self, app: &mut Application) -> Result<()> { - app.subscribe( - &Cid::List(ListCid::Header), - Sub::new(subscription::navigation_clause(), SubClause::Always), - )?; - - Ok(()) - } - - fn unsubscribe(&self, app: &mut Application) -> Result<()> { - app.unsubscribe( - &Cid::List(ListCid::Header), - subscription::navigation_clause(), - )?; - - Ok(()) - } -} - -/// -/// Patch detail page -/// -pub struct PatchView { - active_component: PatchCid, - patch: (PatchId, Patch), - shortcuts: HashMap>, -} - -impl PatchView { - pub fn new(theme: Theme, patch: (PatchId, Patch)) -> Self { - let shortcuts = Self::build_shortcuts(&theme); - PatchView { - active_component: PatchCid::Activity, - patch, - shortcuts, - } - } - - fn build_shortcuts(theme: &Theme) -> HashMap> { - [ - ( - PatchCid::Activity, - tui::realm::ui::shortcuts( - theme, - vec![ - tui::realm::ui::shortcut(theme, "esc", "back"), - tui::realm::ui::shortcut(theme, "tab", "section"), - tui::realm::ui::shortcut(theme, "q", "quit"), - ], - ), - ), - ( - PatchCid::Files, - tui::realm::ui::shortcuts( - theme, - vec![ - tui::realm::ui::shortcut(theme, "esc", "back"), - tui::realm::ui::shortcut(theme, "tab", "section"), - tui::realm::ui::shortcut(theme, "q", "quit"), - ], - ), - ), - ] - .iter() - .cloned() - .collect() - } - - fn update_shortcuts( - &self, - app: &mut Application, - cid: PatchCid, - ) -> Result<()> { - if let Some(shortcuts) = self.shortcuts.get(&cid) { - app.remount( - Cid::Patch(PatchCid::Shortcuts), - shortcuts.clone().to_boxed(), - vec![], - )?; - } - Ok(()) - } -} - -impl ViewPage for PatchView { - fn mount( - &mut self, - app: &mut Application, - context: &Context, - theme: &Theme, - ) -> Result<()> { - let navigation = ui::navigation(theme); - let header = tui::realm::ui::app_header(context, theme, Some(navigation)).to_boxed(); - let activity = ui::activity(theme).to_boxed(); - let files = ui::files(theme).to_boxed(); - let context = ui::context(context, theme, self.patch.clone()).to_boxed(); - - app.remount(Cid::Patch(PatchCid::Header), header, vec![])?; - app.remount(Cid::Patch(PatchCid::Activity), activity, vec![])?; - app.remount(Cid::Patch(PatchCid::Files), files, vec![])?; - app.remount(Cid::Patch(PatchCid::Context), context, vec![])?; - - let active_component = Cid::Patch(self.active_component.clone()); - app.active(&active_component)?; - self.update_shortcuts(app, self.active_component.clone())?; - - Ok(()) - } - - fn unmount(&self, app: &mut Application) -> Result<()> { - app.umount(&Cid::Patch(PatchCid::Header))?; - app.umount(&Cid::Patch(PatchCid::Activity))?; - app.umount(&Cid::Patch(PatchCid::Files))?; - app.umount(&Cid::Patch(PatchCid::Context))?; - app.umount(&Cid::Patch(PatchCid::Shortcuts))?; - Ok(()) - } - - fn update( - &mut self, - app: &mut Application, - _context: &Context, - _theme: &Theme, - message: Message, - ) -> Result> { - if let Message::NavigationChanged(index) = message { - self.active_component = PatchCid::from(index as usize); - - let active_component = Cid::Patch(self.active_component.clone()); - app.active(&active_component)?; - self.update_shortcuts(app, self.active_component.clone())?; - } - - Ok(None) - } - - fn view(&mut self, app: &mut Application, frame: &mut Frame) { - let area = frame.size(); - let context_h = app - .query(&Cid::List(ListCid::Context), Attribute::Height) - .unwrap_or_default() - .unwrap_or(AttrValue::Size(0)) - .unwrap_size(); - let shortcuts_h = 1u16; - - let layout = layout::full_page(area, context_h, shortcuts_h); - - app.view(&Cid::Patch(PatchCid::Header), frame, layout.navigation); - app.view( - &Cid::Patch(self.active_component.clone()), - frame, - layout.component, - ); - app.view(&Cid::Patch(PatchCid::Context), frame, layout.context); - app.view(&Cid::Patch(PatchCid::Shortcuts), frame, layout.shortcuts); - } - - fn subscribe(&self, app: &mut Application) -> Result<()> { - app.subscribe( - &Cid::Patch(PatchCid::Header), - Sub::new(subscription::navigation_clause(), SubClause::Always), - )?; - - Ok(()) - } - - fn unsubscribe(&self, app: &mut Application) -> Result<()> { - app.unsubscribe( - &Cid::Patch(PatchCid::Header), - subscription::navigation_clause(), - )?; - - Ok(()) - } -} - -impl From for PatchCid { - fn from(index: usize) -> Self { - match index { - 0 => PatchCid::Activity, - 1 => PatchCid::Files, - _ => PatchCid::Activity, - } - } -} diff --git a/bin/commands/patch/realm/suite/ui.rs b/bin/commands/patch/realm/suite/ui.rs deleted file mode 100644 index a46e05bf..00000000 --- a/bin/commands/patch/realm/suite/ui.rs +++ /dev/null @@ -1,171 +0,0 @@ -use radicle::cob::patch::{Patch, PatchId}; -use radicle::node::AliasStore; - -use tuirealm::command::{Cmd, CmdResult}; -use tuirealm::tui::layout::Rect; -use tuirealm::{AttrValue, Attribute, Frame, MockComponent, Props, State}; - -use radicle_tui as tui; - -use tui::common::cob::patch::Filter; -use tui::common::context::Context; -use tui::realm::ui::cob; -use tui::realm::ui::layout; -use tui::realm::ui::theme::{style, Theme}; -use tui::realm::ui::widget::{Widget, WidgetComponent}; - -use tui::realm::ui::widget::container::Tabs; -use tui::realm::ui::widget::context::{ContextBar, Progress}; -use tui::realm::ui::widget::label::{self, Label}; - -use super::super::common; - -pub struct Activity { - label: Widget