Skip to content

Commit 05402d8

Browse files
committed
feat: Move create, edit, clone and view overrides into a new page
1 parent 7a21581 commit 05402d8

10 files changed

Lines changed: 1153 additions & 118 deletions

File tree

crates/context_aware_config/src/api/context/handlers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,8 @@ async fn update_handler(
281281
)
282282
.await?;
283283

284-
let (override_resp, config_version) =
285-
conn.transaction::<_, superposition::AppError, _>(|transaction_conn| {
284+
let (override_resp, config_version) = conn
285+
.transaction::<_, superposition::AppError, _>(|transaction_conn| {
286286
let override_resp = operations::update(
287287
&workspace_context,
288288
req.into_inner(),
@@ -423,8 +423,8 @@ async fn move_handler(
423423
)
424424
.await?;
425425

426-
let (move_response, config_version) =
427-
conn.transaction::<_, superposition::AppError, _>(|transaction_conn| {
426+
let (move_response, config_version) = conn
427+
.transaction::<_, superposition::AppError, _>(|transaction_conn| {
428428
let move_response = operations::r#move(
429429
&workspace_context,
430430
ctx_id,

crates/frontend/src/app.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use crate::pages::{
2929
experiment::ExperimentPage,
3030
home::Home,
3131
organisations::Organisations,
32+
override_page::{CreateOverride, EditOverride, OverridePage},
3233
type_template::TypePage,
3334
type_templates::TypesPage,
3435
webhook::Webhook,
@@ -207,6 +208,17 @@ pub fn App(app_envs: Envs) -> impl IntoView {
207208
/>
208209

209210
<Route ssr=SsrMode::Async path="overrides" view=ContextOverride />
211+
<Route
212+
ssr=SsrMode::Async
213+
path="overrides/action/create"
214+
view=CreateOverride
215+
/>
216+
<Route
217+
ssr=SsrMode::Async
218+
path="overrides/:context_id/edit"
219+
view=EditOverride
220+
/>
221+
<Route ssr=SsrMode::Async path="overrides/:context_id" view=OverridePage />
210222

211223
<Route ssr=SsrMode::Async path="resolve" view=Home />
212224

crates/frontend/src/components.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ pub mod cohort_schema;
88
pub mod condition_pills;
99
pub mod context_card;
1010
pub mod context_form;
11+
pub mod context_override_form;
1112
pub mod datetime;
1213
pub mod default_config_form;
1314
pub mod delete_modal;
@@ -37,6 +38,7 @@ pub mod side_nav;
3738
pub mod skeleton;
3839
pub mod sortable;
3940
pub mod stat;
41+
pub mod step_indicator;
4042
pub mod table;
4143
pub mod tip;
4244
pub mod toast;

crates/frontend/src/components/button.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub fn Button(
1717
#[prop(into, default = String::new())] id: String,
1818
#[prop(into, default = String::from("ri-edit-2-line"))] icon_class: String,
1919
#[prop(default = false)] loading: bool,
20+
#[prop(default = false)] disabled: bool,
2021
#[prop(default = ButtonStyle::Fill)] style: ButtonStyle,
2122
#[prop(into, optional)] force_style: Option<String>,
2223
) -> impl IntoView {
@@ -33,18 +34,19 @@ pub fn Button(
3334

3435
move || {
3536
let loading = loading || !*client_side_ready.get();
36-
let loading_class = if loading {
37+
let is_disabled = loading || disabled;
38+
let disabled_class = if is_disabled {
3739
"hover:cursor-not-allowed"
3840
} else {
3941
""
4042
};
4143

4244
view! {
4345
<button
44-
class=format!("{common_style} {style} {class} {loading_class}")
46+
class=format!("{common_style} {style} {class} {disabled_class}")
4547
id=id.clone()
4648
on:click=move |e| on_click.call(e)
47-
disabled=loading
49+
disabled=is_disabled
4850
>
4951
{if loading {
5052
view! { <span class="loading loading-dots loading-sm" /> }.into_view()

crates/frontend/src/components/context_card.rs

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
use std::ops::Deref;
2-
31
use leptos::*;
2+
use leptos_router::A;
43
use serde_json::{Map, Value};
54
use superposition_types::database::models::cac::Context;
65

76
use crate::{
87
components::{
98
condition_pills::Condition as ConditionComponent,
10-
datetime::Datetime,
11-
description::InfoDescription,
129
table::{Table, types::Column},
13-
tooltip::Tooltip,
1410
},
1511
logic::Conditions,
1612
};
@@ -42,7 +38,11 @@ fn ContextOptions(
4238
) -> impl IntoView {
4339
view! {
4440
<div class="w-fit dropdown dropdown-left">
45-
<label tabindex="0" class="btn btn-sm text-xs m-1 w-full">
41+
<label
42+
tabindex="0"
43+
class="btn btn-sm text-xs m-1 w-full"
44+
on:click=|ev: web_sys::MouseEvent| ev.stop_propagation()
45+
>
4646
<i class="ri-more-2-fill" />
4747
</label>
4848
<ul
@@ -86,15 +86,14 @@ pub fn ContextCard(
8686
context: Context,
8787
overrides: Map<String, Value>,
8888
#[prop(default = true)] show_actions: bool,
89+
#[prop(into)] href: String,
8990
#[prop(into)] handle_create_experiment: Callback<String, ()>,
9091
#[prop(into)] handle_delete_experiment: Callback<String, ()>,
9192
#[prop(into)] handle_edit: Callback<String, ()>,
9293
#[prop(into)] handle_clone: Callback<String, ()>,
9394
#[prop(into)] handle_delete: Callback<String, ()>,
9495
) -> impl IntoView {
9596
let conditions = Conditions::from_iter(context.value.clone().into_inner());
96-
let description = context.description.clone();
97-
let change_reason = context.change_reason.clone();
9897

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

110109
let context = store_value(context);
110+
let href = store_value(href);
111111

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

120120
view! {
121-
<div class="rounded-lg shadow bg-base-100 p-6 flex flex-col gap-4">
121+
<div class="block rounded-lg shadow bg-base-100 p-6 flex flex-col gap-4">
122122
<div class="flex justify-between">
123123
<div class="flex gap-4 items-center">
124124
<h3 class="card-title text-base timeline-box text-gray-800 bg-base-100 shadow-md m-0 w-max">
125125
"Condition"
126126
</h3>
127-
<InfoDescription
128-
description=description.deref().to_string()
129-
change_reason=change_reason.deref().to_string()
130-
/>
131-
<Tooltip icon_class="ri-information-line ri-lg">
132-
<div class="flex flex-col gap-4">
133-
<div class="flex flex-col gap-1">
134-
<div class="font-bold">"Created"</div>
135-
<div class="flex gap-1 items-center">
136-
<i class="ri-user-line text-gray-950" />
137-
<span>{context.with_value(|c| c.created_by.clone())}</span>
138-
</div>
139-
<div class="flex gap-1 items-center">
140-
<i class="ri-time-line text-gray-950" />
141-
<Datetime datetime=context.with_value(|c| c.created_at) />
142-
</div>
143-
</div>
144-
<div class="flex flex-col gap-1">
145-
<div class="font-bold">"Last Modified"</div>
146-
<div class="flex gap-1 items-center">
147-
<i class="ri-user-line text-gray-950" />
148-
<span>
149-
{context.with_value(|c| c.last_modified_by.clone())}
150-
</span>
151-
</div>
152-
<div class="flex gap-1 items-center">
153-
<i class="ri-time-line text-gray-950" />
154-
<Datetime datetime=context.with_value(|c| c.last_modified_at) />
155-
</div>
156-
</div>
157-
</div>
158-
</Tooltip>
159127
</div>
160128
<Show when=move || actions_supported>
161-
<div class="h-fit flex gap-4 text-right">
129+
<div class="h-fit flex gap-2 items-center text-right">
130+
<A href=href.with_value(|h| h.clone()) class="btn btn-sm btn-ghost">
131+
{"See More"}
132+
</A>
162133
<ContextOptions
163134
handle_create_experiment=move |_| {
164135
handle_create_experiment.call(context.with_value(|c| c.id.clone()))

0 commit comments

Comments
 (0)