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
data/patterns/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Nitro Kit patterns
|
|
2
|
+
|
|
3
|
+
Reference Rails application patterns built on Nitro Kit 2. Each directory
|
|
4
|
+
contains a `pattern.md` guide, `item.yml` metadata, and application-owned
|
|
5
|
+
reference files under `files/` that you adapt into your own Rails app.
|
|
6
|
+
|
|
7
|
+
| Pattern | Summary |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| [Account settings](account-settings/pattern.md) | Manage profile, preferences, password, browser sessions, and reviewed account deletion. |
|
|
10
|
+
| [Application shell](application-shell/pattern.md) | Give every authenticated route one responsive frame, one navigation tree, one page title, and one place for primary actions. |
|
|
11
|
+
| [Authentication and recovery](authentication/pattern.md) | Sign-in, email verification, password recovery, and safe return navigation for Rails. |
|
|
12
|
+
| [Canonical CRUD resource](crud-resource/pattern.md) | Build a team-scoped resource as one calm Rails workflow with URL-owned queries, one shared form, explicit lifecycle records, and reviewed deletion. |
|
|
13
|
+
| [Active Storage file uploads](file-uploads/pattern.md) | Accept direct or multipart image uploads, process them asynchronously, and expose authorized lifecycle, retry, removal, and cleanup workflows. |
|
|
14
|
+
| [Upgrade a Nitro Kit 1.x application](nitro-kit-1-upgrade/pattern.md) | Migrate behavior-first by inventorying copied Nitro Kit 1 surfaces, preserving unsupported application behavior, and verifying real wide and narrow workflows. |
|
|
15
|
+
| [Resumable onboarding](onboarding/pattern.md) | Persist branch-aware workspace setup, resume exact progress, and complete once before entering the application. |
|
|
16
|
+
| [Subscription billing with Stripe](subscription-billing/pattern.md) | Sell subscriptions through Stripe Checkout, synchronize state from verified webhooks, and hand self-service to the Customer Portal. |
|
|
17
|
+
| [Team management](team-management/pattern.md) | Grow a personal workspace into team membership and invitations while keeping roles explicit, ownership safe, and every query scoped to the current team. |
|
|
18
|
+
| [Webhook deliveries](webhook-deliveries/pattern.md) | Team-scoped signed webhook endpoints, attempts, bounded retries, replay, and delivery inspection. |
|
|
19
|
+
|
|
20
|
+
For lower-level component and Hotwire interaction recipes, see
|
|
21
|
+
[`docs/patterns/`](../docs/patterns/).
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
5
|
+
class AccountDeletion < Base
|
|
6
|
+
def initialize(closure, shell: {})
|
|
7
|
+
@closure = closure
|
|
8
|
+
@shell = shell
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def view_template
|
|
12
|
+
render Page.new(current: :profile, **@shell) do
|
|
13
|
+
DangerZone(
|
|
14
|
+
title: "Permanently delete account",
|
|
15
|
+
description: "This removes your profile and browser sessions. It cannot be undone."
|
|
16
|
+
) do |zone|
|
|
17
|
+
zone.confirmation { render_form }
|
|
18
|
+
zone.escape Button.new("Keep my account", href: settings_profile_path)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def render_form
|
|
25
|
+
Flex(dir: :col, gap: 6, align: :stretch) do
|
|
26
|
+
render_errors(@closure) if @closure.errors.any?
|
|
27
|
+
Alert do |alert|
|
|
28
|
+
alert.title("Review before continuing")
|
|
29
|
+
alert.description(
|
|
30
|
+
"Transfer sole-owned workspaces, settle subscriptions, and export anything you need first."
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
form_with(
|
|
34
|
+
model: @closure,
|
|
35
|
+
scope: :account_deletion,
|
|
36
|
+
url: settings_account_deletion_path,
|
|
37
|
+
method: :delete,
|
|
38
|
+
builder: NitroKit::FormBuilder
|
|
39
|
+
) do |form|
|
|
40
|
+
Flex(dir: :col, gap: 6, align: :stretch) do
|
|
41
|
+
form.fieldset(legend: "Confirm account deletion") do
|
|
42
|
+
form.group do
|
|
43
|
+
form.field(
|
|
44
|
+
:current_password,
|
|
45
|
+
as: :password,
|
|
46
|
+
label: "Current password",
|
|
47
|
+
autocomplete: "current-password",
|
|
48
|
+
required: true,
|
|
49
|
+
value: nil
|
|
50
|
+
)
|
|
51
|
+
form.field(
|
|
52
|
+
:confirmation,
|
|
53
|
+
label: "Type DELETE to confirm",
|
|
54
|
+
autocomplete: "off",
|
|
55
|
+
required: true
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
Flex(dir: :row) do
|
|
60
|
+
form.button(
|
|
61
|
+
"Delete account permanently",
|
|
62
|
+
variant: :destructive,
|
|
63
|
+
data: { turbo_submits_with: "Deleting…" }
|
|
64
|
+
)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
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 add_status(section, message, variant: :success)
|
|
12
|
+
section.status NitroKit::Alert.new(variant:) do |alert|
|
|
13
|
+
alert.title(message)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def add_errors(section, record)
|
|
18
|
+
section.status NitroKit::Alert.new(variant: :destructive) do |alert|
|
|
19
|
+
alert.title("Check the highlighted fields")
|
|
20
|
+
alert.description(record.errors.full_messages.to_sentence)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def render_status(message, variant: :success)
|
|
25
|
+
Alert(variant:) do |alert|
|
|
26
|
+
alert.title(message)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def render_errors(record)
|
|
31
|
+
Alert(variant: :destructive) do |alert|
|
|
32
|
+
alert.title("Check the highlighted fields")
|
|
33
|
+
alert.description(record.errors.full_messages.to_sentence)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def submit_toolbar(&block)
|
|
38
|
+
Toolbar do |toolbar|
|
|
39
|
+
toolbar.leading(&block)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
5
|
+
class Page < Base
|
|
6
|
+
SECTIONS = {
|
|
7
|
+
profile: [ "Profile", :user_round ],
|
|
8
|
+
security: [ "Security", :shield_check ],
|
|
9
|
+
preferences: [ "Preferences", :sliders_horizontal ],
|
|
10
|
+
sessions: [ "Sessions", :monitor_smartphone ]
|
|
11
|
+
}.freeze
|
|
12
|
+
|
|
13
|
+
def initialize(current:, workspace: nil, identity: nil)
|
|
14
|
+
@current = current
|
|
15
|
+
@workspace = workspace
|
|
16
|
+
@identity = identity
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def view_template(&content)
|
|
20
|
+
render UI::ApplicationShell.new(
|
|
21
|
+
title: "Account settings",
|
|
22
|
+
current: :settings,
|
|
23
|
+
navigation: application_navigation,
|
|
24
|
+
workspace: @workspace,
|
|
25
|
+
identity: @identity
|
|
26
|
+
) do
|
|
27
|
+
SettingsLayout(id: "account-settings") do |layout|
|
|
28
|
+
layout.navigation(label: "Account settings sections") do
|
|
29
|
+
SECTIONS.each do |key, (label, icon)|
|
|
30
|
+
layout.item(label, href: section_path(key), icon:, current: key == @current)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
layout.content { render(content) }
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
def application_navigation
|
|
40
|
+
[
|
|
41
|
+
{ key: :projects, label: "Projects", href: projects_path, icon: :folder },
|
|
42
|
+
{ key: :team, label: "Team", href: teams_path, icon: :users },
|
|
43
|
+
{ key: :settings, label: "Settings", href: settings_profile_path, icon: :settings }
|
|
44
|
+
]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def section_path(section)
|
|
48
|
+
case section
|
|
49
|
+
when :profile then settings_profile_path
|
|
50
|
+
when :security then settings_security_path
|
|
51
|
+
when :preferences then settings_preferences_path
|
|
52
|
+
when :sessions then settings_sessions_path
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
5
|
+
class Preferences < Base
|
|
6
|
+
def initialize(user, notice: nil, shell: {})
|
|
7
|
+
@user = user
|
|
8
|
+
@notice = notice
|
|
9
|
+
@shell = shell
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def view_template
|
|
13
|
+
render Page.new(current: :preferences, **@shell) do
|
|
14
|
+
SettingsSection(
|
|
15
|
+
title: "Preferences",
|
|
16
|
+
description: "Personal choices that follow your account across workspaces."
|
|
17
|
+
) do |section|
|
|
18
|
+
add_status(section, @notice) if @notice
|
|
19
|
+
add_errors(section, @user) if @user.errors.any?
|
|
20
|
+
section.form do
|
|
21
|
+
form_with(
|
|
22
|
+
model: @user,
|
|
23
|
+
url: settings_preferences_path,
|
|
24
|
+
method: :patch,
|
|
25
|
+
builder: NitroKit::FormBuilder
|
|
26
|
+
) do |form|
|
|
27
|
+
form.fieldset(
|
|
28
|
+
legend: "Interface and communication",
|
|
29
|
+
description: "System appearance follows your device's light or dark setting."
|
|
30
|
+
) do
|
|
31
|
+
form.group do
|
|
32
|
+
form.field(
|
|
33
|
+
:appearance,
|
|
34
|
+
as: :radio_group,
|
|
35
|
+
label: "Appearance",
|
|
36
|
+
options: [
|
|
37
|
+
[ "Use system setting", "system" ],
|
|
38
|
+
[ "Light", "light" ],
|
|
39
|
+
[ "Dark", "dark" ]
|
|
40
|
+
],
|
|
41
|
+
required: true
|
|
42
|
+
)
|
|
43
|
+
form.field(
|
|
44
|
+
:locale,
|
|
45
|
+
as: :select,
|
|
46
|
+
label: "Language",
|
|
47
|
+
options: [ [ "English", "en" ], [ "Dansk", "da" ], [ "Deutsch", "de" ] ],
|
|
48
|
+
required: true
|
|
49
|
+
)
|
|
50
|
+
form.field(
|
|
51
|
+
:email_notifications,
|
|
52
|
+
as: :switch,
|
|
53
|
+
label: "Email notifications",
|
|
54
|
+
description: "Receive product and workspace activity. Security notices are always sent."
|
|
55
|
+
)
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
submit_toolbar do
|
|
59
|
+
form.submit("Save preferences", data: { turbo_submits_with: "Saving…" })
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
5
|
+
class Profile < Base
|
|
6
|
+
TIME_ZONES = ActiveSupport::TimeZone.all.map { |zone| [ zone.to_s, zone.name ] }.freeze
|
|
7
|
+
|
|
8
|
+
def initialize(user, notice: nil, shell: {})
|
|
9
|
+
@user = user
|
|
10
|
+
@notice = notice
|
|
11
|
+
@shell = shell
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def view_template
|
|
15
|
+
render Page.new(current: :profile, **@shell) do
|
|
16
|
+
Flex(dir: :col, gap: 8, align: :stretch) do
|
|
17
|
+
render_profile_form
|
|
18
|
+
render_deletion_entry
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def render_profile_form
|
|
25
|
+
SettingsSection(
|
|
26
|
+
title: "Profile",
|
|
27
|
+
description: "Personal details shown across your workspaces."
|
|
28
|
+
) do |section|
|
|
29
|
+
add_status(section, @notice) if @notice
|
|
30
|
+
add_errors(section, @user) if @user.errors.any?
|
|
31
|
+
section.form do
|
|
32
|
+
form_with(
|
|
33
|
+
model: @user,
|
|
34
|
+
url: settings_profile_path,
|
|
35
|
+
method: :patch,
|
|
36
|
+
builder: NitroKit::FormBuilder
|
|
37
|
+
) do |form|
|
|
38
|
+
Flex(dir: :col, gap: 4, align: :stretch) do
|
|
39
|
+
form.fieldset(
|
|
40
|
+
legend: "Personal details",
|
|
41
|
+
description: "Your email address changes only through the verified-address flow."
|
|
42
|
+
) do
|
|
43
|
+
form.group do
|
|
44
|
+
form.field(:name, label: "Name", autocomplete: "name", required: true)
|
|
45
|
+
form.field(
|
|
46
|
+
:email_address,
|
|
47
|
+
as: :email,
|
|
48
|
+
label: "Email address",
|
|
49
|
+
description: "Contact support or use your verified-address flow to change this.",
|
|
50
|
+
autocomplete: "email",
|
|
51
|
+
disabled: true
|
|
52
|
+
)
|
|
53
|
+
form.field(
|
|
54
|
+
:time_zone,
|
|
55
|
+
as: :select,
|
|
56
|
+
label: "Time zone",
|
|
57
|
+
options: TIME_ZONES,
|
|
58
|
+
required: true
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
submit_toolbar do
|
|
63
|
+
form.submit("Save profile", data: { turbo_submits_with: "Saving…" })
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def render_deletion_entry
|
|
72
|
+
DangerZone(
|
|
73
|
+
title: "Delete account",
|
|
74
|
+
description: "Permanently remove your account after reviewing affected access and data."
|
|
75
|
+
) do |zone|
|
|
76
|
+
zone.confirmation do
|
|
77
|
+
Button(
|
|
78
|
+
"Review account deletion",
|
|
79
|
+
href: settings_account_deletion_path
|
|
80
|
+
)
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
5
|
+
class Security < Base
|
|
6
|
+
def initialize(password_change, notice: nil, shell: {})
|
|
7
|
+
@password_change = password_change
|
|
8
|
+
@notice = notice
|
|
9
|
+
@shell = shell
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def view_template
|
|
13
|
+
render Page.new(current: :security, **@shell) do
|
|
14
|
+
SettingsSection(
|
|
15
|
+
title: "Password",
|
|
16
|
+
description: "Updating your password signs out every other browser session."
|
|
17
|
+
) do |section|
|
|
18
|
+
add_status(section, @notice) if @notice
|
|
19
|
+
add_errors(section, @password_change) if @password_change.errors.any?
|
|
20
|
+
section.form do
|
|
21
|
+
form_with(
|
|
22
|
+
model: @password_change,
|
|
23
|
+
scope: :security,
|
|
24
|
+
url: settings_security_path,
|
|
25
|
+
method: :patch,
|
|
26
|
+
builder: NitroKit::FormBuilder
|
|
27
|
+
) do |form|
|
|
28
|
+
form.fieldset(
|
|
29
|
+
legend: "Change password",
|
|
30
|
+
description: "Use at least 12 characters and avoid passwords used elsewhere."
|
|
31
|
+
) do
|
|
32
|
+
form.group do
|
|
33
|
+
form.field(
|
|
34
|
+
:current_password,
|
|
35
|
+
as: :password,
|
|
36
|
+
label: "Current password",
|
|
37
|
+
autocomplete: "current-password",
|
|
38
|
+
required: true,
|
|
39
|
+
value: nil
|
|
40
|
+
)
|
|
41
|
+
form.field(
|
|
42
|
+
:password,
|
|
43
|
+
as: :password,
|
|
44
|
+
label: "New password",
|
|
45
|
+
autocomplete: "new-password",
|
|
46
|
+
required: true,
|
|
47
|
+
value: nil
|
|
48
|
+
)
|
|
49
|
+
form.field(
|
|
50
|
+
:password_confirmation,
|
|
51
|
+
as: :password,
|
|
52
|
+
label: "Confirm new password",
|
|
53
|
+
autocomplete: "new-password",
|
|
54
|
+
required: true,
|
|
55
|
+
value: nil
|
|
56
|
+
)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
submit_toolbar do
|
|
60
|
+
form.submit("Update password", data: { turbo_submits_with: "Updating…" })
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module AccountSettings
|
|
5
|
+
class Sessions < Base
|
|
6
|
+
def initialize(sessions, notice: nil, alert: nil, shell: {})
|
|
7
|
+
@sessions = sessions
|
|
8
|
+
@notice = notice
|
|
9
|
+
@alert = alert
|
|
10
|
+
@shell = shell
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def view_template
|
|
14
|
+
render Page.new(current: :sessions, **@shell) do
|
|
15
|
+
Flex(dir: :col, gap: 6, align: :stretch) do
|
|
16
|
+
render_status(@notice) if @notice
|
|
17
|
+
render_status(@alert, variant: :warning) if @alert
|
|
18
|
+
render_sessions
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def render_sessions
|
|
25
|
+
DataSection(
|
|
26
|
+
title: "Browser sessions",
|
|
27
|
+
description: "Review browsers signed in to your account and revoke anything unfamiliar."
|
|
28
|
+
) do |section|
|
|
29
|
+
if other_sessions.any?
|
|
30
|
+
section.actions Button.new(
|
|
31
|
+
"Revoke all others",
|
|
32
|
+
type: :submit,
|
|
33
|
+
form: "revoke-other-sessions",
|
|
34
|
+
variant: :default
|
|
35
|
+
)
|
|
36
|
+
end
|
|
37
|
+
section.table Table.new do |table|
|
|
38
|
+
table.caption("Signed-in browser sessions")
|
|
39
|
+
table.thead do
|
|
40
|
+
table.tr do
|
|
41
|
+
table.th("Browser")
|
|
42
|
+
table.th("IP address")
|
|
43
|
+
table.th("Last active")
|
|
44
|
+
table.th("Action", align: :right)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
table.tbody do
|
|
48
|
+
@sessions.each { |session| render_session(table, session) }
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
form_with(
|
|
53
|
+
url: settings_other_sessions_path,
|
|
54
|
+
method: :delete,
|
|
55
|
+
id: "revoke-other-sessions"
|
|
56
|
+
) { }
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def render_session(table, session)
|
|
60
|
+
table.tr do
|
|
61
|
+
table.th(scope: :row) do
|
|
62
|
+
Flex(dir: :col, gap: 1, align: :start) do
|
|
63
|
+
plain(session.label)
|
|
64
|
+
Badge("Current", size: :sm, color: :success) if session.current?
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
table.td(session.ip_address)
|
|
68
|
+
table.td(session.last_active_at.strftime("%Y-%m-%d %H:%M UTC"))
|
|
69
|
+
table.td(align: :right) do
|
|
70
|
+
if session.current?
|
|
71
|
+
Button("Current session", size: :sm, disabled: true)
|
|
72
|
+
else
|
|
73
|
+
form_with(url: settings_session_path(session.id), method: :delete) do
|
|
74
|
+
Button("Revoke", type: :submit, size: :sm)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def other_sessions
|
|
82
|
+
@sessions.reject(&:current?)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Settings::AccountDeletionsController < Settings::BaseController
|
|
4
|
+
before_action :ensure_account_deletion_allowed
|
|
5
|
+
|
|
6
|
+
def show
|
|
7
|
+
render_deletion AccountSettings::AccountClosure.new(user: Current.user)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def destroy
|
|
11
|
+
closure = AccountSettings::AccountClosure.new(user: Current.user, **deletion_params)
|
|
12
|
+
|
|
13
|
+
if closure.save
|
|
14
|
+
Current.session = nil
|
|
15
|
+
cookies.delete(:session_id)
|
|
16
|
+
reset_session
|
|
17
|
+
redirect_to new_session_path, status: :see_other, notice: "Your account was deleted."
|
|
18
|
+
else
|
|
19
|
+
render_deletion closure, status: :unprocessable_entity
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
def deletion_params
|
|
25
|
+
params.expect(account_deletion: %i[current_password confirmation]).to_h.symbolize_keys
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def ensure_account_deletion_allowed
|
|
29
|
+
head :forbidden unless account_deletion_allowed?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def render_deletion(closure, status: :ok)
|
|
33
|
+
render_settings UI::AccountSettings::AccountDeletion.new(closure), status:
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Settings::OtherSessionsController < Settings::BaseController
|
|
4
|
+
def destroy
|
|
5
|
+
Current.user.sessions.where.not(id: Current.session&.id).destroy_all
|
|
6
|
+
redirect_to settings_sessions_path, status: :see_other, notice: "Other browser sessions revoked."
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Settings::PreferencesController < Settings::BaseController
|
|
4
|
+
def show
|
|
5
|
+
render_preferences
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def update
|
|
9
|
+
if Current.user.update(preference_params)
|
|
10
|
+
redirect_to settings_preferences_path, status: :see_other, notice: "Preferences saved."
|
|
11
|
+
else
|
|
12
|
+
render_preferences status: :unprocessable_entity
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
def preference_params
|
|
18
|
+
params.expect(user: %i[appearance locale email_notifications])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def render_preferences(status: :ok)
|
|
22
|
+
render_settings UI::AccountSettings::Preferences.new(
|
|
23
|
+
Current.user,
|
|
24
|
+
notice: flash[:notice]
|
|
25
|
+
), status:
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Settings::ProfilesController < Settings::BaseController
|
|
4
|
+
def show
|
|
5
|
+
render_settings UI::AccountSettings::Profile.new(Current.user, notice: flash[:notice])
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def update
|
|
9
|
+
if Current.user.update(profile_params)
|
|
10
|
+
redirect_to settings_profile_path, status: :see_other, notice: "Profile saved."
|
|
11
|
+
else
|
|
12
|
+
render_settings UI::AccountSettings::Profile.new(Current.user), status: :unprocessable_entity
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
private
|
|
17
|
+
def profile_params
|
|
18
|
+
params.expect(user: %i[name time_zone])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Settings::SecuritiesController < Settings::BaseController
|
|
4
|
+
def show
|
|
5
|
+
render_security AccountSettings::PasswordChange.new(
|
|
6
|
+
user: Current.user,
|
|
7
|
+
current_session: Current.session
|
|
8
|
+
)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def update
|
|
12
|
+
password_change = AccountSettings::PasswordChange.new(
|
|
13
|
+
user: Current.user,
|
|
14
|
+
current_session: Current.session,
|
|
15
|
+
**security_params
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
if password_change.save
|
|
19
|
+
redirect_to settings_security_path, status: :see_other,
|
|
20
|
+
notice: "Password updated. Other browser sessions were signed out."
|
|
21
|
+
else
|
|
22
|
+
render_security password_change, status: :unprocessable_entity
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
def security_params
|
|
28
|
+
params.expect(security: %i[current_password password password_confirmation]).to_h.symbolize_keys
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def render_security(password_change, status: :ok)
|
|
32
|
+
render_settings UI::AccountSettings::Security.new(
|
|
33
|
+
password_change,
|
|
34
|
+
notice: flash[:notice]
|
|
35
|
+
), status:
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Settings::SessionsController < Settings::BaseController
|
|
4
|
+
def index
|
|
5
|
+
render_sessions
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def destroy
|
|
9
|
+
session = Current.user.sessions.find(params[:id])
|
|
10
|
+
|
|
11
|
+
if session == Current.session
|
|
12
|
+
redirect_to settings_sessions_path, status: :see_other,
|
|
13
|
+
alert: "Sign out normally to end this browser session."
|
|
14
|
+
else
|
|
15
|
+
session.destroy!
|
|
16
|
+
redirect_to settings_sessions_path, status: :see_other, notice: "Browser session revoked."
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
def render_sessions
|
|
22
|
+
summaries = Current.user.sessions.order(updated_at: :desc).map do |session|
|
|
23
|
+
AccountSettings::SessionSummary.new(session, current_session: Current.session)
|
|
24
|
+
end
|
|
25
|
+
render_settings UI::AccountSettings::Sessions.new(
|
|
26
|
+
summaries,
|
|
27
|
+
notice: flash[:notice],
|
|
28
|
+
alert: flash[:alert]
|
|
29
|
+
)
|
|
30
|
+
end
|
|
31
|
+
end
|