Skip to content

Commit

Permalink
fix: Add success alerts and remove divider
Browse files Browse the repository at this point in the history
  • Loading branch information
mahatoankitkumar committed Jan 23, 2025
1 parent 37ba8b1 commit a01761d
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 46 deletions.
10 changes: 2 additions & 8 deletions crates/frontend/src/components/default_config_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ where
view! {
<EditorProvider>
<form class="form-control w-full space-y-4 bg-white text-gray-700 font-mono">

<div class="form-control">
<label class="label">
<span class="label-text">Key Name</span>
Expand All @@ -194,8 +193,6 @@ where

</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Description</span>
Expand All @@ -211,8 +208,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Reason for Change</span>
Expand Down Expand Up @@ -269,13 +264,12 @@ where
})
r#type=InputType::Monaco
/>

</div>
}
}}

</Suspense>
<div class="divider"></div>


{move || {
let input_format = match (
Expand Down Expand Up @@ -337,7 +331,7 @@ where
</label>
{input_format}
</div>
<div class="divider"></div>

}
}}

Expand Down
20 changes: 14 additions & 6 deletions crates/frontend/src/components/dimension_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ use utils::{create_dimension, update_dimension};
use web_sys::MouseEvent;

use crate::components::{
alert::AlertType,
dropdown::{Dropdown, DropdownBtnType, DropdownDirection},
input::{Input, InputType},
};
use crate::providers::alert_provider::enqueue_alert;
use crate::providers::editor_provider::EditorProvider;
use crate::schema::{JsonSchemaType, SchemaType};
use crate::types::FunctionsName;
Expand Down Expand Up @@ -126,9 +128,20 @@ where
match result {
Ok(_) => {
handle_submit();
let success_message = if edit {
"Dimension updated successfully!"
} else {
"New Dimension created successfully!"
};
enqueue_alert(
String::from(success_message),
AlertType::Success,
5000,
);
}
Err(e) => {
set_error_message.set(e);
set_error_message.set(e.clone());
enqueue_alert(e, AlertType::Error, 5000);
// Handle error
// Consider logging or displaying the error
}
Expand Down Expand Up @@ -157,8 +170,6 @@ where

</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Description</span>
Expand All @@ -174,8 +185,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Reason for Change</span>
Expand Down Expand Up @@ -235,7 +244,6 @@ where
}}

</Suspense>
<div class="divider"></div>

{move || {
view! {
Expand Down
1 change: 0 additions & 1 deletion crates/frontend/src/components/experiment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ where
{experiment.with_value(|v| v.name.clone())}
<span class=badge_class>{experiment.with_value(|v| v.status.to_string())}</span>
</h1>
<div class="divider"></div>
<div class="flex flex-row justify-end join m-5">

{move || {
Expand Down
22 changes: 14 additions & 8 deletions crates/frontend/src/components/experiment_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ use web_sys::MouseEvent;

use crate::components::context_form::ContextForm;
use crate::components::variant_form::VariantForm;
use crate::providers::alert_provider::enqueue_alert;
use crate::types::{VariantFormT, VariantFormTs};
use crate::{
components::button::Button,
components::{alert::AlertType, button::Button},
types::{OrganisationId, Tenant},
};

Expand Down Expand Up @@ -133,8 +134,19 @@ where
match result {
Ok(_) => {
handle_submit_clone();
let success_message = if edit {
"Experiment updated successfully!"
} else {
"New Experiment created successfully!"
};
enqueue_alert(
String::from(success_message),
AlertType::Success,
5000,
);
}
Err(_) => {
Err(e) => {
enqueue_alert(e, AlertType::Error, 5000);
// Handle error
// We can consider logging or displaying the error
}
Expand Down Expand Up @@ -162,8 +174,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Description</span>
Expand All @@ -179,8 +189,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Reason for Change</span>
Expand Down Expand Up @@ -214,8 +222,6 @@ where

</div>

<div class="divider"></div>

{move || {
let variants = f_variants.get();
view! {
Expand Down
16 changes: 14 additions & 2 deletions crates/frontend/src/components/function_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ pub mod types;
pub mod utils;

use self::utils::{create_function, test_function, update_function};
use crate::providers::alert_provider::enqueue_alert;
use crate::{
components::{button::Button, monaco_editor::MonacoEditor},
components::{alert::AlertType, button::Button, monaco_editor::MonacoEditor},
types::{FunctionTestResponse, OrganisationId, Tenant},
};
use leptos::*;
Expand Down Expand Up @@ -85,9 +86,20 @@ where
match result {
Ok(_) => {
handle_submit_clone();
let success_message = if edit {
"Function updated successfully!"
} else {
"New Function created successfully!"
};
enqueue_alert(
String::from(success_message),
AlertType::Success,
5000,
);
}
Err(e) => {
set_error_message.set(e);
set_error_message.set(e.clone());
enqueue_alert(e, AlertType::Error, 5000);
}
}
req_inprogress_ws.set(false);
Expand Down
22 changes: 14 additions & 8 deletions crates/frontend/src/components/type_template_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ pub mod utils;

use crate::components::type_template_form::utils::create_type;
use crate::components::{
alert::AlertType,
button::Button,
input::{Input, InputType},
type_template_form::utils::update_type,
};
use crate::providers::editor_provider::EditorProvider;
use crate::providers::{alert_provider::enqueue_alert, editor_provider::EditorProvider};
use crate::schema::{JsonSchemaType, SchemaType};
use crate::types::{OrganisationId, Tenant};
use leptos::*;
Expand Down Expand Up @@ -69,9 +70,20 @@ where
match result {
Ok(_) => {
handle_submit();
let success_message = if edit {
"Type updated successfully!"
} else {
"New Type created successfully!"
};
enqueue_alert(
String::from(success_message),
AlertType::Success,
5000,
);
}
Err(e) => {
set_error_message.set(e);
set_error_message.set(e.clone());
enqueue_alert(e, AlertType::Error, 5000);
}
}
req_inprogress_ws.set(false);
Expand Down Expand Up @@ -99,7 +111,6 @@ where
/>

</div>
<div class="divider"></div>

<div class="form-control">
<label class="label">
Expand All @@ -116,8 +127,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">change_reason</span>
Expand Down Expand Up @@ -148,8 +157,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Reason for Change</span>
Expand All @@ -165,7 +172,6 @@ where
/>
</div>

<div class="divider"></div>
<div class="form-control">
<label class="label">
<span class="label-text">Type Schema</span>
Expand Down
8 changes: 0 additions & 8 deletions crates/frontend/src/components/workspace_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Workspace Admin Email</span>
Expand All @@ -137,8 +135,6 @@ where
</div>

<Show when=move || edit>
<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Mandatory Dimensions</span>
Expand All @@ -158,8 +154,6 @@ where
</div>
</Show>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Workspace Status</span>
Expand All @@ -182,8 +176,6 @@ where
/>
</div>

<div class="divider"></div>

<div class="form-control grid w-full justify-start">
{move || {
let loading = req_inprogess_rs.get();
Expand Down
16 changes: 11 additions & 5 deletions crates/frontend/src/pages/context_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,20 @@ fn form(
Ok(_) => {
logging::log!("Context and overrides submitted successfully");
handle_submit.call(());
let success_message = if edit {
"Context and overrides updated successfully!"
} else {
"Context and overrides created successfully!"
};
enqueue_alert(
String::from(success_message),
AlertType::Success,
5000,
);
}
Err(e) => {
logging::log!("Error submitting context and overrides: {:?}", e);
enqueue_alert(e, AlertType::Error, 5000);
}
}
req_inprogress_ws.set(false);
Expand All @@ -118,7 +129,6 @@ fn form(

disabled=edit
/>
<div class="divider"></div>

<div class="form-control">
<label class="label">
Expand All @@ -135,8 +145,6 @@ fn form(
/>
</div>

<div class="divider"></div>

<div class="form-control">
<label class="label">
<span class="label-text">Reason for Change</span>
Expand All @@ -152,8 +160,6 @@ fn form(
/>
</div>

<div class="divider"></div>

<OverrideForm
overrides=overrides.get_untracked()
default_config=default_config
Expand Down

0 comments on commit a01761d

Please sign in to comment.