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

Don't show delegate Report Icons for Organizers #10547

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
3 changes: 3 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,9 @@ def permissions
can_view_delegate_admin_page: {
scope: can_view_delegate_matters? ? "*" : [],
},
can_view_delegate_report: {
scope: can_view_delegate_matters? ? "*" : delegated_competitions.pluck(:id),
FinnIckler marked this conversation as resolved.
Show resolved Hide resolved
},
can_create_groups: {
scope: groups_with_create_access,
},
Expand Down
6 changes: 3 additions & 3 deletions app/webpacker/components/MyCompetitions/TableCells.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export function DateTableCell({ competition }) {
}

export function ReportTableCell({
permissions, competitionId, isReportPosted, canAdminCompetitions,
permissions, competitionId, isReportPosted, canViewDelegateReport,
}) {
if (permissions.can_administer_competitions.scope === '*' || permissions.can_administer_competitions.scope.includes(competitionId)) {
if (permissions.can_view_delegate_report.scope === '*' || permissions.can_view_delegate_report.scope.includes(competitionId)) {
return (
<Table.Cell>
<>
Expand Down Expand Up @@ -72,7 +72,7 @@ export function ReportTableCell({

// A user might be able to see only certain reports in the list, so we return an empty cell

if (canAdminCompetitions) {
if (canViewDelegateReport) {
return <Table.Cell />;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function UpcomingCompetitionTable({
shouldShowRegistrationStatus = true,
fallbackMessage = null,
}) {
const canAdminCompetitions = permissions.can_administer_competitions.scope === '*' || competitions.some((c) => permissions.can_administer_competitions.scope.includes(c.id));
const canViewDelegateReport = permissions.can_view_delegate_report.scope === '*' || competitions.some((c) => permissions.can_view_delegate_report.scope.includes(c.id));

if (competitions.length === 0 && fallbackMessage) {
return (
Expand All @@ -81,7 +81,7 @@ export default function UpcomingCompetitionTable({
{I18n.t('competitions.competition_info.date')}
</Table.HeaderCell>
<Table.HeaderCell />
{canAdminCompetitions && (
{canViewDelegateReport && (
<>
<Table.HeaderCell />
<Table.HeaderCell />
Expand Down Expand Up @@ -134,7 +134,7 @@ export default function UpcomingCompetitionTable({
<ReportTableCell
competitionId={competition.id}
permissions={permissions}
canAdminCompetitions={canAdminCompetitions}
canViewDelegateReport={canViewDelegateReport}
/>
</Table.Row>
)}
Expand Down
2 changes: 1 addition & 1 deletion app/webpacker/lib/utils/competition-table.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const competitionStatusHint = (competition) => {
return text;
};

export const competitionStatusText = (competition, registrationStatus) => `${registrationStatusHint(registrationStatus?.competing_status)} ${competitionStatusHint(competition)}`;
export const competitionStatusText = (competition, registrationStatus) => `${registrationStatusHint(registrationStatus)} ${competitionStatusHint(competition)}`;

export function dayDifferenceFromToday(yyyymmddDateString) {
const dateLuxon = parseDateString(yyyymmddDateString);
Expand Down
Loading