diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9556bbe..3ef1b93 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,5 +13,5 @@ jobs: test: uses: saucebase-dev/saucebase/.github/workflows/test-module.yml@main with: - module: Settings + module: settings dependencies: saucebase/auth diff --git a/CLAUDE.md b/CLAUDE.md index 6736216..6c2141c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -64,7 +64,7 @@ Other modules can add items to the `settings` group from their own `routes/navig ```bash php artisan test --testsuite=Modules --filter='^Modules\\Settings\\Tests' # PHPUnit -npx playwright test --project="@Settings*" # E2E +npx playwright test --project="@settings*" # E2E ``` E2E tests in `tests/e2e/index.spec.ts` — basic settings page accessibility. diff --git a/LICENSE b/LICENSE index f9a509b..cf78a69 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2025 Saucebase +Copyright (c) 2026 Saucebase Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Taskfile.yml b/Taskfile.yml index 2b055b0..80a3017 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -9,11 +9,17 @@ tasks: test:e2e: desc: Run E2E tests for Settings module - cmd: npx playwright test --project="@Settings*" {{.CLI_ARGS}} + cmd: npx playwright test --project="@settings*" {{.CLI_ARGS}} interactive: true + # ── Database ────────────────────────────────────────────────── + + db:seed: + desc: Seed the Settings module database + cmd: php artisan modules:seed --module=settings + # ── Code Generation ──────────────────────────────────────────── types:generate: desc: Generate TypeScript types from PHP DTOs and enums - cmd: php artisan module:generate-types Settings + cmd: php artisan module:generate-types settings diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php deleted file mode 100644 index 172946d..0000000 --- a/app/Providers/RouteServiceProvider.php +++ /dev/null @@ -1,17 +0,0 @@ -group(module_path('settings', '/routes/web.php')); - Route::middleware('api') - ->group(module_path('settings', '/routes/api.php')); - } -} diff --git a/app/Providers/SettingsServiceProvider.php b/app/Providers/SettingsServiceProvider.php deleted file mode 100644 index 7a91b1c..0000000 --- a/app/Providers/SettingsServiceProvider.php +++ /dev/null @@ -1,16 +0,0 @@ -prefix('api/v1/settings')->group(function () { - Route::apiResource('settings', SettingsController::class, ['as' => 'api']); +Route::middleware('api')->group(function (): void { + Route::middleware(['auth:sanctum'])->prefix('api/v1/settings')->group(function (): void { + Route::apiResource('settings', SettingsController::class, ['as' => 'api']); + }); }); diff --git a/routes/navigation.php b/routes/navigation.php index c8b4ed1..d7c76f3 100644 --- a/routes/navigation.php +++ b/routes/navigation.php @@ -14,7 +14,7 @@ */ // User menu - Settings -Navigation::add('Settings', route('settings.index'), function (Section $section) { +Navigation::add('Settings', fn () => route('settings.index'), function (Section $section) { $section->attributes([ 'group' => 'user', 'slug' => 'settings', @@ -24,7 +24,7 @@ }); // Settings sidebar - General -Navigation::add('General', route('settings.index'), function (Section $section) { +Navigation::add('General', fn () => route('settings.index'), function (Section $section) { $section->attributes([ 'group' => 'settings', 'slug' => 'settings', @@ -34,7 +34,7 @@ }); // Settings sidebar - Profile -Navigation::add('Profile', route('settings.profile'), function (Section $section) { +Navigation::add('Profile', fn () => route('settings.profile'), function (Section $section) { $section->attributes([ 'group' => 'settings', 'slug' => 'profile', @@ -44,7 +44,7 @@ }); // Secondary navigation - Settings -Navigation::add('Settings', route('settings.index'), function (Section $section) { +Navigation::add('Settings', fn () => route('settings.index'), function (Section $section) { $section->attributes([ 'group' => 'secondary', 'slug' => 'settings', diff --git a/routes/web.php b/routes/web.php index 5576950..a37da73 100644 --- a/routes/web.php +++ b/routes/web.php @@ -5,34 +5,36 @@ use Modules\Settings\Http\Controllers\ProfileController; use Modules\Settings\Http\Controllers\SettingsController; -Route::group(['middleware' => [ - 'auth', - 'verified', - 'role:admin|user', -]], function () { - Route::prefix('settings')->group(function () { - Route::get('/', [SettingsController::class, 'index']) - ->name('settings.index'); +Route::middleware('web')->group(function (): void { + Route::group(['middleware' => [ + 'auth', + 'verified', + 'role:admin|user', + ]], function (): void { + Route::prefix('settings')->group(function (): void { + Route::get('/', [SettingsController::class, 'index']) + ->name('settings.index'); - Route::get('profile', [ProfileController::class, 'show']) - ->name('settings.profile'); + Route::get('profile', [ProfileController::class, 'show']) + ->name('settings.profile'); - Route::get('profile/edit', [ProfileController::class, 'edit']) - ->name('settings.profile.edit'); + Route::get('profile/edit', [ProfileController::class, 'edit']) + ->name('settings.profile.edit'); - Route::patch('profile/info', [ProfileController::class, 'updateInfo']) - ->name('settings.profile.update-info'); + Route::patch('profile/info', [ProfileController::class, 'updateInfo']) + ->name('settings.profile.update-info'); - Route::post('profile/avatar', [ProfileController::class, 'updateAvatar']) - ->name('settings.profile.update-avatar'); + Route::post('profile/avatar', [ProfileController::class, 'updateAvatar']) + ->name('settings.profile.update-avatar'); - Route::delete('profile/avatar', [ProfileController::class, 'deleteAvatar']) - ->name('settings.profile.delete-avatar'); + Route::delete('profile/avatar', [ProfileController::class, 'deleteAvatar']) + ->name('settings.profile.delete-avatar'); - Route::get('profile/password', [PasswordController::class, 'edit']) - ->name('settings.profile.password.edit'); + Route::get('profile/password', [PasswordController::class, 'edit']) + ->name('settings.profile.password.edit'); - Route::put('profile/password', [PasswordController::class, 'update']) - ->name('settings.profile.password.update'); + Route::put('profile/password', [PasswordController::class, 'update']) + ->name('settings.profile.password.update'); + }); }); }); diff --git a/app/Filament/Pages/GeneralSettings.php b/src/Filament/Pages/GeneralSettings.php similarity index 100% rename from app/Filament/Pages/GeneralSettings.php rename to src/Filament/Pages/GeneralSettings.php diff --git a/app/Filament/SettingsPlugin.php b/src/Filament/SettingsPlugin.php similarity index 89% rename from app/Filament/SettingsPlugin.php rename to src/Filament/SettingsPlugin.php index 9c4d139..fba3ce3 100644 --- a/app/Filament/SettingsPlugin.php +++ b/src/Filament/SettingsPlugin.php @@ -22,6 +22,11 @@ public function getId(): string return 'settings'; } + public static function getNavigationGroupSort(): int + { + return 3; + } + public function boot(Panel $panel): void { $panel->navigationGroups([ diff --git a/app/Http/Controllers/PasswordController.php b/src/Http/Controllers/PasswordController.php similarity index 100% rename from app/Http/Controllers/PasswordController.php rename to src/Http/Controllers/PasswordController.php diff --git a/app/Http/Controllers/ProfileController.php b/src/Http/Controllers/ProfileController.php similarity index 100% rename from app/Http/Controllers/ProfileController.php rename to src/Http/Controllers/ProfileController.php diff --git a/app/Http/Controllers/SettingsController.php b/src/Http/Controllers/SettingsController.php similarity index 100% rename from app/Http/Controllers/SettingsController.php rename to src/Http/Controllers/SettingsController.php diff --git a/app/Http/Requests/UpdatePasswordRequest.php b/src/Http/Requests/UpdatePasswordRequest.php similarity index 100% rename from app/Http/Requests/UpdatePasswordRequest.php rename to src/Http/Requests/UpdatePasswordRequest.php diff --git a/app/Http/Requests/UpdateProfileAvatarRequest.php b/src/Http/Requests/UpdateProfileAvatarRequest.php similarity index 100% rename from app/Http/Requests/UpdateProfileAvatarRequest.php rename to src/Http/Requests/UpdateProfileAvatarRequest.php diff --git a/app/Http/Requests/UpdateProfileInfoRequest.php b/src/Http/Requests/UpdateProfileInfoRequest.php similarity index 100% rename from app/Http/Requests/UpdateProfileInfoRequest.php rename to src/Http/Requests/UpdateProfileInfoRequest.php diff --git a/src/Providers/SettingsServiceProvider.php b/src/Providers/SettingsServiceProvider.php new file mode 100644 index 0000000..62ff7d3 --- /dev/null +++ b/src/Providers/SettingsServiceProvider.php @@ -0,0 +1,9 @@ +