Skip to content

Commit

Permalink
feat: Create Experiments From Overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
yuvrajjsingh0 committed Feb 25, 2025
1 parent 95a0caf commit ddff41d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 4 additions & 4 deletions crates/frontend/src/components/experiment_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ pub fn experiment_form<NF>(
name: String,
context: Conditions,
variants: VariantFormTs,
#[prop(default=vec![])] overrides: Vec<(String, Value)>,
#[prop(default=Vec::new())] overrides: Vec<(String, Value)>,
handle_submit: NF,
default_config: Vec<DefaultConfig>,
dimensions: Vec<DimensionWithMandatory>,
#[prop(default = String::new())] description: String,
#[prop(default = String::new())] change_reason: String,
) -> impl IntoView
where
NF: Fn() + 'static + Clone,
NF: Fn(String) + 'static + Clone,
{
let init_variants = get_init_state(&variants, overrides);
let default_config = StoredValue::new(default_config);
Expand Down Expand Up @@ -147,8 +147,8 @@ where
};

match result {
Ok(_) => {
handle_submit_clone();
Ok(res) => {
handle_submit_clone(res["experiment_id"].as_str().unwrap_or("").to_string());
let success_message = if edit {
"Experiment updated successfully!"
} else {
Expand Down
7 changes: 6 additions & 1 deletion crates/frontend/src/pages/context_override.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use futures::join;
use leptos::*;
use leptos_router::use_navigate;
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
use superposition_types::{
Expand Down Expand Up @@ -278,9 +279,13 @@ pub fn context_override() -> impl IntoView {
}
};
});
let handle_submit_experiment_form = move || {
let handle_submit_experiment_form = move |experiment_id: String| {
page_resource.refetch();
close_drawer("create_exp_drawer");

let navigate = use_navigate();
let redirect_url = format!("/admin/orgid163684578793361413/test/experiments/{experiment_id}");
navigate(redirect_url.as_str(), Default::default())
};

let handle_create_experiment =
Expand Down
2 changes: 1 addition & 1 deletion crates/frontend/src/pages/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn experiment_page() -> impl IntoView {
variants=FromIterator::from_iter(experiment_ef.variants)
default_config=default_config
dimensions=dimensions
handle_submit=move || { combined_resource.refetch() }
handle_submit=move |_| { combined_resource.refetch() }
/>
</EditorProvider>

Expand Down
2 changes: 1 addition & 1 deletion crates/frontend/src/pages/experiment_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ pub fn experiment_list() -> impl IntoView {
},
);

let handle_submit_experiment_form = move || {
let handle_submit_experiment_form = move |_| {
combined_resource.refetch();
set_exp_form.update(|val| {
*val += 1;
Expand Down

0 comments on commit ddff41d

Please sign in to comment.