Reuse mounts
This commit is contained in:
parent
f3e694d3d6
commit
4b9d23cc3a
|
@ -99,100 +99,63 @@ impl AuthActivity {
|
||||||
// Get default protocol
|
// Get default protocol
|
||||||
let default_protocol: FileTransferProtocol = self.context().config().get_default_protocol();
|
let default_protocol: FileTransferProtocol = self.context().config().get_default_protocol();
|
||||||
// Protocol
|
// Protocol
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_PROTOCOL,
|
super::COMPONENT_RADIO_PROTOCOL,
|
||||||
Box::new(Radio::new(
|
"Protocol",
|
||||||
RadioPropsBuilder::default()
|
&["SFTP", "SCP", "FTP", "FTPS", "AWS S3"],
|
||||||
.with_color(protocol_color)
|
Self::protocol_enum_to_opt(default_protocol),
|
||||||
.with_inverted_color(Color::Black)
|
protocol_color,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, protocol_color)
|
|
||||||
.with_title("Protocol", Alignment::Left)
|
|
||||||
.with_options(&["SFTP", "SCP", "FTP", "FTPS", "AWS S3"])
|
|
||||||
.with_value(Self::protocol_enum_to_opt(default_protocol))
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Address
|
// Address
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_ADDR,
|
super::COMPONENT_INPUT_ADDR,
|
||||||
Box::new(Input::new(
|
"Remote host",
|
||||||
InputPropsBuilder::default()
|
addr_color,
|
||||||
.with_foreground(addr_color)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, addr_color)
|
|
||||||
.with_label("Remote host", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Port
|
// Port
|
||||||
self.view.mount(
|
self.mount_input_ex(
|
||||||
super::COMPONENT_INPUT_PORT,
|
super::COMPONENT_INPUT_PORT,
|
||||||
Box::new(Input::new(
|
"Port number",
|
||||||
InputPropsBuilder::default()
|
port_color,
|
||||||
.with_foreground(port_color)
|
InputType::Number,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, port_color)
|
Some(5),
|
||||||
.with_label("Port number", Alignment::Left)
|
Some(Self::get_default_port_for_protocol(default_protocol).to_string()),
|
||||||
.with_input(InputType::Number)
|
|
||||||
.with_input_len(5)
|
|
||||||
.with_value(Self::get_default_port_for_protocol(default_protocol).to_string())
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Username
|
// Username
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_USERNAME,
|
super::COMPONENT_INPUT_USERNAME,
|
||||||
Box::new(Input::new(
|
"Username",
|
||||||
InputPropsBuilder::default()
|
username_color,
|
||||||
.with_foreground(username_color)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, username_color)
|
|
||||||
.with_label("Username", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Password
|
// Password
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_PASSWORD,
|
super::COMPONENT_INPUT_PASSWORD,
|
||||||
Box::new(Input::new(
|
"Password",
|
||||||
InputPropsBuilder::default()
|
password_color,
|
||||||
.with_foreground(password_color)
|
InputType::Password,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, password_color)
|
|
||||||
.with_label("Password", Alignment::Left)
|
|
||||||
.with_input(InputType::Password)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Bucket
|
// Bucket
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_S3_BUCKET,
|
super::COMPONENT_INPUT_S3_BUCKET,
|
||||||
Box::new(Input::new(
|
"Bucket name",
|
||||||
InputPropsBuilder::default()
|
addr_color,
|
||||||
.with_foreground(addr_color)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, addr_color)
|
|
||||||
.with_label("Bucket name", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Region
|
// Region
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_S3_REGION,
|
super::COMPONENT_INPUT_S3_REGION,
|
||||||
Box::new(Input::new(
|
"Region",
|
||||||
InputPropsBuilder::default()
|
port_color,
|
||||||
.with_foreground(port_color)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, port_color)
|
|
||||||
.with_label("Region", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Profile
|
// Profile
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_S3_PROFILE,
|
super::COMPONENT_INPUT_S3_PROFILE,
|
||||||
Box::new(Input::new(
|
"Profile",
|
||||||
InputPropsBuilder::default()
|
username_color,
|
||||||
.with_foreground(username_color)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, username_color)
|
|
||||||
.with_label("Profile", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Version notice
|
// Version notice
|
||||||
if let Some(version) = self
|
if let Some(version) = self
|
||||||
|
@ -995,4 +958,49 @@ impl AuthActivity {
|
||||||
// Active
|
// Active
|
||||||
self.view.active(id);
|
self.view.active(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mount_radio(&mut self, id: &str, text: &str, opts: &[&str], default: usize, color: Color) {
|
||||||
|
self.view.mount(
|
||||||
|
id,
|
||||||
|
Box::new(Radio::new(
|
||||||
|
RadioPropsBuilder::default()
|
||||||
|
.with_color(color)
|
||||||
|
.with_inverted_color(Color::Black)
|
||||||
|
.with_borders(Borders::ALL, BorderType::Rounded, color)
|
||||||
|
.with_title(text, Alignment::Left)
|
||||||
|
.with_options(opts)
|
||||||
|
.with_value(default)
|
||||||
|
.rewind(true)
|
||||||
|
.build(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_input(&mut self, id: &str, label: &str, fg: Color, typ: InputType) {
|
||||||
|
self.mount_input_ex(id, label, fg, typ, None, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_input_ex(
|
||||||
|
&mut self,
|
||||||
|
id: &str,
|
||||||
|
label: &str,
|
||||||
|
fg: Color,
|
||||||
|
typ: InputType,
|
||||||
|
len: Option<usize>,
|
||||||
|
value: Option<String>,
|
||||||
|
) {
|
||||||
|
let mut props = InputPropsBuilder::default();
|
||||||
|
props
|
||||||
|
.with_foreground(fg)
|
||||||
|
.with_borders(Borders::ALL, BorderType::Rounded, fg)
|
||||||
|
.with_label(label, Alignment::Left)
|
||||||
|
.with_input(typ);
|
||||||
|
if let Some(len) = len {
|
||||||
|
props.with_input_len(len);
|
||||||
|
}
|
||||||
|
if let Some(value) = value {
|
||||||
|
props.with_value(value);
|
||||||
|
}
|
||||||
|
self.view.mount(id, Box::new(Input::new(props.build())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@ pub use ssh_keys::*;
|
||||||
pub use theme::*;
|
pub use theme::*;
|
||||||
// Ext
|
// Ext
|
||||||
use tui_realm_stdlib::{
|
use tui_realm_stdlib::{
|
||||||
List, ListPropsBuilder, Paragraph, ParagraphPropsBuilder, Radio, RadioPropsBuilder, Span,
|
Input, InputPropsBuilder, List, ListPropsBuilder, Paragraph, ParagraphPropsBuilder, Radio,
|
||||||
SpanPropsBuilder,
|
RadioPropsBuilder, Span, SpanPropsBuilder,
|
||||||
};
|
};
|
||||||
use tuirealm::props::{Alignment, PropsBuilder, TableBuilder, TextSpan};
|
use tuirealm::props::{Alignment, InputType, PropsBuilder, TableBuilder, TextSpan};
|
||||||
use tuirealm::tui::{
|
use tuirealm::tui::{
|
||||||
style::Color,
|
style::Color,
|
||||||
widgets::{BorderType, Borders},
|
widgets::{BorderType, Borders},
|
||||||
|
@ -74,21 +74,7 @@ impl SetupActivity {
|
||||||
///
|
///
|
||||||
/// Mount error box
|
/// Mount error box
|
||||||
pub(super) fn mount_error(&mut self, text: &str) {
|
pub(super) fn mount_error(&mut self, text: &str) {
|
||||||
// Mount
|
self.mount_text_dialog(super::COMPONENT_TEXT_ERROR, text, Color::Red);
|
||||||
self.view.mount(
|
|
||||||
super::COMPONENT_TEXT_ERROR,
|
|
||||||
Box::new(Paragraph::new(
|
|
||||||
ParagraphPropsBuilder::default()
|
|
||||||
.with_foreground(Color::Red)
|
|
||||||
.bold()
|
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::Red)
|
|
||||||
.with_texts(vec![TextSpan::from(text)])
|
|
||||||
.with_text_alignment(Alignment::Center)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
|
||||||
// Give focus to error
|
|
||||||
self.view.active(super::COMPONENT_TEXT_ERROR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### umount_error
|
/// ### umount_error
|
||||||
|
@ -102,28 +88,13 @@ impl SetupActivity {
|
||||||
///
|
///
|
||||||
/// Mount quit popup
|
/// Mount quit popup
|
||||||
pub(super) fn mount_quit(&mut self) {
|
pub(super) fn mount_quit(&mut self) {
|
||||||
self.view.mount(
|
self.mount_radio_dialog(
|
||||||
super::COMPONENT_RADIO_QUIT,
|
super::COMPONENT_RADIO_QUIT,
|
||||||
Box::new(Radio::new(
|
"There are unsaved changes! Save changes before leaving?",
|
||||||
RadioPropsBuilder::default()
|
&["Save", "Don't save", "Cancel"],
|
||||||
.with_color(Color::LightRed)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightRed,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightRed)
|
|
||||||
.with_title(
|
|
||||||
"There are unsaved changes! Save changes before leaving?",
|
|
||||||
Alignment::Center,
|
|
||||||
)
|
|
||||||
.with_options(&[
|
|
||||||
String::from("Save"),
|
|
||||||
String::from("Don't save"),
|
|
||||||
String::from("Cancel"),
|
|
||||||
])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Active
|
|
||||||
self.view.active(super::COMPONENT_RADIO_QUIT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### umount_quit
|
/// ### umount_quit
|
||||||
|
@ -137,21 +108,13 @@ impl SetupActivity {
|
||||||
///
|
///
|
||||||
/// Mount save popup
|
/// Mount save popup
|
||||||
pub(super) fn mount_save_popup(&mut self) {
|
pub(super) fn mount_save_popup(&mut self) {
|
||||||
self.view.mount(
|
self.mount_radio_dialog(
|
||||||
super::COMPONENT_RADIO_SAVE,
|
super::COMPONENT_RADIO_SAVE,
|
||||||
Box::new(Radio::new(
|
"Save changes?",
|
||||||
RadioPropsBuilder::default()
|
&["Yes", "No"],
|
||||||
.with_color(Color::LightYellow)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightYellow,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightYellow)
|
|
||||||
.with_title("Save changes?", Alignment::Center)
|
|
||||||
.with_options(&[String::from("Yes"), String::from("No")])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Active
|
|
||||||
self.view.active(super::COMPONENT_RADIO_SAVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### umount_quit
|
/// ### umount_quit
|
||||||
|
@ -253,4 +216,95 @@ impl SetupActivity {
|
||||||
pub(super) fn umount_help(&mut self) {
|
pub(super) fn umount_help(&mut self) {
|
||||||
self.view.umount(super::COMPONENT_TEXT_HELP);
|
self.view.umount(super::COMPONENT_TEXT_HELP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -- mount helpers
|
||||||
|
|
||||||
|
fn mount_text_dialog(&mut self, id: &str, text: &str, color: Color) {
|
||||||
|
// Mount
|
||||||
|
self.view.mount(
|
||||||
|
id,
|
||||||
|
Box::new(Paragraph::new(
|
||||||
|
ParagraphPropsBuilder::default()
|
||||||
|
.with_borders(Borders::ALL, BorderType::Thick, color)
|
||||||
|
.with_foreground(color)
|
||||||
|
.bold()
|
||||||
|
.with_text_alignment(Alignment::Center)
|
||||||
|
.with_texts(vec![TextSpan::from(text)])
|
||||||
|
.build(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
// Give focus to error
|
||||||
|
self.view.active(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_radio_dialog(
|
||||||
|
&mut self,
|
||||||
|
id: &str,
|
||||||
|
text: &str,
|
||||||
|
opts: &[&str],
|
||||||
|
default: usize,
|
||||||
|
color: Color,
|
||||||
|
) {
|
||||||
|
self.view.mount(
|
||||||
|
id,
|
||||||
|
Box::new(Radio::new(
|
||||||
|
RadioPropsBuilder::default()
|
||||||
|
.with_color(color)
|
||||||
|
.with_inverted_color(Color::Black)
|
||||||
|
.with_borders(Borders::ALL, BorderType::Rounded, color)
|
||||||
|
.with_title(text, Alignment::Center)
|
||||||
|
.with_options(opts)
|
||||||
|
.with_value(default)
|
||||||
|
.rewind(true)
|
||||||
|
.build(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
// Active
|
||||||
|
self.view.active(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_radio(&mut self, id: &str, text: &str, opts: &[&str], default: usize, color: Color) {
|
||||||
|
self.view.mount(
|
||||||
|
id,
|
||||||
|
Box::new(Radio::new(
|
||||||
|
RadioPropsBuilder::default()
|
||||||
|
.with_color(color)
|
||||||
|
.with_inverted_color(Color::Black)
|
||||||
|
.with_borders(Borders::ALL, BorderType::Rounded, color)
|
||||||
|
.with_title(text, Alignment::Left)
|
||||||
|
.with_options(opts)
|
||||||
|
.with_value(default)
|
||||||
|
.rewind(true)
|
||||||
|
.build(),
|
||||||
|
)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_input(&mut self, id: &str, label: &str, fg: Color, typ: InputType) {
|
||||||
|
self.mount_input_ex(id, label, fg, typ, None, None);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mount_input_ex(
|
||||||
|
&mut self,
|
||||||
|
id: &str,
|
||||||
|
label: &str,
|
||||||
|
fg: Color,
|
||||||
|
typ: InputType,
|
||||||
|
len: Option<usize>,
|
||||||
|
value: Option<String>,
|
||||||
|
) {
|
||||||
|
let mut props = InputPropsBuilder::default();
|
||||||
|
props
|
||||||
|
.with_foreground(fg)
|
||||||
|
.with_borders(Borders::ALL, BorderType::Rounded, fg)
|
||||||
|
.with_label(label, Alignment::Left)
|
||||||
|
.with_input(typ);
|
||||||
|
if let Some(len) = len {
|
||||||
|
props.with_input_len(len);
|
||||||
|
}
|
||||||
|
if let Some(value) = value {
|
||||||
|
props.with_value(value);
|
||||||
|
}
|
||||||
|
self.view.mount(id, Box::new(Input::new(props.build())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,14 +27,14 @@
|
||||||
* SOFTWARE.
|
* SOFTWARE.
|
||||||
*/
|
*/
|
||||||
// Locals
|
// Locals
|
||||||
use super::{Context, SetupActivity};
|
use super::{Context, InputType, SetupActivity};
|
||||||
use crate::filetransfer::FileTransferProtocol;
|
use crate::filetransfer::FileTransferProtocol;
|
||||||
use crate::fs::explorer::GroupDirs;
|
use crate::fs::explorer::GroupDirs;
|
||||||
use crate::ui::components::bytes::{Bytes, BytesPropsBuilder};
|
use crate::ui::components::bytes::{Bytes, BytesPropsBuilder};
|
||||||
use crate::utils::ui::draw_area_in;
|
use crate::utils::ui::draw_area_in;
|
||||||
// Ext
|
// Ext
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use tui_realm_stdlib::{Input, InputPropsBuilder, Radio, RadioPropsBuilder};
|
use tui_realm_stdlib::{InputPropsBuilder, RadioPropsBuilder};
|
||||||
use tuirealm::tui::{
|
use tuirealm::tui::{
|
||||||
layout::{Constraint, Direction, Layout},
|
layout::{Constraint, Direction, Layout},
|
||||||
style::Color,
|
style::Color,
|
||||||
|
@ -60,118 +60,66 @@ impl SetupActivity {
|
||||||
// Footer
|
// Footer
|
||||||
self.mount_footer();
|
self.mount_footer();
|
||||||
// Input fields
|
// Input fields
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_TEXT_EDITOR,
|
super::COMPONENT_INPUT_TEXT_EDITOR,
|
||||||
Box::new(Input::new(
|
"Text editor",
|
||||||
InputPropsBuilder::default()
|
Color::LightGreen,
|
||||||
.with_foreground(Color::LightGreen)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightGreen)
|
|
||||||
.with_label("Text editor", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.active(super::COMPONENT_INPUT_TEXT_EDITOR); // <-- Focus
|
self.view.active(super::COMPONENT_INPUT_TEXT_EDITOR); // <-- Focus
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_DEFAULT_PROTOCOL,
|
super::COMPONENT_RADIO_DEFAULT_PROTOCOL,
|
||||||
Box::new(Radio::new(
|
"Default protocol",
|
||||||
RadioPropsBuilder::default()
|
&["SFTP", "SCP", "FTP", "FTPS", "AWS S3"],
|
||||||
.with_color(Color::LightCyan)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightCyan,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightCyan)
|
|
||||||
.with_title("Default file transfer protocol", Alignment::Left)
|
|
||||||
.with_options(&["SFTP", "SCP", "FTP", "FTPS", "AWS S3"])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_HIDDEN_FILES,
|
super::COMPONENT_RADIO_HIDDEN_FILES,
|
||||||
Box::new(Radio::new(
|
"Show hidden files (by default)?",
|
||||||
RadioPropsBuilder::default()
|
&["Yes", "No"],
|
||||||
.with_color(Color::LightRed)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightRed,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightRed)
|
|
||||||
.with_title("Show hidden files (by default)?", Alignment::Left)
|
|
||||||
.with_options(&[String::from("Yes"), String::from("No")])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_UPDATES,
|
super::COMPONENT_RADIO_UPDATES,
|
||||||
Box::new(Radio::new(
|
"Check for updates?",
|
||||||
RadioPropsBuilder::default()
|
&["Yes", "No"],
|
||||||
.with_color(Color::LightYellow)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightYellow,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightYellow)
|
|
||||||
.with_title("Check for updates?", Alignment::Left)
|
|
||||||
.with_options(&[String::from("Yes"), String::from("No")])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_PROMPT_ON_FILE_REPLACE,
|
super::COMPONENT_RADIO_PROMPT_ON_FILE_REPLACE,
|
||||||
Box::new(Radio::new(
|
"Prompt when replacing existing files?",
|
||||||
RadioPropsBuilder::default()
|
&["Yes", "No"],
|
||||||
.with_color(Color::LightCyan)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightCyan,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightCyan)
|
|
||||||
.with_title("Prompt when replacing existing files?", Alignment::Left)
|
|
||||||
.with_options(&[String::from("Yes"), String::from("No")])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_GROUP_DIRS,
|
super::COMPONENT_RADIO_GROUP_DIRS,
|
||||||
Box::new(Radio::new(
|
"Group directories",
|
||||||
RadioPropsBuilder::default()
|
&["Display first", "Display last", "No"],
|
||||||
.with_color(Color::LightMagenta)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightMagenta,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightMagenta)
|
|
||||||
.with_title("Group directories", Alignment::Left)
|
|
||||||
.with_options(&[
|
|
||||||
String::from("Display first"),
|
|
||||||
String::from("Display Last"),
|
|
||||||
String::from("No"),
|
|
||||||
])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_LOCAL_FILE_FMT,
|
super::COMPONENT_INPUT_LOCAL_FILE_FMT,
|
||||||
Box::new(Input::new(
|
"File formatter syntax (local)",
|
||||||
InputPropsBuilder::default()
|
Color::LightGreen,
|
||||||
.with_foreground(Color::LightGreen)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightGreen)
|
|
||||||
.with_label("File formatter syntax (local)", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_input(
|
||||||
super::COMPONENT_INPUT_REMOTE_FILE_FMT,
|
super::COMPONENT_INPUT_REMOTE_FILE_FMT,
|
||||||
Box::new(Input::new(
|
"File formatter syntax (remote)",
|
||||||
InputPropsBuilder::default()
|
Color::LightCyan,
|
||||||
.with_foreground(Color::LightCyan)
|
InputType::Text,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightCyan)
|
|
||||||
.with_label("File formatter syntax (remote)", Alignment::Left)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.mount_radio(
|
||||||
super::COMPONENT_RADIO_NOTIFICATIONS_ENABLED,
|
super::COMPONENT_RADIO_NOTIFICATIONS_ENABLED,
|
||||||
Box::new(Radio::new(
|
"Enable notifications?",
|
||||||
RadioPropsBuilder::default()
|
&["Yes", "No"],
|
||||||
.with_color(Color::LightRed)
|
0,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightRed,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightRed)
|
|
||||||
.with_title("Enable notifications?", Alignment::Left)
|
|
||||||
.with_options(&[String::from("Yes"), String::from("No")])
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
self.view.mount(
|
self.view.mount(
|
||||||
super::COMPONENT_INPUT_NOTIFICATIONS_THRESHOLD,
|
super::COMPONENT_INPUT_NOTIFICATIONS_THRESHOLD,
|
||||||
|
|
|
@ -31,7 +31,7 @@ use super::{Context, SetupActivity};
|
||||||
use crate::ui::components::bookmark_list::{BookmarkList, BookmarkListPropsBuilder};
|
use crate::ui::components::bookmark_list::{BookmarkList, BookmarkListPropsBuilder};
|
||||||
use crate::utils::ui::draw_area_in;
|
use crate::utils::ui::draw_area_in;
|
||||||
// Ext
|
// Ext
|
||||||
use tui_realm_stdlib::{Input, InputPropsBuilder, Radio, RadioPropsBuilder};
|
use tui_realm_stdlib::{Input, InputPropsBuilder};
|
||||||
use tuirealm::tui::{
|
use tuirealm::tui::{
|
||||||
layout::{Constraint, Direction, Layout},
|
layout::{Constraint, Direction, Layout},
|
||||||
style::Color,
|
style::Color,
|
||||||
|
@ -169,22 +169,13 @@ impl SetupActivity {
|
||||||
///
|
///
|
||||||
/// Mount delete ssh key component
|
/// Mount delete ssh key component
|
||||||
pub(crate) fn mount_del_ssh_key(&mut self) {
|
pub(crate) fn mount_del_ssh_key(&mut self) {
|
||||||
self.view.mount(
|
self.mount_radio_dialog(
|
||||||
super::COMPONENT_RADIO_DEL_SSH_KEY,
|
super::COMPONENT_RADIO_DEL_SSH_KEY,
|
||||||
Box::new(Radio::new(
|
"Delete key?",
|
||||||
RadioPropsBuilder::default()
|
&["Yes", "No"],
|
||||||
.with_color(Color::LightRed)
|
1,
|
||||||
.with_inverted_color(Color::Black)
|
Color::LightRed,
|
||||||
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightRed)
|
|
||||||
.with_title("Delete key?", Alignment::Center)
|
|
||||||
.with_options(&[String::from("Yes"), String::from("No")])
|
|
||||||
.with_value(1) // Default: No
|
|
||||||
.rewind(true)
|
|
||||||
.build(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
// Active
|
|
||||||
self.view.active(super::COMPONENT_RADIO_DEL_SSH_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ### umount_del_ssh_key
|
/// ### umount_del_ssh_key
|
||||||
|
|
Loading…
Reference in a new issue