]> BookStack Code Mirror - bookstack/blob - resources/views/comments/comment.blade.php
Tests: Updated comment test to account for new editor usage
[bookstack] / resources / views / comments / comment.blade.php
1 @php
2     $commentHtml = $comment->safeHtml();
3 @endphp
4 <div component="{{ $readOnly ? '' : 'page-comment' }}"
5      option:page-comment:comment-id="{{ $comment->id }}"
6      option:page-comment:comment-local-id="{{ $comment->local_id }}"
7      option:page-comment:updated-text="{{ trans('entities.comment_updated_success') }}"
8      option:page-comment:deleted-text="{{ trans('entities.comment_deleted_success') }}"
9      option:page-comment:archive-text="{{ $comment->archived ? trans('entities.comment_unarchive_success') : trans('entities.comment_archive_success') }}"
10      option:page-comment:wysiwyg-text-direction="{{ $locale->htmlDirection() }}"
11      id="comment{{$comment->local_id}}"
12      class="comment-box">
13     <div class="header">
14         <div class="flex-container-row wrap items-center gap-x-xs">
15             @if ($comment->createdBy)
16                 <div>
17                     <img width="50" src="{{ $comment->createdBy->getAvatar(50) }}" class="avatar block mr-xs" alt="{{ $comment->createdBy->name }}">
18                 </div>
19             @endif
20             <div class="meta text-muted flex-container-row wrap items-center flex text-small">
21                 @if ($comment->createdBy)
22                     <a href="{{ $comment->createdBy->getProfileUrl() }}">{{ $comment->createdBy->getShortName(16) }}</a>
23                 @else
24                     {{ trans('common.deleted_user') }}
25                 @endif
26                 <span title="{{ $comment->created_at }}">&nbsp;{{ trans('entities.comment_created', ['createDiff' => $comment->created_at->diffForHumans() ]) }}</span>
27                 @if($comment->isUpdated())
28                     <span class="mx-xs">&bull;</span>
29                     <span title="{{ trans('entities.comment_updated', ['updateDiff' => $comment->updated_at, 'username' => $comment->updatedBy->name ?? trans('common.deleted_user')]) }}">
30                  {{ trans('entities.comment_updated_indicator') }}
31                     </span>
32                 @endif
33             </div>
34             <div class="right-meta flex-container-row justify-flex-end items-center px-s">
35                 @if(!$readOnly && (userCan('comment-create-all') || userCan('comment-update', $comment) || userCan('comment-delete', $comment)))
36                 <div class="actions mr-s">
37                     @if(userCan('comment-create-all'))
38                         <button refs="page-comment@reply-button" type="button" class="text-button text-muted hover-underline text-small p-xs">@icon('reply') {{ trans('common.reply') }}</button>
39                     @endif
40                     @if(!$comment->parent_id && (userCan('comment-update', $comment) || userCan('comment-delete', $comment)))
41                         <button refs="page-comment@archive-button"
42                                 type="button"
43                                 data-is-archived="{{ $comment->archived ? 'true' : 'false' }}"
44                                 class="text-button text-muted hover-underline text-small p-xs">@icon('archive') {{ trans('common.' . ($comment->archived ? 'unarchive' : 'archive')) }}</button>
45                     @endif
46                     @if(userCan('comment-update', $comment))
47                         <button refs="page-comment@edit-button" type="button" class="text-button text-muted hover-underline text-small p-xs">@icon('edit') {{ trans('common.edit') }}</button>
48                     @endif
49                     @if(userCan('comment-delete', $comment))
50                         <div component="dropdown" class="dropdown-container">
51                             <button type="button" refs="dropdown@toggle" aria-haspopup="true" aria-expanded="false" class="text-button text-muted hover-underline text-small p-xs">@icon('delete') {{ trans('common.delete') }}</button>
52                             <ul refs="dropdown@menu" class="dropdown-menu" role="menu">
53                                 <li class="px-m text-small text-muted pb-s">{{trans('entities.comment_delete_confirm')}}</li>
54                                 <li>
55                                     <button refs="page-comment@delete-button" type="button" class="text-button text-neg icon-item">
56                                         @icon('delete')
57                                         <div>{{ trans('common.delete') }}</div>
58                                     </button>
59                                 </li>
60                             </ul>
61                         </div>
62                     @endif
63                     <span class="text-muted">
64                         &nbsp;&bull;&nbsp;
65                     </span>
66                 </div>
67                 @endif
68                 <div>
69                     <a class="bold text-muted text-small" href="#comment{{$comment->local_id}}">#{{$comment->local_id}}</a>
70                 </div>
71             </div>
72         </div>
73
74     </div>
75
76     <div refs="page-comment@content-container" class="content">
77         @if ($comment->parent_id)
78             <p class="comment-reply">
79                 <a class="text-muted text-small" href="#comment{{ $comment->parent_id }}">@icon('reply'){{ trans('entities.comment_in_reply_to', ['commentId' => '#' . $comment->parent_id]) }}</a>
80             </p>
81         @endif
82         @if($comment->content_ref)
83             <div class="comment-reference-indicator-wrap">
84                 <a component="page-comment-reference"
85                    option:page-comment-reference:reference="{{ $comment->content_ref }}"
86                    option:page-comment-reference:view-comment-text="{{ trans('entities.comment_view') }}"
87                    option:page-comment-reference:jump-to-thread-text="{{ trans('entities.comment_jump_to_thread') }}"
88                    option:page-comment-reference:close-text="{{ trans('common.close') }}"
89                    href="#">@icon('bookmark'){{ trans('entities.comment_reference') }} <span>{{ trans('entities.comment_reference_outdated') }}</span></a>
90             </div>
91         @endif
92         {!! $commentHtml  !!}
93     </div>
94
95     @if(!$readOnly && userCan('comment-update', $comment))
96         <form novalidate refs="page-comment@form" hidden class="content pt-s px-s block">
97             <div class="form-group description-input">
98                 <textarea refs="page-comment@input" name="html" rows="3" placeholder="{{ trans('entities.comment_placeholder') }}">{{ $commentHtml }}</textarea>
99             </div>
100             <div class="form-group text-right">
101                 <button type="button" class="button outline" refs="page-comment@form-cancel">{{ trans('common.cancel') }}</button>
102                 <button type="submit" class="button">{{ trans('entities.comment_save') }}</button>
103             </div>
104         </form>
105     @endif
106
107 </div>