mirror of
https://github.com/we-promise/sure.git
synced 2026-04-07 06:21:23 +00:00
Add Reset AI cache button to rules index
Add menu button with confirmation dialog to reset AI cache. Fix menu_item to safely handle non-standard confirm values.
This commit is contained in:
@@ -50,7 +50,8 @@ class DS::MenuItem < DesignSystemComponent
|
||||
data = merged_opts.delete(:data) || {}
|
||||
|
||||
if confirm.present?
|
||||
data = data.merge(turbo_confirm: confirm.to_data_attribute)
|
||||
confirm_value = confirm.respond_to?(:to_data_attribute) ? confirm.to_data_attribute : confirm
|
||||
data = data.merge(turbo_confirm: confirm_value)
|
||||
end
|
||||
|
||||
if frame.present?
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
<div class="flex items-center gap-2">
|
||||
<% if @rules.any? %>
|
||||
<%= render DS::Menu.new do |menu| %>
|
||||
<% menu.with_item(
|
||||
variant: "button",
|
||||
text: "Reset AI cache",
|
||||
href: clear_ai_cache_rules_path,
|
||||
icon: "refresh-cw",
|
||||
method: :post,
|
||||
confirm: CustomConfirm.new(
|
||||
title: "Reset AI cache?",
|
||||
body: "Are you sure you want to reset the AI cache? This will allow AI rules to re-process all transactions. This may incur additional API costs.",
|
||||
btn_text: "Reset Cache"
|
||||
)) %>
|
||||
<% menu.with_item(
|
||||
variant: "button",
|
||||
text: "Delete all rules",
|
||||
|
||||
Reference in New Issue
Block a user