Skip to content

Commit a6a6f30

Browse files
committed
Get rid of the yucky GoTo* stuff
Fold it all into Link instead
1 parent a180a16 commit a6a6f30

File tree

4 files changed

+16
-34
lines changed

4 files changed

+16
-34
lines changed

src/Facades/Menu.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Illuminate\Support\Facades\Facade;
66
use Native\Laravel\Menu\Items\Checkbox;
7-
use Native\Laravel\Menu\Items\GoToUrl;
87
use Native\Laravel\Menu\Items\Label;
98
use Native\Laravel\Menu\Items\Link;
109
use Native\Laravel\Menu\Items\Radio;
@@ -14,10 +13,9 @@
1413
/**
1514
* @method static \Native\Laravel\Menu\Menu make(MenuItem ...$items)
1615
* @method static Checkbox checkbox(string $label, bool $checked = false, ?string $hotkey = null)
17-
* @method static GoToLink goToUrl(string $url, string $label = null, ?string $hotkey = null)
18-
* @method static GoToLink goToRoute(string $url, string $label = null, ?string $hotkey = null)
1916
* @method static Label label(string $label)
2017
* @method static Link link(string $url, string $label = null, ?string $hotkey = null)
18+
* @method static Link route(string $url, string $label = null, ?string $hotkey = null)
2119
* @method static Radio radio(string $label, bool $checked = false, ?string $hotkey = null)
2220
* @method static Role app()
2321
* @method static Role file()

src/Menu/Items/GoToUrl.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/Menu/Items/Link.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,22 @@ class Link extends MenuItem
66
{
77
protected string $type = 'link';
88

9+
protected bool $openInBrowser = false;
10+
911
public function __construct(protected string $url, protected ?string $label, protected ?string $accelerator = null) {}
1012

13+
public function openInBrowser(bool $openInBrowser = true): self
14+
{
15+
$this->openInBrowser = $openInBrowser;
16+
17+
return $this;
18+
}
19+
1120
public function toArray(): array
1221
{
1322
return array_merge(parent::toArray(), [
1423
'url' => $this->url,
24+
'openInBrowser' => $this->openInBrowser,
1525
]);
1626
}
1727
}

src/Menu/MenuBuilder.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,6 @@ public function label(string $label): Items\Label
4343
return new Items\Label($label);
4444
}
4545

46-
public function goToUrl(string $url, ?string $label = null, ?string $hotkey = null): Items\GoToUrl
47-
{
48-
return new Items\GoToUrl($url, $label, $hotkey);
49-
}
50-
51-
public function goToRoute(string $route, ?string $label = null, ?string $hotkey = null): Items\GoToUrl
52-
{
53-
return new Items\GoToUrl(route($route), $label, $hotkey);
54-
}
55-
5646
public function checkbox(string $label, bool $checked = false, ?string $hotkey = null): Items\Checkbox
5747
{
5848
return new Items\Checkbox($label, $checked, $hotkey);
@@ -68,6 +58,11 @@ public function link(string $url, ?string $label = null, ?string $hotkey = null)
6858
return new Items\Link($url, $label, $hotkey);
6959
}
7060

61+
public function route(string $route, ?string $label = null, ?string $hotkey = null): Items\Link
62+
{
63+
return new Items\Link(route($route), $label, $hotkey);
64+
}
65+
7166
public function app(): Items\Role
7267
{
7368
return new Items\Role(RolesEnum::APP_MENU);

0 commit comments

Comments
 (0)