Repository navigation
November: admin dashboard, E2E database reset, tasks #405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9b13a23
8ec3531
5bba129
50dd9cb
8222f5d
cec2fa9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,30 +7,6 @@ vars: | |
|
|
||
| includes: | ||
| # ── BEGIN MODULES ──────────────────────────────────────────────── | ||
| auth: | ||
| taskfile: ./modules/auth/Taskfile.yml | ||
| optional: true | ||
| billing: | ||
| taskfile: ./modules/billing/Taskfile.yml | ||
| optional: true | ||
| announcements: | ||
| taskfile: ./modules/announcements/Taskfile.yml | ||
| optional: true | ||
| roadmap: | ||
| taskfile: ./modules/roadmap/Taskfile.yml | ||
| optional: true | ||
| themes: | ||
| taskfile: ./modules/themes/Taskfile.yml | ||
| optional: true | ||
| blog: | ||
| taskfile: ./modules/blog/Taskfile.yml | ||
| optional: true | ||
| tenancy: | ||
| taskfile: ./modules/tenancy/Taskfile.yml | ||
| optional: true | ||
| newsletter: | ||
| taskfile: ./modules/newsletter/Taskfile.yml | ||
| optional: true | ||
| # ── END MODULES ────────────────────────────────────────────────── | ||
|
|
||
| tasks: | ||
|
|
@@ -44,6 +20,19 @@ tasks: | |
| desc: Start dev server (app, queue, logs, vite) | ||
| cmd: composer dev | ||
|
|
||
| queue: | ||
| desc: Run the queue worker (restarts when code changes) | ||
| cmd: '{{.APP}} php artisan queue:listen --tries=1 --timeout=0' | ||
|
|
||
| schedule: | ||
| desc: Run the scheduler (runs due tasks every minute) | ||
| cmd: '{{.APP}} php artisan schedule:work' | ||
|
|
||
| workers: | ||
| desc: Run the queue worker and scheduler together | ||
| deps: [queue, schedule] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| failfast: true # one stopping stops both (Task 3.46.1+), so jobs never pile up unprocessed | ||
|
|
||
| build: | ||
| desc: Production build (includes SSR) | ||
| cmd: npm run build | ||
|
|
@@ -103,18 +92,29 @@ tasks: | |
| # ── Helpers ─────────────────────────────────────────────────── | ||
|
|
||
| db:reset: | ||
| desc: Reset database (migrate:fresh + module seeds) | ||
| prompt: This will erase ALL data. Are you sure? | ||
| desc: Reset the app and E2E databases (migrate:fresh + module seeds; DEMO=--demo adds sample content) | ||
| prompt: This will erase ALL data, in the E2E database too. Are you sure? | ||
| # Checked before anything runs. Without .env.e2e, --env=e2e loads .env, and a cached | ||
| # config or exported DB_* variables do the same: the E2E reset would wipe the app's database. | ||
| preconditions: | ||
| - sh: test -f .env.e2e | ||
| msg: '.env.e2e is missing. Create it with: php artisan playwright:env' | ||
| - sh: | | ||
| db='echo config("database.default").":".config("database.connections.".config("database.default").".database");' | ||
| [ "$(php artisan tinker --env=e2e --execute="$db" 2>/dev/null)" != "$(php artisan tinker --execute="$db" 2>/dev/null)" ] | ||
| msg: 'The E2E environment resolves to the app database (check .env.e2e, a cached config, or exported DB_* variables). Nothing was reset.' | ||
| cmds: | ||
| - '{{.APP}} php artisan migrate:fresh --seed' | ||
| - '{{.APP}} php artisan modules:seed' | ||
| - '{{.APP}} php artisan modules:seed {{.DEMO}}' | ||
| # On the host, like the E2E run itself; its server only migrates, so an | ||
| # edited migration needs this to apply there. | ||
| - php artisan migrate:fresh --env=e2e --force | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| db:reset:demo: | ||
| desc: Reset database and load sample content (the auth module's demo includes an admin) | ||
| prompt: This will erase ALL data. Are you sure? | ||
| desc: Reset the app and E2E databases and load sample content (the auth module's demo includes an admin) | ||
| cmds: | ||
| - '{{.APP}} php artisan migrate:fresh --seed' | ||
| - '{{.APP}} php artisan modules:seed --demo' | ||
| - task: db:reset | ||
| vars: { DEMO: '--demo' } | ||
|
|
||
| db:seed:demo: | ||
| desc: Seed every module with sample content | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| <?php | ||
|
|
||
| namespace App\Filament\Admin\Widgets; | ||
|
|
||
| use App\Models\User; | ||
| use Filament\Widgets\StatsOverviewWidget; | ||
| use Filament\Widgets\StatsOverviewWidget\Stat; | ||
| use Saucebase\Core\Filament\Concerns\ReadsPeriod; | ||
| use Saucebase\Core\Filament\TrendStat; | ||
|
Comment on lines
+8
to
+9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| /** Opens the dashboard's stats band (10). */ | ||
| class UsersWidget extends StatsOverviewWidget | ||
| { | ||
| use ReadsPeriod; | ||
|
|
||
| protected static ?int $sort = 10; | ||
|
|
||
| protected ?string $pollingInterval = null; | ||
|
|
||
| /** Half the dashboard: pairs with its neighbour in the band. */ | ||
| protected int|string|array $columnSpan = 1; | ||
|
|
||
| protected int|array|null $columns = 2; | ||
|
|
||
| /** The permission behind Auth's Users page. */ | ||
| public static function canView(): bool | ||
| { | ||
| return auth()->user()?->can('manage users') ?? false; | ||
| } | ||
|
|
||
| protected function getStats(): array | ||
| { | ||
| $period = $this->period(); | ||
| $previous = $period->previous(); | ||
|
|
||
| return [ | ||
| TrendStat::make( | ||
| __('New users'), | ||
| User::whereBetween('created_at', [$period->start, $period->end])->count(), | ||
| User::whereBetween('created_at', [$previous->start, $previous->end])->count(), | ||
| $period->series(User::query()), | ||
| ), | ||
| Stat::make(__('Total users'), number_format(User::count())) | ||
| ->descriptionIcon('heroicon-m-users'), | ||
| ]; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: saucebase-dev/saucebase
Length of output: 7301
Web query:
MDN HTML title attribute accessibility keyboard touch tooltip title attributeResult:
Script executed:
Repository: saucebase-dev/saucebase
Length of output: 7254
Provide accessible access to the exact date.
If the exact date appears only in
title, keyboard and touch users may not be able to read it. Show the exact date alongside the relative date, or provide a control that works with keyboard and touch.