Skip to content

Commit f6837fd

Browse files
committed
feat: hide components for specific pages
1 parent 8533500 commit f6837fd

File tree

6 files changed

+30
-18
lines changed

6 files changed

+30
-18
lines changed

front_end/src/app/(main)/(tournaments)/tournaments/components/tournaments_header.tsx

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,21 @@ const TournamentsHeader: React.FC = () => {
6060
<TournamentsTabs current={current} />
6161
</div>
6262

63-
<div className="hidden items-center gap-3 lg:flex">
64-
<TournamentsFilter />
65-
<TournamentsSearch />
66-
67-
{showInfo && isLg ? (
68-
<TournamentsInfoPopover
69-
open={infoOpen}
70-
onOpenChange={(next) => (next ? toggleInfo() : closeInfo())}
71-
offsetPx={POPOVER_GAP}
72-
stickyTopPx={STICKY_TOP}
73-
/>
74-
) : null}
75-
</div>
63+
{current !== "indexes" && (
64+
<div className="hidden items-center gap-3 lg:flex">
65+
<TournamentsFilter />
66+
<TournamentsSearch />
67+
68+
{showInfo && isLg ? (
69+
<TournamentsInfoPopover
70+
open={infoOpen}
71+
onOpenChange={(next) => (next ? toggleInfo() : closeInfo())}
72+
offsetPx={POPOVER_GAP}
73+
stickyTopPx={STICKY_TOP}
74+
/>
75+
) : null}
76+
</div>
77+
)}
7678
</div>
7779
</div>
7880
</div>

front_end/src/app/(main)/(tournaments)/tournaments/components/tournaments_popover/tournaments_info_popover.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import cn from "@/utils/core/cn";
1818

1919
import TournamentsInfo from "./tournaments_info";
2020
import TournamentsInfoButton from "./tournaments_info_button";
21+
import { useTournamentsSection } from "../tournaments_provider";
2122

2223
type Props = {
2324
open: boolean;
@@ -34,6 +35,7 @@ const TournamentsInfoPopover: React.FC<Props> = ({
3435
offsetPx = 12,
3536
stickyTopPx = 0,
3637
}) => {
38+
const { current } = useTournamentsSection();
3739
const { refs, floatingStyles, context, isPositioned } = useFloating({
3840
open,
3941
onOpenChange,
@@ -73,6 +75,10 @@ const TournamentsInfoPopover: React.FC<Props> = ({
7375
role,
7476
]);
7577

78+
if (current === "series" || current === "indexes") {
79+
return null;
80+
}
81+
7682
return (
7783
<>
7884
<TournamentsInfoButton

projects/serializers/common.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from collections import defaultdict
22
from typing import Any, Callable, Iterable
33

4-
from django.db.models import Q, QuerySet
4+
from django.db.models import Q
55
from rest_framework import serializers
66
from rest_framework.exceptions import ValidationError
77

@@ -101,7 +101,6 @@ class Meta:
101101
"description_preview",
102102
)
103103

104-
105104
def get_description_preview(self, project: Project) -> str:
106105
raw = (project.description or "").strip()
107106
if not raw:

projects/services/cache.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def invalidate_projects_questions_count_cache(projects: list[Project]) -> None:
4848
]
4949
cache.delete_many(cache_keys)
5050

51+
5152
def get_project_timeline_data_cached(project: Project):
5253
key = f"project_timeline:v1:{project.id}"
5354
return cache.get_or_set(
@@ -56,5 +57,6 @@ def get_project_timeline_data_cached(project: Project):
5657
PROJECT_TIMELINE_TTL_SECONDS,
5758
)
5859

60+
5961
def get_projects_timeline_cached(projects: list[Project]) -> dict[int, dict]:
60-
return {p.id: get_project_timeline_data_cached(p) for p in projects}
62+
return {p.id: get_project_timeline_data_cached(p) for p in projects}

projects/services/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from django.db import IntegrityError
66
from django.utils import timezone
77
from django.utils.timezone import make_aware
8-
from django.core.cache import cache
98

109
from posts.models import Post
1110
from projects.models import Project, ProjectUserPermission
@@ -211,6 +210,7 @@ def get_max(data: list):
211210
"all_questions_closed": all_questions_closed,
212211
}
213212

213+
214214
def get_questions_count_for_projects(project_ids: list[int]) -> dict[int, int]:
215215
"""
216216
Returns a dict mapping each project_id to its questions_count

projects/views/common.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
serialize_index_data,
2222
serialize_tournaments_with_counts,
2323
)
24-
from projects.services.cache import get_projects_questions_count_cached, get_projects_timeline_cached
24+
from projects.services.cache import (
25+
get_projects_questions_count_cached,
26+
get_projects_timeline_cached,
27+
)
2528
from projects.services.common import (
2629
get_projects_qs,
2730
get_project_permission_for_user,

0 commit comments

Comments
 (0)