Skip to content

Commit

Permalink
Merge pull request #9 from tonypartridge/v3
Browse files Browse the repository at this point in the history
V3 Migration
  • Loading branch information
pxlrbt authored Aug 3, 2023
2 parents f2c5c7b + a128491 commit d6184b2
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
],
"require": {
"php": "^8.0",
"filament/filament": "^2.9.15",
"filament/filament": "^3.0.5.0",
"spatie/laravel-activitylog": "^4.7"
},
"autoload": {
Expand Down
49 changes: 25 additions & 24 deletions resources/views/pages/list-activities.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<x-filament::page>
<x-filament-panels::page>
<div class="space-y-6">
@foreach($this->getActivities() as $activityItem)
<div @class([
Expand All @@ -9,7 +9,7 @@
<div class="flex justify-between">
<div class="flex gap-4 items-center">
@if ($activityItem->causer)
<x-filament::user-avatar :user="$activityItem->causer" class="!w-7 !h-7" />
<x-filament-panels::avatar.user :user="$activityItem->causer" class="!w-7 !h-7"/>
<span class="font-bold">{{ $activityItem->causer?->name }}</span>
@endif
</div>
Expand All @@ -20,19 +20,19 @@
</div>
</div>

<x-filament::hr />
<hr />

<x-tables::table class="w-full overflow-hidden text-sm">
<x-filament-tables::table class="w-full overflow-hidden text-sm">
<x-slot:header>
<x-tables::header-cell>
<x-filament-tables::header-cell>
@lang('filament-activity-log::activities.table.field')
</x-tables::header-cell>
<x-tables::header-cell>
</x-filament-tables::header-cell>
<x-filament-tables::header-cell>
@lang('filament-activity-log::activities.table.old')
</x-tables::header-cell>
<x-tables::header-cell>
</x-filament-tables::header-cell>
<x-filament-tables::header-cell>
@lang('filament-activity-log::activities.table.new')
</x-tables::header-cell>
</x-filament-tables::header-cell>
</x-slot:header>
@php
/* @var \Spatie\Activitylog\Models\Activity $activityItem */
Expand All @@ -43,33 +43,34 @@
$oldValue = data_get($changes, "old.{$field}");
$newValue = data_get($changes, "attributes.{$field}");
@endphp
<x-tables::row @class(['bg-gray-100/30' => $loop->even])>
<x-tables::cell width="20%" class="px-4 py-2 align-top">
<x-filament-tables::row @class(['bg-gray-100/30' => $loop->even])>
<x-filament-tables::cell width="20%" class="px-4 py-2 align-top">
{{ $this->getFieldLabel($field) }}
</x-tables::cell>
<x-tables::cell width="40%" class="px-4 py-2 align-top break-all !whitespace-normal">
</x-filament-tables::cell>
<x-filament-tables::cell width="40%" class="px-4 py-2 align-top break-all !whitespace-normal">
@if(is_array($oldValue))
<pre class="text-xs text-gray-500">{{ json_encode($oldValue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) }}</pre>
@else
{{ $oldValue }}
@endif
</x-tables::cell>
<x-tables::cell width="40%" class="px-4 py-2 align-top break-all !whitespace-normal">
</x-filament-tables::cell>
<x-filament-tables::cell width="40%" class="px-4 py-2 align-top break-all !whitespace-normal">
@if(is_array($newValue))
<pre class="text-xs text-gray-500">{{ json_encode($newValue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) }}</pre>
@else
{{ $newValue }}
@endif
</x-tables::cell>
</x-tables::row>
</x-filament-tables::cell>
</x-filament-tables::row>
@endforeach
</x-tables::table>
</x-filament-tables::table>
</div>
@endforeach

<x-tables::pagination
:paginator="$this->getActivities()"
:records-per-page-select-options="$this->getTableRecordsPerPageSelectOptions()"
/>
<x-filament::pagination
:page-options="$this->getTableRecordsPerPageSelectOptions()"
:paginator="$this->getActivities()"
class="px-3 py-3 sm:px-6"
/>
</div>
</x-filament::page>
</x-filament-panels::page>
4 changes: 2 additions & 2 deletions src/FilamentActivityLogServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace pxlrbt\FilamentActivityLog;

use Filament\PluginServiceProvider;
use Spatie\LaravelPackageTools\Package;
use Spatie\LaravelPackageTools\PackageServiceProvider;

class FilamentActivityLogServiceProvider extends PluginServiceProvider
class FilamentActivityLogServiceProvider extends PackageServiceProvider
{
public static string $name = 'filament-activity-log';

Expand Down
17 changes: 10 additions & 7 deletions src/Pages/ListActivities.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@

use Filament\Forms\Components\Field;
use Filament\Forms\Components\MorphToSelect;
use Filament\Resources\Form;
use Filament\Resources\Pages\Concerns\HasRecordBreadcrumb;
use Filament\Forms\Form;
use Filament\Pages\Concerns\InteractsWithFormActions;
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
use Filament\Resources\Pages\Page;
use Filament\Tables\Concerns\CanPaginateRecords;
use Illuminate\Support\Collection;
use Livewire\Features\SupportPagination\HandlesPagination;
use Filament\Forms\Contracts\HasForms;

abstract class ListActivities extends Page
abstract class ListActivities extends Page implements HasForms
{
use InteractsWithRecord;
use CanPaginateRecords;
use HasRecordBreadcrumb;
use HandlesPagination;
use InteractsWithRecord;
use InteractsWithFormActions;

protected static string $view = 'filament-activity-log::pages.list-activities';

Expand Down Expand Up @@ -47,9 +50,9 @@ public function getFieldLabel(string $name): string

protected function createFieldLabelMap(): Collection
{
$form = static::getResource()::form(new Form());
$form = static::getResource()::form(new Form($this));

$components = collect($form->getSchema());
$components = collect($form->getComponents());
$extracted = collect();

while (($component = $components->shift()) !== null) {
Expand Down

0 comments on commit d6184b2

Please sign in to comment.