From aeaa0b996a7c18a99c15749b8b4b2761763b28f0 Mon Sep 17 00:00:00 2001 From: Ryan Kendall Date: Wed, 23 Aug 2023 10:26:27 +0100 Subject: [PATCH] feat: user can navigate to Frameworks portal --- app/controllers/application_controller.rb | 21 ++++++++++++------- .../cms_entry_points_controller.rb | 1 + .../concerns/manage_support_agents.rb | 8 +++---- app/controllers/concerns/support_agents.rb | 2 ++ .../engagement/application_controller.rb | 8 +------ .../engagement/management/base_controller.rb | 1 - .../frameworks/application_controller.rb | 8 +++++++ .../frameworks/dashboards_controller.rb | 3 +++ .../specify/application_controller.rb | 3 +++ .../support/application_controller.rb | 3 +-- .../support/management/base_controller.rb | 1 - app/helpers/application_helper.rb | 11 ++++++++++ .../frameworks/dashboards/index.html.erb | 1 + app/views/layouts/_navigation_links.html.erb | 19 ++++++++++++++--- app/views/layouts/application.html.erb | 10 ++++----- config/routes.rb | 5 +++++ .../cms_entry_points_controller_spec.rb | 2 +- 17 files changed, 75 insertions(+), 32 deletions(-) create mode 100644 app/controllers/frameworks/application_controller.rb create mode 100644 app/controllers/frameworks/dashboards_controller.rb create mode 100644 app/views/frameworks/dashboards/index.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b6f3a1fc6..9dc8a6e83 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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] # @@ -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 diff --git a/app/controllers/cms_entry_points_controller.rb b/app/controllers/cms_entry_points_controller.rb index 5d79a9750..c8845db85 100644 --- a/app/controllers/cms_entry_points_controller.rb +++ b/app/controllers/cms_entry_points_controller.rb @@ -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 diff --git a/app/controllers/concerns/manage_support_agents.rb b/app/controllers/concerns/manage_support_agents.rb index e88fa12a7..1655bdca5 100644 --- a/app/controllers/concerns/manage_support_agents.rb +++ b/app/controllers/concerns/manage_support_agents.rb @@ -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| diff --git a/app/controllers/concerns/support_agents.rb b/app/controllers/concerns/support_agents.rb index e58fce442..844a1c09b 100644 --- a/app/controllers/concerns/support_agents.rb +++ b/app/controllers/concerns/support_agents.rb @@ -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 diff --git a/app/controllers/engagement/application_controller.rb b/app/controllers/engagement/application_controller.rb index f6ea5d41b..9dbd2d1e3 100644 --- a/app/controllers/engagement/application_controller.rb +++ b/app/controllers/engagement/application_controller.rb @@ -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 diff --git a/app/controllers/engagement/management/base_controller.rb b/app/controllers/engagement/management/base_controller.rb index 3f2522572..99a416174 100644 --- a/app/controllers/engagement/management/base_controller.rb +++ b/app/controllers/engagement/management/base_controller.rb @@ -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 diff --git a/app/controllers/frameworks/application_controller.rb b/app/controllers/frameworks/application_controller.rb new file mode 100644 index 000000000..160a39224 --- /dev/null +++ b/app/controllers/frameworks/application_controller.rb @@ -0,0 +1,8 @@ +class Frameworks::ApplicationController < ApplicationController + include SupportAgents + +private + + def authorize_agent_scope = :access_frameworks_portal? + def portal_namespace = :frameworks +end diff --git a/app/controllers/frameworks/dashboards_controller.rb b/app/controllers/frameworks/dashboards_controller.rb new file mode 100644 index 000000000..f7663a395 --- /dev/null +++ b/app/controllers/frameworks/dashboards_controller.rb @@ -0,0 +1,3 @@ +class Frameworks::DashboardsController < Frameworks::ApplicationController + def index; end +end diff --git a/app/controllers/specify/application_controller.rb b/app/controllers/specify/application_controller.rb index 5f8fd2f4b..bdfcaf759 100644 --- a/app/controllers/specify/application_controller.rb +++ b/app/controllers/specify/application_controller.rb @@ -1,2 +1,5 @@ class Specify::ApplicationController < ApplicationController +private + + def portal_namesapce = :specify end diff --git a/app/controllers/support/application_controller.rb b/app/controllers/support/application_controller.rb index c0ba86e79..5ba3947c8 100644 --- a/app/controllers/support/application_controller.rb +++ b/app/controllers/support/application_controller.rb @@ -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? diff --git a/app/controllers/support/management/base_controller.rb b/app/controllers/support/management/base_controller.rb index 28429c7b9..82107104e 100644 --- a/app/controllers/support/management/base_controller.rb +++ b/app/controllers/support/management/base_controller.rb @@ -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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a1b2ec114..8298ec538 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -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 diff --git a/app/views/frameworks/dashboards/index.html.erb b/app/views/frameworks/dashboards/index.html.erb new file mode 100644 index 000000000..816bbc57d --- /dev/null +++ b/app/views/frameworks/dashboards/index.html.erb @@ -0,0 +1 @@ +

Frameworks Portal

diff --git a/app/views/layouts/_navigation_links.html.erb b/app/views/layouts/_navigation_links.html.erb index e96068ddc..0bc5efa87 100644 --- a/app/views/layouts/_navigation_links.html.erb +++ b/app/views/layouts/_navigation_links.html.erb @@ -4,11 +4,10 @@