-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow different rules and action for delete user (#2714)
* Refactor user profile for remaining components * Rename components module * Remove unnecessary vertical bar between table actions in UserLive.Components * Replace not working private with metadata * Address the user directly yet once more * Fix use of metadata modal * Fix cancel scheduled deletion on admin users * Revert change * There is pre-existing bug that needs to be fixed when clicking outside the modal * Fix test cases and revert to attrs string keys * Rename menu context to current user --------- Co-authored-by: Elias W. BA <[email protected]>
- Loading branch information
Showing
15 changed files
with
311 additions
and
206 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
defmodule LightningWeb.ProfileLive.Components do | ||
use LightningWeb, :component | ||
|
||
attr :current_user, Lightning.Accounts.User, required: true | ||
|
||
def user_info(assigns) do | ||
~H""" | ||
<div class="px-4 sm:px-0"> | ||
<h2 class="text-base font-semibold leading-7 text-gray-900"> | ||
<%= @current_user.first_name %> <%= @current_user.last_name %> | ||
</h2> | ||
<p class="mt-1 text-sm leading-6 text-gray-600"> | ||
Change name, email, password, and request deletion. | ||
</p> | ||
<div class="border-b border-gray-900/10 mt-6 mb-6" /> | ||
<p class="mt-1 text-sm leading-6 text-gray-600"> | ||
Created: <%= @current_user.inserted_at |> Calendar.strftime("%c %Z") %> UTC | ||
</p> | ||
<p class="mt-1 text-sm leading-6 text-gray-600"> | ||
Email: <%= @current_user.email %> | ||
</p> | ||
</div> | ||
""" | ||
end | ||
|
||
attr :page_title, :string, required: true | ||
attr :live_action, :atom, required: true | ||
attr :current_user, Lightning.Accounts.User, required: true | ||
|
||
attr :user_deletion_modal, :atom, | ||
default: LightningWeb.Components.UserDeletionModal | ||
|
||
attr :delete_user_url, :string, required: true | ||
|
||
def action_cards(assigns) do | ||
~H""" | ||
<div id={"user-#{@current_user.id}"} class="md:col-span-2"> | ||
<.live_component | ||
:if={@live_action == :delete} | ||
module={@user_deletion_modal} | ||
id={@current_user.id} | ||
user={@current_user} | ||
logout={true} | ||
return_to={~p"/profile"} | ||
/> | ||
<.live_component | ||
module={LightningWeb.ProfileLive.FormComponent} | ||
id={@current_user.id} | ||
title={@page_title} | ||
action={@live_action} | ||
user={@current_user} | ||
return_to={~p"/profile"} | ||
/> | ||
<.live_component | ||
module={LightningWeb.ProfileLive.MfaComponent} | ||
id={"#{@current_user.id}_mfa_section"} | ||
user={@current_user} | ||
/> | ||
<.live_component | ||
module={LightningWeb.ProfileLive.GithubComponent} | ||
id={"#{@current_user.id}_github_section"} | ||
user={@current_user} | ||
/> | ||
<.delete_user_card url={@delete_user_url} /> | ||
</div> | ||
""" | ||
end | ||
|
||
attr :url, :string, required: true | ||
|
||
defp delete_user_card(assigns) do | ||
~H""" | ||
<div class="bg-white shadow-sm ring-1 ring-gray-900/5 sm:rounded-xl md:col-span-2 mb-4"> | ||
<div class="px-4 py-6 sm:p-8"> | ||
<span class="text-xl">Delete account</span> | ||
<span class="float-right"> | ||
<.link navigate={@url}> | ||
<button | ||
type="button" | ||
class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-danger-500 hover:bg-danger-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-danger-500" | ||
> | ||
Delete my account | ||
</button> | ||
</.link> | ||
</span> | ||
</div> | ||
</div> | ||
""" | ||
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
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.