forked from kemitix/git-next
feat(tui): clean up alert display
This commit is contained in:
parent
ca70c03e8b
commit
853b862f10
2 changed files with 27 additions and 20 deletions
|
@ -103,7 +103,7 @@ impl Handler<ValidateRepo> for RepoActor {
|
||||||
}
|
}
|
||||||
Err(Error::Retryable(message)) => {
|
Err(Error::Retryable(message)) => {
|
||||||
info!(?message, "Retryable");
|
info!(?message, "Retryable");
|
||||||
self.alert_tui(format!("[retryable: {message}]"));
|
self.alert_tui(format!("retryable: {message}"));
|
||||||
logger(self.log.as_ref(), message);
|
logger(self.log.as_ref(), message);
|
||||||
let addr = ctx.address();
|
let addr = ctx.address();
|
||||||
let message_token = self.message_token;
|
let message_token = self.message_token;
|
||||||
|
@ -122,7 +122,7 @@ impl Handler<ValidateRepo> for RepoActor {
|
||||||
}
|
}
|
||||||
Err(Error::UserIntervention(user_notification)) => {
|
Err(Error::UserIntervention(user_notification)) => {
|
||||||
info!(?user_notification, "User Intervention");
|
info!(?user_notification, "User Intervention");
|
||||||
self.alert_tui(format!("[USER INTERVENTION: {user_notification}]"));
|
self.alert_tui(format!("USER INTERVENTION: {user_notification}"));
|
||||||
if let UserNotification::CICheckFailed { log, .. }
|
if let UserNotification::CICheckFailed { log, .. }
|
||||||
| UserNotification::DevNotBasedOnMain { log, .. } = &user_notification
|
| UserNotification::DevNotBasedOnMain { log, .. } = &user_notification
|
||||||
{
|
{
|
||||||
|
@ -136,7 +136,7 @@ impl Handler<ValidateRepo> for RepoActor {
|
||||||
}
|
}
|
||||||
Err(Error::NonRetryable(message)) => {
|
Err(Error::NonRetryable(message)) => {
|
||||||
info!(?message, "NonRetryable");
|
info!(?message, "NonRetryable");
|
||||||
self.alert_tui(format!("[Error: {message}]"));
|
self.alert_tui(format!("Error: {message}"));
|
||||||
logger(self.log.as_ref(), message);
|
logger(self.log.as_ref(), message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use std::string::ToString;
|
||||||
|
|
||||||
//
|
//
|
||||||
use git_next_core::{RepoAlias, RepoBranches};
|
use git_next_core::{RepoAlias, RepoBranches};
|
||||||
use ratatui::{
|
use ratatui::{
|
||||||
|
@ -32,16 +34,10 @@ impl<'a> Identity<'a> {
|
||||||
}
|
}
|
||||||
impl<'a> Identity<'a> {
|
impl<'a> Identity<'a> {
|
||||||
fn spans(self) -> Vec<Span<'a>> {
|
fn spans(self) -> Vec<Span<'a>> {
|
||||||
let repo_alias = Span::from(self.repo_alias.to_string()).style(if self.alert.is_some() {
|
|
||||||
Style::default().fg(Color::Black).bg(Color::Red)
|
|
||||||
} else {
|
|
||||||
Style::default().fg(Color::Cyan).bg(Color::Black)
|
|
||||||
});
|
|
||||||
let alert = self
|
let alert = self
|
||||||
.alert
|
.alert
|
||||||
.map_or(String::new(), |a| format!("{a} "))
|
.map(ToString::to_string)
|
||||||
.fg(Color::Black)
|
.map(|alert| alert.fg(Color::White).bg(Color::Red));
|
||||||
.bg(Color::Red);
|
|
||||||
let message = self.message;
|
let message = self.message;
|
||||||
let main = self
|
let main = self
|
||||||
.repo_branches
|
.repo_branches
|
||||||
|
@ -55,15 +51,26 @@ impl<'a> Identity<'a> {
|
||||||
.repo_branches
|
.repo_branches
|
||||||
.map(RepoBranches::dev)
|
.map(RepoBranches::dev)
|
||||||
.map_or_else(|| "_".to_string(), |b| b.to_string());
|
.map_or_else(|| "_".to_string(), |b| b.to_string());
|
||||||
vec![
|
let mut spans = vec![" ".into()];
|
||||||
" ".into(),
|
match alert {
|
||||||
repo_alias,
|
None => spans.push(
|
||||||
" ".into(),
|
Span::from(self.repo_alias.to_string())
|
||||||
alert,
|
.style(Style::default().fg(Color::Cyan).bg(Color::Black)),
|
||||||
format!("({main} -> {next} -> {dev}) ").into(),
|
),
|
||||||
message.into(),
|
Some(alert) => {
|
||||||
" ".into(),
|
spans.push(
|
||||||
]
|
Span::from(self.repo_alias.to_string())
|
||||||
|
.style(Style::default().fg(Color::White).bg(Color::Red)),
|
||||||
|
);
|
||||||
|
spans.push(" ".into());
|
||||||
|
spans.push(alert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
spans.push(" ".into());
|
||||||
|
spans.push(format!("({main} -> {next} -> {dev}) ").into());
|
||||||
|
spans.push(message.into());
|
||||||
|
spans.push(" ".into());
|
||||||
|
spans
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<'a> From<Identity<'a>> for Title<'a> {
|
impl<'a> From<Identity<'a>> for Title<'a> {
|
||||||
|
|
Loading…
Reference in a new issue