Skip to content

Commit

Permalink
Merge pull request #5948 from escattone/display-inproduct-message-for…
Browse files Browse the repository at this point in the history
…-kb-articles-1607

indicate articles that are targets of in-product links
  • Loading branch information
akatsoulas committed Apr 23, 2024
2 parents 8df9415 + f9c90f5 commit b95b0cd
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kitsune/sumo/static/sumo/img/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions kitsune/sumo/static/sumo/scss/components/_wiki.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@

@import 'selectize/scss/selectize.default';

figure {
&.linked-in-product {
display: flex;
margin-bottom: p.$spacing-xl;

img {
width: 24px;
height: 24px;
margin-right: p.$spacing-sm;
}

figcaption {
font-weight: bold;
line-height: normal;
}
}
}

#id_restrict_to_groups {
// Prevents flickering by hiding the un-selectized select
// until selectize uses it to make a new one that's visible.
Expand Down
8 changes: 8 additions & 0 deletions kitsune/wiki/jinja2/wiki/includes/sidebar_modules.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
{% endif %}
<nav id="doc-tools">
<ul class="sidebar-nav sidebar-folding">
{% if in_staff_group(user) and (document or parent).is_linked_in_product %}
<li>
<figure class="linked-in-product">
<img src="{{ webpack_static('sumo/img/info.svg') }}" alt="{{ _('Information icon') }}" />
<figcaption>{{ _("Article is linked in product") }}</figcaption>
</figure>
</li>
{% endif %}
<li id="editing-tools-sidebar">
{% if user.is_authenticated %}
<h3 class="sidebar-subheading large-only">{{ _('Editing Tools') }}</h3>
Expand Down
12 changes: 12 additions & 0 deletions kitsune/wiki/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from pyquery import PyQuery

from kitsune.gallery.models import Image
from kitsune.inproduct.models import Redirect
from kitsune.products.models import Product, Topic
from kitsune.sumo.apps import ProgrammingError
from kitsune.sumo.i18n import split_into_language_and_path
Expand Down Expand Up @@ -780,6 +781,17 @@ def is_unrestricted_for(self, user, use_cache=True):

return user.id in self.unrestricted_for_user_ids

@cached_property
def is_linked_in_product(self):
if self.parent:
return Redirect.objects.filter(
(Q(locale__in=("", self.locale)) & Q(target__contains=f"kb/{self.parent.slug}"))
| (Q(locale=self.locale) & Q(target__contains=f"kb/{self.slug}"))
).exists()
return Redirect.objects.filter(
locale__in=("", self.locale), target__contains=f"kb/{self.slug}"
).exists()


class AbstractRevision(models.Model):
# **%(class)s** is being used because it will allow a unique reverse name for the field
Expand Down

0 comments on commit b95b0cd

Please sign in to comment.