installer: let user reset the descriptor template

This commit is contained in:
pythcoiner 2025-05-21 18:01:48 +02:00
parent ce8e1f3c3e
commit a51704fcc6
No known key found for this signature in database
GPG Key ID: C1048AEEDF303B88
5 changed files with 36 additions and 7 deletions

View File

@ -165,6 +165,7 @@ pub enum DefineDescriptor {
AddSafetyNetPath, AddSafetyNetPath,
KeyModal(ImportKeyModal), KeyModal(ImportKeyModal),
ThresholdSequenceModal(ThresholdSequenceModal), ThresholdSequenceModal(ThresholdSequenceModal),
Reset,
} }
#[allow(clippy::large_enum_variant)] #[allow(clippy::large_enum_variant)]

View File

@ -218,6 +218,12 @@ impl Step for DefineDescriptor {
self.modal = Some(Box::new(modal)); self.modal = Some(Box::new(modal));
return cmd; 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)) => { Message::DefineDescriptor(message::DefineDescriptor::Path(i, msg)) => {
match msg { match msg {
message::DefinePath::SequenceEdited(seq) => { message::DefinePath::SequenceEdited(seq) => {

View File

@ -253,12 +253,20 @@ pub fn custom_template<'a>(
Message::DefineDescriptor(message::DefineDescriptor::Path(sn_index + 1, msg)) Message::DefineDescriptor(message::DefineDescriptor::Path(sn_index + 1, msg))
}) })
})) }))
.push(Space::with_height(10))
.push( .push(
Row::new().push(Space::with_width(Length::Fill)).push( Row::new()
button::primary(None, "Continue") .push(
.width(Length::Fixed(200.0)) button::secondary(None, "Clear All")
.on_press_maybe(if valid { Some(Message::Next) } else { None }), .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)) .push(Space::with_height(100.0))
.spacing(20), .spacing(20),

View File

@ -160,11 +160,18 @@ pub fn inheritance_template<'a>(
) )
.map(|msg| Message::DefineDescriptor(message::DefineDescriptor::Path(1, msg))), .map(|msg| Message::DefineDescriptor(message::DefineDescriptor::Path(1, msg))),
) )
.push(Space::with_height(10))
.push( .push(
Row::new() 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( .push(
button::secondary(None, "Customize") button::secondary(None, "Customize")
.width(Length::Fixed(200.0)) .width(Length::Fixed(120.0))
.on_press(Message::DefineDescriptor( .on_press(Message::DefineDescriptor(
message::DefineDescriptor::ChangeTemplate( message::DefineDescriptor::ChangeTemplate(
context::DescriptorTemplate::Custom, context::DescriptorTemplate::Custom,

View File

@ -230,11 +230,18 @@ pub fn multisig_security_template<'a>(
} }
}), }),
) )
.push(Space::with_height(10))
.push( .push(
Row::new() 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( .push(
button::secondary(None, "Customize") button::secondary(None, "Customize")
.width(Length::Fixed(200.0)) .width(Length::Fixed(120.0))
.on_press(Message::DefineDescriptor( .on_press(Message::DefineDescriptor(
message::DefineDescriptor::ChangeTemplate( message::DefineDescriptor::ChangeTemplate(
context::DescriptorTemplate::Custom, context::DescriptorTemplate::Custom,