[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) public function getNoteActions(Note $note)
{ {
// Only show buttons if a user is logged in
if (Common::user() == null) {
return [];
}
$actions = []; $actions = [];
Event::handle('add_note_actions', [$this->request, $note, &$actions]); Event::handle('add_note_actions', [$this->request, $note, &$actions]);
return $actions; return $actions;

View File

@ -92,7 +92,7 @@
{% if notes is defined and notes is not empty %} {% if notes is defined and notes is not empty %}
{% for note in notes %} {% for note in notes %}
{% set id = note.getId() - 1 %} {% 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 %} {% endfor %}
{% else %} {% else %}
<h1>{% trans %}No notes here.{% endtrans %}</h1> <h1>{% trans %}No notes here.{% endtrans %}</h1>

View File

@ -29,7 +29,7 @@
{{ parent() }} {{ parent() }}
<div class="content"> <div class="content">
<div class="main"> <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) }} {{ form(reply) }}
</div> </div>
</div> </div>

View File

@ -35,18 +35,15 @@
</div> </div>
</div> </div>
<div class="note-actions"> <div class="note-actions">
{% if have_user %}
{% for act in get_note_actions(note) %} {% for act in get_note_actions(note) %}
{{ form(act) }} {{ form(act) }}
{% endfor %} {% endfor %}
<a href="{{ path('note_reply', {'reply_to': note.getId()}) }}"> {% endif %}
<svg class="icon icon-reply">
<use xlink:href="#icon-reply"></use>
</svg>
</a>
</div> </div>
<div class="replies"> <div class="replies">
{% for reply in note.getReplies() %} {% 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 %} {% endfor %}
</div> </div>
</div> </div>