Skip to content

Commit 5af2e3e

Browse files
authored
Add "showOnAllWorkspaces" option to MenuBar (#568)
Introduce a new `showOnAllWorkspaces` property and its corresponding method to configure this behavior. Update the `toArray` method to include this property and adjust tests to validate its functionality.
1 parent e3d5974 commit 5af2e3e

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/MenuBar/MenuBar.php

+10
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class MenuBar
3232

3333
protected bool $showDockIcon = false;
3434

35+
protected bool $showOnAllWorkspaces = false;
36+
3537
protected Client $client;
3638

3739
public function __construct()
@@ -95,6 +97,13 @@ public function alwaysOnTop($alwaysOnTop = true): self
9597
return $this;
9698
}
9799

100+
public function showOnAllWorkspaces($showOnAllWorkspaces = true): self
101+
{
102+
$this->showOnAllWorkspaces = $showOnAllWorkspaces;
103+
104+
return $this;
105+
}
106+
98107
public function withContextMenu(Menu $menu): self
99108
{
100109
$this->contextMenu = $menu;
@@ -122,6 +131,7 @@ public function toArray(): array
122131
'onlyShowContextMenu' => $this->onlyShowContextMenu,
123132
'contextMenu' => ! is_null($this->contextMenu) ? $this->contextMenu->toArray()['submenu'] : null,
124133
'alwaysOnTop' => $this->alwaysOnTop,
134+
'showOnAllWorkspaces' => $this->showOnAllWorkspaces,
125135
];
126136
}
127137
}

tests/MenuBar/MenuBarTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
$menuBar = MenuBar::create()
1010
->showDockIcon()
1111
->alwaysOnTop()
12+
->showOnAllWorkspaces()
1213
->label('milwad')
1314
->icon('nativephp.png')
1415
->url('https://github.com/milwad-dev')
@@ -22,6 +23,7 @@
2223

2324
$this->assertTrue($menuBarArray['showDockIcon']);
2425
$this->assertTrue($menuBarArray['alwaysOnTop']);
26+
$this->assertTrue($menuBarArray['showOnAllWorkspaces']);
2527
$this->assertEquals('milwad', $menuBarArray['label']);
2628
$this->assertEquals('https://github.com/milwad-dev', $menuBarArray['url']);
2729
$this->assertEquals('nativephp.png', $menuBarArray['icon']);

0 commit comments

Comments
 (0)