[UI] Only show note action buttons if a user is logged in

This commit is contained in:
Hugo Sales 2020-09-10 20:40:58 +00:00 committed by Hugo Sales
parent 9ae31501cc
commit c8b6db650a
4 changed files with 8 additions and 16 deletions

View File

@ -60,11 +60,6 @@ class Runtime implements RuntimeExtensionInterface, EventSubscriberInterface
public function getNoteActions(Note $note)
{
// Only show buttons if a user is logged in
if (Common::user() == null) {
return [];
}
$actions = [];
Event::handle('add_note_actions', [$this->request, $note, &$actions]);
return $actions;

View File

@ -92,7 +92,7 @@
{% if notes is defined and notes is not empty %}
{% for note in notes %}
{% set id = note.getId() - 1 %}
{% include '/note/view.html.twig' with {'note': note} only %}
{% include '/note/view.html.twig' with {'note': note, 'have_user': have_user} only %}
{% endfor %}
{% else %}
<h1>{% trans %}No notes here.{% endtrans %}</h1>

View File

@ -29,7 +29,7 @@
{{ parent() }}
<div class="content">
<div class="main">
{% include '/note/view.html.twig' with {'note': note} only %}
{% include '/note/view.html.twig' with {'note': note, 'have_user': have_user} only %}
{{ form(reply) }}
</div>
</div>

View File

@ -35,18 +35,15 @@
</div>
</div>
<div class="note-actions">
{% for act in get_note_actions(note) %}
{{ form(act) }}
{% endfor %}
<a href="{{ path('note_reply', {'reply_to': note.getId()}) }}">
<svg class="icon icon-reply">
<use xlink:href="#icon-reply"></use>
</svg>
</a>
{% if have_user %}
{% for act in get_note_actions(note) %}
{{ form(act) }}
{% endfor %}
{% endif %}
</div>
<div class="replies">
{% for reply in note.getReplies() %}
{% include '/note/view.html.twig' with {'note': reply, 'skip_reply_to': true} only %}
{% include '/note/view.html.twig' with {'note': reply, 'skip_reply_to': true, 'have_user': have_user} only %}
{% endfor %}
</div>
</div>