nitro_kit 2.0.0.beta.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/LICENSE +21 -28
- data/README.md +10 -9
- data/app/assets/stylesheets/nitro_kit.css +1660 -1401
- data/app/components/nitro_kit/accordion.rb +1 -13
- data/app/components/nitro_kit/app_navigation.rb +0 -12
- data/app/components/nitro_kit/app_shell.rb +5 -11
- data/app/components/nitro_kit/appearance_picker.rb +1 -7
- data/app/components/nitro_kit/combobox.rb +366 -21
- data/app/components/nitro_kit/command_palette.rb +7 -20
- data/app/components/nitro_kit/details_table.rb +5 -11
- data/app/components/nitro_kit/dropzone.rb +3 -15
- data/app/components/nitro_kit/field.rb +20 -2
- data/app/components/nitro_kit/pagination.rb +2 -8
- data/app/components/nitro_kit/settings_layout.rb +3 -9
- data/app/javascript/controllers/nk/app_shell_controller.js +2 -2
- data/app/javascript/controllers/nk/combobox_controller.js +308 -22
- data/app/javascript/controllers/nk/combobox_remote.js +70 -0
- data/app/javascript/controllers/nk/dropzone_controller.js +2 -2
- data/app/javascript/controllers/nk/tabs_controller.js +2 -2
- data/config/locales/en.yml +3 -0
- data/docs/agent_guide.md +43 -13
- data/docs/component_contracts.md +90 -61
- data/docs/customization.md +173 -35
- data/docs/initialization_prompt.md +4 -5
- data/docs/migration_1_to_2.md +10 -8
- data/docs/patterns/application_foundation.md +5 -0
- data/docs/patterns/composition.md +61 -0
- data/docs/patterns/crud_resource.md +5 -0
- data/docs/patterns/inset_workspace.md +21 -22
- data/docs/patterns/resource_form.md +65 -0
- data/docs/rails_integration.md +214 -2
- data/lib/generators/nitro_kit/install_generator.rb +5 -4
- data/lib/nitro_kit/installation.rb +327 -68
- data/lib/nitro_kit/migration_inventory.rb +18 -3
- data/lib/nitro_kit/version.rb +1 -1
- data/lib/rails/commands/nitro_kit/nitro_kit_command.rb +2 -2
- data/patterns/README.md +21 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/account_deletion.rb +72 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/base.rb +44 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/page.rb +57 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/preferences.rb +68 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/profile.rb +86 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/security.rb +69 -0
- data/patterns/account-settings/files/app/components/ui/account_settings/sessions.rb +86 -0
- data/patterns/account-settings/files/app/controllers/settings/account_deletions_controller.rb +35 -0
- data/patterns/account-settings/files/app/controllers/settings/base_controller.rb +12 -0
- data/patterns/account-settings/files/app/controllers/settings/other_sessions_controller.rb +8 -0
- data/patterns/account-settings/files/app/controllers/settings/preferences_controller.rb +27 -0
- data/patterns/account-settings/files/app/controllers/settings/profiles_controller.rb +20 -0
- data/patterns/account-settings/files/app/controllers/settings/securities_controller.rb +37 -0
- data/patterns/account-settings/files/app/controllers/settings/sessions_controller.rb +31 -0
- data/patterns/account-settings/files/app/models/account_settings/account_closure.rb +33 -0
- data/patterns/account-settings/files/app/models/account_settings/password_change.rb +42 -0
- data/patterns/account-settings/files/app/models/account_settings/session_summary.rb +45 -0
- data/patterns/account-settings/files/app/models/concerns/user/account_configurable.rb +18 -0
- data/patterns/account-settings/files/config/routes/account_settings.rb +10 -0
- data/patterns/account-settings/files/db/migrate/20260731020000_add_account_settings.rb +27 -0
- data/patterns/account-settings/files/test/controllers/settings/account_settings_flow_test.rb +84 -0
- data/patterns/account-settings/files/test/models/account_settings/password_change_test.rb +40 -0
- data/patterns/account-settings/files/test/system/account_settings_test.rb +52 -0
- data/patterns/account-settings/item.yml +4 -0
- data/patterns/account-settings/pattern.md +44 -0
- data/patterns/application-shell/files/app/assets/stylesheets/ui/application_shell.css +267 -0
- data/patterns/application-shell/files/app/components/ui/application_shell.rb +184 -0
- data/patterns/application-shell/item.yml +4 -0
- data/patterns/application-shell/pattern.md +110 -0
- data/patterns/authentication/files/app/components/ui/authentication/base.rb +11 -0
- data/patterns/authentication/files/app/components/ui/authentication/page.rb +53 -0
- data/patterns/authentication/files/app/components/ui/email_verifications/show.rb +62 -0
- data/patterns/authentication/files/app/components/ui/password_resets/new.rb +65 -0
- data/patterns/authentication/files/app/components/ui/passwords/edit.rb +72 -0
- data/patterns/authentication/files/app/components/ui/sessions/new.rb +58 -0
- data/patterns/authentication/files/app/components/ui/verification_emails/new.rb +59 -0
- data/patterns/authentication/files/app/controllers/concerns/authentication.rb +66 -0
- data/patterns/authentication/files/app/controllers/concerns/safe_return_navigation.rb +37 -0
- data/patterns/authentication/files/app/controllers/email_verifications_controller.rb +39 -0
- data/patterns/authentication/files/app/controllers/password_resets_controller.rb +33 -0
- data/patterns/authentication/files/app/controllers/passwords_controller.rb +51 -0
- data/patterns/authentication/files/app/controllers/sessions_controller.rb +42 -0
- data/patterns/authentication/files/app/controllers/verification_emails_controller.rb +33 -0
- data/patterns/authentication/files/app/jobs/authentication_delivery_job.rb +17 -0
- data/patterns/authentication/files/app/mailers/authentication_mailer.rb +15 -0
- data/patterns/authentication/files/app/models/authentication/credentials.rb +16 -0
- data/patterns/authentication/files/app/models/authentication/email_request.rb +17 -0
- data/patterns/authentication/files/app/models/concerns/user/email_verifiable.rb +40 -0
- data/patterns/authentication/files/app/models/session.rb +5 -0
- data/patterns/authentication/files/app/views/authentication_mailer/email_verification.html.erb +3 -0
- data/patterns/authentication/files/app/views/authentication_mailer/email_verification.text.erb +5 -0
- data/patterns/authentication/files/app/views/authentication_mailer/password_reset.html.erb +3 -0
- data/patterns/authentication/files/app/views/authentication_mailer/password_reset.text.erb +5 -0
- data/patterns/authentication/files/config/routes/authentication.rb +11 -0
- data/patterns/authentication/files/db/migrate/20260731000000_add_authentication_and_recovery.rb +13 -0
- data/patterns/authentication/files/test/controllers/authentication_flow_test.rb +103 -0
- data/patterns/authentication/files/test/controllers/safe_return_navigation_test.rb +18 -0
- data/patterns/authentication/files/test/mailers/authentication_mailer_test.rb +21 -0
- data/patterns/authentication/files/test/models/user_email_verifiable_test.rb +36 -0
- data/patterns/authentication/files/test/system/authentication_flow_test.rb +23 -0
- data/patterns/authentication/item.yml +12 -0
- data/patterns/authentication/pattern.md +54 -0
- data/patterns/crud-resource/files/app/assets/stylesheets/ui/projects.css +4 -0
- data/patterns/crud-resource/files/app/components/ui/projects/form.rb +89 -0
- data/patterns/crud-resource/files/app/components/ui/projects/index.rb +161 -0
- data/patterns/crud-resource/files/app/components/ui/projects/show.rb +84 -0
- data/patterns/crud-resource/files/app/controllers/projects/archivals_controller.rb +23 -0
- data/patterns/crud-resource/files/app/controllers/projects_controller.rb +70 -0
- data/patterns/crud-resource/files/app/models/project/archival.rb +8 -0
- data/patterns/crud-resource/files/app/models/project/event.rb +12 -0
- data/patterns/crud-resource/files/app/models/project/filter.rb +41 -0
- data/patterns/crud-resource/files/app/models/project.rb +41 -0
- data/patterns/crud-resource/files/app/views/projects/edit.html.erb +19 -0
- data/patterns/crud-resource/files/app/views/projects/index.html.erb +18 -0
- data/patterns/crud-resource/files/app/views/projects/new.html.erb +16 -0
- data/patterns/crud-resource/files/app/views/projects/show.html.erb +28 -0
- data/patterns/crud-resource/files/config/routes/crud_resource.rb +7 -0
- data/patterns/crud-resource/files/db/migrate/20260720000000_create_crud_resource.rb +37 -0
- data/patterns/crud-resource/files/test/controllers/projects_controller_test.rb +64 -0
- data/patterns/crud-resource/files/test/models/project_test.rb +34 -0
- data/patterns/crud-resource/files/test/support/crud_resource_test_helpers.rb +25 -0
- data/patterns/crud-resource/files/test/system/projects_crud_test.rb +87 -0
- data/patterns/crud-resource/item.yml +6 -0
- data/patterns/crud-resource/pattern.md +48 -0
- data/patterns/file-uploads/files/app/assets/stylesheets/ui/uploads.css +133 -0
- data/patterns/file-uploads/files/app/components/ui/uploads/base.rb +30 -0
- data/patterns/file-uploads/files/app/components/ui/uploads/index.rb +188 -0
- data/patterns/file-uploads/files/app/components/ui/uploads/page.rb +33 -0
- data/patterns/file-uploads/files/app/controllers/uploads/base_controller.rb +29 -0
- data/patterns/file-uploads/files/app/controllers/uploads/direct_uploads_controller.rb +55 -0
- data/patterns/file-uploads/files/app/controllers/uploads/retries_controller.rb +14 -0
- data/patterns/file-uploads/files/app/controllers/uploads_controller.rb +40 -0
- data/patterns/file-uploads/files/app/jobs/upload_blob_cleanup_job.rb +9 -0
- data/patterns/file-uploads/files/app/jobs/upload_processing_job.rb +10 -0
- data/patterns/file-uploads/files/app/jobs/upload_repair_job.rb +17 -0
- data/patterns/file-uploads/files/app/models/concerns/team/uploadable.rb +9 -0
- data/patterns/file-uploads/files/app/models/upload.rb +295 -0
- data/patterns/file-uploads/files/config/recurring/uploads.yml +7 -0
- data/patterns/file-uploads/files/config/routes/uploads.rb +5 -0
- data/patterns/file-uploads/files/db/migrate/20260802000000_add_file_uploads.rb +30 -0
- data/patterns/file-uploads/files/test/controllers/uploads_flow_test.rb +77 -0
- data/patterns/file-uploads/files/test/fixtures/files/workspace.png.base64 +1 -0
- data/patterns/file-uploads/files/test/fixtures/uploads.yml +17 -0
- data/patterns/file-uploads/files/test/models/upload_test.rb +55 -0
- data/patterns/file-uploads/files/test/system/file_uploads_test.rb +30 -0
- data/patterns/file-uploads/item.yml +4 -0
- data/patterns/file-uploads/pattern.md +71 -0
- data/patterns/nitro-kit-1-upgrade/files/docs/nitro_kit_1_upgrade.md +57 -0
- data/patterns/nitro-kit-1-upgrade/item.yml +4 -0
- data/patterns/nitro-kit-1-upgrade/pattern.md +30 -0
- data/patterns/onboarding/files/app/assets/stylesheets/ui/onboarding.css +55 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/base.rb +11 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/branch_form.rb +36 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/details_form.rb +67 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/invitation_plan_form.rb +48 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/page.rb +75 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/review.rb +51 -0
- data/patterns/onboarding/files/app/components/ui/onboarding/show.rb +32 -0
- data/patterns/onboarding/files/app/controllers/concerns/requires_finished_onboarding.rb +14 -0
- data/patterns/onboarding/files/app/controllers/onboarding/base_controller.rb +30 -0
- data/patterns/onboarding/files/app/controllers/onboarding/branches_controller.rb +16 -0
- data/patterns/onboarding/files/app/controllers/onboarding/completions_controller.rb +13 -0
- data/patterns/onboarding/files/app/controllers/onboarding/details_controller.rb +16 -0
- data/patterns/onboarding/files/app/controllers/onboarding/invitation_plans_controller.rb +20 -0
- data/patterns/onboarding/files/app/controllers/onboardings_controller.rb +7 -0
- data/patterns/onboarding/files/app/jobs/onboarding_invitation_delivery_job.rb +15 -0
- data/patterns/onboarding/files/app/models/concerns/team/onboardable.rb +23 -0
- data/patterns/onboarding/files/app/models/onboarding/completion.rb +17 -0
- data/patterns/onboarding/files/app/models/onboarding/invitation_delivery.rb +14 -0
- data/patterns/onboarding/files/app/models/onboarding.rb +174 -0
- data/patterns/onboarding/files/config/routes/onboarding.rb +11 -0
- data/patterns/onboarding/files/db/migrate/20260731010000_create_onboarding.rb +60 -0
- data/patterns/onboarding/files/test/controllers/onboarding_flow_test.rb +62 -0
- data/patterns/onboarding/files/test/fixtures/onboarding_completions.yml +3 -0
- data/patterns/onboarding/files/test/fixtures/onboardings.yml +25 -0
- data/patterns/onboarding/files/test/jobs/onboarding_invitation_delivery_job_test.rb +18 -0
- data/patterns/onboarding/files/test/models/onboarding_test.rb +60 -0
- data/patterns/onboarding/files/test/system/onboarding_flow_test.rb +39 -0
- data/patterns/onboarding/item.yml +4 -0
- data/patterns/onboarding/pattern.md +53 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/base.rb +39 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/checkout_result.rb +64 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/page.rb +33 -0
- data/patterns/subscription-billing/files/app/components/ui/billing/show.rb +149 -0
- data/patterns/subscription-billing/files/app/controllers/billing/base_controller.rb +16 -0
- data/patterns/subscription-billing/files/app/controllers/billing/checkouts_controller.rb +65 -0
- data/patterns/subscription-billing/files/app/controllers/billing/portals_controller.rb +18 -0
- data/patterns/subscription-billing/files/app/controllers/billing_controller.rb +17 -0
- data/patterns/subscription-billing/files/app/controllers/webhooks/stripe_events_controller.rb +21 -0
- data/patterns/subscription-billing/files/app/jobs/billing/stripe_event_job.rb +16 -0
- data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_job.rb +16 -0
- data/patterns/subscription-billing/files/app/jobs/billing/subscription_reconciliation_sweep_job.rb +9 -0
- data/patterns/subscription-billing/files/app/models/billing/checkout.rb +58 -0
- data/patterns/subscription-billing/files/app/models/billing/plan.rb +19 -0
- data/patterns/subscription-billing/files/app/models/billing/stripe_event.rb +73 -0
- data/patterns/subscription-billing/files/app/models/billing/subscription.rb +106 -0
- data/patterns/subscription-billing/files/app/models/concerns/team/billable.rb +36 -0
- data/patterns/subscription-billing/files/config/initializers/stripe.rb +29 -0
- data/patterns/subscription-billing/files/config/routes/subscription_billing.rb +10 -0
- data/patterns/subscription-billing/files/db/migrate/20260801000000_add_subscription_billing.rb +61 -0
- data/patterns/subscription-billing/files/test/controllers/billing_flow_test.rb +60 -0
- data/patterns/subscription-billing/files/test/models/billing/subscription_test.rb +40 -0
- data/patterns/subscription-billing/files/test/system/subscription_billing_test.rb +28 -0
- data/patterns/subscription-billing/item.yml +4 -0
- data/patterns/subscription-billing/pattern.md +59 -0
- data/patterns/team-management/files/app/components/ui/invitations/acceptance.rb +33 -0
- data/patterns/team-management/files/app/components/ui/teams/index.rb +87 -0
- data/patterns/team-management/files/app/components/ui/teams/invitation_form.rb +51 -0
- data/patterns/team-management/files/app/components/ui/teams/member_form.rb +78 -0
- data/patterns/team-management/files/app/components/ui/teams/members.rb +125 -0
- data/patterns/team-management/files/app/controllers/invitations/acceptances_controller.rb +29 -0
- data/patterns/team-management/files/app/controllers/teams/base_controller.rb +18 -0
- data/patterns/team-management/files/app/controllers/teams/invitations_controller.rb +42 -0
- data/patterns/team-management/files/app/controllers/teams/memberships_controller.rb +53 -0
- data/patterns/team-management/files/app/controllers/teams_controller.rb +30 -0
- data/patterns/team-management/files/app/mailers/team_invitation_mailer.rb +10 -0
- data/patterns/team-management/files/app/models/concerns/current_team.rb +13 -0
- data/patterns/team-management/files/app/models/concerns/user_teams.rb +37 -0
- data/patterns/team-management/files/app/models/invitation.rb +41 -0
- data/patterns/team-management/files/app/models/membership.rb +45 -0
- data/patterns/team-management/files/app/models/team.rb +25 -0
- data/patterns/team-management/files/app/views/invitations/acceptances/show.html.erb +1 -0
- data/patterns/team-management/files/app/views/team_invitation_mailer/invite.html.erb +10 -0
- data/patterns/team-management/files/app/views/team_invitation_mailer/invite.text.erb +7 -0
- data/patterns/team-management/files/app/views/teams/index.html.erb +15 -0
- data/patterns/team-management/files/app/views/teams/invitations/new.html.erb +22 -0
- data/patterns/team-management/files/app/views/teams/memberships/edit.html.erb +22 -0
- data/patterns/team-management/files/app/views/teams/memberships/index.html.erb +20 -0
- data/patterns/team-management/files/config/routes/team_management.rb +11 -0
- data/patterns/team-management/files/db/migrate/20260717000000_create_team_management.rb +31 -0
- data/patterns/team-management/files/test/models/invitation_test.rb +28 -0
- data/patterns/team-management/files/test/models/membership_test.rb +29 -0
- data/patterns/team-management/files/test/models/team_test.rb +31 -0
- data/patterns/team-management/files/test/support/team_management_test_helpers.rb +22 -0
- data/patterns/team-management/item.yml +4 -0
- data/patterns/team-management/pattern.md +47 -0
- data/patterns/webhook-deliveries/files/app/assets/stylesheets/ui/webhooks.css +179 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/base.rb +38 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/delivery.rb +160 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/endpoint.rb +149 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/form.rb +75 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/index.rb +142 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/page.rb +33 -0
- data/patterns/webhook-deliveries/files/app/components/ui/webhooks/secret.rb +38 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries/replays_controller.rb +13 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_deliveries_controller.rb +7 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints/secrets_controller.rb +41 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhook_endpoints_controller.rb +67 -0
- data/patterns/webhook-deliveries/files/app/controllers/webhooks/base_controller.rb +15 -0
- data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_job.rb +9 -0
- data/patterns/webhook-deliveries/files/app/jobs/webhook_delivery_repair_job.rb +11 -0
- data/patterns/webhook-deliveries/files/app/models/concerns/team/webhookable.rb +11 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/attempt.rb +30 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/delivery.rb +268 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/endpoint.rb +58 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/event.rb +98 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/secret_reveal.rb +53 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/signature.rb +22 -0
- data/patterns/webhook-deliveries/files/app/models/webhook/transport.rb +176 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_deliveries/show.html.erb +5 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/edit.html.erb +1 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/index.html.erb +6 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/new.html.erb +1 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/secrets/new.html.erb +1 -0
- data/patterns/webhook-deliveries/files/app/views/webhook_endpoints/show.html.erb +7 -0
- data/patterns/webhook-deliveries/files/config/recurring/webhooks.yml +4 -0
- data/patterns/webhook-deliveries/files/config/routes/webhook_deliveries.rb +10 -0
- data/patterns/webhook-deliveries/files/db/migrate/20260803000000_add_webhook_deliveries.rb +126 -0
- data/patterns/webhook-deliveries/files/test/controllers/webhook_endpoints_flow_test.rb +48 -0
- data/patterns/webhook-deliveries/files/test/models/webhook/delivery_test.rb +70 -0
- data/patterns/webhook-deliveries/files/test/system/webhook_deliveries_test.rb +29 -0
- data/patterns/webhook-deliveries/item.yml +4 -0
- data/patterns/webhook-deliveries/pattern.md +120 -0
- data/plugins/nitro-kit/.codex-plugin/plugin.json +4 -4
- data/plugins/nitro-kit/skills/nitro-kit-hotwire/SKILL.md +7 -9
- data/plugins/nitro-kit/skills/nitro-kit-hotwire/agents/openai.yaml +1 -1
- data/plugins/nitro-kit/skills/nitro-kit-rails/SKILL.md +10 -9
- data/plugins/nitro-kit/skills/nitro-kit-rails/agents/openai.yaml +1 -1
- data/plugins/nitro-kit/skills/nitro-kit-ui/SKILL.md +27 -16
- data/plugins/nitro-kit/skills/nitro-kit-ui/agents/openai.yaml +1 -1
- data/src/stylesheets/nitro_kit/components/accordion.css +40 -40
- data/src/stylesheets/nitro_kit/components/alert.css +7 -6
- data/src/stylesheets/nitro_kit/components/app_navigation.css +50 -41
- data/src/stylesheets/nitro_kit/components/app_shell.css +371 -280
- data/src/stylesheets/nitro_kit/components/appearance_picker.css +38 -38
- data/src/stylesheets/nitro_kit/components/avatar.css +3 -3
- data/src/stylesheets/nitro_kit/components/avatar_stack.css +18 -18
- data/src/stylesheets/nitro_kit/components/badge.css +5 -2
- data/src/stylesheets/nitro_kit/components/button.css +57 -49
- data/src/stylesheets/nitro_kit/components/button_group.css +14 -14
- data/src/stylesheets/nitro_kit/components/checkbox.css +24 -24
- data/src/stylesheets/nitro_kit/components/checkbox_group.css +13 -13
- data/src/stylesheets/nitro_kit/components/combobox.css +152 -25
- data/src/stylesheets/nitro_kit/components/command_palette.css +59 -59
- data/src/stylesheets/nitro_kit/components/control_group.css +71 -54
- data/src/stylesheets/nitro_kit/components/details_table.css +9 -9
- data/src/stylesheets/nitro_kit/components/dialog.css +8 -12
- data/src/stylesheets/nitro_kit/components/dropdown.css +22 -26
- data/src/stylesheets/nitro_kit/components/dropzone.css +97 -100
- data/src/stylesheets/nitro_kit/components/empty_state.css +1 -0
- data/src/stylesheets/nitro_kit/components/field.css +26 -30
- data/src/stylesheets/nitro_kit/components/fieldset.css +2 -2
- data/src/stylesheets/nitro_kit/components/input.css +6 -14
- data/src/stylesheets/nitro_kit/components/layout.css +165 -165
- data/src/stylesheets/nitro_kit/components/page_header.css +3 -3
- data/src/stylesheets/nitro_kit/components/pagination.css +66 -49
- data/src/stylesheets/nitro_kit/components/pagination_bar.css +6 -6
- data/src/stylesheets/nitro_kit/components/palette.css +24 -22
- data/src/stylesheets/nitro_kit/components/progressive_image.css +38 -41
- data/src/stylesheets/nitro_kit/components/radio_button.css +19 -19
- data/src/stylesheets/nitro_kit/components/radio_button_group.css +43 -43
- data/src/stylesheets/nitro_kit/components/rich_text_area.css +4 -4
- data/src/stylesheets/nitro_kit/components/select.css +2 -2
- data/src/stylesheets/nitro_kit/components/settings_layout.css +17 -18
- data/src/stylesheets/nitro_kit/components/settings_section.css +12 -12
- data/src/stylesheets/nitro_kit/components/sheet.css +10 -10
- data/src/stylesheets/nitro_kit/components/stat_grid.css +9 -9
- data/src/stylesheets/nitro_kit/components/switch.css +23 -23
- data/src/stylesheets/nitro_kit/components/table.css +27 -27
- data/src/stylesheets/nitro_kit/components/tabs.css +32 -34
- data/src/stylesheets/nitro_kit/components/toolbar.css +6 -6
- data/src/stylesheets/nitro_kit/components/tooltip.css +26 -28
- data/src/stylesheets/nitro_kit/layers.css +2 -1
- data/src/stylesheets/nitro_kit/reset.css +9 -9
- data/src/stylesheets/nitro_kit/tailwind.css +6 -2
- data/src/stylesheets/nitro_kit/tokens.css +18 -9
- metadata +238 -2
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Onboarding < ApplicationRecord
|
|
4
|
+
BRANCHES = %w[company personal].freeze
|
|
5
|
+
INVITATION_DECISIONS = %w[pending planned skipped].freeze
|
|
6
|
+
TEAM_SIZES = [ 1, 5, 20, 50 ].freeze
|
|
7
|
+
PRIMARY_USES = %w[projects clients personal].freeze
|
|
8
|
+
MAX_INVITEES = 20
|
|
9
|
+
STEP_TITLES = {
|
|
10
|
+
branch: "Setup type",
|
|
11
|
+
details: "Workspace details",
|
|
12
|
+
invitations: "Invite teammates",
|
|
13
|
+
review: "Review"
|
|
14
|
+
}.freeze
|
|
15
|
+
|
|
16
|
+
belongs_to :team
|
|
17
|
+
belongs_to :started_by, class_name: "User"
|
|
18
|
+
has_one :completion, dependent: :destroy
|
|
19
|
+
|
|
20
|
+
validates :team_id, uniqueness: true
|
|
21
|
+
validates :branch, inclusion: { in: BRANCHES }, allow_nil: true
|
|
22
|
+
validates :invitation_decision, inclusion: { in: INVITATION_DECISIONS }
|
|
23
|
+
validates :workspace_name, presence: true, on: %i[company_details personal_details]
|
|
24
|
+
validates :team_size, inclusion: { in: TEAM_SIZES }, on: :company_details
|
|
25
|
+
validates :primary_use, inclusion: { in: PRIMARY_USES }, on: :personal_details
|
|
26
|
+
validate :validate_invitation_plan, on: :invitations
|
|
27
|
+
validate :validate_completion, on: :completion
|
|
28
|
+
|
|
29
|
+
def step
|
|
30
|
+
return :finished if finished?
|
|
31
|
+
return :branch if branch_in_database.blank?
|
|
32
|
+
return :details if details_completed_at_in_database.blank?
|
|
33
|
+
return :invitations if company? && invitation_decision_in_database == "pending"
|
|
34
|
+
|
|
35
|
+
:review
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def steps
|
|
39
|
+
return [ :branch ] if branch_in_database.blank?
|
|
40
|
+
|
|
41
|
+
company? ? %i[branch details invitations review] : %i[branch details review]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def finished?
|
|
45
|
+
completion&.persisted? || false
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def unfinished?
|
|
49
|
+
!finished?
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def company?
|
|
53
|
+
branch_in_database == "company"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def personal?
|
|
57
|
+
branch_in_database == "personal"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def choose_branch(value)
|
|
61
|
+
transition_from(:branch) do
|
|
62
|
+
self.branch = value
|
|
63
|
+
valid?(:branch) && save!(validate: false)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def save_details(attributes)
|
|
68
|
+
transition_from(:details) do
|
|
69
|
+
allowed = company? ? %i[workspace_name team_size] : %i[workspace_name primary_use]
|
|
70
|
+
assign_attributes(attributes.slice(*allowed))
|
|
71
|
+
context = company? ? :company_details : :personal_details
|
|
72
|
+
next false unless valid?(context)
|
|
73
|
+
|
|
74
|
+
self.details_completed_at = Time.current
|
|
75
|
+
save!(validate: false)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def save_invitation_plan(decision:, invitee_list:)
|
|
80
|
+
transition_from(:invitations) do
|
|
81
|
+
self.invitation_decision = decision
|
|
82
|
+
self.invitee_list = decision == "skipped" ? "" : invitee_list
|
|
83
|
+
valid?(:invitations) && save!(validate: false)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def invitee_list
|
|
88
|
+
invitee_emails.to_a.join("\n")
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def invitee_list=(value)
|
|
92
|
+
self.invitee_emails = value.to_s.lines.map { _1.strip.downcase }.reject(&:blank?).uniq
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def finish!(completed_by:)
|
|
96
|
+
completed = with_lock do
|
|
97
|
+
existing_completion = Onboarding::Completion.find_by(onboarding_id: id)
|
|
98
|
+
next existing_completion if existing_completion
|
|
99
|
+
unless step == :review && valid?(:completion)
|
|
100
|
+
errors.add(:base, "Complete every onboarding step before finishing")
|
|
101
|
+
next false
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
team.update!(name: workspace_name)
|
|
105
|
+
invitations = create_pending_invitations!
|
|
106
|
+
create_completion!(completed_by:).tap do |completion|
|
|
107
|
+
invitations.each do |invitation|
|
|
108
|
+
completion.invitation_deliveries.create!(invitation:)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
completed.enqueue_pending_invitations if completed
|
|
114
|
+
completed
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
private
|
|
118
|
+
def transition_from(expected_step)
|
|
119
|
+
restore_attributes if has_changes_to_save?
|
|
120
|
+
|
|
121
|
+
with_lock do
|
|
122
|
+
errors.clear
|
|
123
|
+
unless step == expected_step
|
|
124
|
+
errors.add(:base, "This onboarding step is no longer current")
|
|
125
|
+
next false
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
yield
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def validate_invitation_plan
|
|
133
|
+
unless %w[planned skipped].include?(invitation_decision)
|
|
134
|
+
errors.add(:invitation_decision, "must continue or skip")
|
|
135
|
+
end
|
|
136
|
+
if invitation_decision == "planned" && invitee_emails.to_a.empty?
|
|
137
|
+
errors.add(:invitee_list, "must include at least one address or skip for now")
|
|
138
|
+
end
|
|
139
|
+
if invitee_emails.to_a.size > MAX_INVITEES
|
|
140
|
+
errors.add(:invitee_list, "cannot contain more than #{MAX_INVITEES} addresses")
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
invitee_emails.to_a.each do |email|
|
|
144
|
+
errors.add(:invitee_list, "contains an invalid address") unless URI::MailTo::EMAIL_REGEXP.match?(email)
|
|
145
|
+
errors.add(:invitee_list, "cannot include your own address") if email.casecmp?(started_by.team_email.to_s)
|
|
146
|
+
errors.add(:invitee_list, "already belongs to this team") if team.users.any? { _1.team_email.to_s.casecmp?(email) }
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
def validate_completion
|
|
151
|
+
errors.add(:workspace_name, :blank) if workspace_name.blank?
|
|
152
|
+
if company?
|
|
153
|
+
errors.add(:team_size, :inclusion) unless TEAM_SIZES.include?(team_size)
|
|
154
|
+
validate_invitation_plan
|
|
155
|
+
elsif personal?
|
|
156
|
+
errors.add(:primary_use, :inclusion) unless PRIMARY_USES.include?(primary_use)
|
|
157
|
+
else
|
|
158
|
+
errors.add(:branch, :inclusion)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def create_pending_invitations!
|
|
163
|
+
return [] unless invitation_decision == "planned"
|
|
164
|
+
|
|
165
|
+
invitee_emails.filter_map do |email|
|
|
166
|
+
invitation = team.invitations.find_or_initialize_by(email:)
|
|
167
|
+
next if invitation.persisted?
|
|
168
|
+
|
|
169
|
+
invitation.invited_by = started_by
|
|
170
|
+
invitation.save!
|
|
171
|
+
invitation
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Draw from config/routes.rb with: draw :onboarding
|
|
4
|
+
resource :onboarding, only: :show do
|
|
5
|
+
scope module: :onboarding do
|
|
6
|
+
resource :branch, only: :update
|
|
7
|
+
resource :details, only: :update
|
|
8
|
+
resource :invitation_plan, only: :update
|
|
9
|
+
resource :completion, only: :create
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
class CreateOnboarding < ActiveRecord::Migration[8.1]
|
|
2
|
+
def change
|
|
3
|
+
create_table :onboardings do |t|
|
|
4
|
+
t.references :team, null: false, foreign_key: true, index: { unique: true }
|
|
5
|
+
t.references :started_by, null: false, foreign_key: { to_table: :users }
|
|
6
|
+
t.string :branch
|
|
7
|
+
t.string :workspace_name
|
|
8
|
+
t.integer :team_size
|
|
9
|
+
t.string :primary_use
|
|
10
|
+
t.string :invitation_decision, null: false, default: "pending"
|
|
11
|
+
t.json :invitee_emails, null: false, default: []
|
|
12
|
+
t.datetime :details_completed_at
|
|
13
|
+
t.timestamps
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
create_table :onboarding_completions do |t|
|
|
17
|
+
t.references :onboarding, null: false, foreign_key: true, index: { unique: true }
|
|
18
|
+
t.references :completed_by, null: false, foreign_key: { to_table: :users }
|
|
19
|
+
t.timestamps
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
create_table :onboarding_invitation_deliveries do |t|
|
|
23
|
+
t.references :completion,
|
|
24
|
+
null: false,
|
|
25
|
+
foreign_key: { to_table: :onboarding_completions },
|
|
26
|
+
index: false
|
|
27
|
+
t.references :invitation,
|
|
28
|
+
null: false,
|
|
29
|
+
foreign_key: { on_delete: :cascade },
|
|
30
|
+
index: { unique: true }
|
|
31
|
+
t.datetime :delivered_at
|
|
32
|
+
t.timestamps
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
add_index :onboarding_invitation_deliveries, :completion_id,
|
|
36
|
+
name: "index_onboarding_deliveries_on_completion"
|
|
37
|
+
add_check_constraint :onboardings,
|
|
38
|
+
"branch IS NULL OR branch IN ('company', 'personal')",
|
|
39
|
+
name: "onboardings_branch"
|
|
40
|
+
add_check_constraint :onboardings,
|
|
41
|
+
"invitation_decision IN ('pending', 'planned', 'skipped')",
|
|
42
|
+
name: "onboardings_invitation_decision"
|
|
43
|
+
add_check_constraint :onboardings,
|
|
44
|
+
"team_size IS NULL OR team_size IN (1, 5, 20, 50)",
|
|
45
|
+
name: "onboardings_team_size"
|
|
46
|
+
add_check_constraint :onboardings,
|
|
47
|
+
"primary_use IS NULL OR primary_use IN ('projects', 'clients', 'personal')",
|
|
48
|
+
name: "onboardings_primary_use"
|
|
49
|
+
add_check_constraint :onboardings,
|
|
50
|
+
<<~SQL.squish,
|
|
51
|
+
details_completed_at IS NULL OR (
|
|
52
|
+
workspace_name IS NOT NULL AND (
|
|
53
|
+
(branch = 'company' AND team_size IS NOT NULL) OR
|
|
54
|
+
(branch = 'personal' AND primary_use IS NOT NULL)
|
|
55
|
+
)
|
|
56
|
+
)
|
|
57
|
+
SQL
|
|
58
|
+
name: "onboardings_completed_details"
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class OnboardingControllerFlowTest < ActionDispatch::IntegrationTest
|
|
4
|
+
setup do
|
|
5
|
+
sign_in users(:owner), team: teams(:new_workspace)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
test "advances company setup and resumes the derived step" do
|
|
9
|
+
patch onboarding_branch_path, params: { onboarding: { branch: "company" } }
|
|
10
|
+
assert_redirected_to onboarding_path
|
|
11
|
+
|
|
12
|
+
patch onboarding_details_path, params: {
|
|
13
|
+
onboarding: { workspace_name: "27 Seagulls", team_size: 20 }
|
|
14
|
+
}
|
|
15
|
+
assert_redirected_to onboarding_path
|
|
16
|
+
|
|
17
|
+
get onboarding_path
|
|
18
|
+
assert_response :success
|
|
19
|
+
assert_select "h1", text: "Invite teammates"
|
|
20
|
+
assert_select "input[value='27 Seagulls']", count: 0
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
test "invalid details render 422 without advancing" do
|
|
24
|
+
onboarding = onboardings(:new_workspace)
|
|
25
|
+
onboarding.choose_branch("company")
|
|
26
|
+
|
|
27
|
+
patch onboarding_details_path, params: {
|
|
28
|
+
onboarding: { workspace_name: "", team_size: 7 }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
assert_response :unprocessable_entity
|
|
32
|
+
assert_equal :details, onboarding.reload.step
|
|
33
|
+
assert_select "[data-nk='alert']", text: /review this step/i
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
test "skip persists and repeated completion has one handoff" do
|
|
37
|
+
onboarding = onboardings(:ready_for_invitations)
|
|
38
|
+
|
|
39
|
+
patch onboarding_invitation_plan_path, params: {
|
|
40
|
+
onboarding: { invitation_decision: "skipped", invitee_list: "ignored@example.test" }
|
|
41
|
+
}
|
|
42
|
+
assert_redirected_to onboarding_path
|
|
43
|
+
|
|
44
|
+
assert_difference "Onboarding::Completion.count", 1 do
|
|
45
|
+
post onboarding_completion_path
|
|
46
|
+
assert_response :see_other
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
assert_no_difference "Onboarding::Completion.count" do
|
|
50
|
+
post onboarding_completion_path
|
|
51
|
+
assert_response :see_other
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "non-manager cannot mutate onboarding" do
|
|
56
|
+
sign_in users(:member), team: teams(:new_workspace)
|
|
57
|
+
|
|
58
|
+
patch onboarding_branch_path, params: { onboarding: { branch: "company" } }
|
|
59
|
+
|
|
60
|
+
assert_response :forbidden
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
new_workspace:
|
|
2
|
+
team: new_workspace
|
|
3
|
+
started_by: owner
|
|
4
|
+
invitation_decision: pending
|
|
5
|
+
invitee_emails: []
|
|
6
|
+
|
|
7
|
+
ready_for_invitations:
|
|
8
|
+
team: another_new_workspace
|
|
9
|
+
started_by: owner
|
|
10
|
+
branch: company
|
|
11
|
+
workspace_name: 27 Seagulls
|
|
12
|
+
team_size: 20
|
|
13
|
+
invitation_decision: pending
|
|
14
|
+
invitee_emails: []
|
|
15
|
+
details_completed_at: <%= 1.minute.ago %>
|
|
16
|
+
|
|
17
|
+
finished:
|
|
18
|
+
team: established
|
|
19
|
+
started_by: owner
|
|
20
|
+
branch: personal
|
|
21
|
+
workspace_name: Existing workspace
|
|
22
|
+
primary_use: projects
|
|
23
|
+
invitation_decision: pending
|
|
24
|
+
invitee_emails: []
|
|
25
|
+
details_completed_at: <%= 1.day.ago %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class OnboardingInvitationDeliveryJobTest < ActiveJob::TestCase
|
|
4
|
+
test "delivers a pending invitation once" do
|
|
5
|
+
delivery = onboarding_completions(:finished).invitation_deliveries.create!(
|
|
6
|
+
invitation: invitations(:pending)
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
assert_emails 1 do
|
|
10
|
+
OnboardingInvitationDeliveryJob.perform_now(delivery.id)
|
|
11
|
+
end
|
|
12
|
+
assert delivery.reload.delivered?
|
|
13
|
+
|
|
14
|
+
assert_no_emails do
|
|
15
|
+
OnboardingInvitationDeliveryJob.perform_now(delivery.id)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
class OnboardingTest < ActiveSupport::TestCase
|
|
4
|
+
setup do
|
|
5
|
+
@user = users(:owner)
|
|
6
|
+
@team = teams(:new_workspace)
|
|
7
|
+
@onboarding = onboardings(:new_workspace)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
test "company progress is derived from persisted answers" do
|
|
11
|
+
assert_equal :branch, @onboarding.step
|
|
12
|
+
|
|
13
|
+
assert @onboarding.choose_branch("company")
|
|
14
|
+
assert_equal :details, @onboarding.reload.step
|
|
15
|
+
|
|
16
|
+
assert @onboarding.save_details(workspace_name: "27 Seagulls", team_size: 20)
|
|
17
|
+
assert_equal :invitations, @onboarding.reload.step
|
|
18
|
+
|
|
19
|
+
assert @onboarding.save_invitation_plan(decision: "skipped", invitee_list: "ignored@example.test")
|
|
20
|
+
assert_equal :review, @onboarding.reload.step
|
|
21
|
+
assert_empty @onboarding.invitee_emails
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
test "personal progress bypasses invitations" do
|
|
25
|
+
@onboarding.choose_branch("personal")
|
|
26
|
+
@onboarding.save_details(workspace_name: "Ada's workshop", primary_use: "projects")
|
|
27
|
+
|
|
28
|
+
assert_equal :review, @onboarding.reload.step
|
|
29
|
+
assert_equal %i[branch details review], @onboarding.steps
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
test "completion creates invitations and completion once" do
|
|
33
|
+
@onboarding.choose_branch("company")
|
|
34
|
+
@onboarding.save_details(workspace_name: "27 Seagulls", team_size: 5)
|
|
35
|
+
@onboarding.save_invitation_plan(
|
|
36
|
+
decision: "planned",
|
|
37
|
+
invitee_list: "grace@example.test\ngrace@example.test"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
assert_difference [
|
|
41
|
+
-> { Onboarding::Completion.count },
|
|
42
|
+
-> { Invitation.count },
|
|
43
|
+
-> { Onboarding::InvitationDelivery.count }
|
|
44
|
+
], 1 do
|
|
45
|
+
@completion = @onboarding.finish!(completed_by: @user)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
assert_no_difference [
|
|
49
|
+
-> { Onboarding::Completion.count },
|
|
50
|
+
-> { Invitation.count },
|
|
51
|
+
-> { Onboarding::InvitationDelivery.count }
|
|
52
|
+
] do
|
|
53
|
+
assert_equal @completion, @onboarding.finish!(completed_by: @user)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
test "existing teams without onboarding bypass setup" do
|
|
58
|
+
assert teams(:established).onboarding_finished?
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require "application_system_test_case"
|
|
2
|
+
|
|
3
|
+
class OnboardingSystemFlowTest < ApplicationSystemTestCase
|
|
4
|
+
test "company setup survives leaving and finishes in the application" do
|
|
5
|
+
sign_in users(:owner), team: teams(:new_workspace)
|
|
6
|
+
visit onboarding_path
|
|
7
|
+
|
|
8
|
+
choose "With a company or team"
|
|
9
|
+
click_on "Continue"
|
|
10
|
+
fill_in "Workspace name", with: "27 Seagulls"
|
|
11
|
+
select "6–20 people", from: "Expected team size"
|
|
12
|
+
click_on "Continue"
|
|
13
|
+
|
|
14
|
+
visit root_path
|
|
15
|
+
visit onboarding_path
|
|
16
|
+
assert_text "Invite teammates"
|
|
17
|
+
|
|
18
|
+
click_on "Skip for now"
|
|
19
|
+
assert_text "Invitations skipped"
|
|
20
|
+
click_on "Finish setup"
|
|
21
|
+
|
|
22
|
+
assert_current_path projects_path
|
|
23
|
+
assert_text "Workspace setup complete"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
test "personal setup bypasses invitations" do
|
|
27
|
+
sign_in users(:owner), team: teams(:new_workspace)
|
|
28
|
+
visit onboarding_path
|
|
29
|
+
|
|
30
|
+
choose "For personal work"
|
|
31
|
+
click_on "Continue"
|
|
32
|
+
fill_in "Workspace name", with: "Ada's workshop"
|
|
33
|
+
choose "Projects and tasks"
|
|
34
|
+
click_on "Continue"
|
|
35
|
+
|
|
36
|
+
assert_text "Review"
|
|
37
|
+
assert_no_text "Invite teammates"
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Resumable onboarding
|
|
2
|
+
|
|
3
|
+
## When to use
|
|
4
|
+
|
|
5
|
+
Use this pattern after authentication when a newly created team needs a short, durable setup flow before entering the application. It supports company and personal branches, saves every accepted step, derives the next step from persisted facts, and hands a completed team to the normal `UI::ApplicationShell`.
|
|
6
|
+
|
|
7
|
+
Accepted invitees bypass this flow. Their team already has a completed setup, so invitation acceptance creates the membership and redirects directly into the application without creating an onboarding record.
|
|
8
|
+
|
|
9
|
+
## Data model
|
|
10
|
+
|
|
11
|
+
Create one `Onboarding` with the new team and owner membership. Existing teams without an onboarding remain finished; this keeps installation additive. Never create onboarding lazily for every team.
|
|
12
|
+
|
|
13
|
+
Do not persist a current-step counter. The model derives `step` from branch, details completion, invitation decision, and the presence of a unique `Onboarding::Completion` record. This prevents contradictory progress such as a personal setup paused on company invitations.
|
|
14
|
+
|
|
15
|
+
- Company: branch → details → invitations → review.
|
|
16
|
+
- Personal: branch → details → review.
|
|
17
|
+
- Finished: completion exists.
|
|
18
|
+
|
|
19
|
+
Changing branch after details are saved is rejected rather than silently deleting branch-specific answers. Invitation decisions are explicit: `planned` stores normalized, deduplicated addresses; `skipped` stores an empty list. Reloading or signing in again therefore opens the exact same derived step.
|
|
20
|
+
|
|
21
|
+
## Completion
|
|
22
|
+
|
|
23
|
+
`Onboarding#finish!` locks the onboarding row, rechecks readiness against current membership, updates the team name, creates only missing pending invitations, and inserts one unique completion record in the same transaction. Each new invitation receives a unique transactional delivery record. A retryable job delivers pending records and marks them complete; replaying completion reschedules anything still pending instead of losing mail after a queue outage.
|
|
24
|
+
|
|
25
|
+
The unique completion index is the final concurrency boundary. Replayed or concurrent submissions return the same completion and cannot create another team, invitation, or delivery. Completion always redirects to one server-owned application path; it never accepts `return_to`.
|
|
26
|
+
|
|
27
|
+
## Team integration
|
|
28
|
+
|
|
29
|
+
The exemplar composes with `team-management`: `Team`, owner `Membership`, `Invitation#email`, and `invited_by`. If the host uses `email_address` and `inviter`, map those names in `create_pending_invitation!`; keep the onboarding transition unchanged.
|
|
30
|
+
|
|
31
|
+
Validate no more than 20 invitees, reject malformed addresses, the setup owner's address, and existing members. Reuse a pending invitation for the same team and address. Do not send invitation mail before completion.
|
|
32
|
+
|
|
33
|
+
Include `RequiresFinishedOnboarding` only in the authenticated application base controller. Do not include it in authentication or invitation controllers. A missing onboarding or a completion means the team is ready; an unfinished record redirects to `onboarding_path`.
|
|
34
|
+
|
|
35
|
+
## Rendering
|
|
36
|
+
|
|
37
|
+
Onboarding is authenticated but pre-application. Render one application-owned Card inside `NitroKit::AuthShell`, one `h1`, a semantic ordered progress list, and the active form. Use ordinary Turbo Drive, 422 validation responses, and 303 redirects. No client progress state, Turbo Frame, stream, or Stimulus controller is required.
|
|
38
|
+
|
|
39
|
+
Branch and optional-step choices are submitted values, not links or custom actions. The invitation form uses two submit buttons against the same resource: continue with normalized addresses or explicitly skip. Review uses `DetailsTable`; completion redirects to `projects_path` inside `UI::ApplicationShell` with the normal flash region. “Sign out and finish later” uses the authentication session resource so a guarded application root cannot loop straight back into onboarding.
|
|
40
|
+
|
|
41
|
+
## Adaptation
|
|
42
|
+
|
|
43
|
+
Draw the route fragment, include `Team::Onboardable`, and use `Team.start_onboarding_for!` when registration or additional-team creation provisions the owner membership. Override `finished_application_path` in `Onboarding::BaseController` if the host application does not enter through projects. Keep authorization scoped through `Current.team` and derive permission from that team’s membership for `Current.user`.
|
|
44
|
+
|
|
45
|
+
## Verification
|
|
46
|
+
|
|
47
|
+
- Exercise company, personal, resumed, explicit-skip, validation, completion, and invited-user bypass paths.
|
|
48
|
+
- Leave after every step, start a fresh browser session, and verify the derived step and submitted values remain.
|
|
49
|
+
- Reject forward/stale transitions without overwriting persisted answers.
|
|
50
|
+
- Submit completion twice and concurrently; assert one completion, stable invitation counts, and one delivery per new invitation.
|
|
51
|
+
- Prove existing pending invitations are reused and member/self/malformed addresses fail before completion.
|
|
52
|
+
- Verify invited users enter a team with no onboarding record and are not intercepted by the application guard.
|
|
53
|
+
- Browser-test Turbo 422 correction, keyboard progress, 390px layout, both appearances, and the final AppShell handoff.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Billing
|
|
5
|
+
class Base < Phlex::HTML
|
|
6
|
+
include NitroKit
|
|
7
|
+
include Phlex::Rails::Helpers::FormWith
|
|
8
|
+
include Phlex::Rails::Helpers::Routes
|
|
9
|
+
|
|
10
|
+
private
|
|
11
|
+
def render_status(message, variant: :success)
|
|
12
|
+
Alert(variant:) do |alert|
|
|
13
|
+
alert.title(message)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def status_label(subscription)
|
|
18
|
+
{
|
|
19
|
+
"active" => "Active",
|
|
20
|
+
"trialing" => "Trial",
|
|
21
|
+
"past_due" => "Past due",
|
|
22
|
+
"unpaid" => "Unpaid",
|
|
23
|
+
"paused" => "Paused",
|
|
24
|
+
"canceled" => "Canceled",
|
|
25
|
+
"incomplete" => "Processing",
|
|
26
|
+
"incomplete_expired" => "Expired"
|
|
27
|
+
}.fetch(subscription.status, subscription.status.humanize)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def status_color(subscription)
|
|
31
|
+
return :success if subscription.entitled? && !subscription.canceling?
|
|
32
|
+
return :warning if subscription.canceling? || subscription.recovery_required?
|
|
33
|
+
return :destructive if subscription.status == "canceled"
|
|
34
|
+
|
|
35
|
+
:neutral
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Billing
|
|
5
|
+
class CheckoutResult < Base
|
|
6
|
+
def initialize(session:, subscription:, shell: {})
|
|
7
|
+
@session = session
|
|
8
|
+
@subscription = subscription
|
|
9
|
+
@shell = shell
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def view_template
|
|
13
|
+
render Page.new(**@shell) do
|
|
14
|
+
Flex(dir: :col, gap: 6, align: :stretch) do
|
|
15
|
+
PageHeader(
|
|
16
|
+
title: result_title,
|
|
17
|
+
description: result_description,
|
|
18
|
+
level: 2
|
|
19
|
+
)
|
|
20
|
+
render_status(result_notice, variant: result_variant)
|
|
21
|
+
Flex(dir: :row) do
|
|
22
|
+
form_with(url: billing_path, method: :get) do
|
|
23
|
+
Button("View billing", type: :submit)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
def synchronized?
|
|
32
|
+
@session.status == "complete" && @subscription&.entitled?
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def result_title
|
|
36
|
+
return "Subscription active" if synchronized?
|
|
37
|
+
return "Confirming subscription" if @session.status == "complete"
|
|
38
|
+
|
|
39
|
+
"Checkout not completed"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def result_description
|
|
43
|
+
return "This workspace now has access to its subscribed plan." if synchronized?
|
|
44
|
+
return "Stripe completed Checkout; the verified webhook is still being applied." if @session.status == "complete"
|
|
45
|
+
|
|
46
|
+
"Return to billing when you are ready to choose a plan."
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def result_notice
|
|
50
|
+
return "Payment confirmed and subscription synchronized." if synchronized?
|
|
51
|
+
return "This page does not grant access. Refresh billing after webhook processing completes." if @session.status == "complete"
|
|
52
|
+
|
|
53
|
+
"No subscription change was made."
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def result_variant
|
|
57
|
+
return :success if synchronized?
|
|
58
|
+
return :info if @session.status == "complete"
|
|
59
|
+
|
|
60
|
+
:warning
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Billing
|
|
5
|
+
class Page < Base
|
|
6
|
+
def initialize(workspace: nil, identity: nil)
|
|
7
|
+
@workspace = workspace
|
|
8
|
+
@identity = identity
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def view_template(&content)
|
|
12
|
+
render UI::ApplicationShell.new(
|
|
13
|
+
title: "Subscription billing",
|
|
14
|
+
current: :billing,
|
|
15
|
+
navigation: application_navigation,
|
|
16
|
+
workspace: @workspace,
|
|
17
|
+
identity: @identity
|
|
18
|
+
) do
|
|
19
|
+
render(content)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def application_navigation
|
|
25
|
+
[
|
|
26
|
+
{ key: :projects, label: "Projects", href: projects_path, icon: :folder },
|
|
27
|
+
{ key: :team, label: "Team", href: teams_path, icon: :users },
|
|
28
|
+
{ key: :billing, label: "Billing", href: billing_path, icon: :credit_card }
|
|
29
|
+
]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|