-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add metric registry change suggestions (#4460)
* Start implementing Metric Registry Change Suggestions * Abstract some components in registry change suggestions liveview * Metric Registry Change Suggestions liveview working * Change type of metric registry submitter form * Wire Metric Registry Change Undo. Fix filters on index page * Dirty hack for metric registry event handling. Improve sorting of suggestions * Do not call MailJet functions outside tests where mailjet is tested * Fix typo in html id Co-authored-by: Tsvetozar Penov <tsvetozar.penov@gmail.com> --------- Co-authored-by: Tsvetozar Penov <tsvetozar.penov@gmail.com>
- Loading branch information
1 parent
758a2fc
commit d1319d0
Showing
22 changed files
with
898 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
defmodule Sanbase.ExAudit.Patch do | ||
def format_patch(%{patch: patch}) when is_map(patch) do | ||
changes = | ||
patch | ||
|> Enum.map(fn {field, change} -> | ||
safe_field = Phoenix.HTML.html_escape(to_string(field)) | ||
safe_change = Phoenix.HTML.html_escape(format_change_value(change)) | ||
|
||
content = PhoenixHTMLHelpers.Tag.content_tag(:strong, safe_field) | ||
PhoenixHTMLHelpers.Tag.content_tag(:li, [content, ": ", safe_change]) | ||
end) | ||
|
||
PhoenixHTMLHelpers.Tag.content_tag(:ul, changes, class: "list-disc list-inside") | ||
end | ||
|
||
def format_patch(_), do: Phoenix.HTML.raw("") | ||
|
||
defp format_change_value({:changed, {:primitive_change, old_val, new_val}}) do | ||
old = inspect(old_val) | ||
new = inspect(new_val) | ||
"#{old} → #{new}" | ||
end | ||
|
||
defp format_change_value({:changed, nested}) when is_map(nested) do | ||
nested_changes = | ||
nested | ||
|> Enum.map_join(", ", fn {k, v} -> | ||
"#{to_string(k)}: #{format_change_value(v)}" | ||
end) | ||
|
||
"{#{nested_changes}}" | ||
end | ||
|
||
defp format_change_value(other), do: inspect(other) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.