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

Update front.html.twig Add border to non federated notifications for admins and moderators #1297

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
55 changes: 52 additions & 3 deletions templates/notifications/_blocks.html.twig
Original file line number Diff line number Diff line change
@@ -1,106 +1,152 @@
{% block entry_created_notification %}
{{ component('user_inline', {user: notification.entry.user}) }} {{ 'added_new_thread'|trans|lower }} - <a
href="{{ entry_url(notification.entry) }}">{{ notification.entry.shortTitle }}</a>
{% if not notification.entry.magazine.apId and (app.user.admin or notification.entry.magazine.userIsModerator(app.user)) %}
style="border-color:var(--kbin-upvoted-color);"
{% set titleString = 'notification_created_on_this_instance'|trans %}
{% set titleString = titleString ~ notification.entry.user.username %}
title="{{ titleString }}"
{% endif %}><div>
{{ component('user_inline', {user: notification.entry.user}) }} {{ 'added_new_thread'|trans|lower }} - <a
href="{{ entry_url(notification.entry) }}">{{ notification.entry.shortTitle ~ modString }}</a>
{% endblock entry_created_notification %}

{% block entry_edited_notification %}
><div>
{{ component('user_inline', {user: notification.entry.user}) }} {{ 'edited_thread'|trans|lower }} - <a
href="{{ entry_url(notification.entry) }}">{{ notification.entry.shortTitle }}</a>
{% endblock entry_edited_notification %}

{% block entry_deleted_notification %}
><div>
<a href="{{ entry_url(notification.entry) }}">{{ notification.entry.shortTitle }}</a>
{% if notification.entry.isTrashed %}{{ 'removed'|trans|lower }}{% else %}{{ 'deleted'|trans|lower }}{% endif %}
{% endblock entry_deleted_notification %}

{% block entry_mentioned_notification %}
><div>
{{ component('user_inline', {user: notification.entry.user}) }} {{ 'mentioned_you'|trans|lower }} - <a
href="{{ entry_url(notification.entry) }}">{{ notification.entry.shortTitle }}</a>
{% endblock entry_mentioned_notification %}

{% block entry_comment_created_notification %}
{% if not notification.comment.magazine.apId and (app.user.admin or notification.comment.magazine.userIsModerator(app.user)) %}
style="border-color:var(--kbin-upvoted-color);"
{% set titleString = 'notification_created_on_this_instance'|trans %}
{% set titleString = titleString ~ notification.comment.user.username %}
title="{{ titleString }}"
{% endif %}><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'added_new_comment'|trans|lower }} - <a
href="{{ entry_comment_view_url(notification.comment) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock entry_comment_created_notification %}

{% block entry_comment_edited_notification %}
><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'edited_comment'|trans|lower }} - <a
href="{{ entry_comment_view_url(notification.comment) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock entry_comment_edited_notification %}

{% block entry_comment_reply_notification %}
><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'replied_to_your_comment'|trans|lower }} - <a
href="{{ entry_comment_view_url(notification.comment) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock entry_comment_reply_notification %}

{% block entry_comment_deleted_notification %}
><div>
{{ 'comment'|trans }} <a
href="{{ entry_url(notification.comment.entry) }}">{{ notification.comment.shortTitle }}</a> -
{% if notification.comment.isTrashed %}{{ 'removed'|trans|lower }}{% else %}{{ 'deleted'|trans|lower }}{% endif %}
{% endblock entry_comment_deleted_notification %}

{% block entry_comment_mentioned_notification %}
><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'mentioned_you'|trans|lower }} - <a
href="{{ entry_comment_view_url(notification.comment) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock entry_comment_mentioned_notification %}

{% block post_created_notification %}
{% if not notification.post.magazine.apId and (app.user.admin or notification.post.magazine.userIsModerator(app.user)) %}
style="border-color:var(--kbin-upvoted-color);"
{% set titleString = 'notification_created_on_this_instance'|trans %}
{% set titleString = titleString ~ notification.post.user.username %}
title="{{ titleString }}"
{% endif %}><div>
{{ component('user_inline', {user: notification.post.user}) }} {{ 'added_new_post'|trans|lower }} - <a
href="{{ post_url(notification.post) }}">{{ notification.post.shortTitle }}</a>
{% endblock post_created_notification %}

{% block post_edited_notification %}
><div>
{{ component('user_inline', {user: notification.post.user}) }} {{ 'edit_post'|trans|lower }} - <a
href="{{ post_url(notification.post) }}">{{ notification.post.shortTitle }}</a>
{% endblock post_edited_notification %}

{% block post_deleted_notification %}
><div>
{{ 'post'|trans }} <a
href="{{ post_url(notification.post) }}">{{ notification.post.shortTitle }}</a> -
{% if notification.comment.isTrashed %}{{ 'removed'|trans|lower }}{% else %}{{ 'deleted'|trans|lower }}{% endif %}
{% endblock post_deleted_notification %}

{% block post_mentioned_notification %}
><div>
{{ component('user_inline', {user: notification.post.user}) }} {{ 'mentioned_you'|trans|lower }} - <a
href="{{ post_url(notification.post) }}">{{ notification.post.shortTitle }}</a>
{% endblock post_mentioned_notification %}

{% block post_comment_created_notification %}
{% if not notification.comment.magazine.apId and (app.user.admin or notification.comment.magazine.userIsModerator(app.user)) %}
style="border-color:var(--kbin-upvoted-color);"
{% set titleString = 'notification_created_on_this_instance'|trans %}
{% set titleString = titleString ~ notification.comment.user.username %}
title="{{ titleString }}"
{% endif %}><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'added_new_comment'|trans|lower }} - <a
href="{{ post_url(notification.comment.post) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock post_comment_created_notification %}

{% block post_comment_edited_notification %}
><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'edited_comment'|trans|lower }} - <a
href="{{ post_url(notification.comment.post) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock post_comment_edited_notification %}

{% block post_comment_reply_notification %}
><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'replied_to_your_comment'|trans|lower }} - <a
href="{{ post_url(notification.comment.post) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock post_comment_reply_notification %}

{% block post_comment_deleted_notification %}
><div>
{{ 'comment'|trans }} <a
href="{{ post_url(notification.comment.post) }}">{{ notification.comment.shortTitle }}</a> -
{% if notification.comment.isTrashed %}{{ 'removed'|trans|lower }}{% else %}{{ 'deleted'|trans|lower }}{% endif %}
{% endblock post_comment_deleted_notification %}

{% block post_comment_mentioned_notification %}
><div>
{{ component('user_inline', {user: notification.comment.user}) }} {{ 'mentioned_you'|trans|lower }} - <a
href="{{ post_url(notification.comment.post) }}#{{ get_url_fragment(notification.comment) }}">{{ notification.comment.shortTitle }}</a>
{% endblock post_comment_mentioned_notification %}

{% block message_notification %}
{{ component('user_inline', {user: notification.message.sender}) }} {{ 'wrote_message'|trans|lower }} <a
{% if (app.user.admin) %}
style="border-color:var(--kbin-upvoted-color);"
{% set titleString = 'wrote_message'|trans %}
{% set titleString = notification.message.sender.username ~ ' ' ~ titleString %}
title="{{ titleString }}"
{% endif %}><div>
{{ component('user_inline', {user: notification.message.sender}) }} ✉ {{ 'wrote_message'|trans|lower }} <a
href="{{ path('messages_single', {'id': notification.message.thread.id}) }}">{{ notification.message.title }}</a>
{% endblock message_notification %}

{% block magazine_ban_notification %}
><div>
{{ component('user_inline', {user: notification.ban.bannedBy}) }} {{ 'banned'|trans|lower }}. {{ 'ban_expired'|trans }} {{ component('date', {date: notification.ban.expiredAt}) }}. {{ notification.ban.reason }}
{% endblock magazine_ban_notification %}

{% block reportlink %}
><div>
{% if notification.report.entry is defined and notification.report.entry is not same as null %}
{% set entry = notification.report.entry %}
<a href="{{ path('entry_single', { 'magazine_name': entry.magazine.name, 'entry_id': entry.id, 'slug': entry.slug }) }}">
Expand All @@ -125,6 +171,7 @@
{% endblock %}

{% block report_created_notification %}
><div>
{{ component('user_inline', {user: notification.report.reporting}) }} {{ 'reported'|trans|lower }} {{ component('user_inline', {user: notification.report.reported}) }}<br />
{{ 'report_subject'|trans }}: {{ block('reportlink') }}<br />
{% if app.user.admin or app.user.moderator or notification.report.magazine.userIsModerator(app.user) %}
Expand All @@ -133,6 +180,7 @@
{% endblock report_created_notification %}

{% block report_rejected_notification %}
><div>
{{ 'own_report_rejected'|trans }} <br />
{{ 'reported_user'|trans }}: {{ component('user_inline', {user: notification.report.reported}) }}<br />
{{ 'report_subject'|trans }}: {{ block('reportlink') }}<br />
Expand All @@ -142,6 +190,7 @@
{% endblock report_rejected_notification %}

{% block report_approved_notification %}
><div>
{% if notification.report.reporting.id is same as app.user.id %}
{{ 'own_report_accepted'|trans }}<br />
{% elseif notification.report.reported.id is same as app.user.id %}
Expand Down
20 changes: 9 additions & 11 deletions templates/notifications/front.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,18 @@
</button>
</div>
</div>

</div>

{% for notification in notifications %}
<div class="{{ html_classes('section section--small notification', {'opacity-50': notification.status is not same as 'new' }) }}">
<div>
{%- with {
notification: notification,
showMagazine: false,
} only -%}
{{ block(notification.type) }}
{%- endwith -%}
</div>
<span>{{ component('date', {date: notification.createdAt}) }}</span>
<div class="{{ html_classes('section section--small notification', {'opacity-50': notification.status is not same as 'new' }) }}"
{%- with {
notification: notification,
showMagazine: false,
} only -%}
{{ block(notification.type) }}
{%- endwith -%}
</div>
<span>{{ component('date', {date: notification.createdAt}) }}</span>
</div>
{% endfor %}
{% if(notifications.haveToPaginate is defined and notifications.haveToPaginate) %}
Expand Down
Loading