Skip to content

Commit

Permalink
Add delete button to delete an org member
Browse files Browse the repository at this point in the history
  • Loading branch information
Shivam Singhal committed Nov 5, 2024
1 parent 2c97b5f commit 736eb96
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/models/accounts/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ def role_for(organization)
access_for(organization).role
end

def membership_for(organization)
access_for(organization)
end

def team_for(organization)
access_for(organization)&.team
end
Expand Down
20 changes: 15 additions & 5 deletions app/views/accounts/organizations/_teams.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@
<% end %>
<% user_role = current_user_role %>
<% member_role = member.role_for(current_organization) %>
<% if can_current_user_edit_role?(member) %>
<% row.with_cell(wrap: true) do %>
<% row.with_cell(wrap: true) do %>
<div class="flex gap-x-2 justify-end">
<%= render V2::ModalComponent.new(title: "Edit role") do |modal| %>
<% if can_current_user_edit_role?(member) %>
<%= render V2::ModalComponent.new(title: "Edit role") do |modal| %>
<% modal.with_button(scheme: :light,
type: :action,
size: :xxs,
Expand All @@ -114,10 +114,20 @@
<% modal.with_body do %>
<%= render partial: "accounts/invitations/edit_form", locals: { email: member.email, member_role: member_role } %>
<% end %>
</div>
<% end %>
<% end %>
<% if can_current_user_remove_member?(member) %>
<%= render V2::ButtonComponent.new(
scheme: :danger,
type: :button,
size: :xxs,
options: accounts_organization_membership_path(current_organization, member.membership_for(current_organization)),
html_options: { method: :delete, data: { turbo_method: :delete, turbo_confirm: "Are you sure you want to remove #{member.email} from the organization?" } }) do |b|
b.with_icon("v2/trash.svg")
end %>
<% end %>
</div>
<% end %>
<% end %>
<% end %>
<% end %>

Expand Down

0 comments on commit 736eb96

Please sign in to comment.