Skip to content

Commit 60ba75f

Browse files
author
Stephan Dilly
committed
fix stash msg popup title/msg
1 parent 1727b50 commit 60ba75f

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

src/components/commit.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ impl CommitComponent {
8080
pub fn new(queue: Queue, theme: &Theme) -> Self {
8181
Self {
8282
queue,
83-
input: TextInputComponent::new(theme),
83+
input: TextInputComponent::new(
84+
theme,
85+
strings::COMMIT_TITLE,
86+
strings::COMMIT_MSG,
87+
),
8488
}
8589
}
8690

src/components/stashmsg.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,11 @@ impl StashMsgComponent {
9696
Self {
9797
options: StashingOptions::default(),
9898
queue,
99-
input: TextInputComponent::new(theme),
99+
input: TextInputComponent::new(
100+
theme,
101+
strings::STASH_POPUP_TITLE,
102+
strings::STASH_POPUP_MSG,
103+
),
100104
}
101105
}
102106
}

src/components/textinput.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,26 @@ use tui::{
1818

1919
/// primarily a subcomponet for user input of text (used in `CommitComponent`)
2020
pub struct TextInputComponent {
21+
title: String,
22+
default_msg: String,
2123
msg: String,
2224
visible: bool,
2325
theme: Theme,
2426
}
2527

2628
impl TextInputComponent {
2729
///
28-
pub fn new(theme: &Theme) -> Self {
30+
pub fn new(
31+
theme: &Theme,
32+
title: &str,
33+
default_msg: &str,
34+
) -> Self {
2935
Self {
3036
msg: String::default(),
3137
visible: false,
3238
theme: *theme,
39+
title: title.to_string(),
40+
default_msg: default_msg.to_string(),
3341
}
3442
}
3543

@@ -49,7 +57,7 @@ impl DrawableComponent for TextInputComponent {
4957
if self.visible {
5058
let txt = if self.msg.is_empty() {
5159
[Text::Styled(
52-
Cow::from(strings::COMMIT_MSG),
60+
Cow::from(self.default_msg.as_str()),
5361
self.theme.text(false, false),
5462
)]
5563
} else {
@@ -62,7 +70,7 @@ impl DrawableComponent for TextInputComponent {
6270
let area = ui::centered_rect(60, 20, f.size());
6371
f.render_widget(Clear, area);
6472
f.render_widget(
65-
dialog_paragraph(strings::COMMIT_TITLE, txt.iter()),
73+
dialog_paragraph(self.title.as_str(), txt.iter()),
6674
area,
6775
);
6876
}

src/strings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ pub static CMD_SPLITTER: &str = " ";
1212
pub static MSG_TITLE_ERROR: &str = "Error";
1313
pub static COMMIT_TITLE: &str = "Commit";
1414
pub static COMMIT_MSG: &str = "type commit message..";
15+
pub static STASH_POPUP_TITLE: &str = "Stash";
16+
pub static STASH_POPUP_MSG: &str = "type name (optional)";
1517
pub static RESET_TITLE: &str = "Reset";
1618
pub static RESET_MSG: &str = "confirm file reset?";
1719

0 commit comments

Comments
 (0)