mirror of
https://github.com/librekeys/picoforge.git
synced 2026-07-28 08:01:19 -07:00
chore: rename local variables across UI module for readability
- dialog.rs: pin entity/text bindings (current/new/confirm) - config/view_model.rs: entity→weak_self, parsed_gpio/driver_value, new_* form fields - config/view.rs: fido_no_rskey→is_fido_no_rskey - passkeys/view_model.rs: entity→weak_self, new→new_pin_value, s→submit_clone/status_content - passkeys/view.rs: ep_set→enterprise_attestation_set - home/view.rs: rk→resident_keys_supported, ep_set→enterprise_attestation_set - sidebar.rs: t→padding_anim_t - ci.yml: fix audit-check short SHA→full SHA
This commit is contained in:
+62
-56
@@ -549,27 +549,27 @@ impl ChangePinContent {
|
||||
return;
|
||||
}
|
||||
|
||||
let current_val = self.current_pin.read(cx).text().to_string();
|
||||
let new_val = self.new_pin.read(cx).text().to_string();
|
||||
let confirm_val = self.confirm_pin.read(cx).text().to_string();
|
||||
let current_pin_text = self.current_pin.read(cx).text().to_string();
|
||||
let new_pin_text = self.new_pin.read(cx).text().to_string();
|
||||
let confirm_pin_text = self.confirm_pin.read(cx).text().to_string();
|
||||
|
||||
if current_val.is_empty() {
|
||||
if current_pin_text.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val != confirm_val {
|
||||
if new_pin_text != confirm_pin_text {
|
||||
self.set_error("PINs do not match".to_string(), cx);
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val.len() < 4 {
|
||||
if new_pin_text.len() < 4 {
|
||||
self.set_error("PIN must be at least 4 characters".to_string(), cx);
|
||||
return;
|
||||
}
|
||||
|
||||
let handle = cx.entity().downgrade();
|
||||
self.set_loading(cx);
|
||||
(self.on_confirm)(current_val, new_val, handle, cx);
|
||||
(self.on_confirm)(current_pin_text, new_pin_text, handle, cx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -632,9 +632,9 @@ impl Render for ChangePinContent {
|
||||
.into_any_element(),
|
||||
|
||||
DialogPhase::Error(err_msg) => {
|
||||
let current = self.current_pin.clone();
|
||||
let new = self.new_pin.clone();
|
||||
let confirm = self.confirm_pin.clone();
|
||||
let current_pin_entity = self.current_pin.clone();
|
||||
let new_pin_entity = self.new_pin.clone();
|
||||
let confirm_pin_entity = self.confirm_pin.clone();
|
||||
let on_confirm = self.on_confirm.clone();
|
||||
let handle = cx.entity().downgrade();
|
||||
|
||||
@@ -655,11 +655,11 @@ impl Render for ChangePinContent {
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child("Current PIN")
|
||||
.child(Input::new(¤t))
|
||||
.child(Input::new(¤t_pin_entity))
|
||||
.child("New PIN")
|
||||
.child(Input::new(&new))
|
||||
.child(Input::new(&new_pin_entity))
|
||||
.child("Confirm New PIN")
|
||||
.child(Input::new(&confirm)),
|
||||
.child(Input::new(&confirm_pin_entity)),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -672,15 +672,17 @@ impl Render for ChangePinContent {
|
||||
)
|
||||
.child(Button::new("confirm").primary().label("Confirm").on_click(
|
||||
move |_, _, cx| {
|
||||
let current_val = current.read(cx).text().to_string();
|
||||
let new_val = new.read(cx).text().to_string();
|
||||
let confirm_val = confirm.read(cx).text().to_string();
|
||||
let current_pin_text =
|
||||
current_pin_entity.read(cx).text().to_string();
|
||||
let new_pin_text = new_pin_entity.read(cx).text().to_string();
|
||||
let confirm_pin_text =
|
||||
confirm_pin_entity.read(cx).text().to_string();
|
||||
|
||||
if current_val.is_empty() {
|
||||
if current_pin_text.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val != confirm_val {
|
||||
if new_pin_text != confirm_pin_text {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error("PINs do not match".to_string(), cx);
|
||||
@@ -689,7 +691,7 @@ impl Render for ChangePinContent {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val.len() < 4 {
|
||||
if new_pin_text.len() < 4 {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error(
|
||||
@@ -704,7 +706,7 @@ impl Render for ChangePinContent {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| this.set_loading(cx));
|
||||
}
|
||||
on_confirm(current_val, new_val, handle.clone(), cx);
|
||||
on_confirm(current_pin_text, new_pin_text, handle.clone(), cx);
|
||||
},
|
||||
)),
|
||||
)
|
||||
@@ -712,9 +714,9 @@ impl Render for ChangePinContent {
|
||||
}
|
||||
|
||||
DialogPhase::Input => {
|
||||
let current = self.current_pin.clone();
|
||||
let new = self.new_pin.clone();
|
||||
let confirm = self.confirm_pin.clone();
|
||||
let current_pin_entity = self.current_pin.clone();
|
||||
let new_pin_entity = self.new_pin.clone();
|
||||
let confirm_pin_entity = self.confirm_pin.clone();
|
||||
let on_confirm = self.on_confirm.clone();
|
||||
let handle = cx.entity().downgrade();
|
||||
|
||||
@@ -725,11 +727,11 @@ impl Render for ChangePinContent {
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child("Current PIN")
|
||||
.child(Input::new(¤t))
|
||||
.child(Input::new(¤t_pin_entity))
|
||||
.child("New PIN")
|
||||
.child(Input::new(&new))
|
||||
.child(Input::new(&new_pin_entity))
|
||||
.child("Confirm New PIN")
|
||||
.child(Input::new(&confirm)),
|
||||
.child(Input::new(&confirm_pin_entity)),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -742,15 +744,17 @@ impl Render for ChangePinContent {
|
||||
)
|
||||
.child(Button::new("confirm").primary().label("Confirm").on_click(
|
||||
move |_, _, cx| {
|
||||
let current_val = current.read(cx).text().to_string();
|
||||
let new_val = new.read(cx).text().to_string();
|
||||
let confirm_val = confirm.read(cx).text().to_string();
|
||||
let current_pin_text =
|
||||
current_pin_entity.read(cx).text().to_string();
|
||||
let new_pin_text = new_pin_entity.read(cx).text().to_string();
|
||||
let confirm_pin_text =
|
||||
confirm_pin_entity.read(cx).text().to_string();
|
||||
|
||||
if current_val.is_empty() {
|
||||
if current_pin_text.is_empty() {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val != confirm_val {
|
||||
if new_pin_text != confirm_pin_text {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error("PINs do not match".to_string(), cx);
|
||||
@@ -759,7 +763,7 @@ impl Render for ChangePinContent {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val.len() < 4 {
|
||||
if new_pin_text.len() < 4 {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error(
|
||||
@@ -774,7 +778,7 @@ impl Render for ChangePinContent {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| this.set_loading(cx));
|
||||
}
|
||||
on_confirm(current_val, new_val, handle.clone(), cx);
|
||||
on_confirm(current_pin_text, new_pin_text, handle.clone(), cx);
|
||||
},
|
||||
)),
|
||||
)
|
||||
@@ -869,22 +873,22 @@ impl SetPinContent {
|
||||
return;
|
||||
}
|
||||
|
||||
let new_val = self.new_pin.read(cx).text().to_string();
|
||||
let confirm_val = self.confirm_pin.read(cx).text().to_string();
|
||||
let new_pin_text = self.new_pin.read(cx).text().to_string();
|
||||
let confirm_pin_text = self.confirm_pin.read(cx).text().to_string();
|
||||
|
||||
if new_val != confirm_val {
|
||||
if new_pin_text != confirm_pin_text {
|
||||
self.set_error("PINs do not match".to_string(), cx);
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val.len() < 4 {
|
||||
if new_pin_text.len() < 4 {
|
||||
self.set_error("PIN must be at least 4 characters".to_string(), cx);
|
||||
return;
|
||||
}
|
||||
|
||||
let handle = cx.entity().downgrade();
|
||||
self.set_loading(cx);
|
||||
(self.on_confirm)(new_val, handle, cx);
|
||||
(self.on_confirm)(new_pin_text, handle, cx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -945,8 +949,8 @@ impl Render for SetPinContent {
|
||||
.into_any_element(),
|
||||
|
||||
DialogPhase::Error(err_msg) => {
|
||||
let new = self.new_pin.clone();
|
||||
let confirm = self.confirm_pin.clone();
|
||||
let new_pin_entity = self.new_pin.clone();
|
||||
let confirm_pin_entity = self.confirm_pin.clone();
|
||||
let on_confirm = self.on_confirm.clone();
|
||||
let handle = cx.entity().downgrade();
|
||||
|
||||
@@ -967,9 +971,9 @@ impl Render for SetPinContent {
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child("New PIN")
|
||||
.child(Input::new(&new))
|
||||
.child(Input::new(&new_pin_entity))
|
||||
.child("Confirm New PIN")
|
||||
.child(Input::new(&confirm)),
|
||||
.child(Input::new(&confirm_pin_entity)),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -982,10 +986,11 @@ impl Render for SetPinContent {
|
||||
)
|
||||
.child(Button::new("confirm").primary().label("Confirm").on_click(
|
||||
move |_, _, cx| {
|
||||
let new_val = new.read(cx).text().to_string();
|
||||
let confirm_val = confirm.read(cx).text().to_string();
|
||||
let new_pin_text = new_pin_entity.read(cx).text().to_string();
|
||||
let confirm_pin_text =
|
||||
confirm_pin_entity.read(cx).text().to_string();
|
||||
|
||||
if new_val != confirm_val {
|
||||
if new_pin_text != confirm_pin_text {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error("PINs do not match".to_string(), cx);
|
||||
@@ -994,7 +999,7 @@ impl Render for SetPinContent {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val.len() < 4 {
|
||||
if new_pin_text.len() < 4 {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error(
|
||||
@@ -1009,7 +1014,7 @@ impl Render for SetPinContent {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| this.set_loading(cx));
|
||||
}
|
||||
on_confirm(new_val, handle.clone(), cx);
|
||||
on_confirm(new_pin_text, handle.clone(), cx);
|
||||
},
|
||||
)),
|
||||
)
|
||||
@@ -1017,8 +1022,8 @@ impl Render for SetPinContent {
|
||||
}
|
||||
|
||||
DialogPhase::Input => {
|
||||
let new = self.new_pin.clone();
|
||||
let confirm = self.confirm_pin.clone();
|
||||
let new_pin_entity = self.new_pin.clone();
|
||||
let confirm_pin_entity = self.confirm_pin.clone();
|
||||
let on_confirm = self.on_confirm.clone();
|
||||
let handle = cx.entity().downgrade();
|
||||
|
||||
@@ -1029,9 +1034,9 @@ impl Render for SetPinContent {
|
||||
v_flex()
|
||||
.gap_4()
|
||||
.child("New PIN")
|
||||
.child(Input::new(&new))
|
||||
.child(Input::new(&new_pin_entity))
|
||||
.child("Confirm New PIN")
|
||||
.child(Input::new(&confirm)),
|
||||
.child(Input::new(&confirm_pin_entity)),
|
||||
)
|
||||
.child(
|
||||
h_flex()
|
||||
@@ -1044,10 +1049,11 @@ impl Render for SetPinContent {
|
||||
)
|
||||
.child(Button::new("confirm").primary().label("Confirm").on_click(
|
||||
move |_, _, cx| {
|
||||
let new_val = new.read(cx).text().to_string();
|
||||
let confirm_val = confirm.read(cx).text().to_string();
|
||||
let new_pin_text = new_pin_entity.read(cx).text().to_string();
|
||||
let confirm_pin_text =
|
||||
confirm_pin_entity.read(cx).text().to_string();
|
||||
|
||||
if new_val != confirm_val {
|
||||
if new_pin_text != confirm_pin_text {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error("PINs do not match".to_string(), cx);
|
||||
@@ -1056,7 +1062,7 @@ impl Render for SetPinContent {
|
||||
return;
|
||||
}
|
||||
|
||||
if new_val.len() < 4 {
|
||||
if new_pin_text.len() < 4 {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| {
|
||||
this.set_error(
|
||||
@@ -1071,7 +1077,7 @@ impl Render for SetPinContent {
|
||||
if let Some(h) = handle.upgrade() {
|
||||
h.update(cx, |this, cx| this.set_loading(cx));
|
||||
}
|
||||
on_confirm(new_val, handle.clone(), cx);
|
||||
on_confirm(new_pin_text, handle.clone(), cx);
|
||||
},
|
||||
)),
|
||||
)
|
||||
|
||||
@@ -124,8 +124,8 @@ impl Render for AppSidebar {
|
||||
|
||||
// ── Header ────────────────────────────────────────────────────
|
||||
let header = {
|
||||
let t = ((sidebar_width - px(48.)) / (px(255.) - px(48.))).clamp(0.0, 1.0);
|
||||
let padding_left = px(8.) + (px(16.) - px(8.)) * t;
|
||||
let padding_anim_t = ((sidebar_width - px(48.)) / (px(255.) - px(48.))).clamp(0.0, 1.0);
|
||||
let padding_left = px(8.) + (px(16.) - px(8.)) * padding_anim_t;
|
||||
|
||||
let width_icon_start = px(120.);
|
||||
let t_icon = ((sidebar_width - px(48.)) / (width_icon_start - px(48.))).clamp(0.0, 1.0);
|
||||
|
||||
@@ -627,20 +627,20 @@ impl Render for ConfigViewModel {
|
||||
|
||||
// RS-Key supports full config read/write over FIDO via CONFIG_READ/CONFIG_WRITE.
|
||||
// Other firmwares (pico-fido) don't: product name, LED driver, curves, etc.
|
||||
let fido_no_rskey = is_fido && !is_rskey;
|
||||
let is_fido_no_rskey = is_fido && !is_rskey;
|
||||
|
||||
let led_card = self
|
||||
.render_led_card(cx, fido_no_rskey, hardware_config_disabled)
|
||||
.render_led_card(cx, is_fido_no_rskey, hardware_config_disabled)
|
||||
.into_any_element();
|
||||
let options_card = self
|
||||
.render_options_card(cx, hardware_config_disabled)
|
||||
.into_any_element();
|
||||
|
||||
let identity_card = self
|
||||
.render_identity_card(cx.theme(), fido_no_rskey, hardware_config_disabled)
|
||||
.render_identity_card(cx.theme(), is_fido_no_rskey, hardware_config_disabled)
|
||||
.into_any_element();
|
||||
let touch_card = self
|
||||
.render_touch_card(cx.theme(), fido_no_rskey)
|
||||
.render_touch_card(cx.theme(), is_fido_no_rskey)
|
||||
.into_any_element();
|
||||
|
||||
let is_wide = window.bounds().size.width > px(1100.0);
|
||||
|
||||
@@ -441,7 +441,7 @@ impl ConfigViewModel {
|
||||
self.loading = true;
|
||||
cx.notify();
|
||||
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
let method_clone = method.clone();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
@@ -459,7 +459,7 @@ impl ConfigViewModel {
|
||||
.await;
|
||||
|
||||
if !device_still_matches {
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
this.device.update(cx, |repo, repo_cx| {
|
||||
repo.refresh(repo_cx);
|
||||
@@ -519,7 +519,7 @@ impl ConfigViewModel {
|
||||
None
|
||||
};
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
|
||||
match result {
|
||||
@@ -667,11 +667,11 @@ impl ConfigViewModel {
|
||||
|
||||
let mut final_led_gpio = current_led_gpio;
|
||||
let led_gpio_str = self.led_gpio_input.read(cx).text().to_string();
|
||||
if let Ok(val) = led_gpio_str.parse::<u8>() {
|
||||
if val != current_led_gpio {
|
||||
if let Ok(parsed_gpio) = led_gpio_str.parse::<u8>() {
|
||||
if parsed_gpio != current_led_gpio {
|
||||
has_changes = true;
|
||||
}
|
||||
final_led_gpio = val;
|
||||
final_led_gpio = parsed_gpio;
|
||||
}
|
||||
|
||||
let mut final_led_driver = current_led_driver;
|
||||
@@ -679,12 +679,12 @@ impl ConfigViewModel {
|
||||
if let Some(idx) = driver_idx
|
||||
&& let Some(driver) = LedDriverType::all().get(idx.row)
|
||||
{
|
||||
let val = driver.value();
|
||||
let current_val = current_led_driver.unwrap_or(1);
|
||||
if val != current_val {
|
||||
let driver_value = driver.value();
|
||||
let current_driver_value = current_led_driver.unwrap_or(1);
|
||||
if driver_value != current_driver_value {
|
||||
has_changes = true;
|
||||
}
|
||||
final_led_driver = Some(val);
|
||||
final_led_driver = Some(driver_value);
|
||||
}
|
||||
|
||||
let brightness = self.led_brightness_slider.read(cx).value().start() as u8;
|
||||
@@ -825,19 +825,19 @@ impl ConfigViewModel {
|
||||
let device = self.device.read(cx);
|
||||
let config = device.status.as_ref().map(|s| &s.config);
|
||||
|
||||
let vid = config
|
||||
let new_vid = config
|
||||
.map(|c| c.vid.clone())
|
||||
.unwrap_or_else(|| "CAFE".into());
|
||||
let pid = config
|
||||
let new_pid = config
|
||||
.map(|c| c.pid.clone())
|
||||
.unwrap_or_else(|| "4242".into());
|
||||
let product = config
|
||||
let new_product = config
|
||||
.map(|c| c.product_name.clone())
|
||||
.unwrap_or_else(|| "My Key".into());
|
||||
let gpio = config
|
||||
let new_gpio = config
|
||||
.map(|c| c.led_gpio.to_string())
|
||||
.unwrap_or_else(|| "25".into());
|
||||
let timeout = config
|
||||
let new_timeout = config
|
||||
.map(|c| c.touch_timeout.to_string())
|
||||
.unwrap_or_else(|| "10".into());
|
||||
|
||||
@@ -865,7 +865,7 @@ impl ConfigViewModel {
|
||||
|
||||
self.enabled_usb_itf = config.and_then(|c| c.enabled_usb_itf);
|
||||
|
||||
let preset = UsbIdentityPreset::from_vid_pid(&vid, &pid);
|
||||
let preset = UsbIdentityPreset::from_vid_pid(&new_vid, &new_pid);
|
||||
self.is_custom_vendor = preset == UsbIdentityPreset::Custom;
|
||||
let preset_idx = UsbIdentityPreset::all()
|
||||
.iter()
|
||||
@@ -880,15 +880,15 @@ impl ConfigViewModel {
|
||||
});
|
||||
|
||||
self.vid_input
|
||||
.update(cx, |input, cx| input.set_value(vid, window, cx));
|
||||
.update(cx, |input, cx| input.set_value(new_vid, window, cx));
|
||||
self.pid_input
|
||||
.update(cx, |input, cx| input.set_value(pid, window, cx));
|
||||
.update(cx, |input, cx| input.set_value(new_pid, window, cx));
|
||||
self.product_name_input
|
||||
.update(cx, |input, cx| input.set_value(product, window, cx));
|
||||
.update(cx, |input, cx| input.set_value(new_product, window, cx));
|
||||
self.led_gpio_input
|
||||
.update(cx, |input, cx| input.set_value(gpio, window, cx));
|
||||
.update(cx, |input, cx| input.set_value(new_gpio, window, cx));
|
||||
self.touch_timeout_input
|
||||
.update(cx, |input, cx| input.set_value(timeout, window, cx));
|
||||
.update(cx, |input, cx| input.set_value(new_timeout, window, cx));
|
||||
self.led_brightness_slider
|
||||
.update(cx, |slider, cx| slider.set_value(brightness, window, cx));
|
||||
|
||||
@@ -969,7 +969,7 @@ impl ConfigViewModel {
|
||||
self.loading = true;
|
||||
cx.notify();
|
||||
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -985,7 +985,7 @@ impl ConfigViewModel {
|
||||
None
|
||||
};
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
match result {
|
||||
Ok(_) => {
|
||||
@@ -1089,7 +1089,7 @@ impl ConfigViewModel {
|
||||
self.loading = true;
|
||||
cx.notify();
|
||||
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -1107,7 +1107,7 @@ impl ConfigViewModel {
|
||||
None
|
||||
};
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
match result {
|
||||
Ok(_) => {
|
||||
|
||||
@@ -180,8 +180,14 @@ impl HomeViewModel {
|
||||
.child("Resident Keys"),
|
||||
)
|
||||
.child({
|
||||
let rk = fido.options.get("rk").copied().unwrap_or(false);
|
||||
Tag::new(if rk { "Supported" } else { "Not Supported" }).active(rk)
|
||||
let resident_keys_supported =
|
||||
fido.options.get("rk").copied().unwrap_or(false);
|
||||
Tag::new(if resident_keys_supported {
|
||||
"Supported"
|
||||
} else {
|
||||
"Not Supported"
|
||||
})
|
||||
.active(resident_keys_supported)
|
||||
}),
|
||||
)
|
||||
.child(
|
||||
@@ -210,8 +216,14 @@ impl HomeViewModel {
|
||||
.child("Enterprise attestation"),
|
||||
)
|
||||
.child(div().font_medium().text_color(theme.foreground).child({
|
||||
let ep_set = fido.options.get("ep").copied().unwrap_or(false);
|
||||
Tag::new(if ep_set { "Set" } else { "Not Set" }).active(ep_set)
|
||||
let enterprise_attestation_set =
|
||||
fido.options.get("ep").copied().unwrap_or(false);
|
||||
Tag::new(if enterprise_attestation_set {
|
||||
"Set"
|
||||
} else {
|
||||
"Not Set"
|
||||
})
|
||||
.active(enterprise_attestation_set)
|
||||
})),
|
||||
)
|
||||
.when(fido.remaining_discoverable_credentials.is_some(), |this| {
|
||||
|
||||
@@ -86,7 +86,7 @@ impl PasskeysViewModel {
|
||||
let theme = cx.theme();
|
||||
|
||||
let fido_info = self.device.read(cx).fido_info.clone();
|
||||
let ep_set = fido_info
|
||||
let enterprise_attestation_set = fido_info
|
||||
.as_ref()
|
||||
.and_then(|f| f.options.get("ep").copied())
|
||||
.unwrap_or(false);
|
||||
@@ -111,8 +111,8 @@ impl PasskeysViewModel {
|
||||
.child(
|
||||
h_flex().gap_2().child(
|
||||
Switch::new("enable-ea-switch")
|
||||
.checked(ep_set)
|
||||
.disabled(ep_set)
|
||||
.checked(enterprise_attestation_set)
|
||||
.disabled(enterprise_attestation_set)
|
||||
.on_click(enable_ea_listener),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -63,7 +63,7 @@ impl PasskeysViewModel {
|
||||
cx.notify();
|
||||
|
||||
log::info!("Unlocking FIDO storage...");
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let pin_for_bg = pin.clone();
|
||||
@@ -72,7 +72,7 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::get_credentials_blocking(pin_for_bg) })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
match result {
|
||||
Ok(creds) => {
|
||||
@@ -117,7 +117,7 @@ impl PasskeysViewModel {
|
||||
cx.notify();
|
||||
|
||||
log::info!("Deleting credential...");
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -125,7 +125,7 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::delete_credential_blocking(pin, credential_id) })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| match result {
|
||||
let _ = weak_self.update(cx, |this, cx| match result {
|
||||
Ok(_) => {
|
||||
log::info!("Credential deleted successfully.");
|
||||
let _ = dialog_handle.update(cx, |d, cx| {
|
||||
@@ -146,14 +146,14 @@ impl PasskeysViewModel {
|
||||
}
|
||||
|
||||
fn refresh_credentials(&mut self, pin: String, cx: &mut Context<Self>) {
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
.background_executor()
|
||||
.spawn(async move { DeviceRepo::get_credentials_blocking(pin) })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
if let Ok(creds) = result {
|
||||
this.credentials = creds;
|
||||
@@ -272,7 +272,7 @@ impl PasskeysViewModel {
|
||||
cx.notify();
|
||||
|
||||
log::info!("Setting up FIDO PIN...");
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -280,7 +280,7 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::change_fido_pin_blocking(None, new) })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| match result {
|
||||
let _ = weak_self.update(cx, |this, cx| match result {
|
||||
Ok(msg) => {
|
||||
log::info!("PIN configured: {}", msg);
|
||||
let _ = dialog_handle.update(cx, |d, cx| {
|
||||
@@ -387,7 +387,7 @@ impl PasskeysViewModel {
|
||||
|
||||
window.open_dialog(cx, move |dialog, window, _| {
|
||||
let current = current_pin.clone();
|
||||
let new = new_pin.clone();
|
||||
let new_pin_value = new_pin.clone();
|
||||
let confirm = confirm_pin.clone();
|
||||
let slider_handle = slider.clone();
|
||||
let submit_for_ok = submit.clone();
|
||||
@@ -415,7 +415,7 @@ impl PasskeysViewModel {
|
||||
gpui_component::v_flex()
|
||||
.gap_2()
|
||||
.child(format!("New PIN (min {} chars)", current_min))
|
||||
.child(gpui_component::input::Input::new(&new))
|
||||
.child(gpui_component::input::Input::new(&new_pin_value))
|
||||
)
|
||||
.child("Confirm New PIN")
|
||||
.child(gpui_component::input::Input::new(&confirm)),
|
||||
@@ -425,7 +425,7 @@ impl PasskeysViewModel {
|
||||
false
|
||||
})
|
||||
.footer(move |_, _window, _cx, _| {
|
||||
let s = submit_for_btn.clone();
|
||||
let submit_clone = submit_for_btn.clone();
|
||||
vec![
|
||||
gpui_component::button::Button::new("cancel")
|
||||
.label("Cancel")
|
||||
@@ -434,7 +434,7 @@ impl PasskeysViewModel {
|
||||
.primary()
|
||||
.label("Update")
|
||||
.on_click(move |_, window, cx| {
|
||||
s(window, cx);
|
||||
submit_clone(window, cx);
|
||||
}),
|
||||
]
|
||||
})
|
||||
@@ -455,7 +455,7 @@ impl PasskeysViewModel {
|
||||
cx.notify();
|
||||
|
||||
log::info!("Changing FIDO PIN...");
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
let new_for_sync = new.clone();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
@@ -464,7 +464,7 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::change_fido_pin_blocking(Some(current), new) })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| match result {
|
||||
let _ = weak_self.update(cx, |this, cx| match result {
|
||||
Ok(msg) => {
|
||||
log::info!("PIN changed: {}", msg);
|
||||
let _ = dialog_handle.update(cx, |d, cx| {
|
||||
@@ -498,7 +498,7 @@ impl PasskeysViewModel {
|
||||
self.loading = true;
|
||||
cx.notify();
|
||||
log::info!("Updating minimum PIN length to {}...", min_len);
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let current_for_bg = current.clone();
|
||||
@@ -511,10 +511,10 @@ impl PasskeysViewModel {
|
||||
|
||||
if let Err(e) = res_len {
|
||||
log::error!("Failed to set minimum PIN length: {}", e);
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
let _ = status_handle.update(cx, |s, cx| {
|
||||
s.set_error(format!("Failed to set length: {}", e), cx);
|
||||
let _ = status_handle.update(cx, |status_content, cx| {
|
||||
status_content.set_error(format!("Failed to set length: {}", e), cx);
|
||||
});
|
||||
cx.notify();
|
||||
});
|
||||
@@ -529,28 +529,31 @@ impl PasskeysViewModel {
|
||||
async move { DeviceRepo::change_fido_pin_blocking(Some(current), new_pin) },
|
||||
)
|
||||
.await;
|
||||
let _ = entity.update(cx, |this, cx| match res_pin {
|
||||
let _ = weak_self.update(cx, |this, cx| match res_pin {
|
||||
Ok(_) => {
|
||||
log::info!("Minimum length and PIN updated successfully.");
|
||||
let _ = status_handle.update(cx, |s, cx| {
|
||||
s.set_success("Minimum length and PIN updated.".to_string(), cx);
|
||||
let _ = status_handle.update(cx, |status_content, cx| {
|
||||
status_content
|
||||
.set_success("Minimum length and PIN updated.".to_string(), cx);
|
||||
});
|
||||
this.sync_fido_state(Some(new_pin_for_sync), cx);
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Length set, but PIN change failed: {}", e);
|
||||
this.loading = false;
|
||||
let _ = status_handle.update(cx, |s, cx| {
|
||||
s.set_error(format!("Length set, but PIN change failed: {}", e), cx);
|
||||
let _ = status_handle.update(cx, |status_content, cx| {
|
||||
status_content
|
||||
.set_error(format!("Length set, but PIN change failed: {}", e), cx);
|
||||
});
|
||||
cx.notify();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
log::info!("Minimum PIN length updated to {}.", min_len);
|
||||
let _ = status_handle.update(cx, |s, cx| {
|
||||
s.set_success(format!("Minimum length updated to {}.", min_len), cx);
|
||||
let _ = status_handle.update(cx, |status_content, cx| {
|
||||
status_content
|
||||
.set_success(format!("Minimum length updated to {}.", min_len), cx);
|
||||
});
|
||||
this.sync_fido_state(None, cx);
|
||||
});
|
||||
@@ -571,7 +574,7 @@ impl PasskeysViewModel {
|
||||
cx.notify();
|
||||
|
||||
log::info!("Request Attestation CSR...");
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -579,15 +582,15 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::get_enterprise_attestation_csr_blocking() })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
this.csr_loading = false;
|
||||
match result {
|
||||
Ok(pem) => {
|
||||
log::info!("CSR retrieved successfully ({} bytes).", pem.len());
|
||||
this.csr_pem = Some(pem);
|
||||
let _ = status_handle.update(cx, |s, cx| {
|
||||
s.set_success(
|
||||
let _ = status_handle.update(cx, |status_content, cx| {
|
||||
status_content.set_success(
|
||||
"CSR retrieved from device. Click \"View CSR\" to inspect or save it.".to_string(),
|
||||
cx,
|
||||
);
|
||||
@@ -595,8 +598,8 @@ impl PasskeysViewModel {
|
||||
}
|
||||
Err(e) => {
|
||||
log::error!("Failed to retrieve CSR: {}", e);
|
||||
let _ = status_handle.update(cx, |s, cx| {
|
||||
s.set_error(format!("Failed to retrieve CSR: {}", e), cx);
|
||||
let _ = status_handle.update(cx, |status_content, cx| {
|
||||
status_content.set_error(format!("Failed to retrieve CSR: {}", e), cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -622,7 +625,7 @@ impl PasskeysViewModel {
|
||||
"Uploading enterprise attestation certificate from: {}",
|
||||
cert_path
|
||||
);
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -632,7 +635,7 @@ impl PasskeysViewModel {
|
||||
})
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
match result {
|
||||
Ok(msg) => {
|
||||
@@ -684,7 +687,7 @@ impl PasskeysViewModel {
|
||||
cx.notify();
|
||||
|
||||
log::info!("Enabling enterprise attestation...");
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
self._task = Some(cx.spawn(async move |_, cx| {
|
||||
let result = cx
|
||||
@@ -692,7 +695,7 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::enable_enterprise_attestation_blocking(pin) })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| match result {
|
||||
let _ = weak_self.update(cx, |this, cx| match result {
|
||||
Ok(msg) => {
|
||||
log::info!("{}", msg);
|
||||
let _ = dialog_handle.update(cx, |d, cx| {
|
||||
@@ -714,7 +717,7 @@ impl PasskeysViewModel {
|
||||
|
||||
pub(super) fn open_upload_cert_dialog(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
let window_handle = window.window_handle();
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
let receiver = cx.prompt_for_paths(gpui::PathPromptOptions {
|
||||
files: true,
|
||||
@@ -741,7 +744,7 @@ impl PasskeysViewModel {
|
||||
window,
|
||||
cx,
|
||||
move |pin, dialog_handle, cx| {
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.execute_upload_cert(pin, cert_path.clone(), dialog_handle, cx);
|
||||
});
|
||||
},
|
||||
@@ -776,7 +779,7 @@ impl PasskeysViewModel {
|
||||
self.loading = true;
|
||||
|
||||
let status_handle = dialog::open_status_dialog("Resetting Device...", window, cx);
|
||||
let entity = cx.entity().downgrade();
|
||||
let weak_self = cx.entity().downgrade();
|
||||
|
||||
let _ = status_handle.update(cx, |d, cx| {
|
||||
d.set_loading(
|
||||
@@ -808,7 +811,7 @@ impl PasskeysViewModel {
|
||||
.await;
|
||||
|
||||
if !reconnected {
|
||||
let _ = entity.update(cx, |this, cx| {
|
||||
let _ = weak_self.update(cx, |this, cx| {
|
||||
this.loading = false;
|
||||
let _ = status_handle.update(cx, |d, cx| {
|
||||
d.set_error(
|
||||
@@ -830,7 +833,7 @@ impl PasskeysViewModel {
|
||||
.spawn(async move { DeviceRepo::reset_device_blocking() })
|
||||
.await;
|
||||
|
||||
let _ = entity.update(cx, |this, cx| match result {
|
||||
let _ = weak_self.update(cx, |this, cx| match result {
|
||||
Ok(msg) => {
|
||||
log::info!("Device Reset: {}", msg);
|
||||
this.lock_storage(cx);
|
||||
|
||||
Reference in New Issue
Block a user