Skip to content

Commit

Permalink
Create separate panel for Delegates
Browse files Browse the repository at this point in the history
  • Loading branch information
danieljames-dj committed May 1, 2024
1 parent 0ae6062 commit 2e6c8a6
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 38 deletions.
5 changes: 5 additions & 0 deletions app/controllers/panel_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class PanelController < ApplicationController
before_action :authenticate_user!
before_action -> { redirect_to_root_unless_user(:staff_or_any_delegate?) }
before_action -> { redirect_to_root_unless_user(:can_access_senior_delegate_panel?) }, only: [:pending_claims_for_subordinate_delegates]
before_action -> { redirect_to_root_unless_user(:can_access_delegate_panel?) }, only: [:delegate]
before_action -> { redirect_to_root_unless_user(:can_access_board_panel?) }, only: [:board]
before_action -> { redirect_to_root_unless_user(:can_access_senior_delegate_panel?) }, only: [:senior_delegate]
before_action -> { redirect_to_root_unless_user(:can_access_leader_panel?) }, only: [:leader]
Expand All @@ -25,6 +26,10 @@ def pending_claims_for_subordinate_delegates

def self.panel_list
{
"delegate" => {
"importantLinks" => "important-links",
"delegateCrashCourse" => "delegate-crash-course",
},
"board" => {
"seniorDelegatesList" => "senior-delegates-list",
"leadersAdmin" => "leaders-admin",
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,10 @@ def can_access_senior_delegate_panel?
admin? || board_member? || senior_delegate?
end

def can_access_delegate_panel?
admin? || any_kind_of_delegate?
end

def can_access_panel?
(
can_access_wfc_panel? ||
Expand Down
3 changes: 3 additions & 0 deletions app/views/layouts/_navigation.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@
<%= t '.panel' %>
</li>
<li><%= link_to t('.panel'), panel_path %></li>
<% if current_user.can_access_delegate_panel? %>
<li><%= link_to "Delegate panel", panel_delegate_path %></li>
<% end %>
<% if current_user.can_access_wfc_panel? %>
<li><%= link_to "WFC panel", panel_wfc_path %></li>
<% end %>
Expand Down
2 changes: 2 additions & 0 deletions app/views/panel/delegate.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<% provide(:title, 'Delegate Panel') %>
<%= react_component("Panel/Delegate") %>
37 changes: 0 additions & 37 deletions app/views/panel/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,4 @@
</li>
</ul>
<% end %>
<% if current_user&.can_view_delegate_matters? %>
<h2>Delegates</h2>

<ul>
<li>
<%= link_to "Delegate Crash course", panel_delegate_crash_course_path %>
</li>
<li>
<%= link_to "Guidelines for Disciplinary Incidents", "https://documents.worldcubeassociation.org/edudoc/guidelines-for-disciplinary-incidents/guidelines-for-disciplinary-incidents.pdf" %>
</li>
<li>
<%= link_to "Delegates", delegates_path(anchor: "all") %>
</li>
<li>
<%= link_to "WR Submission Form", "https://docs.google.com/forms/d/e/1FAIpQLSeJwf6b7yGGyWFhU0xfKSF3ki_nITyIKXVFRP86unb9EYRtHQ/viewform" %>
</li>
<li>
<%= link_to "Gear Order Form", "https://forms.gle/owX3ppZahYkoq9s48" %>
</li>
<li>
<%= link_to "Travel Reimbursement Form", "https://docs.google.com/forms/d/12tz2I_EeBORm14kQO6ZB5TOp321YbXkIXvrxUNIHxN0/viewform" %>
</li>
<li>
<%= link_to "Equipment Funding Form", "https://docs.google.com/forms/d/e/1FAIpQLSebkWMyG2kRzR3cDm3jXFVMFCwd5u4XI6Yt35givu0SOidpHg/viewform" %>
</li>
<li>
<%= link_to "Bands for WCA Dues", country_bands_path %>
</li>
<li>
<%= link_to "Visual Guide for Regulation 3j", "https://drive.google.com/file/d/1m6THsA8fXRN7QFM4ApJbm6eVODKGbMLx/view" %>
</li>
<li>
<%= link_to "Visual Guide for Regulation 5b5f", "https://drive.google.com/file/d/15XszaCGNvy3Dk6X6qERzZWZaDH1RH04z/view" %>
</li>
</ul>
<% end %>
</div>
102 changes: 102 additions & 0 deletions app/webpacker/components/Panel/Delegate/ImportantLinks.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React from 'react';
import { Header, List } from 'semantic-ui-react';
import { allDelegatePageUrl, countryBandsUrl } from '../../../lib/requests/routes.js.erb';

const disciplinaryIncidentsGuidelinesLink = 'https://documents.worldcubeassociation.org/edudoc/guidelines-for-disciplinary-incidents/guidelines-for-disciplinary-incidents.pdf';
const wrSubmissionFormLink = 'https://docs.google.com/forms/d/e/1FAIpQLSeJwf6b7yGGyWFhU0xfKSF3ki_nITyIKXVFRP86unb9EYRtHQ/viewform';
const gearOrderFormLink = 'https://forms.gle/owX3ppZahYkoq9s48';
const travelReimbursementFormLink = 'https://docs.google.com/forms/d/12tz2I_EeBORm14kQO6ZB5TOp321YbXkIXvrxUNIHxN0/viewform';
const equipmentFundingFormLink = 'https://docs.google.com/forms/d/e/1FAIpQLSebkWMyG2kRzR3cDm3jXFVMFCwd5u4XI6Yt35givu0SOidpHg/viewform';
const visualGuideForReg3j = 'https://drive.google.com/file/d/1m6THsA8fXRN7QFM4ApJbm6eVODKGbMLx/view';
const visualGuideForReg5b5f = 'https://drive.google.com/file/d/15XszaCGNvy3Dk6X6qERzZWZaDH1RH04z/view';

export default function ImportantLinks() {
return (
<>
<Header as="h2">Important Links</Header>
<List>
<List.Item>
<a
href={disciplinaryIncidentsGuidelinesLink}
target="_blank"
rel="noreferrer"
>
Guidelines for Disciplinary Incidents
</a>
</List.Item>
<List.Item>
<a
href={allDelegatePageUrl}
target="_blank"
rel="noreferrer"
>
All Delegates
</a>
</List.Item>
<List.Item>
<a
href={wrSubmissionFormLink}
target="_blank"
rel="noreferrer"
>
WR Submission Form
</a>
</List.Item>
<List.Item>
<a
href={gearOrderFormLink}
target="_blank"
rel="noreferrer"
>
Gear Order Form
</a>
</List.Item>
<List.Item>
<a
href={travelReimbursementFormLink}
target="_blank"
rel="noreferrer"
>
Travel Reimbursement Form
</a>
</List.Item>
<List.Item>
<a
href={equipmentFundingFormLink}
target="_blank"
rel="noreferrer"
>
Equipment Funding Form
</a>
</List.Item>
<List.Item>
<a
href={countryBandsUrl}
target="_blank"
rel="noreferrer"
>
Bands for WCA Dues
</a>
</List.Item>
<List.Item>
<a
href={visualGuideForReg3j}
target="_blank"
rel="noreferrer"
>
Visual Guide for Regulation 3j
</a>
</List.Item>
<List.Item>
<a
href={visualGuideForReg5b5f}
target="_blank"
rel="noreferrer"
>
Visual Guide for Regulation 5b5f
</a>
</List.Item>
</List>
</>
);
}
25 changes: 25 additions & 0 deletions app/webpacker/components/Panel/Delegate/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import PanelTemplate from '../PanelTemplate';
import { PANEL_LIST } from '../../../lib/wca-data.js.erb';
import ImportantLinks from './ImportantLinks';

const delegateCrashCourseLink = 'https://documents.worldcubeassociation.org/edudoc/delegate-crash-course/delegate_crash_course.pdf';

const sections = [
{
id: PANEL_LIST.delegate.importantLinks,
name: 'Important Links',
component: ImportantLinks,
},
{
id: PANEL_LIST.delegate.delegateCrashCourse,
name: 'Delegate Crash Course',
link: delegateCrashCourseLink,
},
];

export default function Delegate() {
return (
<PanelTemplate heading="Delegate Panel" sections={sections} />
);
}
2 changes: 2 additions & 0 deletions app/webpacker/lib/requests/routes.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ export const WCA_API_PAGINATION = 25;

export const delegatesPageUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.delegates_path)%>`;

export const allDelegatePageUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.delegates_path(anchor: 'all'))%>`;

export const teamsCommitteesCouncilsPageUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.teams_committees_councils_path)%>`;

export const translatorsPageUrl = `<%= CGI.unescape(Rails.application.routes.url_helpers.translators_path)%>`;
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@
post 'competitions/:id/disconnect_stripe' => 'competitions#disconnect_stripe', as: :competition_disconnect_stripe

get 'panel' => 'panel#index'
get 'panel/delegate-crash-course', to: redirect('https://documents.worldcubeassociation.org/edudoc/delegate-crash-course/delegate_crash_course.pdf', status: 302)
get 'panel/pending-claims(/:user_id)' => 'panel#pending_claims_for_subordinate_delegates', as: 'pending_claims'
scope 'panel' do
get 'delegate' => 'panel#delegate', as: :panel_delegate
get 'wfc' => 'panel#wfc', as: :panel_wfc
get 'wrt' => 'panel#wrt', as: :panel_wrt
get 'wst' => 'panel#wst', as: :panel_wst
Expand Down

0 comments on commit 2e6c8a6

Please sign in to comment.