Skip to content

Commit

Permalink
Add a "back" link to the navigation
Browse files Browse the repository at this point in the history
This solves half of #271 by implementing a link to take the user back to
the main application. It's assumed that `root_url` without a namespace
returns the main application's root.
  • Loading branch information
nickcharlton committed Jan 7, 2020
1 parent 74ba62c commit 1f7cbbd
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/assets/stylesheets/administrate/components/_buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,11 @@ input[type="submit"],
}
}
}

.button--alt {
background-color: transparent;
border: $base-border;
border-color: $blue;
color: $blue;
margin-bottom: $base-spacing;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ $_navigation-link-padding: 0.6em;

.navigation {
flex: 1 0 10rem;
padding-bottom: $base-spacing;
padding-right: calc(#{$base-spacing} - #{$_navigation-link-padding});
padding-top: $base-spacing;
padding: $base-spacing;
padding-left: 0;
}

.navigation__link {
Expand Down
2 changes: 2 additions & 0 deletions app/views/administrate/application/_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ as defined by the routes in the `admin/` namespace
%>

<nav class="navigation" role="navigation">
<%= link_to "Back to app", root_url, class: "button button--alt" %>

<% Administrate::Namespace.new(namespace).resources.each do |resource| %>
<%= link_to(
display_resource_name(resource),
Expand Down
7 changes: 7 additions & 0 deletions spec/features/navigation_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
require "rails_helper"

describe "navigation" do
it "has the link of back to application" do
visit admin_customers_path

navigation = find(".navigation")
expect(navigation).to have_link("Back to app")
end

it "highlights the link to the current page's resource type" do
visit admin_customers_path

Expand Down

0 comments on commit 1f7cbbd

Please sign in to comment.