Skip to content

Commit

Permalink
feat: user can navigate to Frameworks portal
Browse files Browse the repository at this point in the history
  • Loading branch information
ryantk committed Aug 23, 2023
1 parent 89a4674 commit aeaa0b9
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 32 deletions.
21 changes: 14 additions & 7 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def maintenance

protected

helper_method :current_user, :support?, :cookie_policy, :record_ga?, :engagement?
helper_method :current_user, :cookie_policy, :record_ga?, :engagement_portal?, :support_portal?, :frameworks_portal?

# @return [User, Guest]
#
Expand Down Expand Up @@ -62,17 +62,24 @@ def check_user_belongs_to_journey?
render "errors/not_found", status: :not_found
end

# Is the user currently on the support side?
def support?
false
def support_portal?
portal_namespace.to_s.inquiry.support?
end

def engagement?
false
def engagement_portal?
portal_namespace.to_s.inquiry.engagement?
end

def frameworks_portal?
portal_namespace.to_s.inquiry.frameworks?
end

def portal_namespace
:none
end

def record_ga?
true
!(support_portal? || engagement_portal? || frameworks_portal?)
end

def cookie_policy
Expand Down
1 change: 1 addition & 0 deletions app/controllers/cms_entry_points_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def home_page
return support_root_path if policy.access_proc_ops_portal?
return engagement_root_path if policy.access_e_and_o_portal?
return support_case_statistics_path if policy.access_statistics?
return frameworks_root_path if policy.access_frameworks_portal?

cms_no_roles_assigned_path
end
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/concerns/manage_support_agents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ def update

private

def portal_edit_management_agent_path(agent) = send("edit_#{portal_scope}_management_agent_path", agent)
def portal_new_management_agent_path = send("new_#{portal_scope}_management_agent_path")
def portal_management_agents_path = send("#{portal_scope}_management_agents_path")
def portal_management_path = send("#{portal_scope}_management_path")
def portal_edit_management_agent_path(agent) = send("edit_#{portal_namespace}_management_agent_path", agent)
def portal_new_management_agent_path = send("new_#{portal_namespace}_management_agent_path")
def portal_management_agents_path = send("#{portal_namespace}_management_agents_path")
def portal_management_path = send("#{portal_namespace}_management_path")

def agent_form_params
params.require(:agent).permit(:email, :first_name, :last_name, roles: []).tap do |p|
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/concerns/support_agents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ def authorize_agent!
def on_not_authorized_error = redirect_to on_not_authorized_error_redirect_path

def on_not_authorized_error_redirect_path = current_agent.roles.any? ? cms_not_authorized_path : cms_no_roles_assigned_path

def tracking_base_properties = super.merge(agent_id: current_agent.id)
end
8 changes: 1 addition & 7 deletions app/controllers/engagement/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ def current_url_b64(tab = "")

private

def record_ga? = false

def support? = false

def engagement? = true

def pundit_user = current_agent
def portal_namespace = :engagement

def authorize_agent_scope = :access_e_and_o_portal?
end
Expand Down
1 change: 0 additions & 1 deletion app/controllers/engagement/management/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Engagement
class Management::BaseController < ::Engagement::ApplicationController
private

def portal_scope = :engagement
def authorize_agent_scope = :access_admin_settings?
end
end
8 changes: 8 additions & 0 deletions app/controllers/frameworks/application_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class Frameworks::ApplicationController < ApplicationController
include SupportAgents

private

def authorize_agent_scope = :access_frameworks_portal?
def portal_namespace = :frameworks
end
3 changes: 3 additions & 0 deletions app/controllers/frameworks/dashboards_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Frameworks::DashboardsController < Frameworks::ApplicationController
def index; end
end
3 changes: 3 additions & 0 deletions app/controllers/specify/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class Specify::ApplicationController < ApplicationController
private

def portal_namesapce = :specify
end
3 changes: 1 addition & 2 deletions app/controllers/support/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def record_action(case_id:, action:, data: {})
).call
end

def support? = true
def record_ga? = false
def portal_namespace = :support

def notifications_unread?
return false if current_agent.nil?
Expand Down
1 change: 0 additions & 1 deletion app/controllers/support/management/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module Support
class Management::BaseController < ::Support::ApplicationController
private

def portal_scope = :support
def authorize_agent_scope = :access_admin_settings?
end
end
11 changes: 11 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@ def banner_message
def dsi_url(**args)
::Dsi::Uri.new(**args).call.to_s
end

def container_width_class
enable_wide_container? ? "wide-container" : ""
end

def enable_wide_container?
on_cases_index = current_page?(support_cases_path) || current_page?("/support")
on_frameworks = request.path.starts_with?("/frameworks")

(on_cases_index && Flipper.enabled?(:cms_panel_view)) || on_frameworks
end
end
1 change: 1 addition & 0 deletions app/views/frameworks/dashboards/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1 class="govuk-header-l">Frameworks Portal</h1>
19 changes: 16 additions & 3 deletions app/views/layouts/_navigation_links.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
<ul id="navigation" class="govuk-header__navigation-list" aria-label="Top level navigation">
<% unless current_user.guest? %>
<li id="userInfo" class="navbar-component__navigation-item--right govuk-header__navigation-item">
<%# TODO: Use UserDecorator for full_name %>
Signed in as <%= current_user.first_name %> <%= current_user.last_name %>
</li>

<% if support? %>
<% if support_portal? %>
<%= turbo_stream_from current_agent, "notifications" %>
<%= render "layouts/navigation_links_notifications", notifications_unread: notifications_unread? %>

Expand All @@ -29,9 +28,15 @@
<li class="navbar-component__navigation-item--right govuk-header__navigation-item">
<%= link_to I18n.t("support.case.search.heading"), new_support_case_search_path, class: "govuk-header__link" %>
</li>

<% if policy(:cms_portal).access_frameworks_portal? %>
<li class="navbar-component__navigation-item--right govuk-header__navigation-item">
<%= link_to 'Frameworks', frameworks_root_path, class: "govuk-header__link" %>
</li>
<% end %>
<% end %>

<% if engagement? %>
<% if engagement_portal? %>
<li class="navbar-component__navigation-item--right govuk-header__navigation-item">
<%= link_to "Cases", engagement_root_path, class: "govuk-header__link" %>
</li>
Expand All @@ -43,6 +48,14 @@
<% end %>
<% end %>

<% if frameworks_portal? %>
<% if policy(:cms_portal).access_proc_ops_portal? %>
<li class="navbar-component__navigation-item--right govuk-header__navigation-item">
<%= link_to 'Case Management', support_root_path, class: "govuk-header__link" %>
</li>
<% end %>
<% end %>

<li class="navbar-component__navigation-item--right govuk-header__navigation-item">
<%= link_to I18n.t("generic.button.sign_out"), sign_out_path, method: :delete, class: "govuk-header__link" %>
</li>
Expand Down
10 changes: 4 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<% cases_index = current_page?(support_cases_path) || current_page?("/support") %>

<!DOCTYPE html>
<html lang="en" class="govuk-template ">

Expand Down Expand Up @@ -52,7 +50,7 @@

<%= stylesheet_link_tag "application" %>

<% if support? %>
<% if support_portal? %>
<%= javascript_include_tag "tinymce/tinymce.min" %>
<% end %>
<%= javascript_include_tag "application" %>
Expand All @@ -77,7 +75,7 @@
<a href="#main-content" class="govuk-skip-link">Skip to main content</a>

<header class="govuk-header" role="banner" data-module="govuk-header">
<div class="govuk-header__container govuk-width-container <%= 'wide-container' if cases_index && Flipper.enabled?(:cms_panel_view) %>">
<div class="govuk-header__container govuk-width-container <%= container_width_class %>">
<div class="govuk-header__logo">
<a href="https://www.gov.uk" class="govuk-header__link govuk-header__link--homepage">
<span class="govuk-header__logotype">
Expand All @@ -100,7 +98,7 @@
</div>
</header>

<div class="govuk-width-container <%= 'wide-container' if cases_index && Flipper.enabled?(:cms_panel_view) %>">
<div class="govuk-width-container <%= container_width_class %>">
<div class="govuk-phase-banner">
<p class="govuk-phase-banner__content">
<strong class="govuk-tag govuk-phase-banner__content__tag">
Expand All @@ -119,7 +117,7 @@
</div>

<footer class="govuk-footer " role="contentinfo">
<div class="govuk-width-container <%= 'wide-container' if cases_index && Flipper.enabled?(:cms_panel_view) %>">
<div class="govuk-width-container <%= container_width_class %>">
<div class="govuk-footer__meta">
<div class="govuk-footer__meta-item govuk-footer__meta-item--grow">

Expand Down
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@
end
end

# Frameworks portal
namespace :frameworks do
root to: "dashboards#index"
end

namespace :exit_survey do
resources :start, only: %i[show]
resources :satisfaction, only: %i[edit update]
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/cms_entry_points_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"e_and_o" => :engagement_root_path,
"internal" => :support_root_path,
"analyst" => :support_case_statistics_path,
"framework_evaluator" => :frameworks_root_path
"framework_evaluator" => :frameworks_root_path,
}

home_paths.each do |role, home_path|
Expand Down

0 comments on commit aeaa0b9

Please sign in to comment.