Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Team management page updates #14926

Merged
merged 16 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 40 additions & 35 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,6 @@ def deny_non_bva_admins
redirect_to "/unauthorized" unless Bva.singleton.user_has_access?(current_user)
end

def manage_teams_menu_items
current_user.administered_teams.map do |team|
title = if team.type == DvcTeam.name
"#{team.name} DVC team management"
elsif team.type == JudgeTeam.name
"#{team.name} Judge team management"
else
"#{team.name} team management"
end

{
title: title,
link: team.user_admin_path
}
end
end

def admin_menu_items
[
{
title: COPY::TEAM_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/team_management", action: "index")
}, {
title: COPY::USER_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/user_management", action: "index")
}
]
end

def handle_non_critical_error(endpoint, err)
Rails.logger.error "#{err.message}\n#{err.backtrace.join("\n")}"

Expand Down Expand Up @@ -144,22 +115,56 @@ def application_urls
end
helper_method :application_urls

def dropdown_urls
urls = [
def defult_menu_items
[
{ title: "Help", link: help_url },
{ title: "Send Feedback", link: feedback_url, target: "_blank" },
{ title: "Release History", link: release_history_url, target: "_blank" }
]
end

urls.concat(manage_teams_menu_items) if current_user&.administered_teams&.any?
urls.concat(admin_menu_items) if Bva.singleton.user_has_access?(current_user)
def manage_teams_menu_items
current_user.administered_teams.map do |team|
{
title: "#{team.name} team management",
link: team.user_admin_path
}
end
end

def manage_all_teams_menu_item
{
title: COPY::TEAM_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/team_management", action: "index")
}
end

if ApplicationController.dependencies_faked? && current_user.present?
urls.append(title: "Switch User", link: url_for(controller: "/test/users", action: "index"))
def manage_users_menu_item
{
title: COPY::USER_MANAGEMENT_PAGE_DROPDOWN_LINK,
link: url_for(controller: "/user_management", action: "index")
}
end

def admin_menu_items
admin_urls = []
admin_urls.concat(manage_teams_menu_items) if current_user&.administered_teams&.any?
admin_urls.push(manage_users_menu_item) if current_user&.can_view_user_management?
if current_user&.can_view_team_management? || current_user&.can_view_judge_team_management?
admin_urls.unshift(manage_all_teams_menu_item)
end
admin_urls.flatten
end

def dropdown_urls
urls = defult_menu_items
urls.concat(admin_menu_items)

if current_user.present?
urls.append(title: "Sign Out", link: url_for(controller: "/sessions", action: "destroy"), border: true)
if ApplicationController.dependencies_faked?
urls.append(title: "Switch User", link: url_for(controller: "/test/users", action: "index"))
end
else
urls.append(title: "Sign In", link: url_for("/search"), border: true)
end
Expand Down
47 changes: 29 additions & 18 deletions app/controllers/team_management_controller.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
# frozen_string_literal: true

class TeamManagementController < ApplicationController
before_action :deny_non_bva_admins
before_action :verify_access

def index
respond_to do |format|
format.html { render template: "queue/index" }
format.json do
render json: {
dvc_teams: DvcTeam.all.order(:id).map { |dt| serialize_org(dt) },
judge_teams: JudgeTeam.all.order(:id).map { |jt| serialize_org(jt) },
private_bars: PrivateBar.all.order(:id).map { |private_bar| serialize_org(private_bar) },
vsos: Vso.all.order(:id).map { |vso| serialize_org(vso) },
other_orgs: other_orgs.map { |org| serialize_org(org) }
}
render json: current_user.can_view_team_management? ? all_teams : judge_teams
end
end
end
Expand Down Expand Up @@ -79,21 +73,38 @@ def create_field_vso
private

def update_params
params.require(:organization).permit(:name, :participant_id, :url)
params.require(:organization).permit(:name, :participant_id, :url, :accepts_priority_pushed_cases)
end

def judge_teams
{
judge_teams: JudgeTeam.order(:name).map { |jt| serialize_org(jt) }
}
end

def all_teams
judge_teams.merge(
dvc_teams: DvcTeam.order(:name).map { |dt| serialize_org(dt) },
private_bars: PrivateBar.order(:name).map { |private_bar| serialize_org(private_bar) },
vsos: Vso.order(:name).map { |vso| serialize_org(vso) },
other_orgs: other_orgs.map { |org| serialize_org(org) }
)
end

def other_orgs
Organization.all.order(:id).reject { |org| org.is_a?(JudgeTeam) || org.is_a?(DvcTeam) || org.is_a?(Representative) }
Organization.order(:name).reject { |org| org.is_a?(JudgeTeam) || org.is_a?(DvcTeam) || org.is_a?(Representative) }
end

def serialize_org(org)
{
id: org.id,
name: org.name,
participant_id: org.participant_id,
type: org.type,
url: org.url,
user_admin_path: org.user_admin_path
Copy link
Contributor

@lomky lomky Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we lost this along the way, link no longer works in this PR - checking Stack PR 3

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works in the final PR - not sweating it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

}
org.serialize.merge(
current_user_can_toggle_priority_pushed_cases: current_user.can_view_judge_team_management?,
user_admin_path: current_user.can_view_team_management? ? org.user_admin_path : nil
)
end

def verify_access
unless current_user.can_view_team_management? || current_user.can_view_judge_team_management?
redirect_to "/unauthorized"
end
end
end
14 changes: 13 additions & 1 deletion app/models/organization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Organization < CaseflowRecord
has_many :judge_team_roles, through: :organizations_users
has_many :non_admin_users, -> { non_admin }, class_name: "OrganizationsUser"
require_dependency "dvc_team"

validates :name, presence: true
validates :url, presence: true, uniqueness: true

Expand Down Expand Up @@ -137,6 +137,18 @@ def completed_tasks_tab
::OrganizationCompletedTasksTab.new(assignee: self, show_regional_office_column: show_regional_office_in_queue?)
end

def serialize
{
accepts_priority_pushed_cases: accepts_priority_pushed_cases,
id: id,
name: name,
participant_id: participant_id,
type: type,
url: url,
user_admin_path: user_admin_path
}
end

private

def clean_url
Expand Down
4 changes: 4 additions & 0 deletions app/models/organizations/dvc_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,8 @@ def can_receive_task?(_task)
def selectable_in_queue?
false
end

def serialize
super.merge(name: dvc.full_name.titleize)
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 31, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use dvc full names as team name

end
end
4 changes: 4 additions & 0 deletions app/models/organizations/judge_team.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ def selectable_in_queue?
false
end

def serialize
super.merge(name: judge.full_name.titleize)
Copy link
Contributor Author

@hschallhorn hschallhorn Aug 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use judge full names as team name

end

private

def use_judge_team_roles?
Expand Down
12 changes: 12 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ def can_act_on_behalf_of_judges?
member_of_organization?(SpecialCaseMovementTeam.singleton)
end

def can_view_team_management?
member_of_organization?(Bva.singleton)
end

def can_view_judge_team_management?
DvcTeam.for_dvc(self).present?
end

def can_view_user_management?
member_of_organization?(Bva.singleton)
end

def show_regional_office_in_queue?
HearingsManagement.singleton.user_has_access?(self)
end
Expand Down
1 change: 1 addition & 0 deletions client/COPY.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@
"TEAM_MANAGEMENT_ID_COLUMN_HEADING": "ID",
"TEAM_MANAGEMENT_NAME_COLUMN_HEADING": "Name",
"TEAM_MANAGEMENT_URL_COLUMN_HEADING": "URL",
"TEAM_MANAGEMENT_PRIORITY_DISTRIBUTION_COLUMN_HEADING": "Priority Case Distribution",
"TEAM_MANAGEMENT_PARTICIPANT_ID_COLUMN_HEADING": "BGS Participant ID",
"TEAM_MANAGEMENT_UPDATE_ROW_BUTTON": "Update",
"TEAM_MANAGEMENT_ADD_JUDGE_LABEL": "Judge Teams",
Expand Down
Loading