Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

user-menu.blade.php 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. @php
  2. $user = filament()->auth()->user();
  3. $items = filament()->getUserMenuItems();
  4. $profileItem = $items['profile'] ?? $items['account'] ?? null;
  5. $profileItemUrl = $profileItem?->getUrl();
  6. $profilePage = filament()->getProfilePage();
  7. $hasProfileItem = filament()->hasProfile() || filled($profileItemUrl);
  8. $logoutItem = $items['logout'] ?? null;
  9. $items = \Illuminate\Support\Arr::except($items, ['account', 'logout', 'profile']);
  10. $hasPanelShiftDropdown = filament()->hasPlugin('panel-shift-dropdown');
  11. @endphp
  12. @if($hasPanelShiftDropdown)
  13. {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_BEFORE) }}
  14. @endif
  15. @if (! $hasPanelShiftDropdown)
  16. <x-filament::dropdown
  17. placement="bottom-end"
  18. teleport
  19. :attributes="
  20. \Filament\Support\prepare_inherited_attributes($attributes)
  21. ->class(['fi-user-menu'])
  22. "
  23. >
  24. <x-slot name="trigger">
  25. <button
  26. aria-label="{{ __('filament-panels::layout.actions.open_user_menu.label') }}"
  27. type="button"
  28. class="shrink-0"
  29. >
  30. <x-filament-panels::avatar.user :user="$user"/>
  31. </button>
  32. </x-slot>
  33. @if ($profileItem?->isVisible() ?? true)
  34. {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_BEFORE) }}
  35. @if ($hasProfileItem)
  36. <x-filament::dropdown.list>
  37. <x-filament::dropdown.list.item
  38. :color="$profileItem?->getColor()"
  39. :icon="$profileItem?->getIcon() ?? \Filament\Support\Facades\FilamentIcon::resolve('panels::user-menu.profile-item') ?? 'heroicon-m-user-circle'"
  40. :href="$profileItemUrl ?? filament()->getProfileUrl()"
  41. :target="($profileItem?->shouldOpenUrlInNewTab() ?? false) ? '_blank' : null"
  42. tag="a"
  43. >
  44. {{ $profileItem?->getLabel() ?? ($profilePage ? $profilePage::getLabel() : null) ?? filament()->getUserName($user) }}
  45. </x-filament::dropdown.list.item>
  46. </x-filament::dropdown.list>
  47. @else
  48. <x-filament::dropdown.header
  49. :color="$profileItem?->getColor()"
  50. :icon="$profileItem?->getIcon() ?? \Filament\Support\Facades\FilamentIcon::resolve('panels::user-menu.profile-item') ?? 'heroicon-m-user-circle'"
  51. >
  52. {{ $profileItem?->getLabel() ?? filament()->getUserName($user) }}
  53. </x-filament::dropdown.header>
  54. @endif
  55. {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_PROFILE_AFTER) }}
  56. @endif
  57. @if (filament()->hasDarkMode() && (! filament()->hasDarkModeForced()))
  58. <x-filament::dropdown.list>
  59. <x-filament-panels::theme-switcher/>
  60. </x-filament::dropdown.list>
  61. @endif
  62. <x-filament::dropdown.list>
  63. @foreach ($items as $key => $item)
  64. @php
  65. $itemPostAction = $item->getPostAction();
  66. @endphp
  67. <x-filament::dropdown.list.item
  68. :action="$itemPostAction"
  69. :color="$item->getColor()"
  70. :href="$item->getUrl()"
  71. :icon="$item->getIcon()"
  72. :method="filled($itemPostAction) ? 'post' : null"
  73. :tag="filled($itemPostAction) ? 'form' : 'a'"
  74. :target="$item->shouldOpenUrlInNewTab() ? '_blank' : null"
  75. >
  76. {{ $item->getLabel() }}
  77. </x-filament::dropdown.list.item>
  78. @endforeach
  79. <x-filament::dropdown.list.item
  80. :action="$logoutItem?->getUrl() ?? filament()->getLogoutUrl()"
  81. :color="$logoutItem?->getColor()"
  82. :icon="$logoutItem?->getIcon() ?? \Filament\Support\Facades\FilamentIcon::resolve('panels::user-menu.logout-button') ?? 'heroicon-m-arrow-left-on-rectangle'"
  83. method="post"
  84. tag="form"
  85. >
  86. {{ $logoutItem?->getLabel() ?? __('filament-panels::layout.actions.logout.label') }}
  87. </x-filament::dropdown.list.item>
  88. </x-filament::dropdown.list>
  89. </x-filament::dropdown>
  90. @endif
  91. {{ \Filament\Support\Facades\FilamentView::renderHook(\Filament\View\PanelsRenderHook::USER_MENU_AFTER) }}