diff --git a/CHANGELOG.md b/CHANGELOG.md index 914a24cd..d725eaca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Neueste Version oben. Jeder Abschnitt beginnt mit `## MAJOR.MINOR.PATCH` und enthält kurze Stichpunkte für Anwenderinnen und Anwender – keine Commit-Texte. Der Self-Updater zeigt diese Abschnitte bei neuen Versionen an. +## 0.40.0 + +- Automatisches Menü: Jeder Hauptpunkt hat jetzt ein passendes Symbol (Startseite, Neuigkeiten, Termine, Gruppen, Nachrichten …); Seiten in der Hauptnavigation ein Seiten-Symbol. Untermenüpunkte bleiben ohne +- Menü-Editor: Beim Umstieg vom automatischen Menü werden die Symbole übernommen; wer einen Bereich wählt, bekommt dessen Symbol vorgeschlagen +- Für Plugins: `Navigation::add(…, icon: 'lucide-name')`; ohne Angabe gilt ein Standard bzw. ein neutrales Symbol + ## 0.39.1 - Plugin-SDK: Sind mehrere Plugins mit eigener Oberfläche aktiv, konnte das CSS eines Plugins die Handy-/Desktop-Umschaltung (z. B. `ih:lg:hidden`) eines anderen überschreiben. Regeln mit Variante werden beim Bauen jetzt verstärkt – Plugins bitte mit der neuen `inhaus-sdk/vite.js` neu bauen diff --git a/app/Filament/Pages/MenuSettings.php b/app/Filament/Pages/MenuSettings.php index 98ddbee9..9726525c 100644 --- a/app/Filament/Pages/MenuSettings.php +++ b/app/Filament/Pages/MenuSettings.php @@ -19,6 +19,7 @@ use Filament\Notifications\Notification; use Filament\Pages\Page; use Filament\Schemas\Components\Section; use Filament\Schemas\Components\Utilities\Get; +use Filament\Schemas\Components\Utilities\Set; use Filament\Schemas\Schema; use Filament\Support\Icons\Heroicon; use Illuminate\Support\HtmlString; @@ -105,6 +106,8 @@ class MenuSettings extends Page Select::make('type')->label('Art')->options($types)->default('module')->required()->live()->native(false)->selectablePlaceholder(false), Select::make('module')->label('Bereich')->required()->native(false) ->options(fn (Get $get) => $navigation->modules() + (filled($get('module')) && ! isset($navigation->modules()[$get('module')]) ? [$get('module') => $get('module').' (Plugin deaktiviert)'] : [])) + // Symbol des Bereichs vorschlagen, solange noch keines gewählt ist + ->live()->afterStateUpdated(fn (?string $state, Get $get, Set $set) => $state && blank($get('icon')) ? $set('icon', $navigation->iconFor($state)) : null) ->visible(fn (Get $get) => $get('type') === 'module'), Select::make('target')->label(fn (Get $get) => $navigation->sourceTypes()[$get('type')] ?? 'Ziel') ->options(fn (Get $get) => $navigation->sourceOptions((string) $get('type'))) @@ -185,9 +188,9 @@ class MenuSettings extends Page foreach ($navigation->automatic(request(), auth()->user()) as $item) { if (isset($modules[$item['key']])) { - $items[] = ['id' => (string) Str::uuid(), 'type' => 'module', 'module' => $item['key'], 'label' => null, 'roles' => [], 'children' => []]; + $items[] = ['id' => (string) Str::uuid(), 'type' => 'module', 'module' => $item['key'], 'label' => null, 'icon' => $item['icon'], 'roles' => [], 'children' => []]; } elseif (preg_match('/^page-(\d+)$/', $item['key'], $m) && array_key_exists('page', $navigation->sourceTypes())) { - $items[] = ['id' => (string) Str::uuid(), 'type' => 'page', 'target' => $m[1], 'subpages' => true, 'label' => null, 'roles' => [], 'children' => []]; + $items[] = ['id' => (string) Str::uuid(), 'type' => 'page', 'target' => $m[1], 'subpages' => true, 'label' => null, 'icon' => $item['icon'], 'roles' => [], 'children' => []]; } } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index bde1e5ae..cdb01884 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -112,7 +112,7 @@ class AppServiceProvider extends ServiceProvider ? $this->app->make(Widgets::class)->resolveOne($data['widget'], $user, request()) : null)); - $this->app->make(Navigation::class)->add('editorial', 'Redaktion', '/redaktion', active: ['editorial', 'pages.editor', 'news.editor.*', 'forms.builder', 'media.*'], sort: 85, + $this->app->make(Navigation::class)->add('editorial', 'Redaktion', '/redaktion', active: ['editorial', 'pages.editor', 'news.editor.*', 'forms.builder', 'media.*'], sort: 85, icon: 'pen-line', visible: fn (User $user) => $this->app->make(Editorial::class)->visibleFor($user)); $this->registerMedia(); diff --git a/app/Support/Navigation.php b/app/Support/Navigation.php index 2835e0e1..55a4bc19 100644 --- a/app/Support/Navigation.php +++ b/app/Support/Navigation.php @@ -11,7 +11,7 @@ use Illuminate\Http\Request; /** * Hauptnavigation des Portals als Registry: Kern und Plugins tragen Einträge ein. * - * app(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: 'news.*', sort: 20); + * app(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: 'news.*', sort: 20, icon: 'newspaper'); * * Dynamische Einträge (z. B. Seiten aus dem Seitenbaum) liefert ein Provider: * @@ -25,7 +25,7 @@ use Illuminate\Http\Request; */ class Navigation { - /** @var array, sort: int, ability: string|null, visible: Closure|null}> */ + /** @var array, sort: int, ability: string|null, visible: Closure|null, icon: string|null}> */ private array $items = []; /** @var array */ @@ -33,6 +33,30 @@ class Navigation public const MENU_SETTING = 'navigation.menu'; + /** Symbole im automatischen Menü, wenn ein Bereich keines mitgibt (auch separat installierte Plugins) */ + public const DEFAULT_ICONS = [ + 'home' => 'house', + 'people' => 'contact', + 'editorial' => 'pen-line', + 'news' => 'newspaper', + 'events' => 'calendar-days', + 'downloads' => 'folder-down', + 'qm' => 'shield-check', + 'gemeinsam' => 'handshake', + 'speiseplan' => 'utensils', + 'it-service' => 'headset', + 'glossar' => 'book-a', + 'stellen' => 'briefcase', + 'umfragen' => 'vote', + 'ideen' => 'lightbulb', + 'forms' => 'clipboard-list', + 'chat' => 'message-circle', + 'gruppen' => 'users-round', + 'kleinanzeigen' => 'shopping-bag', + ]; + + public const FALLBACK_ICON = 'layout-grid'; + /** @var array */ private array $sources = []; @@ -41,17 +65,31 @@ class Navigation public function __construct() { - $this->add('home', 'Startseite', '/', active: 'dashboard', sort: 0); - $this->add('people', 'Personen', '/personen', active: 'people.*', sort: 90); + $this->add('home', 'Startseite', '/', active: 'dashboard', sort: 0, icon: 'house'); + $this->add('people', 'Personen', '/personen', active: 'people.*', sort: 90, icon: 'contact'); } /** * @param string|list $active Routennamen (mit *), bei denen der Eintrag aktiv ist * @param (Closure(User): bool)|null $visible zusätzliche Bedingung je Person */ - public function add(string $key, string $label, string $href, string|array $active = [], int $sort = 50, ?string $ability = null, ?Closure $visible = null): void + /** + * @param string|null $icon Lucide-Symbol im automatischen Menü (z. B. „calendar-days“) + */ + public function add(string $key, string $label, string $href, string|array $active = [], int $sort = 50, ?string $ability = null, ?Closure $visible = null, ?string $icon = null): void { - $this->items[$key] = ['label' => $label, 'href' => $href, 'active' => (array) $active, 'sort' => $sort, 'ability' => $ability, 'visible' => $visible]; + $this->items[$key] = ['label' => $label, 'href' => $href, 'active' => (array) $active, 'sort' => $sort, 'ability' => $ability, 'visible' => $visible, 'icon' => $icon]; + } + + /** + * Symbol eines Bereichs: angegeben, sonst ein passender Standard (auch für Plugins, die + * noch kein Symbol mitgeben), sonst ein neutrales. + */ + public function iconFor(string $key): string + { + $icon = $this->items[$key]['icon'] ?? self::DEFAULT_ICONS[$key] ?? null; + + return Icons::has($icon) ? $icon : self::FALLBACK_ICON; } public function remove(string $key): void @@ -139,6 +177,7 @@ class Navigation 'href' => $item['href'], 'active' => $item['active'] !== [] && $request->routeIs(...$item['active']), 'sort' => $item['sort'], + 'icon' => $this->iconFor($key), ]); foreach ($this->providers as $key => $provider) { @@ -150,7 +189,8 @@ class Navigation } return $items->sortBy('sort') - ->map(fn (array $item) => ['key' => $item['key'], 'label' => $item['label'], 'href' => $item['href'], 'active' => (bool) $item['active'], 'icon' => null, 'new_tab' => false, 'children' => []]) + // Jeder Hauptpunkt mit Symbol – Seiten aus der Hauptnavigation mit Seiten-Symbol + ->map(fn (array $item) => ['key' => $item['key'], 'label' => $item['label'], 'href' => $item['href'], 'active' => (bool) $item['active'], 'icon' => Icons::has($item['icon'] ?? null) ? $item['icon'] : 'file-text', 'new_tab' => false, 'children' => []]) ->values() ->all(); } diff --git a/app/Version.php b/app/Version.php index d8f4393b..3acc8ef6 100644 --- a/app/Version.php +++ b/app/Version.php @@ -9,5 +9,5 @@ namespace App; */ final class Version { - public const VERSION = '0.39.1'; + public const VERSION = '0.40.0'; } diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md index c21b1c47..67b47e53 100644 --- a/docs/PLUGINS.md +++ b/docs/PLUGINS.md @@ -56,7 +56,7 @@ class Plugin extends BasePlugin public function register(): void { // Menüpunkt im Portal - $this->app->make(Navigation::class)->add('mein-plugin', 'Mein Bereich', '/mein-bereich', active: 'mein-plugin.*', sort: 40); + $this->app->make(Navigation::class)->add('mein-plugin', 'Mein Bereich', '/mein-bereich', active: 'mein-plugin.*', sort: 40, icon: 'sparkles'); // Rechte, die im Rollen-Formular erscheinen $this->app->make(Abilities::class)->define('mein-plugin.manage', 'Mein Bereich verwalten', 'Mein Plugin'); @@ -133,6 +133,7 @@ $this->app->make(Blocks::class)->add(BlockType::make('mein-plugin.liste', 'Meine `app(Navigation::class)->source('typ', 'Bezeichnung', fn () => [id => 'Name'], fn (string $id, array $item, Request $request, ?User $user) => ['label' => …, 'href' => …, 'active' => …, 'children' => [...]] ?: null)`. - Symbole: `App\Support\Icons` (alle Lucide-Symbole lokal; kuratierte Auswahl in `resources/icons/icons.json`, nach Änderungen `npm run icons`), im Portal `` aus `@/components/AppIcon.vue`. - Seitenköpfe im Portal: `@/components/PageHeader.vue` (Titel, Beschreibung, Pfad, Slot „actions“). +- Menü-Symbol: `add(…, icon: 'calendar-days')` – ein Lucide-Name; ohne Angabe ein neutrales Symbol. Dynamische Punkte können `'icon'` mitliefern. - Dynamische Menüpunkte: `app(Navigation::class)->provider('mein-plugin', fn (Request $request, ?User $user) => [...])`; feste Menüpunkte können mit `visible: fn (User $user) => …` je Person ausgeblendet werden. - Benachrichtigungen (Glocke im Portal): `$user->notify(new App\Notifications\PortalNotification($titel, $text, $url))`. diff --git a/plugins-core/downloads/src/DownloadsPlugin.php b/plugins-core/downloads/src/DownloadsPlugin.php index 450a15cd..b96059de 100644 --- a/plugins-core/downloads/src/DownloadsPlugin.php +++ b/plugins-core/downloads/src/DownloadsPlugin.php @@ -25,7 +25,7 @@ class DownloadsPlugin extends Plugin $this->app->singleton(FolderTree::class); - $this->app->make(Navigation::class)->add('downloads', 'Downloads', '/downloads', active: 'downloads.*', sort: 50); + $this->app->make(Navigation::class)->add('downloads', 'Downloads', '/downloads', active: 'downloads.*', sort: 50, icon: 'folder-down'); $abilities = $this->app->make(Abilities::class); $abilities->define('downloads.manage', 'Downloads: gesamten Bereich verwalten', 'Downloads'); diff --git a/plugins-core/events/src/EventsPlugin.php b/plugins-core/events/src/EventsPlugin.php index 61082f2f..5be5e2e4 100644 --- a/plugins-core/events/src/EventsPlugin.php +++ b/plugins-core/events/src/EventsPlugin.php @@ -39,7 +39,7 @@ class EventsPlugin extends Plugin $this->app->make(GlobalSearch::class)->add('events', 'Termine', 'calendar-days', fn (...$args) => app(EventSearch::class)(...$args), sort: 20); - $this->app->make(Navigation::class)->add('events', 'Termine', '/termine', active: 'events.*', sort: 30); + $this->app->make(Navigation::class)->add('events', 'Termine', '/termine', active: 'events.*', sort: 30, icon: 'calendar-days'); $this->app->make(Abilities::class)->define('events.manage', 'Termine verwalten', 'Termine', portal: true); Gate::policy(Event::class, EventPolicy::class); diff --git a/plugins-core/gemeinsam/src/GemeinsamPlugin.php b/plugins-core/gemeinsam/src/GemeinsamPlugin.php index 83bf0269..f9cd366c 100644 --- a/plugins-core/gemeinsam/src/GemeinsamPlugin.php +++ b/plugins-core/gemeinsam/src/GemeinsamPlugin.php @@ -10,7 +10,7 @@ class GemeinsamPlugin extends Plugin { public function register(): void { - $this->app->make(Navigation::class)->add('gemeinsam', 'Gemeinsam', '/gemeinsam', active: 'gemeinsam.*', sort: 65); + $this->app->make(Navigation::class)->add('gemeinsam', 'Gemeinsam', '/gemeinsam', active: 'gemeinsam.*', sort: 65, icon: 'handshake'); $this->app->make(Abilities::class)->define('gemeinsam.manage', 'Personalnachrichten pflegen (Gemeinsam feiern …)', 'Gemeinsam', portal: true); } } diff --git a/plugins-core/glossar/src/GlossarPlugin.php b/plugins-core/glossar/src/GlossarPlugin.php index 7cfdda4b..847a73bd 100644 --- a/plugins-core/glossar/src/GlossarPlugin.php +++ b/plugins-core/glossar/src/GlossarPlugin.php @@ -11,7 +11,7 @@ class GlossarPlugin extends Plugin { public function register(): void { - $this->app->make(Navigation::class)->add('glossar', 'Glossar', '/glossar', active: 'glossary.*', sort: 75); + $this->app->make(Navigation::class)->add('glossar', 'Glossar', '/glossar', active: 'glossary.*', sort: 75, icon: 'book-a'); $this->app->make(Abilities::class)->define('glossary.manage', 'Glossar pflegen', 'Glossar', portal: true); $this->app->make(GlobalSearch::class)->add('glossar', 'Glossar', 'book-open', fn (...$args) => app(GlossarySearch::class)(...$args), sort: 45); } diff --git a/plugins-core/ideen/src/IdeenPlugin.php b/plugins-core/ideen/src/IdeenPlugin.php index f2b7781e..c58297b7 100644 --- a/plugins-core/ideen/src/IdeenPlugin.php +++ b/plugins-core/ideen/src/IdeenPlugin.php @@ -16,7 +16,7 @@ class IdeenPlugin extends Plugin { public function register(): void { - $this->app->make(Navigation::class)->add('ideen', 'Ideenbox', '/ideen', active: 'ideas.*', sort: 76); + $this->app->make(Navigation::class)->add('ideen', 'Ideenbox', '/ideen', active: 'ideas.*', sort: 76, icon: 'lightbulb'); $this->app->make(Digest::class)->add('ideen', 'Neue Ideen', 40, fn (User $user, CarbonImmutable $since) => Idea::query() ->whereNull('hidden_at')->where('created_at', '>=', $since)->orderByDesc('supports_count')->latest()->limit(5)->get() ->map(fn (Idea $idea) => [ diff --git a/plugins-core/it-service/src/ItServicePlugin.php b/plugins-core/it-service/src/ItServicePlugin.php index 26db03f0..61606df3 100644 --- a/plugins-core/it-service/src/ItServicePlugin.php +++ b/plugins-core/it-service/src/ItServicePlugin.php @@ -21,7 +21,7 @@ class ItServicePlugin extends Plugin $this->app->singleton(Settings::class); $this->app->make(Abilities::class)->define('it-service.manage', 'IT-Service (OpenNIT) einrichten', 'IT-Service'); - $this->app->make(Navigation::class)->add('it-service', 'IT-Service', '/it-service', active: 'it-service.*', sort: 75); + $this->app->make(Navigation::class)->add('it-service', 'IT-Service', '/it-service', active: 'it-service.*', sort: 75, icon: 'headset'); // Knopf „Meine IT“ im Profilkasten der Startseite Hooks::filter('greeting.actions', fn (array $actions, User $user) => app(Settings::class)->configured() && app(PluginAccess::class)->allows('it-service', $user) diff --git a/plugins-core/news/src/NewsPlugin.php b/plugins-core/news/src/NewsPlugin.php index 86bb5dad..782cd8a3 100644 --- a/plugins-core/news/src/NewsPlugin.php +++ b/plugins-core/news/src/NewsPlugin.php @@ -60,7 +60,7 @@ class NewsPlugin extends Plugin $this->app->make(GlobalSearch::class)->add('news', 'Neuigkeiten', 'newspaper', fn (...$args) => app(NewsSearch::class)(...$args), sort: 10); - $this->app->make(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: ['news.index', 'news.show'], sort: 20); + $this->app->make(Navigation::class)->add('news', 'Neuigkeiten', '/neuigkeiten', active: ['news.index', 'news.show'], sort: 20, icon: 'newspaper'); $abilities = $this->app->make(Abilities::class); $abilities->define('news.manage', 'Neuigkeiten: alle Kategorien verwalten', 'Neuigkeiten'); diff --git a/plugins-core/qm/src/QmPlugin.php b/plugins-core/qm/src/QmPlugin.php index a305829c..6fa3e177 100644 --- a/plugins-core/qm/src/QmPlugin.php +++ b/plugins-core/qm/src/QmPlugin.php @@ -23,7 +23,7 @@ class QmPlugin extends Plugin $this->app->singleton($class); } - $this->app->make(Navigation::class)->add('qm', 'Qualitätsmanagement', '/qm', active: 'qm.*', sort: 55, + $this->app->make(Navigation::class)->add('qm', 'Qualitätsmanagement', '/qm', active: 'qm.*', sort: 55, icon: 'shield-check', visible: fn (User $user) => $this->app->make(QmAccess::class)->allows($user)); // Startseite: noch zu bestätigende QM-Dokumente (nur wenn es welche gibt) diff --git a/plugins-core/speiseplan/src/SpeiseplanPlugin.php b/plugins-core/speiseplan/src/SpeiseplanPlugin.php index e070c9ad..86758ca5 100644 --- a/plugins-core/speiseplan/src/SpeiseplanPlugin.php +++ b/plugins-core/speiseplan/src/SpeiseplanPlugin.php @@ -15,7 +15,7 @@ class SpeiseplanPlugin extends Plugin public function register(): void { - $this->app->make(Navigation::class)->add('speiseplan', 'Speiseplan', '/speiseplan', active: 'speiseplan.*', sort: 70); + $this->app->make(Navigation::class)->add('speiseplan', 'Speiseplan', '/speiseplan', active: 'speiseplan.*', sort: 70, icon: 'utensils'); $this->app->make(Abilities::class)->define('speiseplan.manage', 'Speiseplan hochladen', 'Speiseplan', portal: true); } diff --git a/plugins-core/stellen/src/StellenPlugin.php b/plugins-core/stellen/src/StellenPlugin.php index d2432f01..4d6e6dfb 100644 --- a/plugins-core/stellen/src/StellenPlugin.php +++ b/plugins-core/stellen/src/StellenPlugin.php @@ -19,7 +19,7 @@ class StellenPlugin extends Plugin { public function register(): void { - $this->app->make(Navigation::class)->add('stellen', 'Stellen', '/stellen', active: 'jobs.*', sort: 72); + $this->app->make(Navigation::class)->add('stellen', 'Stellen', '/stellen', active: 'jobs.*', sort: 72, icon: 'briefcase'); $this->app->make(Digest::class)->add('stellen', 'Neue interne Stellen', 50, fn (User $user, CarbonImmutable $since) => JobPosting::query() ->open()->where('published_at', '>=', $since)->latest('published_at')->limit(5)->get() diff --git a/plugins-core/umfragen/src/UmfragenPlugin.php b/plugins-core/umfragen/src/UmfragenPlugin.php index 5cd10ba0..166d23bb 100644 --- a/plugins-core/umfragen/src/UmfragenPlugin.php +++ b/plugins-core/umfragen/src/UmfragenPlugin.php @@ -19,7 +19,7 @@ class UmfragenPlugin extends Plugin { public function register(): void { - $this->app->make(Navigation::class)->add('umfragen', 'Umfragen', '/umfragen', active: 'polls.*', sort: 74); + $this->app->make(Navigation::class)->add('umfragen', 'Umfragen', '/umfragen', active: 'polls.*', sort: 74, icon: 'vote'); $this->app->make(Digest::class)->add('umfragen', 'Ihre Meinung ist gefragt', 30, fn (User $user) => Poll::query() ->open()->visibleTo($user)->latest('published_at')->limit(10)->get() ->reject(fn (Poll $poll) => $poll->hasVoted($user))->take(5) diff --git a/sdk/stubs/Plugin.php.stub b/sdk/stubs/Plugin.php.stub index ed93c388..7999c6cf 100644 --- a/sdk/stubs/Plugin.php.stub +++ b/sdk/stubs/Plugin.php.stub @@ -20,7 +20,7 @@ class {{studly}}Plugin extends Plugin public function register(): void { // Menüpunkt im Portal („Mehr“ bzw. unter „Menü“ im Backend frei anordenbar) - $this->app->make(Navigation::class)->add('{{slug}}', '{{name}}', '/{{slug}}', active: '{{slug}}.*', sort: 80); + $this->app->make(Navigation::class)->add('{{slug}}', '{{name}}', '/{{slug}}', active: '{{slug}}.*', sort: 80, icon: 'sparkles'); // Kachel auf der Startseite – Vue-Komponente resources/js/widgets/Hello.vue $this->app->make(Widgets::class)->add('{{slug}}.hello', '{{slug}}::Hello', 'aside', sort: 90, diff --git a/tests/Feature/HeaderItemsTest.php b/tests/Feature/HeaderItemsTest.php index f9069fe4..759cfa31 100644 --- a/tests/Feature/HeaderItemsTest.php +++ b/tests/Feature/HeaderItemsTest.php @@ -22,13 +22,16 @@ class HeaderItemsTest extends TestCase $items->add('forms', 'forms::Broken', fn () => throw new \RuntimeException('kaputt')); $user = User::factory()->create(); - $this->actingAs($user)->get('/')->assertInertia(fn (Assert $p) => $p - ->has('headerItems', 1)->where('headerItems.0.component', 'news::Unread')->where('headerItems.0.props.unread', 3)); + // Nur die hier angemeldeten Symbole betrachten – lokal installierte Plugins bringen ggf. eigene mit + $mine = fn (array $items) => collect($items)->whereIn('key', ['news', 'events', 'forms'])->values()->all(); + $this->actingAs($user)->get('/')->assertInertia(fn (Assert $p) => $p->where('headerItems', fn ($items) => $mine($items->all()) === [ + ['key' => 'news', 'component' => 'news::Unread', 'props' => ['unread' => 3]], + ])); // Vom Modul ausgeschlossene Rollen sehen das Symbol nicht $role = Role::query()->create(['name' => 'Extern']); app(PluginAccess::class)->exclude('news', [$role->id]); $external = User::factory()->withRoles([$role])->create(); - $this->actingAs($external)->get('/')->assertInertia(fn (Assert $p) => $p->has('headerItems', 0)); + $this->actingAs($external)->get('/')->assertInertia(fn (Assert $p) => $p->where('headerItems', fn ($items) => $mine($items->all()) === [])); } } diff --git a/tests/Feature/MenuTest.php b/tests/Feature/MenuTest.php index 25e8f9fb..1fa964c8 100644 --- a/tests/Feature/MenuTest.php +++ b/tests/Feature/MenuTest.php @@ -45,6 +45,25 @@ class MenuTest extends TestCase $this->assertContains('news', $keys); } + public function test_every_top_level_item_of_the_automatic_menu_has_an_icon(): void + { + $navigation = app(Navigation::class); + $navigation->add('eigenes-plugin', 'Eigenes', '/eigenes', sort: 99); + $navigation->add('mit-symbol', 'Mit Symbol', '/mit', sort: 98, icon: 'rocket'); + $navigation->add('falsches-symbol', 'Falsch', '/falsch', sort: 97, icon: 'gibt-es-nicht'); + $this->page('Leitbild')->forceFill(['in_navigation' => true])->save(); + + $menu = collect($this->menuFor(User::factory()->admin()->create()))->keyBy('key'); + + $this->assertTrue($menu->every(fn ($item) => filled($item['icon'])), 'Jeder Hauptpunkt hat ein Symbol'); + $this->assertSame('house', $menu['home']['icon']); + $this->assertSame('newspaper', $menu['news']['icon']); + $this->assertSame('rocket', $menu['mit-symbol']['icon']); + $this->assertSame(Navigation::FALLBACK_ICON, $menu['eigenes-plugin']['icon']); + $this->assertSame(Navigation::FALLBACK_ICON, $menu['falsches-symbol']['icon']); + $this->assertSame('file-text', $menu->first(fn ($i) => str_starts_with($i['key'], 'page-'))['icon']); + } + public function test_custom_menu_with_pages_subpages_groups_links_and_roles(): void { $mav = $this->page('Mitarbeitervertretung'); @@ -101,6 +120,7 @@ class MenuTest extends TestCase $component = Livewire::test(MenuSettings::class); $items = $component->get('data.items'); $this->assertSame('home', collect($items)->first()['module']); + $this->assertSame('house', collect($items)->first()['icon'], 'Symbole des automatischen Menüs werden übernommen'); $component->set('data.items', [ 'x' => ['id' => 'x', 'type' => 'module', 'module' => 'news', 'label' => 'News', 'icon' => 'newspaper', 'roles' => [], 'children' => [ diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 29b71521..591e9325 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'inhaus/inhaus', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '93e83469f308f39f18f11899ba884a7a6f6f0f3e', + 'reference' => 'a704d12d2ad19f8bf5d8c5f527f32ee4837f7f81', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -550,7 +550,7 @@ 'inhaus/inhaus' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '93e83469f308f39f18f11899ba884a7a6f6f0f3e', + 'reference' => 'a704d12d2ad19f8bf5d8c5f527f32ee4837f7f81', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(),