Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

indicate articles that are targets of in-product links #5948

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
indicate articles that are targets of in-product links
  • Loading branch information
escattone committed Apr 18, 2024
commit f9c90f5efb7a550e08d210cc2f23d1b5eed62ebc
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 @@ -779,6 +780,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