gui: forbid edit bitcoind client config if internal
This commit is contained in:
parent
bfe73fad18
commit
6d8c9e437f
@ -72,9 +72,12 @@ impl App {
|
||||
|
||||
fn load_state(&mut self, menu: &Menu) -> Command<Message> {
|
||||
self.state = match menu {
|
||||
menu::Menu::Settings => {
|
||||
state::SettingsState::new(self.data_dir.clone(), self.wallet.clone()).into()
|
||||
}
|
||||
menu::Menu::Settings => state::SettingsState::new(
|
||||
self.data_dir.clone(),
|
||||
self.wallet.clone(),
|
||||
self.internal_bitcoind.is_some(),
|
||||
)
|
||||
.into(),
|
||||
menu::Menu::Home => Home::new(self.wallet.clone(), &self.cache.coins).into(),
|
||||
menu::Menu::Coins => CoinsPanel::new(
|
||||
&self.cache.coins,
|
||||
|
||||
@ -22,13 +22,19 @@ pub struct BitcoindSettingsState {
|
||||
warning: Option<Error>,
|
||||
config_updated: bool,
|
||||
daemon_is_external: bool,
|
||||
bitcoind_is_internal: bool,
|
||||
|
||||
settings: Vec<Box<dyn Setting>>,
|
||||
current: Option<usize>,
|
||||
}
|
||||
|
||||
impl BitcoindSettingsState {
|
||||
pub fn new(config: Option<Config>, cache: &Cache, daemon_is_external: bool) -> Self {
|
||||
pub fn new(
|
||||
config: Option<Config>,
|
||||
cache: &Cache,
|
||||
daemon_is_external: bool,
|
||||
bitcoind_is_internal: bool,
|
||||
) -> Self {
|
||||
let settings = if let Some(config) = &config {
|
||||
vec![
|
||||
BitcoindSettings::new(
|
||||
@ -44,6 +50,7 @@ impl BitcoindSettingsState {
|
||||
|
||||
BitcoindSettingsState {
|
||||
daemon_is_external,
|
||||
bitcoind_is_internal,
|
||||
warning: None,
|
||||
config_updated: false,
|
||||
settings,
|
||||
@ -106,7 +113,8 @@ impl State for BitcoindSettingsState {
|
||||
}
|
||||
|
||||
fn view<'a>(&'a self, cache: &'a Cache) -> Element<'a, view::Message> {
|
||||
let can_edit = self.current.is_none() && !self.daemon_is_external;
|
||||
let can_edit =
|
||||
self.current.is_none() && !self.daemon_is_external && !self.bitcoind_is_internal;
|
||||
view::settings::bitcoind_settings(
|
||||
cache,
|
||||
self.warning.as_ref(),
|
||||
|
||||
@ -32,14 +32,16 @@ pub struct SettingsState {
|
||||
data_dir: PathBuf,
|
||||
wallet: Arc<Wallet>,
|
||||
setting: Option<Box<dyn State>>,
|
||||
internal_bitcoind: bool,
|
||||
}
|
||||
|
||||
impl SettingsState {
|
||||
pub fn new(data_dir: PathBuf, wallet: Arc<Wallet>) -> Self {
|
||||
pub fn new(data_dir: PathBuf, wallet: Arc<Wallet>, internal_bitcoind: bool) -> Self {
|
||||
Self {
|
||||
data_dir,
|
||||
wallet,
|
||||
setting: None,
|
||||
internal_bitcoind,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -58,6 +60,7 @@ impl State for SettingsState {
|
||||
daemon.config().cloned(),
|
||||
cache,
|
||||
daemon.is_external(),
|
||||
self.internal_bitcoind,
|
||||
)
|
||||
.into(),
|
||||
);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user