I'm unable to restore the first version of the model , as all buttons become disabled especially when you have a single revision.
I think problem is that you are comparing the current version the lastVersion version instead of the previous one and when restoring you are restoring the version in green instead of the one in red which is the previous one .
My suggestion to fix this problem is to restore the version in red instead of the one in green this way all versions become restorable including the first one.
To do this we need to make the following changes in the RevionsPage.php:
Change the action from this :
public function restoreVersionAction(): Action
{
return Action::make('restoreVersion')
->label(__('filament-versionable::actions.restore.label'))
->requiresConfirmation()
->modalDescription(__('filament-versionable::actions.restore.modal_description'))
->modalSubmitActionLabel(__('filament-versionable::actions.restore.modal_submit_action_label'))
->disabled(fn () => $this->version->is($this->record->lastVersion))
->action(fn () => $this->restoreVersion());
}
To this:
public function restoreVersionAction(): Action
{
return Action::make('restoreVersion')
->label(__('filament-versionable::actions.restore.label'))
->requiresConfirmation()
->modalDescription(__('filament-versionable::actions.restore.modal_description'))
->modalSubmitActionLabel(__('filament-versionable::actions.restore.modal_submit_action_label'))
->disabled(fn () => $this->version->is($this->record->previousVersion))
->action(fn () => $this->restoreVersion());
}
And change this :
public function restoreVersion()
{
$this->version->revert();
return redirect(static::$resource::getUrl('edit', ['record' => $this->getRecord()]));
}
To this:
public function restoreVersion()
{
$this->version->previousVersion()->revert();
return redirect(static::$resource::getUrl('edit', ['record' => $this->getRecord()]));
}
and this should fix the problem.
How to reproduce the bug
When you create a post for example , then apply a modifications, it shows that you have 1 Revisions , but when you click the button to go to revisions page, the revision is there , but all buttons are disabled, and you are unable to restore the first revision
What happened?
I'm unable to restore the first version of the model , as all buttons become disabled especially when you have a single revision. I think problem is that you are comparing the
current
version thelastVersion
version instead of theprevious
one and when restoring you are restoring the version ingreen
instead of the one inred
which is the previous one . My suggestion to fix this problem is to restore the version inred
instead of the one ingreen
this way all versions become restorable including the first one. To do this we need to make the following changes in the RevionsPage.php: Change the action from this :To this:
And change this :
To this:
and this should fix the problem.
How to reproduce the bug
When you create a post for example , then apply a modifications, it shows that you have
1 Revisions
, but when you click the button to go to revisions page, the revision is there , but all buttons are disabled, and you are unable to restore the first revisionPackage Version
0.0.8
PHP Version
8.3.8
Laravel Version
11.18.1
Which operating systems does with happen with?
Windows
Notes
No response