Skip to content

Commit 45f6e75

Browse files
committed
feat: $panel.urls.panel state
1 parent c4fb9f8 commit 45f6e75

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

panel/lab/internals/panel/urls/index.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010
<k-code>{{ $panel.urls.api }}</k-code>
1111
</k-text>
1212
</k-lab-example>
13+
<k-lab-example label="panel" :code="false">
14+
<k-text>
15+
<p>
16+
<code>window.panel.urls.panel</code> returns the base URL for the
17+
Panel
18+
</p>
19+
<k-code>{{ $panel.urls.panel }}</k-code>
20+
</k-text>
21+
</k-lab-example>
1322
<k-lab-example label="site" :code="false">
1423
<k-text>
1524
<p>

src/Panel/State.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,9 @@ public function url(): string
315315
public function urls(): array
316316
{
317317
return [
318-
'api' => $this->kirby->url('api'),
319-
'site' => $this->kirby->url('index')
318+
'api' => $this->kirby->url('api'),
319+
'panel' => $this->kirby->url('panel'),
320+
'site' => $this->kirby->url('index')
320321
];
321322
}
322323

tests/Panel/StateTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,9 @@ public function testFilterOnlyRequestWithGlobal(): void
158158
$expected = [
159159
'a' => 'A',
160160
'urls' => [
161-
'api' => '/api',
162-
'site' => '/'
161+
'api' => '/api',
162+
'panel' => '/panel',
163+
'site' => '/'
163164
]
164165
];
165166

@@ -487,6 +488,7 @@ public function testUrls(): void
487488
$state = new State();
488489
$urls = $state->urls();
489490
$this->assertArrayHasKey('api', $urls);
491+
$this->assertArrayHasKey('panel', $urls);
490492
$this->assertArrayHasKey('site', $urls);
491493
}
492494

0 commit comments

Comments
 (0)