From a51704fcc66fcfa7e5bc133eaf2f7c406ee19e8b Mon Sep 17 00:00:00 2001 From: pythcoiner Date: Wed, 21 May 2025 18:01:48 +0200 Subject: [PATCH] installer: let user reset the descriptor template --- liana-gui/src/installer/message.rs | 1 + .../installer/step/descriptor/editor/mod.rs | 6 ++++++ .../installer/view/editor/template/custom.rs | 18 +++++++++++++----- .../view/editor/template/inheritance.rs | 9 ++++++++- .../template/multisig_security_wallet.rs | 9 ++++++++- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/liana-gui/src/installer/message.rs b/liana-gui/src/installer/message.rs index 04c61840..b4ffb57b 100644 --- a/liana-gui/src/installer/message.rs +++ b/liana-gui/src/installer/message.rs @@ -165,6 +165,7 @@ pub enum DefineDescriptor { AddSafetyNetPath, KeyModal(ImportKeyModal), ThresholdSequenceModal(ThresholdSequenceModal), + Reset, } #[allow(clippy::large_enum_variant)] diff --git a/liana-gui/src/installer/step/descriptor/editor/mod.rs b/liana-gui/src/installer/step/descriptor/editor/mod.rs index d9c33571..7be260b0 100644 --- a/liana-gui/src/installer/step/descriptor/editor/mod.rs +++ b/liana-gui/src/installer/step/descriptor/editor/mod.rs @@ -218,6 +218,12 @@ impl Step for DefineDescriptor { self.modal = Some(Box::new(modal)); return cmd; } + Message::DefineDescriptor(message::DefineDescriptor::Reset) => { + self.keys.clear(); + self.paths.clear(); + self.load_template(self.descriptor_template); + self.modal = None; + } Message::DefineDescriptor(message::DefineDescriptor::Path(i, msg)) => { match msg { message::DefinePath::SequenceEdited(seq) => { diff --git a/liana-gui/src/installer/view/editor/template/custom.rs b/liana-gui/src/installer/view/editor/template/custom.rs index 78d0b2c1..af34b624 100644 --- a/liana-gui/src/installer/view/editor/template/custom.rs +++ b/liana-gui/src/installer/view/editor/template/custom.rs @@ -253,12 +253,20 @@ pub fn custom_template<'a>( Message::DefineDescriptor(message::DefineDescriptor::Path(sn_index + 1, msg)) }) })) + .push(Space::with_height(10)) .push( - Row::new().push(Space::with_width(Length::Fill)).push( - button::primary(None, "Continue") - .width(Length::Fixed(200.0)) - .on_press_maybe(if valid { Some(Message::Next) } else { None }), - ), + Row::new() + .push( + button::secondary(None, "Clear All") + .width(Length::Fixed(200.0)) + .on_press(Message::DefineDescriptor(message::DefineDescriptor::Reset)), + ) + .push(Space::with_width(Length::Fill)) + .push( + button::primary(None, "Continue") + .width(Length::Fixed(200.0)) + .on_press_maybe(if valid { Some(Message::Next) } else { None }), + ), ) .push(Space::with_height(100.0)) .spacing(20), diff --git a/liana-gui/src/installer/view/editor/template/inheritance.rs b/liana-gui/src/installer/view/editor/template/inheritance.rs index 4d076bec..34a3c639 100644 --- a/liana-gui/src/installer/view/editor/template/inheritance.rs +++ b/liana-gui/src/installer/view/editor/template/inheritance.rs @@ -160,11 +160,18 @@ pub fn inheritance_template<'a>( ) .map(|msg| Message::DefineDescriptor(message::DefineDescriptor::Path(1, msg))), ) + .push(Space::with_height(10)) .push( Row::new() + .push( + button::secondary(None, "Clear All") + .width(Length::Fixed(120.0)) + .on_press(Message::DefineDescriptor(message::DefineDescriptor::Reset)), + ) + .push(Space::with_width(40)) .push( button::secondary(None, "Customize") - .width(Length::Fixed(200.0)) + .width(Length::Fixed(120.0)) .on_press(Message::DefineDescriptor( message::DefineDescriptor::ChangeTemplate( context::DescriptorTemplate::Custom, diff --git a/liana-gui/src/installer/view/editor/template/multisig_security_wallet.rs b/liana-gui/src/installer/view/editor/template/multisig_security_wallet.rs index d8cf1c57..ba49b163 100644 --- a/liana-gui/src/installer/view/editor/template/multisig_security_wallet.rs +++ b/liana-gui/src/installer/view/editor/template/multisig_security_wallet.rs @@ -230,11 +230,18 @@ pub fn multisig_security_template<'a>( } }), ) + .push(Space::with_height(10)) .push( Row::new() + .push( + button::secondary(None, "Clear All") + .width(Length::Fixed(120.0)) + .on_press(Message::DefineDescriptor(message::DefineDescriptor::Reset)), + ) + .push(Space::with_width(40)) .push( button::secondary(None, "Customize") - .width(Length::Fixed(200.0)) + .width(Length::Fixed(120.0)) .on_press(Message::DefineDescriptor( message::DefineDescriptor::ChangeTemplate( context::DescriptorTemplate::Custom,