Skip to content

Commit

Permalink
move attachments inside details modal
Browse files Browse the repository at this point in the history
  • Loading branch information
danilopolani committed Feb 19, 2024
1 parent a83203c commit b329088
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 75 deletions.
2 changes: 1 addition & 1 deletion resources/dist/css/theme.css

Large diffs are not rendered by default.

48 changes: 0 additions & 48 deletions resources/views/modals/attachments.blade.php

This file was deleted.

56 changes: 56 additions & 0 deletions resources/views/modals/details.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,62 @@ class="text-sm"
{!! $template !!}
</div>

<div class="mt-4">
<p class="font-bold mb-1">Attachments</p>
<table class="w-full table-auto border-collapse text-left rtl:text-right divide-y dark:divide-gray-700 text-sm rounded-lg overflow-hidden">
<thead>
<tr class="bg-gray-50 dark:bg-gray-500/10">
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-medium text-gray-600 dark:text-gray-300 cursor-default">
Name
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-medium text-gray-600 dark:text-gray-300 cursor-default">
Size
</span>
</th>
<th>
<span class="p-0 flex items-center w-full px-4 py-2 whitespace-nowrap space-x-1 rtl:space-x-reverse font-medium text-gray-600 dark:text-gray-300 cursor-default">
Disk
</span>
</th>
<th class="w-5"></th>
</tr>
</thead>
<tbody class="divide-y whitespace-nowrap dark:divide-gray-700">
@forelse ($log->attachments as $attachment)
<tr class="dark:bg-gray-700/50 odd:bg-white even:bg-gray-50 even:dark:bg-gray-700/80">
<td class="px-4 py-2 dark:text-white">
{{ $attachment->name }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->readableSize() }}
</td>
<td class="px-4 py-2 dark:text-white">
{{ $attachment->disk ?: '-' }}
</td>
<td class="px-4 py-2">
@if ($attachment->canBeDownloaded())
<a
href="{{ URL::route('download.attachment', $attachment) }}"
class="font-medium text-primary-500 hover:text-primary-400"
target="_blank"
download>
Download
</a>
@endif
</td>
</tr>
@empty
<tr class="dark:bg-gray-700/50 odd:bg-white even:bg-gray-50 even:dark:bg-gray-700/80">
<td class="px-4 py-2 italic text-xs opacity-80" colspan="4">No attachment available</td>
</tr>
@endforelse
</tbody>
</table>
</div>

<div class="mt-4">
<p class="font-bold mb-1">Variables</p>
<pre wire:ignore x-ref="variables" class="hljs w-full rounded p-3 shadow-sm focus:border-primary-600 focus:ring-1 focus:ring-inset focus:ring-primary-600 disabled:opacity-70 border border-gray-300/50 dark:border-gray-600/50"><code class="language-json">{!! $variables !!}</code></pre>
Expand Down
27 changes: 2 additions & 25 deletions src/Resources/LogResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,31 +57,8 @@ public static function table(Tables\Table $table): Tables\Table

Tables\Columns\TextColumn::make('subject')
->searchable()
->limit(25)
->tooltip(
fn (Tables\Columns\TextColumn $column): ?string => strlen($column->getState()) > $column->getCharacterLimit() ? $column->getState() : null
),

Tables\Columns\TextColumn::make('attachments')
->limitList(2)
->expandableLimitedList()
->badge()
->separator(',')
->getStateUsing(
fn (Log $record): array => $record
->attachments
->pluck('name')
->all()
)
->action(
Tables\Actions\Action::make('attachments')
->modalContent(fn (Log $record) => View::make('mailcarrier::modals.attachments', [
'attachments' => $record->attachments,
]))
->modalSubmitAction(false)
->modalCancelActionLabel('Close')
->modalFooterActionsAlignment(Alignment::Center)
),
->icon(fn (Log $record) => $record->attachments->isNotEmpty() ? 'heroicon-o-paper-clip' : '')
->iconColor('primary'),

Tables\Columns\TextColumn::make('tries')
->badge()
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/LogResource/Pages/ListLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ListLogs extends ListRecords
protected function getTableQuery(): EloquentBuilder
{
return Log::query()
->with('template')
->with(['template', 'attachments'])
->latest();
}

Expand Down

0 comments on commit b329088

Please sign in to comment.