From 5db64f5c205beb4fd66a900e8182a74519a8632f Mon Sep 17 00:00:00 2001 From: Shubhranshu Sanjeev Date: Mon, 18 Nov 2024 19:47:01 +0530 Subject: [PATCH] fix: resolved comments --- crates/frontend/src/pages/context_override.rs | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/crates/frontend/src/pages/context_override.rs b/crates/frontend/src/pages/context_override.rs index cd3107a6..fedbb1ee 100644 --- a/crates/frontend/src/pages/context_override.rs +++ b/crates/frontend/src/pages/context_override.rs @@ -207,30 +207,40 @@ pub fn context_override() -> impl IntoView { let on_context_edit = Callback::new(move |data: (Context, Map)| { let (context, overrides) = data; - let conditions = - Conditions::from_context_json(&context.condition.into()).unwrap(); - - selected_context_ws.set(Some(Data { - context: conditions, - overrides: overrides.into_iter().collect::>(), - })); - set_form_mode.set(Some(FormMode::Edit)); - - open_drawer("context_and_override_drawer"); + match Conditions::from_context_json(&context.condition.into()) { + Ok(conditions) => { + selected_context_ws.set(Some(Data { + context: conditions, + overrides: overrides.into_iter().collect::>(), + })); + set_form_mode.set(Some(FormMode::Edit)); + open_drawer("context_and_override_drawer"); + } + Err(e) => { + logging::error!("Error parsing context: {}", e); + enqueue_alert(e.to_string(), AlertType::Error, 5000); + } + }; }); let on_context_clone = Callback::new(move |data: (Context, Map)| { let (context, overrides) = data; - let conditions = - Conditions::from_context_json(&context.condition.into()).unwrap(); - selected_context_ws.set(Some(Data { - context: conditions, - overrides: overrides.into_iter().collect::>(), - })); - set_form_mode.set(Some(FormMode::Create)); + match Conditions::from_context_json(&context.condition.into()) { + Ok(conditions) => { + selected_context_ws.set(Some(Data { + context: conditions, + overrides: overrides.into_iter().collect::>(), + })); + set_form_mode.set(Some(FormMode::Create)); - open_drawer("context_and_override_drawer"); + open_drawer("context_and_override_drawer"); + } + Err(e) => { + logging::error!("Error parsing context: {}", e); + enqueue_alert(e.to_string(), AlertType::Error, 5000); + } + }; }); let on_context_delete = Callback::new(move |id: String| {