-
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 e8cc993
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) | ||
Check failure on line 2 in app/helpers/navigation_items_helper.rb GitHub Actions / Lint Ruby / Run RuboCop
|
||
list = [ | ||
Check failure on line 3 in app/helpers/navigation_items_helper.rb GitHub Actions / Lint Ruby / Run RuboCop
|
||
{ text: "Publications", href: root_path }, | ||
Check failure on line 4 in app/helpers/navigation_items_helper.rb GitHub Actions / Lint Ruby / Run RuboCop
|
||
] | ||
|
||
if is_editor | ||
list << { text: "Add artefact", href: new_artefact_path } | ||
Check failure on line 8 in app/helpers/navigation_items_helper.rb GitHub Actions / Lint Ruby / Run RuboCop
|
||
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 |