Skip to content

Commit

Permalink
Add destroy link in the show template
Browse files Browse the repository at this point in the history
  • Loading branch information
shouichi authored and pablobm committed Feb 18, 2022
1 parent b39db6b commit e510efe
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/assets/stylesheets/administrate/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ input[type="submit"],
color: $blue;
}

.button--danger {
background-color: $red;

&:hover {
background-color: mix($black, $red, 20%);
color: $white;
}
}

.button--nav {
margin-bottom: $base-spacing;
}
8 changes: 8 additions & 0 deletions app/views/administrate/application/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ as well as a link to its edit page.
[:edit, namespace, page.resource],
class: "button",
) if valid_action?(:edit) && show_action?(:edit, page.resource) %>

<%= link_to(
t("administrate.actions.destroy"),
[namespace, page.resource],
class: "button button--danger",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
) if valid_action?(:destroy) && show_action?(:destroy, page.resource) %>
</div>
</header>

Expand Down
8 changes: 8 additions & 0 deletions spec/features/show_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,14 @@
expect(page).to have_header("Edit #{displayed(customer)}")
end

it "displays destroy link" do
customer = create(:customer)

visit admin_customer_path(customer)

expect { click_on "Destroy" }.to change(Customer, :count).from(1).to(0)
end

it "displays translated labels" do
custom_label = "Newsletter Subscriber"
customer = create(:customer)
Expand Down

0 comments on commit e510efe

Please sign in to comment.