Skip to content

Commit

Permalink
Merge #1432: gui(settings): add a button to copy auth fields & mask p…
Browse files Browse the repository at this point in the history
…assword

9679f0f gui(settings): add a copy button for electrum server address (pythcoiner)
46cb154 gui(settings): replace node password by stars(*) (pythcoiner)
523bcbd gui(settings): add a copy button to auth fields (pythcoiner)

Pull request description:

  fixes #1160
  ![image](https://github.com/user-attachments/assets/e508010a-4fb1-443d-a615-0dff402eb3e0)

ACKs for top commit:
  jp1ac4:
    Tested ACK 9679f0f.

Tree-SHA512: 880e35ade18b614e25b5add8fbc17615504e0b7c35a0cd2e9fbc7861b8d24765a2b2a91bcb68d0d4c6f15bbc41ddccf78fd61890aafd33fd6f5d35355f9725e0
  • Loading branch information
edouardparis committed Dec 20, 2024
2 parents 7367abc + 9679f0f commit ecce76a
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 3 additions & 1 deletion liana-gui/src/app/state/settings/bitcoind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::str::FromStr;
use std::sync::Arc;

use chrono::{NaiveDate, Utc};
use iced::Command;
use iced::{clipboard, Command};
use tracing::info;

use liana::miniscript::bitcoin::Network;
Expand Down Expand Up @@ -361,6 +361,7 @@ impl BitcoindSettings {
});
}
}
view::SettingsEditMessage::Clipboard(text) => return clipboard::write(text),
};
Command::none()
}
Expand Down Expand Up @@ -468,6 +469,7 @@ impl ElectrumSettings {
});
}
}
view::SettingsEditMessage::Clipboard(text) => return clipboard::write(text),
_ => {}
};
Command::none()
Expand Down
1 change: 1 addition & 0 deletions liana-gui/src/app/view/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub enum SettingsEditMessage {
BitcoindRpcAuthTypeSelected(RpcAuthType),
Cancel,
Confirm,
Clipboard(String),
}

#[derive(Debug, Clone)]
Expand Down
27 changes: 23 additions & 4 deletions liana-gui/src/app/view/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,11 +504,23 @@ pub fn bitcoind<'a>(

let mut col_fields = Column::new();
for (k, v) in rows {
col_fields = col_fields.push(
col_fields = col_fields.push({
let t = if k == "Password:" {
"*".to_string().repeat(v.len())
} else {
v.clone()
};
Row::new()
.push(Container::new(text(k).bold().small()).width(Length::Fill))
.push(text(v).small()),
);
.push(text(t).small())
.push(Space::with_width(10))
.push(
Button::new(icon::clipboard_icon())
.style(theme::Button::TransparentBorder)
.on_press(SettingsEditMessage::Clipboard(v.to_string())),
)
.align_items(Alignment::Center)
});
}

card::simple(Container::new(
Expand Down Expand Up @@ -685,7 +697,14 @@ pub fn electrum<'a>(
col_fields = col_fields.push(
Row::new()
.push(Container::new(text(k).bold().small()).width(Length::Fill))
.push(text(v).small()),
.push(text(v.clone()).small())
.push(Space::with_width(10))
.push(
Button::new(icon::clipboard_icon())
.style(theme::Button::TransparentBorder)
.on_press(SettingsEditMessage::Clipboard(v.to_string())),
)
.align_items(Alignment::Center),
);
}

Expand Down

0 comments on commit ecce76a

Please sign in to comment.