refactor: simplify auth popup to show status instead of URL
This commit is contained in:
+19
-46
@@ -304,12 +304,10 @@ pub fn render_device_auth_popup(
|
||||
|
||||
let border_color = if error.is_some() {
|
||||
Color::Red
|
||||
} else if url == "starting..." {
|
||||
} else if url == "starting..." || !url.is_empty() {
|
||||
Color::Yellow
|
||||
} else if url.is_empty() {
|
||||
POPUP_BORDER
|
||||
} else {
|
||||
Color::Green
|
||||
POPUP_BORDER
|
||||
};
|
||||
|
||||
let block = Block::default()
|
||||
@@ -340,18 +338,31 @@ pub fn render_device_auth_popup(
|
||||
" Press Enter to retry | Esc to cancel ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
} else if url == "starting..." {
|
||||
} else if url == "starting..." || !url.is_empty() {
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" Starting authorization... ",
|
||||
" Authorization in progress... ",
|
||||
Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD),
|
||||
)));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" A browser tab will open or you can copy the URL manually. ",
|
||||
" A browser tab should open automatically. ",
|
||||
Style::default().fg(Color::White),
|
||||
)));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" If not, check that GOOGLE_CLIENT_ID and ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
} else if url.is_empty() {
|
||||
lines.push(Line::from(Span::styled(
|
||||
" GOOGLE_CLIENT_SECRET are set correctly. ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" (Esc to cancel) ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
} else {
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" Google Tasks Authorization ",
|
||||
@@ -363,11 +374,6 @@ pub fn render_device_auth_popup(
|
||||
Style::default().fg(Color::White),
|
||||
)));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" Set env vars GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET ",
|
||||
Style::default().fg(Color::Yellow),
|
||||
)));
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" Press Enter to start ",
|
||||
Style::default().fg(Color::Cyan),
|
||||
@@ -376,39 +382,6 @@ pub fn render_device_auth_popup(
|
||||
" Press Esc to skip ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
} else {
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" Authorize in your browser: ",
|
||||
Style::default().fg(Color::White).add_modifier(Modifier::BOLD),
|
||||
)));
|
||||
lines.push(Line::from(""));
|
||||
// Show a shortened version of the URL for readability
|
||||
if url.len() > 70 {
|
||||
let short_url: String = url.chars().take(67).collect();
|
||||
lines.push(Line::from(Span::styled(
|
||||
format!(" {}", short_url),
|
||||
Style::default().fg(Color::Cyan),
|
||||
)));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" ... (full URL in terminal log) ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
} else {
|
||||
lines.push(Line::from(Span::styled(
|
||||
format!(" {}", url),
|
||||
Style::default().fg(Color::Cyan),
|
||||
)));
|
||||
}
|
||||
lines.push(Line::from(""));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" Waiting for browser authorization... ",
|
||||
Style::default().fg(Color::Yellow).add_modifier(Modifier::BOLD),
|
||||
)));
|
||||
lines.push(Line::from(Span::styled(
|
||||
" (Esc to cancel) ",
|
||||
Style::default().fg(Color::DarkGray),
|
||||
)));
|
||||
}
|
||||
|
||||
let paragraph = Paragraph::new(Text::from(lines))
|
||||
|
||||
Reference in New Issue
Block a user