Skip to content

Commit

Permalink
Merge pull request #8383 from alphagov/562_Add-More-page
Browse files Browse the repository at this point in the history
562 add more page
  • Loading branch information
farahTW authored Oct 30, 2023
2 parents 3aa8d64 + bfe4f4b commit b6f45b2
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/controllers/admin/more_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Admin::MoreController < Admin::BaseController
before_action :check_new_design_system_permissions, only: %i[index]
layout :get_layout

def index; end

private

def check_new_design_system_permissions
forbidden! unless new_design_system?
end

def get_layout
design_system_actions = %w[index] if preview_design_system?(next_release: false)

if design_system_actions&.include?(action_name)
"design_system"
else
"admin"
end
end
end
58 changes: 58 additions & 0 deletions app/helpers/admin/url_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,58 @@ def admin_topical_events_header_menu_link
admin_header_menu_link "Topical events", admin_topical_events_path
end

def admin_topical_events_link
admin_link "Topical events", admin_topical_events_path
end

def admin_organisations_header_menu_link
admin_header_menu_link "Departments & agencies", admin_organisations_path
end

def admin_organisations_link
admin_link "Organisations", admin_organisations_path
end

def admin_roles_header_menu_link
admin_header_menu_link "Roles", admin_roles_path
end

def admin_roles_link
admin_link "Roles", admin_roles_path
end

def admin_people_header_menu_link
admin_header_menu_link "People", admin_people_path
end

def admin_people_link
admin_link "People", admin_people_path
end

def admin_worldwide_organisations_header_menu_link
admin_header_menu_link "Worldwide organisations", admin_worldwide_organisations_path
end

def admin_worldwide_organisations_link
admin_link "Worldwide organisations", admin_worldwide_organisations_path
end

def admin_world_location_news_header_menu_link
admin_header_menu_link "World location news", admin_world_location_news_index_path
end

def admin_world_location_news_link
admin_link "World location news", admin_world_location_news_index_path
end

def admin_policy_groups_header_menu_link
admin_header_menu_link "Groups", admin_policy_groups_path
end

def admin_policy_groups_link
admin_link "Groups", admin_policy_groups_path
end

def admin_users_header_link
tag.li(link_to("All users", admin_users_path))
end
Expand All @@ -53,30 +81,60 @@ def admin_fields_of_operation_header_menu_link
end
end

def admin_fields_of_operation_link
if current_user && current_user.can_handle_fatalities?
admin_link "Fields of operation", admin_operational_fields_path
end
end

def admin_cabinet_ministers_header_menu_link
admin_header_menu_link "Cabinet ministers order", admin_cabinet_ministers_path
end

def admin_cabinet_ministers_link
admin_link "Cabinet ministers order", admin_cabinet_ministers_path
end

def admin_get_involved_header_menu_link
if can?(:administer, :get_involved_section)
admin_header_menu_link "Get involved", admin_get_involved_path
end
end

def admin_get_involved_link
if can?(:administer, :get_involved_section)
admin_link "Get involved", admin_get_involved_path
end
end

def admin_sitewide_settings_header_menu_link
if can?(:administer, :sitewide_settings_section)
admin_header_menu_link "Sitewide settings", admin_sitewide_settings_path
end
end

def admin_sitewide_settings_link
if can?(:administer, :sitewide_settings_section)
admin_link "Sitewide settings", admin_sitewide_settings_path
end
end

def admin_governments_header_menu_link
admin_header_menu_link "Governments", admin_governments_path
end

def admin_governments_link
admin_link "Governments", admin_governments_path
end

def admin_header_menu_link(name, path)
tag.li(link_to(name, path, role: "menuitem"), class: "masthead-menu-item")
end

def admin_link(name, path)
link_to(name, path, class: "govuk-link")
end

def admin_header_link(name, path, path_matcher = nil, options = {})
path_matcher ||= Regexp.new("^#{Regexp.escape(path)}")
if user_signed_in?
Expand Down
24 changes: 24 additions & 0 deletions app/views/admin/more/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<% content_for :page_title, "More" %>
<% content_for :title, "More" %>
<% content_for :title_margin_bottom, 6 %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render "govuk_publishing_components/components/list", {
items: [
admin_cabinet_ministers_link,
admin_fields_of_operation_link,
admin_get_involved_link,
admin_governments_link,
admin_policy_groups_link,
admin_organisations_link,
admin_people_link,
admin_roles_link,
admin_sitewide_settings_link,
admin_topical_events_link,
admin_world_location_news_link,
admin_worldwide_organisations_link,
],
} %>
</div>
</div>
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ def redirect(path, options = { prefix: Whitehall.router_prefix })
get :new_document_options, to: "new_document#new_document_options_redirect"
post :new_document_options, to: "new_document#new_document_options_redirect"

get "/more" => "more#index", as: :more

resources :statistics_announcements, except: [:destroy] do
member do
get :cancel
Expand Down
16 changes: 16 additions & 0 deletions test/functional/admin/more_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require "test_helper"

class Admin::MoreControllerTest < ActionController::TestCase
setup do
login_as_preview_design_system_user :writer
end

view_test "GET #index renders the 'More' page with a correctly formatted list of links" do
get :index

assert_response :success
assert_select "h1.govuk-heading-xl", text: "More"
assert_select ".govuk-list"
assert_select "a.govuk-link", text: "Cabinet ministers order"
end
end

0 comments on commit b6f45b2

Please sign in to comment.