# Copyright © The Debusine Developers
# See the AUTHORS file at the top-level directory of this distribution
#
# This file is part of Debusine. It is subject to the license terms
# in the LICENSE file found in the top-level directory of this
# distribution. No part of Debusine, including this file, may be copied,
# modified, propagated, or distributed except according to the terms
# contained in the LICENSE file.

"""Base for views using the rightbar UI layout."""

from typing import Any, override

from django.views.generic.base import ContextMixin

from debusine.web.views.sidebar import SidebarItem


class RightbarUIMixin(ContextMixin):
    """Base class for views using a sidebar layout."""

    base_template = "web/_base_rightbar.html"

    def get_sidebar_items(self) -> list[SidebarItem]:
        """Return a list of sidebar items."""
        return []

    @override
    def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
        """Add UI elements to the template context."""
        context = super().get_context_data(**kwargs)
        context["sidebar_items"] = self.get_sidebar_items()
        return context
