Commit Graph

5 Commits (master)

Author SHA1 Message Date
Boban Blaskovic 030185f02e URL-prefix workspace routing: /w/{public_id}/... persistent in path
User: 'workspace stays in URL only until tab change' + 'use random 25-char
string or UUID for workspace identifier'.

Migration:
- workspaces.public_id: varchar(25) unique nullable.
- Backfill existing rows with Str::random(25).

Workspace model:
- Auto-fill public_id on create via booted() with collision-check loop.
- Override getRouteKeyName() → 'public_id' so route-model-binding uses
  the opaque public_id everywhere (not the guessable slug).

Routes:
- Authed routes wrapped in prefix 'w/{wsId}' → URL shape
  /w/bPSyuQpMDI0bl0LBKlwVOLdsl/dashboard etc.
- Bare /dashboard /sites /servers etc. now redirect to current
  workspace's prefixed URL (covers external bookmarks / first visit).

ResolveCurrentWorkspace middleware:
- Resolution priority: route param {wsId} → ?workspace query →
  session sticky → user.current_workspace_id → first owned.
- On resolve: URL::defaults(['wsId' => public_id]) auto-injects param
  into every route() call, so all Volt wire:navigate / @route()
  helpers carry the workspace through the entire SPA session.
- forceFill + saveQuietly to avoid triggering observers on user.

Sidebar:
- Workspace-switch links now point to /w/{public_id}/dashboard (not
  the slug ?workspace=…).

TestCase:
- URL::defaults({wsId: 'test-workspace'}) so route('dashboard') etc.
  generates valid URLs in tests.
- actingAsWithWorkspace() helper for tests that need a real workspace
  bound to a logged-in user.

Browser-verified: click Sidebar → Sites navigates to
/w/bPSyuQpMDI0bl0LBKlwVOLdsl/sites, public_id sticks across every
internal navigation. 36/36 Page-Pest still green.
2026-06-01 01:34:38 +02:00
Boban Blaskovic 555101c993 Step 1/5: Workspace multi-tenancy foundation
User accepted 5-step plan: Workspace → Sub-Sidebar → Switcher → Plan/
Quota → Billing.

This step adds the workspace layer underneath everything:
- Workspace model with HasUuids + relations (sites/servers/clusters/
  backups/members/invitations/activities) + plan-based quotas + feature
  flags + isOverQuota() + hasFeature() helpers.
- Plan presets: free/starter/pro/agency/enterprise with sites,
  servers, team, storage_gb, features map (audit/monitoring/
  email_relay/multi_workspace/white_label/reports/sso).
- BelongsToWorkspace trait: global scope filters by app('current
  Workspace'), creating-hook auto-fills workspace_id from container.
  Falls back to no-scope when no workspace bound (tests, console).
- Migrations: workspaces table + workspace_id foreignUuid added to
  all 10 domain tables (clusters/servers/sites/backups/team_members/
  invitations/security_events/certificates/activities/crons).
- users gets current_workspace_id nullable FK.
- team_members unique changed to composite (workspace_id, user_id) so
  one user can belong to multiple workspaces.
- ResolveCurrentWorkspace middleware: resolves active workspace from
  ?workspace=slug → session → user.current_workspace_id → first owned.
  Wired into web middleware group via bootstrap/app.php.
- WorkspaceFactory + workspace_id added to all 10 domain factories
  so tests/seed work without explicit workspace context.
- DatabaseSeeder rewritten: creates Marie Weber as owner of 'Acme
  Agency' (Pro plan) workspace + 'Marie · Personal' (Free) workspace
  for switcher demo. Binds app('currentWorkspace') so seeded sites/
  servers/backups/etc. land in the right workspace.
- Sidebar component reads auth user's current workspace for the ws-
  switch panel — no more hard-coded 'Acme Cluster' string.

Full Pest regression: 47/47 green. 2 workspaces seeded:
- Acme Agency (pro): 87 sites, 6 servers, 128 sec events, 102 backups
- Marie · Personal (free): 0 sites
2026-06-01 01:12:00 +02:00
Boban Blaskovic 29622eff77 Migrate all primary keys + foreign keys to UUID (HasUuids trait)
Per user request: switch from auto-increment IDs to UUID v4 across all
models.

Models — added HasUuids trait:
- User, Cluster, Server, Site, Backup, TeamMember, Invitation,
  SecurityEvent, Certificate, Activity, Cron.

Migrations — $table->id() → $table->uuid('id')->primary(),
$table->foreignId(...) → $table->foreignUuid(...) across stock laravel
users/sessions/jobs migrations + all 10 domain migrations.

Routes: sites/{site} (and any other implicit route-model binding) keeps
working since Laravel resolves by primary key as a string. Tested:
clicking a site row → URL now /sites/019e800c-520a-7022-badd-2ef9d9ed5c61.

Re-seeded: 6 users, 87 sites, 6 servers, 128 security events, 30
activities, 102 backups, 47 crons, 87 certs, 5 team members, 3 invites.

Full Pest regression: 47/47 green. Browser-verified login + sites
index + site details + WP/PHP/Files tabs with template-exact chrome.
2026-06-01 00:00:44 +02:00
Boban Blaskovic 7276e27408 Domain models: Cluster/Server/Site/Backup/TeamMember/Invitation/SecurityEvent/Certificate/Activity/Cron
Full Eloquent foundation matching template data:
- 10 migrations (clusters, servers, sites, backups, team_members,
  invitations, security_events, certificates, activities, crons).
- 10 models with relationships + casts + accessors.
- 10 factories.
- DatabaseSeeder seeds matching template stats:
  - Marie Weber (m.weber@acme-cluster.de / clupilot) as owner
  - Admin (admin@clupilot.test / clupilot)
  - 1 Acme Cluster, 6 named servers (eu-prod-01/-02, edge-ams,
    us-east-01, staging, ap-bom-01) with CPU/RAM/disk loads from template
  - 87 sites distributed [23,19,14,18,6,7] per server
  - 102 backups, 87 SSL certificates, 47 cronjobs
  - 128 security events (matches template 'Blocked / 24h')
  - 5 team members + 3 pending invitations
  - 30 activity feed entries.
2026-05-31 22:33:09 +02:00
Boban Blaskovic 624b21fcb9 Initial CluPilot stack setup
Laravel 12 + Livewire v3 + Tailwind v4 + Reverb WebSocket
behind Nginx Proxy Manager (external SSL termination, HTTP-only internal).
MariaDB 11, Redis 7, Mailpit. Dark auth views.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-27 23:00:14 +02:00