Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 0 additions & 16 deletions src/unfold/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import hashlib
import time
from collections.abc import Callable
from http import HTTPStatus
from typing import Any
from urllib.parse import parse_qs, urlparse

Expand Down Expand Up @@ -64,11 +63,6 @@ def get_urls(self) -> list[URLPattern]:
urlpatterns = (
[
path("search/", self.admin_view(self.search), name="search"),
path(
"toggle-sidebar/",
self.admin_view(self.toggle_sidebar),
name="toggle_sidebar",
),
]
+ extra_urls
+ super().get_urls()
Expand Down Expand Up @@ -171,16 +165,6 @@ def index(
request, self.index_template or "admin/index.html", context
)

def toggle_sidebar(
self, request: HttpRequest, extra_context: dict[str, Any] | None = None
) -> HttpResponse:
if "toggle_sidebar" not in request.session:
request.session["toggle_sidebar"] = True
else:
request.session["toggle_sidebar"] = not request.session["toggle_sidebar"]

return HttpResponse(status=HTTPStatus.OK)

def _search_apps(
self, app_list: list[dict[str, Any]], search_term: str
) -> list[SearchResult]:
Expand Down
2 changes: 1 addition & 1 deletion src/unfold/templates/unfold/helpers/welcomemsg.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="flex flex-row grow font-semibold items-center min-w-0 mr-3">
{% if is_nav_sidebar_enabled %}
<span class="cursor-pointer flex flex-row items-center">
<span class="material-symbols-outlined hidden! xl:block!" hx-get="{% url "admin:toggle_sidebar" %}" hx-swap="none" x-on:click="sidebarDesktopOpen = !sidebarDesktopOpen">
<span class="material-symbols-outlined hidden! xl:block!" x-on:click="sidebarDesktopOpen = !sidebarDesktopOpen; localStorage.setItem('sidebarDesktopOpen', sidebarDesktopOpen ? '1' : '0');">
dock_to_right
</span>

Expand Down
12 changes: 11 additions & 1 deletion src/unfold/templates/unfold/layouts/skeleton.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,17 @@
{% endblock %}
</head>

<body class="antialiased bg-base-50 font-sans text-font-default-light text-sm dark:bg-base-900 dark:text-font-default-dark {% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}" data-admin-utc-offset="{% now "Z" %}" x-data="{ {% if opts %}activeTab: 'general',{% endif %} sidebarMobileOpen: false, sidebarDesktopOpen: {% if request.session.toggle_sidebar == False %}false{% else %}true{% endif %} }" x-init="activeTab = {% if opts %}window.location.hash?.replace('#', '') || 'general'{% else %}''{% endif %}">
<body class="antialiased bg-base-50 font-sans text-font-default-light text-sm dark:bg-base-900 dark:text-font-default-dark {% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}" data-admin-utc-offset="{% now "Z" %}"
x-data="{
{% if opts %}activeTab: 'general',{% endif %}
sidebarMobileOpen: false,
sidebarDesktopOpen: (localStorage.getItem('sidebarDesktopOpen') !== null) ? (localStorage.getItem('sidebarDesktopOpen') == '1') : true
}"
x-init="
activeTab = {% if opts %}window.location.hash?.replace('#', '') || 'general'{% else %}''{% endif %};
$watch('sidebarDesktopOpen', value => localStorage.setItem('sidebarDesktopOpen', value ? '1' : '0'));
"
>
{% if colors %}
<style id="unfold-theme-colors">
:root {
Expand Down