Skip to content

Commit

Permalink
fix: Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushjain17 committed Jan 2, 2025
1 parent 031503b commit f68829c
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 31 deletions.
2 changes: 1 addition & 1 deletion crates/frontend/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
pub async fn fetch_dimensions(
filters: &PaginationParams,
tenant: String,
org_id: String
org_id: String,
) -> Result<PaginatedResponse<DimensionWithMandatory>, ServerFnError> {
let client = reqwest::Client::new();
let host = use_host_server();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub async fn update_default_config(
key: String,
tenant: String,
payload: DefaultConfigUpdateReq,
org_id: String
org_id: String,
) -> Result<serde_json::Value, String> {
let host = get_host();
let url = format!("{host}/default-config/{key}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub async fn conclude_experiment(
exp_id: String,
variant_id: String,
tenant: &String,
org_id: &String
org_id: &String,
) -> Result<Experiment, String> {
let client = reqwest::Client::new();
let host = get_host();
Expand Down
4 changes: 2 additions & 2 deletions crates/frontend/src/components/function_form/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub async fn create_function(
runtime_version: String,
description: String,
tenant: String,
org_id: String
org_id: String,
) -> Result<Function, String> {
let payload = FunctionCreateRequest {
function_name,
Expand All @@ -29,7 +29,7 @@ pub async fn create_function(
url,
reqwest::Method::POST,
Some(payload),
construct_request_headers(&[("x-tenant", &tenant),("x-org-id", &org_id)])?,
construct_request_headers(&[("x-tenant", &tenant), ("x-org-id", &org_id)])?,
)
.await?;

Expand Down
7 changes: 6 additions & 1 deletion crates/frontend/src/components/workspace_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ where
let handle_submit = handle_submit_clone;
async move {
let result = if is_edit {
update_workspace(workspace_name_rs.get(), org_id.get().to_string(), update_payload).await
update_workspace(
workspace_name_rs.get(),
org_id.get().to_string(),
update_payload,
)
.await
} else {
create_workspace(org_id.get().to_string(), create_payload).await
};
Expand Down
54 changes: 32 additions & 22 deletions crates/frontend/src/pages/context_override.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,36 @@ pub fn context_override() -> impl IntoView {
let (modal_visible, set_modal_visible) = create_signal(false);
let (delete_id, set_delete_id) = create_signal::<Option<String>>(None);

let page_resource: Resource<(String, String), PageResource> = create_blocking_resource(
move || (tenant_rws.get().0, org_rws.get().0),
|(current_tenant, org_id)| async move {
let empty_list_filters = PaginationParams::all_entries();
let (config_result, dimensions_result, default_config_result) = join!(
fetch_config(current_tenant.to_string(), None, org_id.clone()),
fetch_dimensions(&empty_list_filters, current_tenant.to_string(), org_id.clone()),
fetch_default_config(&empty_list_filters, current_tenant.to_string(), org_id.clone())
);
PageResource {
config: config_result.unwrap_or_default(),
dimensions: dimensions_result
.unwrap_or_default()
.data
.into_iter()
.filter(|d| d.dimension != "variantIds")
.collect(),
default_config: default_config_result.unwrap_or_default().data,
}
},
);
let page_resource: Resource<(String, String), PageResource> =
create_blocking_resource(
move || (tenant_rws.get().0, org_rws.get().0),
|(current_tenant, org_id)| async move {
let empty_list_filters = PaginationParams::all_entries();
let (config_result, dimensions_result, default_config_result) = join!(
fetch_config(current_tenant.to_string(), None, org_id.clone()),
fetch_dimensions(
&empty_list_filters,
current_tenant.to_string(),
org_id.clone()
),
fetch_default_config(
&empty_list_filters,
current_tenant.to_string(),
org_id.clone()
)
);
PageResource {
config: config_result.unwrap_or_default(),
dimensions: dimensions_result
.unwrap_or_default()
.data
.into_iter()
.filter(|d| d.dimension != "variantIds")
.collect(),
default_config: default_config_result.unwrap_or_default().data,
}
},
);

let handle_context_create = Callback::new(move |_| {
set_form_mode.set(Some(FormMode::Create));
Expand Down Expand Up @@ -241,7 +250,8 @@ pub fn context_override() -> impl IntoView {
let confirm_delete = Callback::new(move |_| {
if let Some(id) = delete_id.get().clone() {
spawn_local(async move {
let result = delete_context(tenant_rws.get().0, id, org_rws.get().0).await;
let result =
delete_context(tenant_rws.get().0, id, org_rws.get().0).await;

match result {
Ok(_) => {
Expand Down
3 changes: 2 additions & 1 deletion crates/frontend/src/pages/custom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ pub fn types_page() -> impl IntoView {
let tenant = tenant_rws.get().0;
let org = org_rws.get().0;
let _ =
delete_type(tenant, row_data.clone().type_name, org).await;
delete_type(tenant, row_data.clone().type_name, org)
.await;
types_resource.refetch();
}
});
Expand Down
3 changes: 2 additions & 1 deletion crates/frontend/src/pages/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ pub fn function_page() -> impl IntoView {
let combined_resource: Resource<(String, String, String), CombinedResource> =
create_blocking_resource(source, |(function_name, tenant, org_id)| async move {
let function_result =
fetch_function(function_name.to_string(), tenant.to_string(), org_id).await;
fetch_function(function_name.to_string(), tenant.to_string(), org_id)
.await;

CombinedResource {
function: function_result.ok(),
Expand Down
5 changes: 4 additions & 1 deletion crates/frontend/src/pages/function/function_create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use leptos_router::use_navigate;
use serde::{Deserialize, Serialize};
use superposition_types::database::models::cac::Function;

use crate::{components::function_form::FunctionEditor, types::{OrganisationId, Tenant}};
use crate::{
components::function_form::FunctionEditor,
types::{OrganisationId, Tenant},
};

#[derive(Serialize, Deserialize, Clone, Debug)]
struct CombinedResource {
Expand Down

0 comments on commit f68829c

Please sign in to comment.