From 87e9761139abcd85f54865a6362fd37243efa6da Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 9 Jan 2025 16:01:59 +0530 Subject: [PATCH] Move WFC panel to default panel --- app/controllers/panel_controller.rb | 1 - app/models/user.rb | 11 +++++--- app/views/panel/wfc.html.erb | 2 -- app/webpacker/components/Panel/Wfc.jsx | 25 ------------------- .../lib/hooks/useLoggedInUserPermissions.js | 1 - config/routes.rb | 1 - spec/requests/wfc_spec.rb | 6 ++--- 7 files changed, 10 insertions(+), 37 deletions(-) delete mode 100644 app/views/panel/wfc.html.erb delete mode 100644 app/webpacker/components/Panel/Wfc.jsx diff --git a/app/controllers/panel_controller.rb b/app/controllers/panel_controller.rb index c4fac82896..409cd6db11 100644 --- a/app/controllers/panel_controller.rb +++ b/app/controllers/panel_controller.rb @@ -5,7 +5,6 @@ class PanelController < ApplicationController before_action :authenticate_user! before_action -> { redirect_to_root_unless_user(:has_permission?, 'can_access_panels', params[:panel_id].to_sym) }, only: [:index] - before_action -> { redirect_to_root_unless_user(:has_permission?, 'can_access_panels', :wfc) }, only: [:wfc] before_action -> { redirect_to_root_unless_user(:has_permission?, 'can_access_panels', :staff) }, only: [:staff] before_action -> { redirect_to_root_unless_user(:has_permission?, 'can_access_panels', :admin) }, only: [:generate_db_token] before_action -> { redirect_to_root_unless_user(:can_access_senior_delegate_panel?) }, only: [:pending_claims_for_subordinate_delegates] diff --git a/app/models/user.rb b/app/models/user.rb index a6ed85808e..aa2a882c6f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -677,7 +677,13 @@ def self.panel_list }, wfc: { name: 'WFC panel', - pages: [], + pages: [ + panel_pages[:duesExport], + panel_pages[:countryBands], + panel_pages[:xeroUsers], + panel_pages[:duesRedirect], + panel_pages[:bannedCompetitors], + ], }, wrt: { name: 'WRT panel', @@ -771,9 +777,6 @@ def permissions can_edit_groups: { scope: groups_with_edit_access, }, - can_access_wfc_senior_matters: { - scope: can_access_wfc_senior_matters? ? "*" : [], - }, can_access_panels: { scope: panels_with_access, }, diff --git a/app/views/panel/wfc.html.erb b/app/views/panel/wfc.html.erb deleted file mode 100644 index 31dbae536b..0000000000 --- a/app/views/panel/wfc.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -<% provide(:title, 'WFC Panel') %> -<%= react_component("Panel/Wfc") %> \ No newline at end of file diff --git a/app/webpacker/components/Panel/Wfc.jsx b/app/webpacker/components/Panel/Wfc.jsx deleted file mode 100644 index 65762c96fa..0000000000 --- a/app/webpacker/components/Panel/Wfc.jsx +++ /dev/null @@ -1,25 +0,0 @@ -import React from 'react'; -import PanelTemplate from './PanelTemplate'; -import { PANEL_PAGES } from '../../lib/wca-data.js.erb'; -import useLoggedInUserPermissions from '../../lib/hooks/useLoggedInUserPermissions'; -import Loading from '../Requests/Loading'; - -export default function Wfc() { - const { loggedInUserPermissions, loading } = useLoggedInUserPermissions(); - - if (loading) return ; - - return ( - - ); -} diff --git a/app/webpacker/lib/hooks/useLoggedInUserPermissions.js b/app/webpacker/lib/hooks/useLoggedInUserPermissions.js index 57b57cef48..026c5b1f0a 100644 --- a/app/webpacker/lib/hooks/useLoggedInUserPermissions.js +++ b/app/webpacker/lib/hooks/useLoggedInUserPermissions.js @@ -15,7 +15,6 @@ export default function useLoggedInUserPermissions() { const loggedInUserPermissions = React.useMemo(() => ({ canViewDelegateAdminPage: Boolean(data?.can_view_delegate_admin_page.scope === '*'), canEditGroup: (groupId) => Boolean(data?.can_edit_groups.scope === '*' || data?.can_edit_groups.scope.includes(groupId)), - canAccessWfcSeniorMatters: Boolean(data?.can_access_wfc_senior_matters.scope === '*'), }), [data]); return { loggedInUserPermissions, loading }; diff --git a/config/routes.rb b/config/routes.rb index 3d6e1c1064..99770e3f6b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -187,7 +187,6 @@ get 'panel/pending-claims(/:user_id)' => 'panel#pending_claims_for_subordinate_delegates', as: 'pending_claims' scope 'panel' do get 'staff' => 'panel#staff', as: :panel_staff - get 'wfc' => 'panel#wfc', as: :panel_wfc get 'generate_db_token' => 'panel#generate_db_token', as: :panel_generate_db_token end get 'panel/:panel_id' => 'panel#index', as: :panel_index diff --git a/spec/requests/wfc_spec.rb b/spec/requests/wfc_spec.rb index c24d6c3e87..1393ef09c0 100644 --- a/spec/requests/wfc_spec.rb +++ b/spec/requests/wfc_spec.rb @@ -7,7 +7,7 @@ context "when not signed in" do sign_out it "redirect to login page" do - get panel_wfc_path + get panel_index_path(:wfc) expect(response).to redirect_to new_user_session_path end end @@ -15,7 +15,7 @@ context "when signed in as a regular user" do sign_in { FactoryBot.create :user } it "redirect to root" do - get panel_wfc_path + get panel_index_path(:wfc) expect(response).to redirect_to root_url end end @@ -23,7 +23,7 @@ context "when signed in as a WFC member" do sign_in { FactoryBot.create :user, :wfc_member } it "shows the page" do - get panel_wfc_path + get panel_index_path(:wfc) expect(response).to be_successful end end