Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Panel/Ui/Buttons/ViewButton.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,17 @@ public static function normalize(array $button): array
public function props(): array
{
// helper for props that support Kirby queries
$resolve = fn ($value) =>
$resolve = fn (string|null $value) =>
$value ?
$this->model?->toSafeString($value) ?? $value :
null;

$options = $this->options;

if (is_string($options) === true) {
$options = $resolve($options);
}

return [
...$props = parent::props(),
'dialog' => $resolve($props['dialog']),
Expand All @@ -178,7 +184,7 @@ public function props(): array
'link' => $resolve($props['link']),
'text' => $resolve($props['text']),
'theme' => $resolve($props['theme']),
'options' => $this->options
'options' => $options
];
}

Expand Down
2 changes: 2 additions & 0 deletions tests/Panel/Ui/Buttons/ViewButtonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,13 @@ public function testPropsWithQueries(): void
model: $model,
text: 'Page: {{ page.url }}',
link: 'https://getkirby.com/{{ page.slug }}',
options: 'my/options/{{ page.slug }}'
);

$props = $component->props();
$this->assertSame('Page: /test', $props['text']);
$this->assertSame('https://getkirby.com/test', $props['link']);
$this->assertSame('my/options/test', $props['options']);
}

public function testResolve(): void
Expand Down