defmodule RulesteadAdmin.Components.AuditComponents do
@moduledoc false
use Phoenix.Component
attr(:active?, :boolean, required: true)
attr(:flag_key, :string, required: true)
attr(:environment_name, :string, required: true)
attr(:reason, :string, default: nil)
attr(:kill_path, :string, required: true)
attr(:timeline_path, :string, required: true)
attr(:show_release_button, :boolean, default: false)
def kill_switch_banner(assigns) do
~H"""
{if(@active?, do: "Kill switch active", else: "Kill switch inactive")}
{@flag_key} is forcing authored evaluation back to the default value in
{@environment_name}.
No environment override is active for {@flag_key} in {@environment_name}.
Latest reason: {@reason}
"""
end
attr(:mode, :atom, required: true)
attr(:flag_key, :string, required: true)
attr(:production?, :boolean, required: true)
attr(:confirmation_value, :string, default: "")
attr(:reason_value, :string, default: "")
attr(:error, :string, default: nil)
def kill_switch_form(assigns) do
assigns =
assign(assigns,
title: if(assigns.mode == :engage, do: "Engage kill switch", else: "Release kill switch"),
event: if(assigns.mode == :engage, do: "engage", else: "release"),
submit_label:
if(assigns.mode == :engage, do: "Confirm kill switch", else: "Confirm release")
)
~H"""
"""
end
attr(:entry, :map, required: true)
attr(:show_flag, :boolean, default: false)
attr(:show_rollback, :boolean, default: false)
def timeline_row(assigns) do
~H"""
{@entry.title}
{@entry.meta}
Automatic source {@entry.source_label}
Manual rollout action
{@entry.summary}
Flag: {@entry.resource_key}
Reason: {@entry.reason}
Rollback of audit event {@entry.rollback_of_event_id}
Show raw detail
{inspect(@entry.raw, pretty: true)}
"""
end
attr(:entry, :map, required: true)
attr(:source_label, :string, default: "Before")
attr(:current_target_label, :string, default: nil)
attr(:proposed_target_label, :string, default: "After")
attr(:structured_label, :string, default: "Readable diff")
def diff_card(assigns) do
~H"""
{@structured_label}
{@source_label}
{Map.get(@entry, :source_summary) || Map.get(@entry, :before_summary)}
{@current_target_label}
{Map.get(@entry, :current_target_summary) || "Not available"}
{@proposed_target_label}
{Map.get(@entry, :proposed_target_summary) || Map.get(@entry, :after_summary)}
"""
end
end