Skip to content

Commit

Permalink
Use new_sidebar flag to enable the bookmark feature
Browse files Browse the repository at this point in the history
  • Loading branch information
smanga24 committed Jan 13, 2025
1 parent b615d64 commit 5486382
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/core/templatetags/sidebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ def get_part_context(self):
page = self.context.get("self")
is_bookmarked = bookmarks_service.is_page_bookmarked(user, page)
post_url = reverse("interactions:bookmark")
is_new_sidebar_enabled = flag_is_active(self.context["request"], "new_sidebar")
return {
"post_url": post_url,
"user": user,
"page": page,
"is_bookmarked": is_bookmarked,
"csrf_token": self.context["csrf_token"],
"is_new_sidebar_enabled": is_new_sidebar_enabled,
}


Expand Down
16 changes: 14 additions & 2 deletions src/interactions/templates/interactions/bookmark_page_input.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@
hx-select="button"
hx-target="this"
hx-swap="outerHTML">
{% include 'dwds/elements/bookmark-icon.html' %}
<span class="dwds-sr-only">{{ is_bookmarked|yesno:'Bookmarked,Bookmark this page' }}</span>
{% if is_new_sidebar_enabled %}
{% include 'dwds/elements/bookmark-icon.html' %}
{% else %}
{% include 'dwds/elements/icon.html' with id='bookmark-icon' is_filled=is_bookmarked %}
{% endif %}
<span class="{{ is_new_sidebar_enabled|yesno:'dwds-sr-only,' }}">
{% if is_bookmarked %}
Bookmarked
{% elif is_new_sidebar_enabled %}
Bookmark this page
{% else %}
Bookmark
{% endif %}
</span>
</button>
{% endif %}
2 changes: 2 additions & 0 deletions src/interactions/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from django.template.response import TemplateResponse
from django.urls import reverse
from django.views.decorators.http import require_http_methods
from waffle import flag_is_active
from wagtail.models import Page

from interactions.services import bookmarks as bookmarks_service
Expand All @@ -25,6 +26,7 @@ def bookmark(request, *args, **kwargs):
"user": user,
"page": page,
"is_bookmarked": is_bookmarked,
"is_new_sidebar_enabled": flag_is_active(request, "new_sidebar"),
}

return TemplateResponse(
Expand Down

0 comments on commit 5486382

Please sign in to comment.