You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

user-menu.blade.php 4.6KB

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