Fix deleted users being shown as "System" in activity log (#1010)

* Show deleted users as "Deleted user"

* Update shown icon

* Apply suggestions from code review

Co-authored-by: Boy132 <Boy132@users.noreply.github.com>

* Update app/Models/ActivityLog.php

Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com>

---------

Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
Co-authored-by: MartinOscar <40749467+RMartinOscar@users.noreply.github.com>
This commit is contained in:
David Groselj 2025-02-15 16:43:32 +00:00 committed by GitHub
parent b355830db4
commit 206cc76a8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -42,7 +42,7 @@ class ListActivities extends ListRecords
TextColumn::make('user')
->state(function (ActivityLog $activityLog) use ($server) {
if (!$activityLog->actor instanceof User) {
return 'System';
return $activityLog->actor_id === null ? 'System' : 'Deleted user';
}
$user = $activityLog->actor->username;
@ -72,7 +72,7 @@ class ListActivities extends ListRecords
TextInput::make('user')
->formatStateUsing(function (ActivityLog $activityLog) use ($server) {
if (!$activityLog->actor instanceof User) {
return 'System';
return $activityLog->actor_id === null ? 'System' : 'Deleted user';
}
$user = $activityLog->actor->username;

View File

@ -153,7 +153,11 @@ class ActivityLog extends Model implements HasIcon, HasLabel
return 'tabler-api';
}
return $this->actor instanceof User ? 'tabler-user' : 'tabler-device-desktop';
if ($this->actor instanceof User) {
return 'tabler-user';
}
return $this->actor_id === null ? 'tabler-device-desktop' : 'tabler-user-off';
}
public function getLabel(): string