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,188 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Uploads
|
|
5
|
+
class Index < Base
|
|
6
|
+
def initialize(
|
|
7
|
+
uploads:,
|
|
8
|
+
notice: nil,
|
|
9
|
+
alert: nil,
|
|
10
|
+
direct_upload: true,
|
|
11
|
+
stream: nil,
|
|
12
|
+
context_key: "preview",
|
|
13
|
+
shell: {}
|
|
14
|
+
)
|
|
15
|
+
@uploads = uploads
|
|
16
|
+
@notice = notice
|
|
17
|
+
@alert = alert
|
|
18
|
+
@direct_upload = direct_upload
|
|
19
|
+
@stream = stream
|
|
20
|
+
@context_key = context_key
|
|
21
|
+
@shell = shell
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def view_template
|
|
25
|
+
turbo_stream_from(@stream, :uploads) if @stream
|
|
26
|
+
render Page.new(**@shell) do
|
|
27
|
+
Flex(dir: :col, gap: 6, align: :stretch) do
|
|
28
|
+
PageHeader(
|
|
29
|
+
title: "Workspace images",
|
|
30
|
+
description: "Upload JPEG or PNG images. Processing finishes before an image becomes available.",
|
|
31
|
+
level: 2
|
|
32
|
+
)
|
|
33
|
+
render_notice
|
|
34
|
+
render_upload_form
|
|
35
|
+
render_uploads
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
def render_notice
|
|
42
|
+
message, variant = @alert ? [ @alert, :destructive ] : [ @notice, :success ]
|
|
43
|
+
return unless message
|
|
44
|
+
|
|
45
|
+
Alert(variant:) { |alert| alert.title(message) }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def render_upload_form
|
|
49
|
+
SettingsSection(
|
|
50
|
+
title: "Upload an image",
|
|
51
|
+
description: "Images stay private until server-side inspection succeeds.",
|
|
52
|
+
id: "workspace-image-upload-#{@context_key}",
|
|
53
|
+
data: { turbo_permanent: true, ui: "upload-form" }
|
|
54
|
+
) do |section|
|
|
55
|
+
section.form do
|
|
56
|
+
form_with(
|
|
57
|
+
scope: :upload,
|
|
58
|
+
url: uploads_path,
|
|
59
|
+
builder: NitroKit::FormBuilder,
|
|
60
|
+
multipart: true
|
|
61
|
+
) do |form|
|
|
62
|
+
form.group do
|
|
63
|
+
form.dropzone(
|
|
64
|
+
:file,
|
|
65
|
+
label: "Choose an image",
|
|
66
|
+
description: "One JPEG or PNG image, no larger than 10 MB.",
|
|
67
|
+
presentation: :minimal,
|
|
68
|
+
accept: Upload::ACCEPTED_CONTENT_TYPES.join(","),
|
|
69
|
+
max_bytes: Upload::MAX_BYTES,
|
|
70
|
+
direct_upload: @direct_upload,
|
|
71
|
+
required: true
|
|
72
|
+
)
|
|
73
|
+
Flex(dir: :row, justify: :end) do
|
|
74
|
+
form.submit("Upload image", data: { turbo_submits_with: "Queuing image…" })
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def render_uploads
|
|
83
|
+
DataSection(
|
|
84
|
+
title: "Recent uploads",
|
|
85
|
+
description: "Pending and processing files remain unavailable until server-side inspection succeeds."
|
|
86
|
+
) do |section|
|
|
87
|
+
if @uploads.empty?
|
|
88
|
+
section.empty_state NitroKit::EmptyState.new(
|
|
89
|
+
title: "No images uploaded",
|
|
90
|
+
description: "Choose an image above to create the first upload.",
|
|
91
|
+
variant: :borderless,
|
|
92
|
+
level: 3
|
|
93
|
+
) do |empty|
|
|
94
|
+
empty.icon NitroKit::Icon.new(:image)
|
|
95
|
+
end
|
|
96
|
+
else
|
|
97
|
+
section.table NitroKit::Table.new(data: { ui: "upload-table" }) do |table|
|
|
98
|
+
render_table(table)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def render_table(table)
|
|
105
|
+
table.caption("Workspace image uploads", data: { ui: "upload-caption" })
|
|
106
|
+
table.thead do
|
|
107
|
+
table.tr do
|
|
108
|
+
table.th("Image")
|
|
109
|
+
table.th("Size", data: { ui: "upload-optional-column" })
|
|
110
|
+
table.th("Uploaded by", data: { ui: "upload-optional-column" })
|
|
111
|
+
table.th("Status")
|
|
112
|
+
table.th("Actions")
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
table.tbody do
|
|
116
|
+
@uploads.each { |upload| render_upload(table, upload) }
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def render_upload(table, upload)
|
|
121
|
+
table.tr(
|
|
122
|
+
aria: { busy: upload.processing? ? true : nil },
|
|
123
|
+
data: { upload_state: upload.status }
|
|
124
|
+
) do
|
|
125
|
+
table.th(scope: :row, data: { ui: "upload-identity-cell" }) { render_identity(upload) }
|
|
126
|
+
table.td(formatted_size(upload.byte_size), data: { ui: "upload-optional-column" })
|
|
127
|
+
table.td(upload.user&.name || "Former member", data: { ui: "upload-optional-column" })
|
|
128
|
+
table.td(data: { ui: "upload-status-cell" }) do
|
|
129
|
+
div(
|
|
130
|
+
role: "status",
|
|
131
|
+
aria: {
|
|
132
|
+
live: "polite",
|
|
133
|
+
atomic: "true",
|
|
134
|
+
label: "#{upload.filename} status"
|
|
135
|
+
}
|
|
136
|
+
) do
|
|
137
|
+
Badge(status_label(upload), color: status_color(upload), size: :sm)
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
table.td(data: { ui: "upload-actions-cell" }) { render_actions(upload) }
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def render_identity(upload)
|
|
145
|
+
Flex(dir: :row, align: :center, gap: 3, data: { ui: "upload-identity" }) do
|
|
146
|
+
if upload.ready?
|
|
147
|
+
ProgressiveImage(
|
|
148
|
+
attachment: upload.file,
|
|
149
|
+
alt: "Preview of #{upload.filename}",
|
|
150
|
+
size: :sm,
|
|
151
|
+
data: { ui: "upload-thumbnail" }
|
|
152
|
+
)
|
|
153
|
+
else
|
|
154
|
+
span(data: { ui: "upload-placeholder" }) { Icon(:image) }
|
|
155
|
+
end
|
|
156
|
+
div do
|
|
157
|
+
span(data: { ui: "upload-filename" }) { upload.filename }
|
|
158
|
+
small(data: { ui: "upload-failure" }) { upload.failure_message } if upload.failed?
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def render_actions(upload)
|
|
164
|
+
Flex(dir: :row, gap: 2, justify: :end, wrap: :wrap, data: { ui: "upload-actions" }) do
|
|
165
|
+
if upload.retryable?
|
|
166
|
+
ButtonTo(
|
|
167
|
+
"Retry",
|
|
168
|
+
href: upload_retry_path(upload),
|
|
169
|
+
method: :post,
|
|
170
|
+
label: "Retry #{upload.filename}",
|
|
171
|
+
size: :sm,
|
|
172
|
+
variant: :primary
|
|
173
|
+
)
|
|
174
|
+
end
|
|
175
|
+
Dialog(id: "remove_upload_#{upload.id}") do |dialog|
|
|
176
|
+
dialog.trigger("Remove", label: "Remove #{upload.filename}", size: :sm)
|
|
177
|
+
dialog.panel(title: "Remove #{upload.filename}?", description: "This permanently removes the uploaded file.") do
|
|
178
|
+
Flex(dir: :row, gap: 2, justify: :end, wrap: :wrap) do
|
|
179
|
+
Button("Cancel", html: { command: "close", commandfor: "#{dialog.id}-panel" })
|
|
180
|
+
ButtonTo("Remove file", href: upload_path(upload), method: :delete, variant: :destructive)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
end
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module UI
|
|
4
|
+
module Uploads
|
|
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: "File uploads",
|
|
14
|
+
current: :uploads,
|
|
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: :uploads, label: "Uploads", href: uploads_path, icon: :upload }
|
|
29
|
+
]
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Uploads::BaseController < ApplicationController
|
|
4
|
+
before_action :require_upload_context
|
|
5
|
+
|
|
6
|
+
private
|
|
7
|
+
def require_upload_context
|
|
8
|
+
return if upload_member?
|
|
9
|
+
|
|
10
|
+
head :forbidden
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def upload_member?
|
|
14
|
+
return false unless Current.user && Current.team && Current.respond_to?(:membership)
|
|
15
|
+
|
|
16
|
+
membership = Current.membership
|
|
17
|
+
membership &&
|
|
18
|
+
membership.user_id == Current.user.id &&
|
|
19
|
+
membership.team_id == Current.team.id
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def current_team_uploads
|
|
23
|
+
Current.team.uploads
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def set_upload
|
|
27
|
+
@upload = current_team_uploads.find(params[:upload_id] || params[:id])
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Uploads::DirectUploadsController < Uploads::BaseController
|
|
4
|
+
InvalidBlobMetadata = Class.new(StandardError)
|
|
5
|
+
|
|
6
|
+
rate_limit to: 30, within: 1.minute, by: -> { Current.user&.id || request.remote_ip }
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
blob = ActiveStorage::Blob.create_before_direct_upload!(
|
|
10
|
+
**blob_attributes,
|
|
11
|
+
metadata: upload_metadata
|
|
12
|
+
)
|
|
13
|
+
blob.update!(analyzed: true)
|
|
14
|
+
|
|
15
|
+
render json: blob.as_json(root: false).merge(
|
|
16
|
+
signed_id: blob.signed_id(purpose: :file_upload_intake, expires_in: 2.hours),
|
|
17
|
+
direct_upload: {
|
|
18
|
+
url: blob.service_url_for_direct_upload,
|
|
19
|
+
headers: blob.service_headers_for_direct_upload
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
rescue ActionController::ParameterMissing, InvalidBlobMetadata => error
|
|
23
|
+
render json: { error: error.message }, status: :unprocessable_entity
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
def blob_attributes
|
|
28
|
+
attributes = params.expect(blob: %i[filename byte_size checksum content_type]).to_h.symbolize_keys
|
|
29
|
+
filename = attributes.fetch(:filename).to_s
|
|
30
|
+
checksum = attributes.fetch(:checksum).to_s
|
|
31
|
+
byte_size = Integer(attributes.fetch(:byte_size))
|
|
32
|
+
content_type = attributes.fetch(:content_type)
|
|
33
|
+
raise InvalidBlobMetadata, "Filename is required" if filename.blank?
|
|
34
|
+
raise InvalidBlobMetadata, "Filename is too long" if filename.bytesize > 255
|
|
35
|
+
raise InvalidBlobMetadata, "Checksum is required" if checksum.blank?
|
|
36
|
+
raise InvalidBlobMetadata, "Checksum is invalid" if checksum.bytesize > 128
|
|
37
|
+
raise InvalidBlobMetadata, "File is empty" unless byte_size.positive?
|
|
38
|
+
raise InvalidBlobMetadata, "File is larger than 10 MB" if byte_size > Upload::MAX_BYTES
|
|
39
|
+
unless content_type.in?(Upload::ACCEPTED_CONTENT_TYPES)
|
|
40
|
+
raise InvalidBlobMetadata, "File must be a JPEG or PNG image"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
attributes.merge(filename:, checksum:, byte_size:)
|
|
44
|
+
rescue KeyError, ArgumentError, TypeError => error
|
|
45
|
+
raise InvalidBlobMetadata, error.message
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def upload_metadata
|
|
49
|
+
{
|
|
50
|
+
upload_pattern: "file_uploads",
|
|
51
|
+
upload_team_id: Current.team.id.to_s,
|
|
52
|
+
upload_user_id: Current.user.id.to_s
|
|
53
|
+
}
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class Uploads::RetriesController < Uploads::BaseController
|
|
4
|
+
rate_limit to: 5, within: 1.hour, by: -> { Current.user&.id || request.remote_ip }
|
|
5
|
+
|
|
6
|
+
before_action :set_upload
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
@upload.retry!
|
|
10
|
+
redirect_to uploads_path, status: :see_other, notice: "Upload queued for another attempt."
|
|
11
|
+
rescue Upload::NotRetryable => error
|
|
12
|
+
redirect_to uploads_path, status: :see_other, alert: error.message
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UploadsController < Uploads::BaseController
|
|
4
|
+
rate_limit to: 10, within: 1.minute, by: -> { Current.user&.id || request.remote_ip }, only: :create
|
|
5
|
+
|
|
6
|
+
def index
|
|
7
|
+
render UI::Uploads::Index.new(
|
|
8
|
+
uploads: current_team_uploads.includes(file_attachment: :blob).recent_first,
|
|
9
|
+
notice:,
|
|
10
|
+
alert:,
|
|
11
|
+
stream: Current.team,
|
|
12
|
+
context_key: Current.team.id
|
|
13
|
+
)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def create
|
|
17
|
+
Upload.receive!(team: Current.team, user: Current.user, upload: upload_param)
|
|
18
|
+
redirect_to uploads_path, status: :see_other, notice: "Upload received and queued for processing."
|
|
19
|
+
rescue Upload::MissingFile,
|
|
20
|
+
Upload::FileTooLarge,
|
|
21
|
+
Upload::BlobAlreadyAttached,
|
|
22
|
+
Upload::BlobNotOwned,
|
|
23
|
+
ActiveSupport::MessageVerifier::InvalidSignature => error
|
|
24
|
+
redirect_to uploads_path, status: :see_other, alert: error.message
|
|
25
|
+
rescue ActiveRecord::RecordNotFound
|
|
26
|
+
redirect_to uploads_path,
|
|
27
|
+
status: :see_other,
|
|
28
|
+
alert: "Upload expired or no longer exists. Choose the file again."
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def destroy
|
|
32
|
+
current_team_uploads.find(params[:id]).destroy!
|
|
33
|
+
redirect_to uploads_path, status: :see_other, notice: "Upload removed."
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
def upload_param
|
|
38
|
+
params.dig(:upload, :file)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UploadBlobCleanupJob < ApplicationJob
|
|
4
|
+
retry_on StandardError, wait: :polynomially_longer, attempts: 5
|
|
5
|
+
|
|
6
|
+
def perform
|
|
7
|
+
ActiveStorage::Blob.unattached.where(created_at: ...24.hours.ago).find_each(&:purge_later)
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UploadRepairJob < ApplicationJob
|
|
4
|
+
retry_on StandardError, wait: :polynomially_longer, attempts: 5
|
|
5
|
+
|
|
6
|
+
def perform
|
|
7
|
+
pending_cutoff = 5.minutes.ago
|
|
8
|
+
processing_cutoff = 30.minutes.ago
|
|
9
|
+
|
|
10
|
+
Upload.pending.where(updated_at: ...pending_cutoff).find_each do |upload|
|
|
11
|
+
upload.repair!(expected_status: "pending", stale_before: pending_cutoff)
|
|
12
|
+
end
|
|
13
|
+
Upload.processing.where(processing_started_at: ...processing_cutoff).find_each do |upload|
|
|
14
|
+
upload.repair!(expected_status: "processing", stale_before: processing_cutoff)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|