From dc7950a14ce1c4e06f45ecc77b62030e23238c63 Mon Sep 17 00:00:00 2001 From: Wendell Adriel Date: Wed, 21 Jan 2026 10:50:49 +0000 Subject: [PATCH 1/2] drift:v12.11.2 (#255) Sync from base tag v12.11.2 --- .github/workflows/tests.yml | 4 ++-- composer.json | 2 +- config/filesystems.php | 2 +- database/migrations/0001_01_01_000001_create_cache_table.php | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0634ceb4e..eac012da5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,8 +18,8 @@ jobs: php-version: ['8.4', '8.5'] steps: - - name: Checkout - uses: actions/checkout@v4 + - name: Checkout code + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/composer.json b/composer.json index c37cf2474..e371c30fd 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ ], "dev": [ "Composer\\Config::disableProcessTimeout", - "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others" + "npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1 --timeout=0\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite --kill-others" ], "dev:ssr": [ "npm run build:ssr", diff --git a/config/filesystems.php b/config/filesystems.php index 82ea8a89d..37d8fca4f 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -41,7 +41,7 @@ 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => rtrim(env('APP_URL'), '/').'/storage', + 'url' => rtrim(env('APP_URL', 'http://localhost'), '/').'/storage', 'visibility' => 'public', 'throw' => false, 'report' => false, diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/0001_01_01_000001_create_cache_table.php index b9c106be8..ed758bdf4 100644 --- a/database/migrations/0001_01_01_000001_create_cache_table.php +++ b/database/migrations/0001_01_01_000001_create_cache_table.php @@ -14,13 +14,13 @@ public function up(): void Schema::create('cache', function (Blueprint $table) { $table->string('key')->primary(); $table->mediumText('value'); - $table->integer('expiration'); + $table->integer('expiration')->index(); }); Schema::create('cache_locks', function (Blueprint $table) { $table->string('key')->primary(); $table->string('owner'); - $table->integer('expiration'); + $table->integer('expiration')->index(); }); } From 8ee088337ad8d3cb9035c4f4f75a90a422dc7e91 Mon Sep 17 00:00:00 2001 From: Wendell Adriel Date: Wed, 21 Jan 2026 15:50:01 +0000 Subject: [PATCH 2/2] Refactor active URL hook (#250) * Refactor active URL hook * Create whenCurrentUrl helper --- resources/js/components/app-header.tsx | 10 +++--- resources/js/components/nav-main.tsx | 6 ++-- resources/js/hooks/use-active-url.ts | 22 ------------- resources/js/hooks/use-current-url.ts | 42 ++++++++++++++++++++++++ resources/js/layouts/settings/layout.tsx | 6 ++-- 5 files changed, 54 insertions(+), 32 deletions(-) delete mode 100644 resources/js/hooks/use-active-url.ts create mode 100644 resources/js/hooks/use-current-url.ts diff --git a/resources/js/components/app-header.tsx b/resources/js/components/app-header.tsx index 9c3c5d8b4..b02f2cfd4 100644 --- a/resources/js/components/app-header.tsx +++ b/resources/js/components/app-header.tsx @@ -29,7 +29,7 @@ import { TooltipTrigger, } from '@/components/ui/tooltip'; import { UserMenuContent } from '@/components/user-menu-content'; -import { useActiveUrl } from '@/hooks/use-active-url'; +import { useCurrentUrl } from '@/hooks/use-current-url'; import { useInitials } from '@/hooks/use-initials'; import { cn, toUrl } from '@/lib/utils'; import { dashboard } from '@/routes'; @@ -70,7 +70,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) { const page = usePage(); const { auth } = page.props; const getInitials = useInitials(); - const { urlIsActive } = useActiveUrl(); + const { isCurrentUrl, whenCurrentUrl } = useCurrentUrl(); return ( <>
@@ -157,8 +157,10 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) { href={item.href} className={cn( navigationMenuTriggerStyle(), - urlIsActive(item.href) && + whenCurrentUrl( + item.href, activeItemStyles, + ), 'h-9 cursor-pointer px-3', )} > @@ -167,7 +169,7 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) { )} {item.title} - {urlIsActive(item.href) && ( + {isCurrentUrl(item.href) && (
)} diff --git a/resources/js/components/nav-main.tsx b/resources/js/components/nav-main.tsx index 93cf68ad2..cebd7c658 100644 --- a/resources/js/components/nav-main.tsx +++ b/resources/js/components/nav-main.tsx @@ -7,11 +7,11 @@ import { SidebarMenuButton, SidebarMenuItem, } from '@/components/ui/sidebar'; -import { useActiveUrl } from '@/hooks/use-active-url'; +import { useCurrentUrl } from '@/hooks/use-current-url'; import { type NavItem } from '@/types'; export function NavMain({ items = [] }: { items: NavItem[] }) { - const { urlIsActive } = useActiveUrl(); + const { isCurrentUrl } = useCurrentUrl(); return ( @@ -21,7 +21,7 @@ export function NavMain({ items = [] }: { items: NavItem[] }) { diff --git a/resources/js/hooks/use-active-url.ts b/resources/js/hooks/use-active-url.ts deleted file mode 100644 index b4bf2becc..000000000 --- a/resources/js/hooks/use-active-url.ts +++ /dev/null @@ -1,22 +0,0 @@ -import type { InertiaLinkProps } from '@inertiajs/react'; -import { usePage } from '@inertiajs/react'; - -import { toUrl } from '@/lib/utils'; - -export function useActiveUrl() { - const page = usePage(); - const currentUrlPath = new URL(page.url, window?.location.origin).pathname; - - function urlIsActive( - urlToCheck: NonNullable, - currentUrl?: string, - ) { - const urlToCompare = currentUrl ?? currentUrlPath; - return toUrl(urlToCheck) === urlToCompare; - } - - return { - currentUrl: currentUrlPath, - urlIsActive, - }; -} diff --git a/resources/js/hooks/use-current-url.ts b/resources/js/hooks/use-current-url.ts new file mode 100644 index 000000000..7e119bd6e --- /dev/null +++ b/resources/js/hooks/use-current-url.ts @@ -0,0 +1,42 @@ +import type { InertiaLinkProps } from '@inertiajs/react'; +import { usePage } from '@inertiajs/react'; + +import { toUrl } from '@/lib/utils'; + +export function useCurrentUrl() { + const page = usePage(); + const currentUrlPath = new URL(page.url, window?.location.origin).pathname; + + function isCurrentUrl( + urlToCheck: NonNullable, + currentUrl?: string, + ) { + const urlToCompare = currentUrl ?? currentUrlPath; + const urlString = toUrl(urlToCheck); + + if (!urlString.startsWith('http')) { + return urlString === urlToCompare; + } + + try { + const absoluteUrl = new URL(urlString); + return absoluteUrl.pathname === urlToCompare; + } catch { + return false; + } + } + + function whenCurrentUrl( + urlToCheck: NonNullable, + ifTrue, + ifFalse = null, + ) { + return isCurrentUrl(urlToCheck) ? ifTrue : ifFalse; + } + + return { + currentUrl: currentUrlPath, + isCurrentUrl, + whenCurrentUrl, + }; +} diff --git a/resources/js/layouts/settings/layout.tsx b/resources/js/layouts/settings/layout.tsx index dff70f7eb..fab634fe3 100644 --- a/resources/js/layouts/settings/layout.tsx +++ b/resources/js/layouts/settings/layout.tsx @@ -4,7 +4,7 @@ import { type PropsWithChildren } from 'react'; import Heading from '@/components/heading'; import { Button } from '@/components/ui/button'; import { Separator } from '@/components/ui/separator'; -import { useActiveUrl } from '@/hooks/use-active-url'; +import { useCurrentUrl } from '@/hooks/use-current-url'; import { cn, toUrl } from '@/lib/utils'; import { edit as editAppearance } from '@/routes/appearance'; import { edit } from '@/routes/profile'; @@ -36,7 +36,7 @@ const sidebarNavItems: NavItem[] = [ ]; export default function SettingsLayout({ children }: PropsWithChildren) { - const { urlIsActive } = useActiveUrl(); + const { isCurrentUrl } = useCurrentUrl(); // When server-side rendering, we only render the layout on the client... if (typeof window === 'undefined') { @@ -63,7 +63,7 @@ export default function SettingsLayout({ children }: PropsWithChildren) { variant="ghost" asChild className={cn('w-full justify-start', { - 'bg-muted': urlIsActive(item.href), + 'bg-muted': isCurrentUrl(item.href), })} >