diff --git a/crates/context_aware_config/samples/default_config.json b/crates/context_aware_config/samples/default_config.json deleted file mode 100644 index 2a21b3b4..00000000 --- a/crates/context_aware_config/samples/default_config.json +++ /dev/null @@ -1,157 +0,0 @@ -{ - "logs_endpoint": "", - "logs_pusher_timer": "", - "logs_memory_required": "", - "logs_encryption_level": "", - "logs_should_push": "", - "logs_public_key": "", - "headurl": "", - "godel_webview_access": true, - "ui_blurBackground": true, - "ui_nbListItemCaching": true, - "ui_nbList_bgCacheCapacity":4, - "useCommits": true, - "preRenderConfig": "1.0", - "safemode": true, - "urls_api": "", - "urls_endUrl": [], - "urls_webReleaseDomain": "", - "urls_assets": "", - - - "app_list": [ - "in.juspay.dotp", - "in.juspay.ec", - "in.juspay.escrow", - "in.juspay.flyer", - "in.juspay.hyperos", - "in.juspay.hyperos.placeholder", - "in.juspay.hyperpay", - "in.juspay.upiintent" - ], - - "package_version": "1.0.0", - "package": { - "in.juspay.hyperpay": "https://sandbox.assets.juspay.in/hyper/bundles/app/in.juspay.hyperpay/main/common/android/v1-index_bundle.zip", - "in.juspay.upiintent": "https://sandbox.assets.juspay.in/juspay/payments/in.juspay.upiintent/beta/2.0rc1/v1-index_bundle.zip", - "in.juspay.inappupi": "https://sandbox.assets.juspay.in/juspay/payments/in.juspay.inappupi/beta/2.0rc1/v1-index_bundle.zip", - "in.juspay.hyperupi": "https://sandbox.assets.juspay.in/juspay/payments/in.juspay.hyperupi/beta/2.0rc1/v1-index_bundle.zip", - "in.juspay.ec": "https://sandbox.assets.juspay.in/juspay/payments/in.juspay.ec/beta/2.0rc1/v1-index_bundle.zip", - "in.juspay.dotp": "https://sandbox.assets.juspay.in/juspay/payments/in.juspay.dotp/beta/2.0rc1/v1-index_bundle.zip", - "in.juspay.flyer": "https://sandbox.assets.juspay.in/juspay/payments/in.juspay.flyer/beta/2.0rc1/v1-index_bundle.zip", - "in.juspay.escrow": "https://sandbox.assets.juspay.in/hyper/bundles/web/beta/in.juspay.escrow/2.0.0/common/stable/index.js" - }, - - "package_dependencies": { - "in.juspay.dotp": { - "entry": "base.html", - "root": "payments/in.juspay.dotp/" - }, - "in.juspay.ec": { - "entry": "base.html", - "required_apps": [ - "in.juspay.dotp", - "in.juspay.escrow", - "in.juspay.flyer", - "in.juspay.godel.placeholder", - "in.juspay.hyperos.placeholder", - "in.juspay.upiintent", - "in.juspay.vies" - ], - "root": "payments/in.juspay.ec/" - }, - "in.juspay.escrow": { - "entry": "base.html", - "root": "payments/in.juspay.escrow/" - }, - "in.juspay.flyer": { - "entry": "base.html", - "root": "payments/in.juspay.flyer/" - }, - "in.juspay.godel": { - "entry": "base.html", - "root": "payments/in.juspay.godel/" - }, - - "in.juspay.godel.placeholder": { - "entry": "", - "root": "payments/in.juspay.godel/" - }, - "in.juspay.hyperapi": { - "entry": "base.html", - "required_apps": [ - "in.juspay.ec" - ], - "root": "payments/in.juspay.hyperapi/" - }, - "in.juspay.hyperos": { - "entry": "", - "root": "" - }, - "in.juspay.hyperos.placeholder": { - "entry": "", - "root": "" - }, - "in.juspay.hyperpay": { - "entry": "base.html", - "required_apps": [ - "in.juspay.ec" - ], - "root": "payments/in.juspay.hyperpay/" - }, - "in.juspay.upiintent": { - - "entry": "base.html", - "root": "payments/in.juspay.upiintent/" - - }, - "in.juspay.vies": { - - "entry": "base.html", - "root": "payments/in.juspay.vies/" - - } - }, - - "package_assets": { - "in.juspay.dotp": { - "config": "https://assets.juspay.in/juspay/payments/in.juspay.dotp/release/v1-config.zip" - }, - "in.juspay.ec": { - "config": "https://assets.juspay.in/juspay/payments/in.juspay.ec/release/v1-config.zip" - }, - "in.juspay.escrow": { - "configuration": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/configuration/1.22/v1-configuration.zip", - "icons": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/configuration/1.22/v1-icons.zip", - "strings": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/configuration/1.22/v1-strings.zip" - }, - "in.juspay.godel": { - "acs_js_source": "https://assets.juspay.in/juspay/payments/in.juspay.godel/release/1.0rc2/v1-acs.zip", - "boot_loader_js_source": "https://assets.juspay.in/hyper/bundles/release/in.juspay.godel/android/1.0rc2/common/stable/v1-boot_loader.zip", - "config": "https://d3e0hckk6jr53z.cloudfront.net/godel/v1-config.zip" - }, - "in.juspay.godel.placeholder": { - "acs_js_source": "https://assets.juspay.in/juspay/payments/in.juspay.godel/release/1.0rc2/v1-acs.zip", - "boot_loader_js_source": "https://assets.juspay.in/hyper/bundles/release/in.juspay.godel/android/1.0rc2/common/stable/v1-boot_loader.zip", - "config": "https://d3e0hckk6jr53z.cloudfront.net/godel/v1-config.zip" - }, - "in.juspay.hyperos": { - "config": "https://assets.juspay.in/juspay/payments/2.0/release/v1-config.zip", - "manifest": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/android/release/manifest.json" - }, - "in.juspay.hyperos.placeholder": { - "tracker": "https://assets.juspay.in/juspay/payments/2.0/release/v1-tracker.zip" - }, - "in.juspay.hyperpay": { - "configuration": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/configuration/1.22/v1-configuration.zip", - "icons": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/configuration/1.22/v1-icons.zip", - "strings": "https://assets.juspay.in/hyper/bundles/in.juspay.merchants/toi/configuration/1.22/v1-strings.zip" - }, - "in.juspay.upiintent": { - "config": "https://assets.juspay.in/hyper/bundles/android/release/in.juspay.upiintent/2.0.0/common/2.0.109/v1-config.zip" - }, - "in.juspay.vies": { - "config": "https://assets.juspay.in/juspay/payments/in.juspay.vies/release/1.0.89/v1-config.zip" - } - } -} diff --git a/crates/context_aware_config/samples/dimensions.json b/crates/context_aware_config/samples/dimensions.json deleted file mode 100644 index ce3617b9..00000000 --- a/crates/context_aware_config/samples/dimensions.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "dimensions": [ - { - "condition": { - "==": [{"var":"tier"}, "1"] - }, - "overrideWithKeys": ["tier1"] - - }, - { - "condition": { - "==": [{"var":"merchantId"}, "zee5"] - }, - "overrideWithKeys": ["zee5"] - } - ] - -} \ No newline at end of file diff --git a/crates/context_aware_config/samples/overrides.json b/crates/context_aware_config/samples/overrides.json deleted file mode 100644 index 1b1d09d4..00000000 --- a/crates/context_aware_config/samples/overrides.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "tier1" :{ - "package": { - "in.juspay.hyperpay": "changed hyperpay by tier 1", - "in.juspay.upiintent": "changed upiintent by tier 1" - }, - "package_dependencies": { - "in.juspay.ec": { - "entry": "changed entry of ec by tier 1", - "required_apps": [ - "in.juspay.dotp", - "in.juspay.escrow", - "in.juspay.flyer" - ] - } - }, - "package_assets" : { - "in.juspay.upiintent": { - "config": "changed upiintent config by tier 1" - } - } - - - }, - "zee5": { - "app_list": [], - "logs_should_push": "changed shoudl push by zee5", - "logs_public_key": "changed blogs public key by zee5", - "package_assets": { - "in.juspay.hyperpay": { - "configuration": "changed configuration by zee5", - "strings": "changed hyperpay strings by zee5" - }, - "in.juspay.upiintent": { - "config": "changed upintent by zee5" - }, - "new_key": { - "config" : "added by zee5" - } - } - } -} diff --git a/crates/context_aware_config/src/api/default_config/handlers.rs b/crates/context_aware_config/src/api/default_config/handlers.rs index 4bea3cb1..880095b9 100644 --- a/crates/context_aware_config/src/api/default_config/handlers.rs +++ b/crates/context_aware_config/src/api/default_config/handlers.rs @@ -8,7 +8,7 @@ use actix_web::{ use chrono::Utc; use diesel::{ r2d2::{ConnectionManager, PooledConnection}, - ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl, + ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl, TextExpressionMethods, }; use diesel::{Connection, SelectableHelper}; use jsonschema::{Draft, JSONSchema, ValidationError}; @@ -42,10 +42,13 @@ use crate::{ helpers::add_config_version, }; -use super::types::CreateReq; +use super::types::{CreateReq, DefaultConfigFilters}; pub fn endpoints() -> Scope { - Scope::new("").service(create).service(get).service(delete) + Scope::new("") + .service(create) + .service(list_default_configs) + .service(delete) } #[put("/{key}")] @@ -213,14 +216,26 @@ fn fetch_default_key( } #[get("")] -async fn get( +async fn list_default_configs( db_conn: DbConnection, - filters: Query, + pagination: Query, + filters: Query, ) -> superposition::Result>> { let DbConnection(mut conn) = db_conn; - if let Some(true) = filters.all { - let result: Vec = dsl::default_configs.get_results(&mut conn)?; + let filters = filters.into_inner(); + + let query_builder = |filters: &DefaultConfigFilters| { + let mut builder = dsl::default_configs.into_boxed(); + if let Some(ref config_name) = filters.name { + builder = builder + .filter(schema::default_configs::key.like(format!["%{}%", config_name])); + } + builder + }; + + if let Some(true) = pagination.all { + let result: Vec = query_builder(&filters).get_results(&mut conn)?; return Ok(Json(PaginatedResponse { total_pages: 1, total_items: result.len() as i64, @@ -228,17 +243,17 @@ async fn get( })); } - let n_default_configs: i64 = dsl::default_configs.count().get_result(&mut conn)?; - let limit = filters.count.unwrap_or(10); - let mut builder = dsl::default_configs - .into_boxed() - .order(dsl::created_at.desc()) - .limit(limit); - if let Some(page) = filters.page { + let base_query = query_builder(&filters); + let count_query = query_builder(&filters); + + let n_default_configs: i64 = count_query.count().get_result(&mut conn)?; + let limit = pagination.count.unwrap_or(10); + let mut query = base_query.order(dsl::created_at.desc()).limit(limit); + if let Some(page) = pagination.page { let offset = (page - 1) * limit; - builder = builder.offset(offset); + query = query.offset(offset); } - let result: Vec = builder.load(&mut conn)?; + let result: Vec = query.load(&mut conn)?; let total_pages = (n_default_configs as f64 / limit as f64).ceil() as i64; Ok(Json(PaginatedResponse { total_pages, diff --git a/crates/context_aware_config/src/api/default_config/types.rs b/crates/context_aware_config/src/api/default_config/types.rs index 8366d00d..ee7a5000 100644 --- a/crates/context_aware_config/src/api/default_config/types.rs +++ b/crates/context_aware_config/src/api/default_config/types.rs @@ -38,3 +38,9 @@ where let value: Value = Deserialize::deserialize(deserializer)?; Ok(Some(value)) } + + +#[derive(Deserialize, Debug)] +pub struct DefaultConfigFilters { + pub name: Option, +} diff --git a/crates/frontend/src/api.rs b/crates/frontend/src/api.rs index b6e8871d..66652404 100644 --- a/crates/frontend/src/api.rs +++ b/crates/frontend/src/api.rs @@ -3,9 +3,9 @@ use superposition_types::Config; use crate::{ types::{ - ConfigVersionListResponse, DefaultConfig, Dimension, ExperimentListFilters, - ExperimentResponse, FetchTypeTemplateResponse, FunctionResponse, ListFilters, - PaginatedResponse, + ConfigVersionListResponse, DefaultConfig, DefaultConfigFilters, Dimension, + ExperimentListFilters, ExperimentResponse, FetchTypeTemplateResponse, + FunctionResponse, PaginatedResponse, PaginationFilters, }, utils::{ construct_request_headers, get_host, parse_json_response, request, @@ -15,7 +15,7 @@ use crate::{ // #[server(GetDimensions, "/fxn", "GetJson")] pub async fn fetch_dimensions( - filters: &ListFilters, + filters: &PaginationFilters, tenant: String, ) -> Result, ServerFnError> { let client = reqwest::Client::new(); @@ -37,13 +37,23 @@ pub async fn fetch_dimensions( // #[server(GetDefaultConfig, "/fxn", "GetJson")] pub async fn fetch_default_config( - filters: &ListFilters, + pagination_filters: &PaginationFilters, + filters: &DefaultConfigFilters, tenant: String, ) -> Result, ServerFnError> { let client = reqwest::Client::new(); let host = use_host_server(); - - let url = format!("{}/default-config?{}", host, filters.to_string()); + let filters = filters.to_string(); + let url = if filters.is_empty() { + format!("{}/default-config?{}", host, pagination_filters.to_string()) + } else { + format!( + "{}/default-config?{}&{}", + host, + pagination_filters.to_string(), + filters + ) + }; let response: PaginatedResponse = client .get(url) .header("x-tenant", tenant) @@ -109,7 +119,7 @@ pub async fn delete_context( pub async fn fetch_experiments( filters: &ExperimentListFilters, - pagination: &ListFilters, + pagination: &PaginationFilters, tenant: String, ) -> Result, ServerFnError> { let client = reqwest::Client::new(); @@ -140,7 +150,7 @@ pub async fn fetch_experiments( } pub async fn fetch_functions( - filters: ListFilters, + filters: PaginationFilters, tenant: String, ) -> Result, ServerFnError> { let client = reqwest::Client::new(); diff --git a/crates/frontend/src/components/default_config_form.rs b/crates/frontend/src/components/default_config_form.rs index ca065035..ec4045a4 100644 --- a/crates/frontend/src/components/default_config_form.rs +++ b/crates/frontend/src/components/default_config_form.rs @@ -9,7 +9,7 @@ use crate::components::alert::AlertType; use crate::providers::alert_provider::enqueue_alert; use crate::providers::editor_provider::EditorProvider; use crate::schema::EnumVariants; -use crate::types::ListFilters; +use crate::types::PaginationFilters; use crate::{ api::{fetch_functions, fetch_types}, components::{ @@ -51,7 +51,7 @@ where move || tenant_rs.get(), |current_tenant| async move { match fetch_functions( - ListFilters { + PaginationFilters { page: None, count: None, all: Some(true), diff --git a/crates/frontend/src/components/dimension_form.rs b/crates/frontend/src/components/dimension_form.rs index 706548f7..7f714eef 100644 --- a/crates/frontend/src/components/dimension_form.rs +++ b/crates/frontend/src/components/dimension_form.rs @@ -10,7 +10,7 @@ use crate::components::{ }; use crate::providers::editor_provider::EditorProvider; use crate::schema::{JsonSchemaType, SchemaType}; -use crate::types::{FunctionsName, ListFilters, TypeTemplate}; +use crate::types::{FunctionsName, PaginationFilters, TypeTemplate}; use crate::{api::fetch_functions, components::button::Button}; use leptos::*; use serde_json::{json, Value}; @@ -42,7 +42,7 @@ where move || tenant_rs.get(), |current_tenant| async move { match fetch_functions( - ListFilters { + PaginationFilters { page: None, count: None, all: Some(true), diff --git a/crates/frontend/src/pages/config_version_list.rs b/crates/frontend/src/pages/config_version_list.rs index 1425ae33..90db2042 100644 --- a/crates/frontend/src/pages/config_version_list.rs +++ b/crates/frontend/src/pages/config_version_list.rs @@ -8,7 +8,7 @@ use crate::components::skeleton::Skeleton; use crate::components::stat::Stat; use crate::components::table::types::{ColumnSortable, TablePaginationProps}; use crate::components::table::{types::Column, Table}; -use crate::types::{ConfigVersionListResponse, ListFilters}; +use crate::types::{ConfigVersionListResponse, PaginationFilters}; use crate::utils::use_url_base; use crate::api::fetch_snapshots; @@ -18,7 +18,7 @@ pub fn config_version_list() -> impl IntoView { let tenant_rs = use_context::>().unwrap(); // Signals for filters - let (filters, set_filters) = create_signal(ListFilters { + let (filters, set_filters) = create_signal(PaginationFilters { page: Some(1), count: Some(10), // Limit of 10 items per page all: None, diff --git a/crates/frontend/src/pages/context_override.rs b/crates/frontend/src/pages/context_override.rs index 51ba2cb7..2c28ee53 100644 --- a/crates/frontend/src/pages/context_override.rs +++ b/crates/frontend/src/pages/context_override.rs @@ -20,7 +20,9 @@ use crate::components::skeleton::{Skeleton, SkeletonVariant}; use crate::providers::alert_provider::enqueue_alert; use crate::providers::condition_collapse_provider::ConditionCollapseProvider; use crate::providers::editor_provider::EditorProvider; -use crate::types::{DefaultConfig, Dimension, ListFilters, PaginatedResponse}; +use crate::types::{ + DefaultConfig, DefaultConfigFilters, Dimension, PaginatedResponse, PaginationFilters, +}; #[derive(Clone, Debug, Default)] pub struct Data { @@ -147,15 +149,20 @@ pub fn context_override() -> impl IntoView { let page_resource: Resource = create_blocking_resource( move || tenant_rs.get().clone(), |current_tenant| async move { - let empty_list_filters = ListFilters { + let empty_list_filters = PaginationFilters { page: None, count: None, all: Some(true), }; + let empty_defaultconfig_filters = DefaultConfigFilters::default(); let (config_result, dimensions_result, default_config_result) = join!( fetch_config(current_tenant.to_string(), None), fetch_dimensions(&empty_list_filters, current_tenant.to_string()), - fetch_default_config(&empty_list_filters, current_tenant.to_string()) + fetch_default_config( + &empty_list_filters, + &empty_defaultconfig_filters, + current_tenant.to_string() + ) ); PageResource { config: config_result.unwrap_or_default(), diff --git a/crates/frontend/src/pages/default_config.rs b/crates/frontend/src/pages/default_config.rs index 786ce97c..69ea1d03 100644 --- a/crates/frontend/src/pages/default_config.rs +++ b/crates/frontend/src/pages/default_config.rs @@ -1,16 +1,19 @@ use crate::api::{delete_default_config, fetch_default_config}; -use crate::components::default_config_form::DefaultConfigForm; -use crate::components::drawer::{close_drawer, open_drawer, Drawer, DrawerBtn}; -use crate::components::skeleton::Skeleton; -use crate::components::stat::Stat; -use crate::components::table::types::ColumnSortable; -use crate::components::table::{ - types::{Column, TablePaginationProps}, - Table, +use crate::components::{ + button::Button, + default_config_form::DefaultConfigForm, + drawer::{close_drawer, open_drawer, Drawer, DrawerBtn}, + skeleton::Skeleton, + stat::Stat, + table::{ + types::{Column, ColumnSortable, TablePaginationProps}, + Table, + }, +}; +use crate::types::{ + BreadCrums, DefaultConfigFilters, PaginatedResponse, PaginationFilters, }; - -use crate::types::{BreadCrums, ListFilters, PaginatedResponse}; use crate::utils::{ get_local_storage, set_local_storage, unwrap_option_or_default_with_error, update_page_direction, @@ -32,15 +35,26 @@ pub struct RowData { pub fn default_config() -> impl IntoView { let tenant_rs = use_context::>().unwrap(); let enable_grouping = create_rw_signal(false); - let (filters, set_filters) = create_signal(ListFilters { - page: Some(1), - count: Some(10), - all: None, - }); + let (pagination_filters_rs, pagination_filters_ws) = + create_signal(PaginationFilters { + page: Some(1), + count: Some(10), + all: None, + }); + + let filters_rws = create_rw_signal(DefaultConfigFilters::default()); let default_config_resource = create_blocking_resource( - move || (tenant_rs.get(), filters.get()), - |(current_tenant, filters)| async move { - match fetch_default_config(&filters, current_tenant).await { + move || { + ( + tenant_rs.get(), + pagination_filters_rs.get(), + filters_rws.get(), + ) + }, + |(current_tenant, pagination_filters, filters)| async move { + match fetch_default_config(&pagination_filters, &filters, current_tenant) + .await + { Ok(data) => data, Err(_) => PaginatedResponse::default(), } @@ -53,7 +67,7 @@ pub fn default_config() -> impl IntoView { let bread_crums = Signal::derive(move || get_bread_crums(key_prefix.get())); let set_filters_none = move || { - set_filters.set(ListFilters { + pagination_filters_ws.set(PaginationFilters { page: None, count: None, all: Some(true), @@ -61,7 +75,7 @@ pub fn default_config() -> impl IntoView { }; let set_filters_default = move || { - set_filters.set(ListFilters { + pagination_filters_ws.set(PaginationFilters { page: Some(1), count: Some(10), all: None, @@ -102,13 +116,13 @@ pub fn default_config() -> impl IntoView { }; let handle_next_click = Callback::new(move |total_pages: i64| { - set_filters.update(|f| { + pagination_filters_ws.update(|f| { f.page = update_page_direction(f.page, total_pages, true); }); }); let handle_prev_click = Callback::new(move |_| { - set_filters.update(|f| { + pagination_filters_ws.update(|f| { f.page = update_page_direction(f.page, 1, false); }); }); @@ -308,7 +322,7 @@ pub fn default_config() -> impl IntoView { filtered_rows = modify_rows(filtered_rows.clone(), key_prefix.get(), cols); } let total_default_config_keys = default_config.total_items.to_string(); - let filters = filters.get(); + let filters = pagination_filters_rs.get(); let (current_page, total_pages) = if enable_grouping.get() { (1, 1) } else { @@ -365,6 +379,11 @@ pub fn default_config() -> impl IntoView { +
+ +
, +) -> impl IntoView { + let filters = filters_rws.get_untracked(); + let filters_buffer_rws = create_rw_signal(filters.clone()); + view! { + + Filters + + + +
+
+
+ + +
+
+
+
+
+
+ } +} diff --git a/crates/frontend/src/pages/dimensions.rs b/crates/frontend/src/pages/dimensions.rs index 203e46f4..77e95ce1 100644 --- a/crates/frontend/src/pages/dimensions.rs +++ b/crates/frontend/src/pages/dimensions.rs @@ -10,7 +10,7 @@ use crate::components::{ Table, }, }; -use crate::types::{ListFilters, PaginatedResponse}; +use crate::types::{PaginatedResponse, PaginationFilters}; use crate::utils::update_page_direction; use leptos::*; @@ -32,7 +32,7 @@ pub fn dimensions() -> impl IntoView { let tenant_rs = use_context::>().unwrap(); let (delete_modal_visible_rs, delete_modal_visible_ws) = create_signal(false); let (delete_id_rs, delete_id_ws) = create_signal::>(None); - let (filters, set_filters) = create_signal(ListFilters { + let (filters, set_filters) = create_signal(PaginationFilters { page: Some(1), count: Some(10), all: None, diff --git a/crates/frontend/src/pages/experiment.rs b/crates/frontend/src/pages/experiment.rs index b8172dd7..ba0427fc 100644 --- a/crates/frontend/src/pages/experiment.rs +++ b/crates/frontend/src/pages/experiment.rs @@ -14,7 +14,10 @@ use crate::{ skeleton::{Skeleton, SkeletonVariant}, }, providers::editor_provider::EditorProvider, - types::{DefaultConfig, Dimension, Experiment, ListFilters, PaginatedResponse}, + types::{ + DefaultConfig, DefaultConfigFilters, Dimension, Experiment, PaginatedResponse, + PaginationFilters, + }, utils::{close_modal, show_modal}, }; @@ -43,15 +46,20 @@ pub fn experiment_page() -> impl IntoView { // Perform all fetch operations concurrently let experiments_future = fetch_experiment(exp_id.to_string(), tenant.to_string()); - let empty_list_filters = ListFilters { + let empty_list_filters = PaginationFilters { page: None, count: None, all: Some(true), }; + + let empty_default_config_filters = DefaultConfigFilters::default(); let dimensions_future = fetch_dimensions(&empty_list_filters, tenant.to_string()); - let config_future = - fetch_default_config(&empty_list_filters, tenant.to_string()); + let config_future = fetch_default_config( + &empty_list_filters, + &empty_default_config_filters, + tenant.to_string(), + ); let (experiments_result, dimensions_result, config_result) = join!(experiments_future, dimensions_future, config_future); diff --git a/crates/frontend/src/pages/experiment_list.rs b/crates/frontend/src/pages/experiment_list.rs index 78a16943..c1c7758c 100644 --- a/crates/frontend/src/pages/experiment_list.rs +++ b/crates/frontend/src/pages/experiment_list.rs @@ -15,7 +15,8 @@ use crate::components::{experiment_form::ExperimentForm, stat::Stat, table::Tabl use crate::providers::condition_collapse_provider::ConditionCollapseProvider; use crate::providers::editor_provider::EditorProvider; use crate::types::{ - ExperimentListFilters, ExperimentResponse, ListFilters, PaginatedResponse, + DefaultConfigFilters, ExperimentListFilters, ExperimentResponse, PaginatedResponse, + PaginationFilters, }; use crate::utils::update_page_direction; @@ -49,16 +50,17 @@ pub fn experiment_list() -> impl IntoView { sort_by: Some(SortBy::Desc), }); - let (pagination_filters_rs, pagination_filters_ws) = create_signal(ListFilters { - page: Some(1), - count: Some(10), - all: None, - }); + let (pagination_filters_rs, pagination_filters_ws) = + create_signal(PaginationFilters { + page: Some(1), + count: Some(10), + all: None, + }); let (reset_exp_form, set_exp_form) = create_signal(0); let combined_resource: Resource< - (String, ExperimentListFilters, ListFilters), + (String, ExperimentListFilters, PaginationFilters), CombinedResource, > = create_blocking_resource( move || { @@ -75,10 +77,14 @@ pub fn experiment_list() -> impl IntoView { &pagination_filters, current_tenant.to_string(), ); + let empty_defaultconfig_filters = DefaultConfigFilters::default(); let dimensions_future = fetch_dimensions(&pagination_filters, current_tenant.to_string()); - let config_future = - fetch_default_config(&pagination_filters, current_tenant.to_string()); + let config_future = fetch_default_config( + &pagination_filters, + &empty_defaultconfig_filters, + current_tenant.to_string(), + ); let (experiments_result, dimensions_result, config_result) = join!(experiments_future, dimensions_future, config_future); diff --git a/crates/frontend/src/pages/function/function_list.rs b/crates/frontend/src/pages/function/function_list.rs index f68b9d84..014bb211 100644 --- a/crates/frontend/src/pages/function/function_list.rs +++ b/crates/frontend/src/pages/function/function_list.rs @@ -7,7 +7,7 @@ use crate::components::skeleton::Skeleton; use crate::components::table::types::TablePaginationProps; use crate::components::{stat::Stat, table::Table}; -use crate::types::{FunctionResponse, ListFilters, PaginatedResponse}; +use crate::types::{FunctionResponse, PaginatedResponse, PaginationFilters}; use crate::utils::update_page_direction; use super::utils::function_table_columns; @@ -22,7 +22,7 @@ struct CombinedResource { #[component] pub fn function_list() -> impl IntoView { let tenant_rs = use_context::>().unwrap(); - let (filters, set_filters) = create_signal(ListFilters { + let (filters, set_filters) = create_signal(PaginationFilters { page: Some(1), count: Some(10), all: None, diff --git a/crates/frontend/src/pages/home.rs b/crates/frontend/src/pages/home.rs index 4ae1d5b3..0aa55425 100644 --- a/crates/frontend/src/pages/home.rs +++ b/crates/frontend/src/pages/home.rs @@ -12,7 +12,7 @@ use web_sys::{HtmlButtonElement, HtmlSpanElement, MouseEvent}; use crate::components::condition_pills::types::Conditions; use crate::components::skeleton::{Skeleton, SkeletonVariant}; use crate::providers::condition_collapse_provider::ConditionCollapseProvider; -use crate::types::ListFilters; +use crate::types::PaginationFilters; use crate::{ api::{fetch_config, fetch_dimensions}, components::{ @@ -186,7 +186,7 @@ pub fn home() -> impl IntoView { move || tenant_rs.get(), |tenant| async { match fetch_dimensions( - &ListFilters { + &PaginationFilters { page: None, count: None, all: Some(true), diff --git a/crates/frontend/src/types.rs b/crates/frontend/src/types.rs index 2cd32e49..3753ac2e 100644 --- a/crates/frontend/src/types.rs +++ b/crates/frontend/src/types.rs @@ -174,6 +174,27 @@ impl Display for ExperimentListFilters { } } +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub struct DefaultConfigFilters { + pub name: Option, +} + +impl Default for DefaultConfigFilters { + fn default() -> Self { + Self { name: None } + } +} + +impl Display for DefaultConfigFilters { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + let mut query_params = vec![]; + if let Some(key_name) = &self.name { + query_params.push(format!("name={}", key_name)); + } + write!(f, "{}", query_params.join("&")) + } +} + #[derive(Deserialize, Serialize, Clone, PartialEq, Debug, strum_macros::Display)] #[strum(serialize_all = "UPPERCASE")] pub enum VariantType { @@ -266,8 +287,6 @@ impl From for Experiment { } } -/*************************** Context-Override types ********************************/ - #[derive(Serialize, Deserialize, Clone, Debug)] pub struct Dimension { pub dimension: String, @@ -373,13 +392,13 @@ pub struct ConfigVersion { #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct ListFilters { +pub struct PaginationFilters { pub page: Option, pub count: Option, pub all: Option, } -impl Display for ListFilters { +impl Display for PaginationFilters { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let mut parts = vec![];