Skip to content

Commit

Permalink
Merge pull request #6857 from getkirby/fix/6850-language-selector-for…
Browse files Browse the repository at this point in the history
…-single-language

Hide language selector for single language
  • Loading branch information
bastianallgeier authored Dec 10, 2024
2 parents 896c640 + bf659d2 commit 720fa68
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Panel/Ui/Buttons/LanguagesDropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public function props(): array

public function render(): array|null
{
if ($this->kirby->multilang() === false) {
// hides the language selector when there are less than 2 languages
if ($this->kirby->languages()->count() < 2) {
return null;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/Panel/Ui/Buttons/LanguagesDropdownTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,32 @@ public function testProps()
$this->assertFalse($props['hasChanges']);
}

/**
* @covers ::render
*/
public function testRenderDefault()
{
$page = new Page(['slug' => 'test']);
$button = new LanguagesDropdown($page);
$this->assertNull($button->render());
}

/**
* @covers ::render
*/
public function testRenderSingleLang()
{
$this->enableMultilang();
$this->app([
'languages' => [
'en' => [
'code' => 'en',
'default' => true,
'name' => 'English'
]
]
]);

$page = new Page(['slug' => 'test']);
$button = new LanguagesDropdown($page);
$this->assertNull($button->render());
Expand Down

0 comments on commit 720fa68

Please sign in to comment.