diff --git a/app/assets/stylesheets/administrate/components/_buttons.scss b/app/assets/stylesheets/administrate/components/_buttons.scss index d05fe5881e..d2394f92d1 100644 --- a/app/assets/stylesheets/administrate/components/_buttons.scss +++ b/app/assets/stylesheets/administrate/components/_buttons.scss @@ -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; } diff --git a/app/views/administrate/application/show.html.erb b/app/views/administrate/application/show.html.erb index 2e860e39cd..41e5b787b3 100644 --- a/app/views/administrate/application/show.html.erb +++ b/app/views/administrate/application/show.html.erb @@ -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) %> diff --git a/spec/features/show_page_spec.rb b/spec/features/show_page_spec.rb index 55d980a7f3..d3e5730cad 100644 --- a/spec/features/show_page_spec.rb +++ b/spec/features/show_page_spec.rb @@ -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)