Tell scheduling apart from unpublishing in the history
Giving a record a future date was recorded as "unpublished", and announced to webhooks as such. The history now compares before and after. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,7 @@ class RevisionsRelationManager extends RelationManager
|
||||
->color(fn (string $state) => match ($state) {
|
||||
'published' => 'success',
|
||||
'unpublished' => 'warning',
|
||||
'scheduled' => 'info',
|
||||
'created' => 'info',
|
||||
'deleted', 'erased' => 'danger',
|
||||
default => 'gray',
|
||||
@@ -77,7 +78,7 @@ class RevisionsRelationManager extends RelationManager
|
||||
->filters([
|
||||
SelectFilter::make('event')
|
||||
->label(__('panel.revisions.fields.event'))
|
||||
->options(fn () => collect(['created', 'updated', 'published', 'unpublished', 'deleted', 'restored', 'erased'])
|
||||
->options(fn () => collect(['created', 'updated', 'published', 'scheduled', 'unpublished', 'deleted', 'restored', 'erased'])
|
||||
->mapWithKeys(fn (string $e) => [$e => __("panel.revisions.events.{$e}")])
|
||||
->all()),
|
||||
])
|
||||
|
||||
@@ -131,11 +131,23 @@ trait HasRevisions
|
||||
|
||||
// Ask the model itself: "published" means different things to a page
|
||||
// with a status and a project with only a date.
|
||||
if (method_exists($this, 'isPublishedNow')) {
|
||||
return $this->isPublishedNow() ? 'published' : 'unpublished';
|
||||
if (! method_exists($this, 'isPublishedNow')) {
|
||||
return 'updated';
|
||||
}
|
||||
|
||||
return 'updated';
|
||||
// Before and after, because the change is what has a name: going live,
|
||||
// coming off, or being given a date — which is neither, and which a
|
||||
// history that only asked "is it live now?" called "unpublished".
|
||||
$before = (clone $this)->setRawAttributes($this->getRawOriginal());
|
||||
$now = $this->isPublishedNow();
|
||||
$was = $before->isPublishedNow();
|
||||
|
||||
return match (true) {
|
||||
$now && ! $was => 'published',
|
||||
! $now && $was => 'unpublished',
|
||||
! $now && method_exists($this, 'isScheduled') && $this->isScheduled() => 'scheduled',
|
||||
default => 'updated',
|
||||
};
|
||||
}
|
||||
|
||||
protected function revisionValue(mixed $value): mixed
|
||||
|
||||
Reference in New Issue
Block a user