$state value in configureTitleUsing is different with $state value in modifiedTitle for TimeLineTitleEntry
Opened this issue · 1 comments
Package Version
v1.0.7
Laravel Version
v11.29.0
PHP Version
PHP 8.2.18
Problem description
When the title value is evaluate using TimeLineTitleEntry->configureTitleUsing, wrong $state is been used.
Expected behavior
update date of activity logs shown in ActivityLogTimelineTableAction should be the same when
modifyTitleUsing method is called or when it is not called.
Steps to reproduce
- checkout the example repo
- login to filament admin panel at /admin (username: admin@example.com, password: admin)
- view activitylog for ExampleResource, the update date is actually wrong. (latest date should be 5 Nov 2024)
- uncomment the modifyTitleUsing method in ExampleResource
- view the activitylog for ExampleResource again, the update date is now correct.
Conclusion:
When there is multiple activity logs with different date,
when use the following code to modify the title of the activity log, all update date of the activity log is wrong.
ActivityLogTimelineTableAction::make()
->modifyTitleUsing(function($state, $record) {
if ($state['description'] == $state['event']) {
$aliases = [
];
$className = isset($state['subject']) ? class_basename($state['subject']) : class_basename($record->subject_type);
$className = $aliases[$className] ?? Str::lower(Str::snake($className, ' '));
$causer = $state['causer'];
$causerName = $causer->name ?? $causer->first_name ?? $causer->last_name ?? $causer->username ?? 'Unknown';
$update_at = \Carbon\Carbon::parse($state['update'])->translatedFormat(config('filament-activitylog.datetime_format'));
return new HtmlString(
sprintf(
'The <strong>%s</strong> was <strong>%s</strong> by <strong>%s</strong>. <br><small> Updated at: <strong>%s</strong></small>',
$className,
$state['event'],
$causerName,
$update_at
)
);
}
})
Reproduction repository (issue will be closed if this is not valid)
https://github.com/huiyang/example-app
Relevant log output
No response
Can anyone explain why we need this part of the code?
If you try changing the description, as I did here:
The timeline title won't appear because the description and event are no longer equal.
I suggest removing this part of the code to fix the issue for anyone who wants to update the description.
Additionally, there's a CSS issue when you click the timeline menu link and the modal appears: