Skip to content

Commit

Permalink
Revert using the VersionId render mode in the Panel
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Aug 12, 2024
1 parent 44feac1 commit 200e6c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
14 changes: 13 additions & 1 deletion src/Panel/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ abstract public function buttons(): array;
*/
public function content(): array
{
return Form::for($this->model)->values();
$version = $this->model->version('changes');
$changes = [];

if ($version->exists() === true) {
$changes = $version->content()->toArray();
}

return Form::for(
model: $this->model,
props: [
'values' => $changes
]
)->values();
}

/**
Expand Down
21 changes: 3 additions & 18 deletions src/Panel/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Kirby\Cms\File as CmsFile;
use Kirby\Cms\ModelWithContent;
use Kirby\Content\VersionId;
use Kirby\Filesystem\Asset;
use Kirby\Panel\Ui\Buttons\ViewButtons;
use Kirby\Toolkit\I18n;
Expand Down Expand Up @@ -372,25 +371,11 @@ public function props(): array
*/
public function view(): array
{
$page = $this->model;

// This is placed here as a proof of concept
// @todo we need to find a better place for it
// to switch into changes mode in the panel
VersionId::$render = VersionId::changes();

$view = [
'breadcrumb' => $page->panel()->breadcrumb(),
return [
'breadcrumb' => $this->model->panel()->breadcrumb(),
'component' => 'k-page-view',
'props' => $this->props(),
'title' => $page->title()->toString(),
'title' => $this->model->title()->toString(),
];

// The render mode needs to be undone here to keep unit tests working
// That's the downside of such static properties. They are likely to
// cause side-effects
VersionId::$render = null;

return $view;
}
}

0 comments on commit 200e6c2

Please sign in to comment.