-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create design_system.html.erb layout. Make the ReportsController use the new layout. Create a helper to build the navigation link structure for the navbar. Write tests for the NavigationItems helper.
- Loading branch information
1 parent
1506373
commit 6a4830e
Showing
4 changed files
with
86 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module NavigationItemsHelper | ||
def navigation_items(is_editor) | ||
list = [ | ||
{ text: "Publications", href: root_path }, | ||
] | ||
|
||
if is_editor | ||
list << { text: "Add artefact", href: new_artefact_path } | ||
list << { text: "Downtime", href: downtimes_path } | ||
end | ||
|
||
list << { text: "Reports", href: reports_path } | ||
list << { text: "Search by user", href: user_search_path } | ||
list << { text: "Sign out", href: "/auth/gds/sign_out" } | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<% environment = GovukPublishingComponents::AppHelpers::Environment.current_acceptance_environment %> | ||
<%= render "govuk_publishing_components/components/layout_for_admin", product_title: "Publisher", browser_title: yield(:page_title), environment: environment do %> | ||
<% render "layouts/google_tag_manager" %> | ||
<%= render "govuk_publishing_components/components/skip_link" %> | ||
<% user = current_user %> | ||
<%= render "govuk_publishing_components/components/layout_header", { | ||
product_name: "Publisher", | ||
environment: environment, | ||
navigation_items: navigation_items(current_user.govuk_editor?) | ||
} %> | ||
|
||
<div class="govuk-width-container"> | ||
<% [:success, :info, :warning, :danger, :notice, :alert].select { |k| flash[k].present? }.each do |k| %> | ||
<% | ||
case k | ||
when :notice | ||
alert_class = "success" | ||
when :alert | ||
alert_class = "danger" | ||
else | ||
alert_class = k | ||
end | ||
%> | ||
<div class="alert alert-<%= alert_class %>" | ||
data-module="auto-track-event" | ||
data-track-action="alert-<%= alert_class %>" | ||
data-track-label="<%= strip_tags(flash[k]) %>"> | ||
<%= flash[k] %> | ||
</div> | ||
<% end %> | ||
<%= yield %> | ||
</div> | ||
|
||
<%= render "govuk_publishing_components/components/layout_footer", { | ||
navigation: [], | ||
} %> | ||
<% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
require "test_helper" | ||
|
||
class NavigationItemsHelperTest < ActionView::TestCase | ||
context "NavigationItemsHelper" do | ||
should "include editor only links when user is an editor" do | ||
assert_equal [ | ||
{ text: "Publications", href: root_path }, | ||
{ text: "Add artefact", href: new_artefact_path }, | ||
{ text: "Downtime", href: downtimes_path }, | ||
{ text: "Reports", href: reports_path }, | ||
{ text: "Search by user", href: user_search_path }, | ||
{ text: "Sign out", href: "/auth/gds/sign_out" }, | ||
], navigation_items(true) | ||
end | ||
|
||
should "include not include editor only links when user is not an editor" do | ||
assert_equal [ | ||
{ text: "Publications", href: root_path }, | ||
{ text: "Reports", href: reports_path }, | ||
{ text: "Search by user", href: user_search_path }, | ||
{ text: "Sign out", href: "/auth/gds/sign_out" }, | ||
], navigation_items(false) | ||
end | ||
end | ||
end |