Skip to content

Commit

Permalink
fix: error on empty/null user in revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
mansoorkhan96 committed Sep 21, 2024
1 parent 00f697d commit 9195e52
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions resources/lang/en/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
'content_tab_label' => 'Revisions',
'revision_by' => 'Revision by :name',
'revisions_list' => 'Revisions list',
'anonymous_user' => 'Anonymous User',
];
1 change: 1 addition & 0 deletions resources/lang/fr/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
'content_tab_label' => 'Révisions',
'revision_by' => 'Révision par :name',
'revisions_list' => 'Liste des révisions',
'anonymous_user' => 'Utilisateur anonyme',
];
1 change: 1 addition & 0 deletions resources/lang/nl/page.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
'content_tab_label' => 'Revisies',
'revision_by' => 'Revisies door :name',
'revisions_list' => 'Revisielijst',
'anonymous_user' => 'Anonieme gebruiker',
];
34 changes: 21 additions & 13 deletions resources/views/revisions-page.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
<x-slot name="heading">
<div class="flex items-center justify-between">
<div class="flex items-center gap-x-3">
<x-filament-panels::avatar.user
:user="$this->version->user"
size="lg"
/>
@if ($this->version->user)
<x-filament-panels::avatar.user
:user="$this->version->user"
size="lg"
/>
@endif

<div class="flex items-center gap-x-3">
<div class="flex flex-col">
<span>
{{ __('filament-versionable::page.revision_by', ['name' => $this->version->user->name]) }}
{{ __('filament-versionable::page.revision_by', [
'name' => $this->version->user?->name ?? __('filament-versionable::page.anonymous_user'),
]) }}
</span>

<small class="text-sm font-medium text-gray-500 dark:text-gray-400">
Expand Down Expand Up @@ -72,17 +76,19 @@ class="divide-y divide-gray-200 dark:divide-white/10"
<li
wire:click="showVersion({{ $version->id }})"
@class([
'pb-4' => $loop->first,
'pt-4' => $loop->last,
'pb-4' => $loop->first && !$loop->last,
'pt-4' => $loop->last && !$loop->first,
'py-4' => !$loop->first && !$loop->last,
'group cursor-pointer',
])
>
<div class="flex items-center gap-x-2">
<x-filament-panels::avatar.user
:user="$version->user"
size="sm"
/>
@if ($version->user)
<x-filament-panels::avatar.user
:user="$version->user"
size="sm"
/>
@endif

<span
style="flex: 1 1 auto;"
Expand All @@ -96,12 +102,14 @@ class="divide-y divide-gray-200 dark:divide-white/10"
'text-primary-600' => $version->id === $this->version->id,
'font-normal text-gray-500 group-hover:text-primary-600 dark:text-gray-400',
])
title="{{ __('filament-versionable::page.revision_by', ['name' => $version->user->name]) }}"
title="{{ __('filament-versionable::page.revision_by', [
'name' => $version->user?->name ?? __('filament-versionable::page.anonymous_user'),
]) }}"
>
{{ __('filament-versionable::page.revision_by', ['name' => '']) }}
</span>

{{ $version->user->name }}
{{ $version->user?->name ?? __('filament-versionable::page.anonymous_user') }}
</span>

<span class="flex-none text-xs text-gray-500 dark:text-gray-400">
Expand Down
Empty file removed stubs/.gitkeep
Empty file.

0 comments on commit 9195e52

Please sign in to comment.