Skip to content

Commit

Permalink
fix: removed edit option for experiment contexts (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
ShubhranshuSanjeev authored and Datron committed Sep 6, 2024
1 parent c615b77 commit a9b01a6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/cac_toml/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cac_toml"
version = "0.2.1"
version = "0.0.1"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
28 changes: 21 additions & 7 deletions crates/frontend/src/components/context_card.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ pub fn context_card(
Column::default("VALUE".to_string()),
];

let actions_supported = show_actions
&& !conditions
.iter()
.any(|condition| condition.left_operand == "variantIds");

let edit_unsupported = conditions
.iter()
.any(|condition| matches!(condition.operator, ConditionOperator::Other(_)));
Expand All @@ -57,23 +62,25 @@ pub fn context_card(
<h3 class="card-title text-base timeline-box text-gray-800 bg-base-100 shadow-md font-mono m-0 w-max">
"Condition"
</h3>
<Show when=move || show_actions>
<Show when=move || actions_supported>
<div class="h-fit text-right space-x-4">
<Show when=move || !edit_unsupported.clone()>
<Show when=move || !edit_unsupported>
<i
class="ri-pencil-line ri-lg text-blue-500 cursor-pointer"
on:click=move |_| {
handle_edit.call((context.get_value(), overrides.get_value()));
}
/>
></i>

<i
class="ri-file-copy-line ri-lg text-blue-500 cursor-pointer"
on:click=move |_| {
handle_clone.call((context.get_value(), overrides.get_value()));
}
/>
></i>

</Show>
<Show when=move || edit_unsupported.clone()>
<Show when=move || edit_unsupported>
<span class="badge badge-warning text-xs ml-2 flex items-center">
{"Edit Unsupported"}
</span>
Expand All @@ -84,14 +91,21 @@ pub fn context_card(
let context_id = context_id.get_value();
handle_delete.call(context_id);
}
/>
></i>

</div>
</Show>
<Show when=move || !actions_supported>
<span class="badge badge-warning text-xs ml-2 flex items-center">
{"Edit Unsupported"}
</span>
</Show>
</div>

<div class="pl-5">
<ConditionComponent
conditions=conditions // Clone only once before reusing in multiple closures
// Clone only once before reusing in multiple closures
conditions=conditions
id=context_id.get_value()
class="xl:w-[400px] h-fit"
/>
Expand Down
11 changes: 6 additions & 5 deletions crates/frontend/src/components/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,16 +219,17 @@ fn basic_input(
/>

{move || {
error_rs
.get()
.map(|err| {
match error_rs.get() {
Some(err) => {
view! {
<span class="flex gap-2 px-4 text-xs font-semibold text-red-600">
<i class="ri-close-circle-line"></i>
{err}
</span>
}
});
}.into_view()
},
None => ().into_view()
}
}}

</div>
Expand Down

0 comments on commit a9b01a6

Please sign in to comment.