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 ae783fd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
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 ae783fd

Please sign in to comment.