inbox: Adjust table header

This commit is contained in:
Erik Kundt
2024-02-25 00:10:08 +01:00
parent 42d0ce7039
commit bb104bd409
2 changed files with 12 additions and 11 deletions
+7
View File
@@ -3,7 +3,9 @@ mod ui;
use anyhow::Result;
use radicle::identity::Project;
use radicle::node::notifications::NotificationId;
use radicle::storage::ReadRepository;
use radicle::storage::git::Repository;
use radicle::Profile;
@@ -39,12 +41,16 @@ pub struct InboxState {
notifications: Vec<NotificationItem>,
selected: Option<NotificationItem>,
mode: common::Mode,
project: Project,
}
impl TryFrom<&Context> for InboxState {
type Error = anyhow::Error;
fn try_from(context: &Context) -> Result<Self, Self::Error> {
let doc = context.repository.identity_doc()?;
let project = doc.project()?;
let notifications = inbox::all(&context.repository, &context.profile)?;
let mut items = vec![];
@@ -72,6 +78,7 @@ impl TryFrom<&Context> for InboxState {
notifications: items,
selected,
mode: context.mode.clone(),
project,
})
}
}
+5 -11
View File
@@ -1,6 +1,7 @@
use std::cmp;
use std::vec;
use radicle::identity::Project;
use tokio::sync::mpsc::UnboundedSender;
use termion::event::Key;
@@ -143,12 +144,14 @@ impl Render<()> for ListPage {
struct NotificationsProps {
notifications: Vec<NotificationItem>,
project: Project,
}
impl From<&InboxState> for NotificationsProps {
fn from(state: &InboxState) -> Self {
Self {
notifications: state.notifications.clone(),
project: state.project.clone(),
}
}
}
@@ -272,17 +275,8 @@ impl Render<()> for Notifications {
frame,
layout[0],
HeaderProps {
cells: [
String::from("").into(),
String::from(" ● ").into(),
String::from("ID / Name").into(),
String::from("Summary").into(),
String::from("Type").into(),
String::from("Status").into(),
String::from("Author").into(),
String::from("Updated").into(),
],
widths,
cells: [String::from("").into(), self.props.project.name().into()],
widths: [Constraint::Length(0), Constraint::Fill(1)],
focus,
cutoff,
cutoff_after,