1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-08-09 10:22:51 +03:00

Attachments: Hid edit/delete controls where lacking permission

Added test to cover.
Also migrated related ajax-delete-row component to ts.

For #5323
This commit is contained in:
Dan Brown
2024-12-11 20:38:30 +00:00
parent 0ece664475
commit fcf0bf79a9
4 changed files with 74 additions and 22 deletions

View File

@@ -15,23 +15,27 @@
option:event-emit-select:name="insert"
type="button"
title="{{ trans('entities.attachments_insert_link') }}"
class="drag-card-action text-center text-link">@icon('link') </button>
<button component="event-emit-select"
option:event-emit-select:name="edit"
option:event-emit-select:id="{{ $attachment->id }}"
type="button"
title="{{ trans('common.edit') }}"
class="drag-card-action text-center text-link">@icon('edit')</button>
<div component="dropdown" class="flex-fill relative">
<button refs="dropdown@toggle"
class="drag-card-action text-center text-link">@icon('link')</button>
@if(userCan('attachment-update', $attachment))
<button component="event-emit-select"
option:event-emit-select:name="edit"
option:event-emit-select:id="{{ $attachment->id }}"
type="button"
title="{{ trans('common.delete') }}"
class="drag-card-action text-center text-neg">@icon('close')</button>
<div refs="dropdown@menu" class="dropdown-menu">
<p class="text-neg small px-m mb-xs">{{ trans('entities.attachments_delete') }}</p>
<button refs="ajax-delete-row@delete" type="button" class="text-link small delete text-item">{{ trans('common.confirm') }}</button>
title="{{ trans('common.edit') }}"
class="drag-card-action text-center text-link">@icon('edit')</button>
@endif
@if(userCan('attachment-delete', $attachment))
<div component="dropdown" class="flex-fill relative">
<button refs="dropdown@toggle"
type="button"
title="{{ trans('common.delete') }}"
class="drag-card-action text-center text-neg">@icon('close')</button>
<div refs="dropdown@menu" class="dropdown-menu">
<p class="text-neg small px-m mb-xs">{{ trans('entities.attachments_delete') }}</p>
<button refs="ajax-delete-row@delete" type="button" class="text-link small delete text-item">{{ trans('common.confirm') }}</button>
</div>
</div>
</div>
@endif
</div>
</div>
@endforeach