-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Wrap sensitive attribute rendering in a new `SensitiveAttribute…
…` live component This will handle hiding the value by default and having a "click to display" icon The icon can then be clicked to hide it again
- Loading branch information
1 parent
652611d
commit c107815
Showing
7 changed files
with
86 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
defmodule AshAdmin.Components.Resource.SensitiveAttribute do | ||
use Phoenix.LiveComponent | ||
|
||
import AshAdmin.CoreComponents | ||
|
||
def mount(socket) do | ||
{:ok, assign(socket, viewed: false)} | ||
end | ||
|
||
def render(assigns) do | ||
assigns = assign(assigns, present?: assigns.value not in [nil, ""]) | ||
|
||
~H""" | ||
<div> | ||
<span :if={@present? && !@viewed} class="italic"> | ||
--redacted-- | ||
<span class="cursor-pointer" phx-click="toggle_sensitive_attribute" phx-target={@myself}> | ||
<.icon name="hero-eye-solid" class="w-5 h-5 text-gray-500" /> | ||
</span> | ||
</span> | ||
<span :if={@present? && @viewed}> | ||
<%= render_slot(@inner_block) %> | ||
<span class="cursor-pointer" phx-click="toggle_sensitive_attribute" phx-target={@myself}> | ||
<.icon name="hero-eye-slash-solid" class="w-5 h-5 text-gray-500" /> | ||
</span> | ||
</span> | ||
</div> | ||
""" | ||
end | ||
|
||
def handle_event("toggle_sensitive_attribute", _params, socket) do | ||
{:noreply, assign(socket, viewed: !socket.assigns.viewed)} | ||
end | ||
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"!comment!":"This file was auto-generated by `mix phx.digest`. Remove it and all generated artefacts with `mix phx.digest.clean --all`", | ||
"version":1, | ||
"latest":{"assets/app.css":"assets/app-161d914bba3ef8912bae46d62332075a.css","assets/app.js":"assets/app-aac45a999218cb837d0d4006c02b7dff.js"}, | ||
"digests":{"assets/app-161d914bba3ef8912bae46d62332075a.css":{"size":35588,"sha512":"UD0fP1n3WDpLGBt/Z/B2CpSpg8DUFlcIM3LV86qlBW28sgXzM2nOogI6tFmH6IclRlq2VBl+O5Pc+TKkBgHTcg==","digest":"161d914bba3ef8912bae46d62332075a","logical_path":"assets/app.css","mtime":63867247404},"assets/app-aac45a999218cb837d0d4006c02b7dff.js":{"size":108631,"sha512":"Q/jSWd9SG+3D9BjNSTSo3XNU/Q0xBrdwB/OgT7W4clywBHa5VxbBNh0QBT5ZsBfTZ7MANggW8XW9rOM5UVteYg==","digest":"aac45a999218cb837d0d4006c02b7dff","logical_path":"assets/app.js","mtime":63867247404},"assets/app-cdfeb0af86efa39e60bcea317f8c65d5.js":{"digest":"cdfeb0af86efa39e60bcea317f8c65d5","logical_path":"assets/app.js","mtime":63867247325,"sha512":"4cLBcG07unx230U6//4lAjOnKo5FAbYVeHCy/46Fa0UbVVcI0tmfCArbloLf0mEfRgzLZev132DFudJhCydOqQ==","size":108632}} | ||
"latest":{"assets/app.css":"assets/app-f480ad9fb2a3744d668ac31cc919441f.css","assets/app.js":"assets/app-aac45a999218cb837d0d4006c02b7dff.js"}, | ||
"digests":{"assets/app-aac45a999218cb837d0d4006c02b7dff.js":{"size":108631,"sha512":"Q/jSWd9SG+3D9BjNSTSo3XNU/Q0xBrdwB/OgT7W4clywBHa5VxbBNh0QBT5ZsBfTZ7MANggW8XW9rOM5UVteYg==","digest":"aac45a999218cb837d0d4006c02b7dff","logical_path":"assets/app.js","mtime":63867771918},"assets/app-f480ad9fb2a3744d668ac31cc919441f.css":{"size":37300,"sha512":"g15iWMXrhNqfFRVkrKH4c9XonkZnDWFEdGuzX0BW319sucBZFfD0lZ8GTgPJcKl3gyhUqH0Lm4jy80LgfFao7w==","digest":"f480ad9fb2a3744d668ac31cc919441f","logical_path":"assets/app.css","mtime":63867771918}} | ||
} |