Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 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3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 2x 2x 1x 1x 3x 3x 3x 3x 3x 3x 3x 15x 15x 3x 3x 3x 3x 3x 3x 3x 6x 6x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x | <template>
<div class="admin-panel" data-testid="admin-panel">
<!-- Admin Access Check -->
<div
v-if="!authStore.isAdmin.value && !authStore.isClubManager.value"
class="text-center py-12"
data-testid="admin-access-denied"
>
<div class="max-w-md mx-auto">
<div class="text-red-600 text-6xl mb-4">🚫</div>
<h2 class="text-2xl font-bold text-fg mb-2">Access Denied</h2>
<p class="text-fg-muted">
You need administrator privileges to access this page.
</p>
</div>
</div>
<!-- Admin Content (only for admins) -->
<div v-else>
<!-- Admin Description -->
<div class="mb-6">
<p class="text-fg-muted">Manage league data and configurations</p>
</div>
<!-- Admin Navigation -->
<div class="mb-6 sm:mb-8" data-testid="admin-nav">
<!-- Mobile: native select grouped by category -->
<label for="admin-section-select" class="sr-only">Admin section</label>
<select
id="admin-section-select"
v-model="currentSection"
data-testid="admin-section-select"
class="sm:hidden block w-full px-3 py-2.5 text-base font-medium bg-card border border-line rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-brand-500 focus:border-brand-500"
>
<optgroup
v-for="category in adminCategories"
:key="category.id"
:label="category.name"
>
<option
v-for="section in category.sections"
:key="section.id"
:value="section.id"
>
{{ section.name }}
</option>
</optgroup>
</select>
<!-- Desktop: two-level tab bar (categories + sub-tabs) -->
<div class="hidden sm:block space-y-2" aria-label="Admin sections">
<nav
class="flex flex-wrap gap-1 bg-surface-alt p-1 rounded-lg"
aria-label="Admin categories"
>
<button
v-for="category in adminCategories"
:key="category.id"
@click="selectCategory(category.id)"
:data-testid="`admin-category-${category.id}`"
:class="[
currentCategory === category.id
? 'bg-card text-fg shadow'
: 'text-fg-muted hover:text-fg',
'px-4 py-2 text-sm font-medium rounded-md transition-colors whitespace-nowrap',
]"
>
{{ category.name }}
</button>
</nav>
<nav
v-if="currentCategorySections.length > 1"
class="flex flex-wrap gap-1 px-1"
aria-label="Admin sub-sections"
>
<button
v-for="section in currentCategorySections"
:key="section.id"
@click="currentSection = section.id"
:data-testid="`admin-tab-${section.id}`"
:class="[
currentSection === section.id
? 'text-brand-700 border-brand-500 dark:text-brand-300 dark:border-brand-300'
: 'text-fg-muted hover:text-fg border-transparent hover:border-line',
'px-3 py-1.5 text-sm font-medium border-b-2 transition-colors whitespace-nowrap',
]"
>
{{ section.name }}
</button>
</nav>
</div>
</div>
<!-- Section Content -->
<div
class="bg-card rounded-lg shadow-sm border border-line"
data-testid="admin-content"
>
<!-- Invite Requests Management -->
<div
v-if="currentSection === 'invite-requests'"
class="p-3 sm:p-6"
data-testid="admin-section-invite-requests"
>
<AdminInviteRequests @approve="openInviteFromRequest" />
</div>
<!-- Channel Access Requests -->
<div
v-if="currentSection === 'channel-requests'"
class="p-3 sm:p-6"
data-testid="admin-section-channel-requests"
>
<AdminChannelRequests />
</div>
<!-- Live Match Notifications (per-club Telegram/Discord) -->
<div
v-if="currentSection === 'club-notifications'"
class="p-3 sm:p-6"
data-testid="admin-section-club-notifications"
>
<AdminClubNotifications />
</div>
<!-- Age Groups Management -->
<div
v-if="currentSection === 'age-groups'"
class="p-3 sm:p-6"
data-testid="admin-section-age-groups"
>
<AdminAgeGroups />
</div>
<!-- Seasons Management -->
<div
v-if="currentSection === 'seasons'"
class="p-3 sm:p-6"
data-testid="admin-section-seasons"
>
<AdminSeasons />
</div>
<!-- Leagues Management -->
<div
v-if="currentSection === 'leagues'"
class="p-3 sm:p-6"
data-testid="admin-section-leagues"
>
<AdminLeagues />
</div>
<!-- Divisions Management -->
<div
v-if="currentSection === 'divisions'"
class="p-3 sm:p-6"
data-testid="admin-section-divisions"
>
<AdminDivisions />
</div>
<!-- Clubs Management -->
<div
v-if="currentSection === 'clubs'"
class="p-3 sm:p-6"
data-testid="admin-section-clubs"
>
<AdminClubs />
</div>
<!-- Teams Management -->
<div
v-if="currentSection === 'teams'"
class="p-3 sm:p-6"
data-testid="admin-section-teams"
>
<AdminTeams />
</div>
<!-- Players Management -->
<div
v-if="currentSection === 'players'"
class="p-3 sm:p-6"
data-testid="admin-section-players"
>
<AdminPlayers />
</div>
<!-- Matches Management -->
<div
v-if="currentSection === 'matches'"
class="p-3 sm:p-6"
data-testid="admin-section-matches"
>
<AdminMatches />
</div>
<!-- Goals Management -->
<div
v-if="currentSection === 'goals'"
class="p-3 sm:p-6"
data-testid="admin-section-goals"
>
<AdminGoals />
</div>
<!-- Playoffs Management -->
<div
v-if="currentSection === 'playoffs'"
class="p-3 sm:p-6"
data-testid="admin-section-playoffs"
>
<AdminPlayoffs />
</div>
<!-- Invites Management -->
<div
v-if="currentSection === 'invites'"
class="p-3 sm:p-6"
data-testid="admin-section-invites"
>
<AdminInvites
:prefill="invitePrefill"
@prefill-done="invitePrefill = null"
/>
</div>
<!-- Support Inbox -->
<div
v-if="currentSection === 'support-inbox'"
class="p-3 sm:p-6"
data-testid="admin-section-support-inbox"
>
<AdminSupportInbox />
</div>
<!-- Content Reports (live chat moderation, SB-1324) -->
<div
v-if="currentSection === 'content-reports'"
class="p-3 sm:p-6"
data-testid="admin-section-content-reports"
>
<AdminContentReports />
</div>
<!-- Tournaments Management -->
<div
v-if="currentSection === 'tournaments'"
class="p-3 sm:p-6"
data-testid="admin-section-tournaments"
>
<AdminTournaments />
</div>
<!-- Cache Management -->
<div
v-if="currentSection === 'cache'"
class="p-3 sm:p-6"
data-testid="admin-section-cache"
>
<AdminCache />
</div>
<!-- Users / Login Activity -->
<div
v-if="currentSection === 'users'"
class="p-3 sm:p-6"
data-testid="admin-section-users"
>
<AdminUsers />
</div>
<!-- Power Rating audit: Elo vs Massey (SB-1812) -->
<div
v-if="currentSection === 'power-rating-audit'"
class="p-3 sm:p-6"
data-testid="admin-section-power-rating-audit"
>
<AdminPowerRatingAudit />
</div>
</div>
</div>
</div>
</template>
<script>
import { ref, computed, watch } from 'vue';
import { useAuthStore } from '@/stores/auth';
import { invitePrefillFromRequest } from '@/utils/inviteRequests';
import AdminAgeGroups from './admin/AdminAgeGroups.vue';
import AdminSeasons from './admin/AdminSeasons.vue';
import AdminLeagues from './admin/AdminLeagues.vue';
import AdminDivisions from './admin/AdminDivisions.vue';
import AdminClubs from './admin/AdminClubs.vue';
import AdminTeams from './admin/AdminTeams.vue';
import AdminPlayers from './admin/AdminPlayers.vue';
import AdminMatches from './admin/AdminMatches.vue';
import AdminGoals from './admin/AdminGoals.vue';
import AdminInvites from './admin/AdminInvites.vue';
import AdminSupportInbox from './admin/AdminSupportInbox.vue';
import AdminChannelRequests from './admin/AdminChannelRequests.vue';
import AdminClubNotifications from './admin/AdminClubNotifications.vue';
import AdminInviteRequests from './admin/AdminInviteRequests.vue';
import AdminPlayoffs from './admin/AdminPlayoffs.vue';
import AdminCache from './admin/AdminCache.vue';
import AdminUsers from './admin/AdminUsers.vue';
import AdminTournaments from './admin/AdminTournaments.vue';
import AdminContentReports from './admin/AdminContentReports.vue';
import AdminPowerRatingAudit from './admin/AdminPowerRatingAudit.vue';
export default {
name: 'AdminPanel',
components: {
AdminAgeGroups,
AdminSeasons,
AdminLeagues,
AdminDivisions,
AdminClubs,
AdminTeams,
AdminPlayers,
AdminMatches,
AdminGoals,
AdminInvites,
AdminSupportInbox,
AdminChannelRequests,
AdminClubNotifications,
AdminInviteRequests,
AdminPlayoffs,
AdminCache,
AdminUsers,
AdminTournaments,
AdminContentReports,
AdminPowerRatingAudit,
},
setup() {
const authStore = useAuthStore();
// Define all sections with role requirements + category assignment.
// Categories drive the two-level desktop tab bar (SB-7). Mobile still
// renders a single flat <select> grouped by <optgroup>.
const allAdminSections = [
{
id: 'invite-requests',
name: 'Requests',
adminOnly: true,
category: 'access',
},
{
id: 'channel-requests',
name: 'Handle Requests (old)',
adminOnly: false,
category: 'access',
},
{
id: 'club-notifications',
name: 'Live Match Notifications',
adminOnly: false,
category: 'access',
},
{ id: 'invites', name: 'Invites', adminOnly: false, category: 'access' },
{
id: 'support-inbox',
name: 'Support Inbox',
adminOnly: true,
category: 'access',
},
{
id: 'content-reports',
name: 'Content Reports',
adminOnly: true,
category: 'access',
},
{
id: 'age-groups',
name: 'Age Groups',
adminOnly: true,
category: 'league-setup',
},
{
id: 'seasons',
name: 'Seasons',
adminOnly: true,
category: 'league-setup',
},
{
id: 'leagues',
name: 'Leagues',
adminOnly: true,
category: 'league-setup',
},
{
id: 'divisions',
name: 'Divisions',
adminOnly: true,
category: 'league-setup',
},
{
id: 'clubs',
name: 'Clubs',
adminOnly: true,
category: 'teams-players',
},
{
id: 'teams',
name: 'Teams',
adminOnly: false,
category: 'teams-players',
},
{
id: 'players',
name: 'Players',
adminOnly: false,
category: 'teams-players',
},
{ id: 'matches', name: 'Matches', adminOnly: false, category: 'matches' },
{ id: 'goals', name: 'Goals', adminOnly: false, category: 'matches' },
{
id: 'playoffs',
name: 'Playoffs',
adminOnly: true,
category: 'matches',
},
{
id: 'tournaments',
name: 'Tournaments',
adminOnly: true,
category: 'matches',
},
{ id: 'cache', name: 'Cache', adminOnly: true, category: 'system' },
{ id: 'users', name: 'Users', adminOnly: true, category: 'system' },
{
id: 'power-rating-audit',
name: 'Power Rating audit',
adminOnly: true,
category: 'system',
},
];
const categoryDefs = [
{ id: 'access', name: 'Access' },
{ id: 'league-setup', name: 'League Setup' },
{ id: 'teams-players', name: 'Teams & Players' },
{ id: 'matches', name: 'Matches' },
{ id: 'system', name: 'System' },
];
// Sections visible to the current user (role filter).
const adminSections = computed(() => {
if (authStore.isAdmin.value) {
return allAdminSections;
}
// Club managers only see non-adminOnly sections.
return allAdminSections.filter(section => !section.adminOnly);
});
// Categories that have at least one visible section for this role.
// Each carries its filtered sections list for the second-row sub-tabs.
const adminCategories = computed(() => {
const visible = adminSections.value;
return categoryDefs
.map(cat => ({
...cat,
sections: visible.filter(s => s.category === cat.id),
}))
.filter(cat => cat.sections.length > 0);
});
// Default to the first section the user can actually see.
const initialSection = adminSections.value[0]?.id || 'teams';
const currentSection = ref(initialSection);
const currentCategory = computed(() => {
const section = allAdminSections.find(s => s.id === currentSection.value);
return section?.category || adminCategories.value[0]?.id;
});
const currentCategorySections = computed(() => {
const cat = adminCategories.value.find(
c => c.id === currentCategory.value
);
return cat?.sections || [];
});
const selectCategory = catId => {
const cat = adminCategories.value.find(c => c.id === catId);
if (cat && cat.sections.length > 0) {
currentSection.value = cat.sections[0].id;
}
};
// "Approve" on an invite request opens the Invites section with the
// form pre-filled from it (SB-1312, SB-1392). Leaving Invites drops it.
const invitePrefill = ref(null);
const openInviteFromRequest = request => {
invitePrefill.value = invitePrefillFromRequest(request);
currentSection.value = 'invites';
};
watch(currentSection, section => {
if (section !== 'invites') invitePrefill.value = null;
});
return {
authStore,
invitePrefill,
openInviteFromRequest,
currentSection,
currentCategory,
adminSections,
adminCategories,
currentCategorySections,
selectCategory,
};
},
};
</script>
<style scoped>
.admin-panel {
max-width: 1200px;
margin: 0 auto;
}
</style>
|