Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions crates/frontend/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::pages::{
experiment::ExperimentPage,
home::Home,
organisations::Organisations,
override_page::{CreateOverride, EditOverride, OverridePage},
type_template::TypePage,
type_templates::TypesPage,
webhook::Webhook,
Expand Down Expand Up @@ -306,6 +307,35 @@ pub fn App(app_envs: Envs) -> impl IntoView {
view=ContextOverride
/>

<Route
ssr=SsrMode::Async
path=join_route_parts([
RouteSegment::Overrides,
RouteSegment::Action,
RouteSegment::Create,
])
view=CreateOverride
/>

<Route
ssr=SsrMode::Async
path=join_route_parts([
RoutePart::from(RouteSegment::Overrides),
RoutePart::from("context_id"),
RoutePart::from(RouteSegment::Edit),
])
view=EditOverride
/>

<Route
ssr=SsrMode::Async
path=join_route_parts([
RoutePart::from(RouteSegment::Overrides),
RoutePart::from("context_id"),
])
view=OverridePage
/>

<Route
ssr=SsrMode::Async
path=join_route_parts([RouteSegment::Resolve])
Expand Down
2 changes: 2 additions & 0 deletions crates/frontend/src/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod cohort_schema;
pub mod condition_pills;
pub mod context_card;
pub mod context_form;
pub mod context_override_form;
pub mod datetime;
pub mod default_config_form;
pub mod delete_modal;
Expand Down Expand Up @@ -38,6 +39,7 @@ pub mod side_nav;
pub mod skeleton;
pub mod sortable;
pub mod stat;
pub mod step_indicator;
pub mod table;
pub mod tip;
pub mod toast;
Expand Down
8 changes: 5 additions & 3 deletions crates/frontend/src/components/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub fn Button(
#[prop(into, default = String::new())] id: String,
#[prop(into, default = String::from("ri-edit-2-line"))] icon_class: String,
#[prop(default = false)] loading: bool,
#[prop(default = false)] disabled: bool,
#[prop(default = ButtonStyle::Fill)] style: ButtonStyle,
#[prop(into, optional)] force_style: Option<String>,
) -> impl IntoView {
Expand All @@ -33,18 +34,19 @@ pub fn Button(

move || {
let loading = loading || !*client_side_ready.get();
let loading_class = if loading {
let is_disabled = loading || disabled;
let disabled_class = if is_disabled {
"hover:cursor-not-allowed"
} else {
""
};

view! {
<button
class=format!("{common_style} {style} {class} {loading_class}")
class=format!("{common_style} {style} {class} {disabled_class}")
id=id.clone()
on:click=move |e| on_click.call(e)
disabled=loading
disabled=is_disabled
>
{if loading {
view! { <span class="loading loading-dots loading-sm" /> }.into_view()
Expand Down
55 changes: 13 additions & 42 deletions crates/frontend/src/components/context_card.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
use std::ops::Deref;

use leptos::*;
use leptos_router::A;
use serde_json::{Map, Value};
use superposition_types::database::models::cac::Context;

use crate::{
components::{
condition_pills::Condition as ConditionComponent,
datetime::Datetime,
description::InfoDescription,
table::{Table, types::Column},
tooltip::Tooltip,
},
logic::Conditions,
};
Expand Down Expand Up @@ -42,7 +38,11 @@ fn ContextOptions(
) -> impl IntoView {
view! {
<div class="w-fit dropdown dropdown-left">
<label tabindex="0" class="btn btn-sm text-xs m-1 w-full">
<label
tabindex="0"
class="btn btn-sm text-xs m-1 w-full"
on:click=|ev: web_sys::MouseEvent| ev.stop_propagation()
>
<i class="ri-more-2-fill" />
</label>
<ul
Expand Down Expand Up @@ -86,15 +86,14 @@ pub fn ContextCard(
context: Context,
overrides: Map<String, Value>,
#[prop(default = true)] show_actions: bool,
#[prop(into)] href: String,
#[prop(into)] handle_create_experiment: Callback<String, ()>,
#[prop(into)] handle_delete_experiment: Callback<String, ()>,
#[prop(into)] handle_edit: Callback<String, ()>,
#[prop(into)] handle_clone: Callback<String, ()>,
#[prop(into)] handle_delete: Callback<String, ()>,
) -> impl IntoView {
let conditions = Conditions::from_iter(context.value.clone().into_inner());
let description = context.description.clone();
let change_reason = context.change_reason.clone();

let override_table_rows = overrides
.clone()
Expand All @@ -108,6 +107,7 @@ pub fn ContextCard(
.collect::<Vec<Map<String, Value>>>();

let context = store_value(context);
let href = store_value(href);

let table_columns = vec![
Column::default_no_collapse("KEY".to_string()),
Expand All @@ -118,47 +118,18 @@ pub fn ContextCard(
show_actions && !conditions.0.iter().any(|c| c.variable == "variantIds");

view! {
<div class="rounded-lg shadow bg-base-100 p-6 flex flex-col gap-4">
<div class="block rounded-lg shadow bg-base-100 p-6 flex flex-col gap-4">
<div class="flex justify-between">
<div class="flex gap-4 items-center">
<h3 class="card-title text-base timeline-box text-gray-800 bg-base-100 shadow-md m-0 w-max">
"Condition"
</h3>
<InfoDescription
description=description.deref().to_string()
change_reason=change_reason.deref().to_string()
/>
<Tooltip icon_class="ri-information-line ri-lg">
<div class="flex flex-col gap-4">
<div class="flex flex-col gap-1">
<div class="font-bold">"Created"</div>
<div class="flex gap-1 items-center">
<i class="ri-user-line text-gray-950" />
<span>{context.with_value(|c| c.created_by.clone())}</span>
</div>
<div class="flex gap-1 items-center">
<i class="ri-time-line text-gray-950" />
<Datetime datetime=context.with_value(|c| c.created_at) />
</div>
</div>
<div class="flex flex-col gap-1">
<div class="font-bold">"Last Modified"</div>
<div class="flex gap-1 items-center">
<i class="ri-user-line text-gray-950" />
<span>
{context.with_value(|c| c.last_modified_by.clone())}
</span>
</div>
<div class="flex gap-1 items-center">
<i class="ri-time-line text-gray-950" />
<Datetime datetime=context.with_value(|c| c.last_modified_at) />
</div>
</div>
</div>
</Tooltip>
</div>
<Show when=move || actions_supported>
<div class="h-fit flex gap-4 text-right">
<div class="h-fit flex gap-2 items-center text-right">
<A href=href.with_value(|h| h.clone()) class="btn btn-sm btn-ghost">
{"See More"}
</A>
<ContextOptions
handle_create_experiment=move |_| {
handle_create_experiment.call(context.with_value(|c| c.id.clone()))
Expand Down
Loading
Loading