vibecarbon 0.1.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.
- package/LICENSE +663 -0
- package/README.md +188 -0
- package/carbon/.claude/hooks/task-completed-gate.sh +19 -0
- package/carbon/.claude/hooks/teammate-idle-gate.sh +29 -0
- package/carbon/.claude/settings.json +29 -0
- package/carbon/.cursor/rules/vibecarbon.mdc +6 -0
- package/carbon/.dockerignore +57 -0
- package/carbon/.env.example +219 -0
- package/carbon/.github/copilot-instructions.md +3 -0
- package/carbon/.github/workflows/deploy.yml +346 -0
- package/carbon/.github/workflows/vibecarbon-build.yml +81 -0
- package/carbon/.windsurfrules +74 -0
- package/carbon/AGENTS.md +422 -0
- package/carbon/CLAUDE.md +3 -0
- package/carbon/DEVELOPMENT.md +187 -0
- package/carbon/Dockerfile +98 -0
- package/carbon/LICENSE +21 -0
- package/carbon/PRODUCTION.md +364 -0
- package/carbon/README.md +193 -0
- package/carbon/TESTING.md +138 -0
- package/carbon/backup/Dockerfile +75 -0
- package/carbon/backup/backup.sh +95 -0
- package/carbon/backup/compose-backup.sh +140 -0
- package/carbon/biome.json +83 -0
- package/carbon/cloud-init/docker-ce-setup.yaml +55 -0
- package/carbon/cloud-init/k3s/master-init.sh +215 -0
- package/carbon/cloud-init/k3s/supabase-init.sh +167 -0
- package/carbon/cloud-init/k3s/worker-init.sh +147 -0
- package/carbon/components.json +24 -0
- package/carbon/content/blog/authentication-guide.mdx +34 -0
- package/carbon/content/blog/getting-started.mdx +41 -0
- package/carbon/content/changelog/v0-1-0.mdx +40 -0
- package/carbon/content/docs/analytics.mdx +90 -0
- package/carbon/content/docs/authentication.mdx +231 -0
- package/carbon/content/docs/background-jobs.mdx +116 -0
- package/carbon/content/docs/cli.mdx +630 -0
- package/carbon/content/docs/database.mdx +236 -0
- package/carbon/content/docs/deployment.mdx +227 -0
- package/carbon/content/docs/development.mdx +238 -0
- package/carbon/content/docs/environments.mdx +84 -0
- package/carbon/content/docs/getting-started.mdx +112 -0
- package/carbon/content/docs/legal/privacy-policy.mdx +89 -0
- package/carbon/content/docs/legal/terms-of-service.mdx +99 -0
- package/carbon/content/docs/optional-services.mdx +160 -0
- package/carbon/db/Dockerfile +23 -0
- package/carbon/docker-compose.dev-init.yml +5 -0
- package/carbon/docker-compose.metabase.override.yml +14 -0
- package/carbon/docker-compose.metabase.prod.yml +28 -0
- package/carbon/docker-compose.metabase.yml +84 -0
- package/carbon/docker-compose.n8n.override.yml +14 -0
- package/carbon/docker-compose.n8n.prod.yml +31 -0
- package/carbon/docker-compose.n8n.yml +97 -0
- package/carbon/docker-compose.observability.override.yml +18 -0
- package/carbon/docker-compose.observability.prod.yml +28 -0
- package/carbon/docker-compose.observability.yml +125 -0
- package/carbon/docker-compose.override.yml +28 -0
- package/carbon/docker-compose.prod.yml +294 -0
- package/carbon/docker-compose.yml +508 -0
- package/carbon/docker-entrypoint.sh +12 -0
- package/carbon/ha/activate-standby.sh +52 -0
- package/carbon/ha/primary-init.sql +36 -0
- package/carbon/ha/standby-init.sh +74 -0
- package/carbon/k8s/LICENSE +99 -0
- package/carbon/k8s/README.md +272 -0
- package/carbon/k8s/base/app/deployment.yaml +130 -0
- package/carbon/k8s/base/app/hpa.yaml +44 -0
- package/carbon/k8s/base/app/kustomization.yaml +10 -0
- package/carbon/k8s/base/app/network-policy.yaml +124 -0
- package/carbon/k8s/base/app/pdb.yaml +14 -0
- package/carbon/k8s/base/app/rbac.yaml +36 -0
- package/carbon/k8s/base/app/service.yaml +16 -0
- package/carbon/k8s/base/backup/cronjob.yaml +120 -0
- package/carbon/k8s/base/backup/kustomization.yaml +7 -0
- package/carbon/k8s/base/backup/network-policy.yaml +31 -0
- package/carbon/k8s/base/backup/rbac.yaml +7 -0
- package/carbon/k8s/base/cluster-autoscaler/deployment.yaml +103 -0
- package/carbon/k8s/base/cluster-autoscaler/kustomization.yaml +17 -0
- package/carbon/k8s/base/cluster-autoscaler/rbac.yaml +109 -0
- package/carbon/k8s/base/config/configmap.yaml +48 -0
- package/carbon/k8s/base/config/kustomization.yaml +8 -0
- package/carbon/k8s/base/hetzner-ccm/kustomization.yaml +9 -0
- package/carbon/k8s/base/hetzner-csi/kustomization.yaml +9 -0
- package/carbon/k8s/base/kustomization.yaml +43 -0
- package/carbon/k8s/base/namespace.yaml +7 -0
- package/carbon/k8s/base/network-policies.yaml +95 -0
- package/carbon/k8s/base/registry/kustomization.yaml +5 -0
- package/carbon/k8s/base/registry/local-registry.yaml +193 -0
- package/carbon/k8s/base/traefik/certificate.yaml +21 -0
- package/carbon/k8s/base/traefik/configmap.yaml +13 -0
- package/carbon/k8s/base/traefik/deployment.yaml +165 -0
- package/carbon/k8s/base/traefik/ingressroute.yaml +141 -0
- package/carbon/k8s/base/traefik/kustomization.yaml +11 -0
- package/carbon/k8s/base/traefik/middleware.yaml +109 -0
- package/carbon/k8s/base/traefik/network-policy.yaml +92 -0
- package/carbon/k8s/base/traefik/service.yaml +38 -0
- package/carbon/k8s/flux/README.md +49 -0
- package/carbon/k8s/flux/clusters/primary/vibecarbon.yaml +128 -0
- package/carbon/k8s/flux/clusters/standby/vibecarbon.yaml +83 -0
- package/carbon/k8s/gitops/cert-manager-webhook-hetzner/helm-release.yaml +38 -0
- package/carbon/k8s/gitops/cert-manager-webhook-hetzner/helm-repository.yaml +16 -0
- package/carbon/k8s/gitops/cert-manager-webhook-hetzner/kustomization.yaml +10 -0
- package/carbon/k8s/gitops/supabase/helm-release.yaml +66 -0
- package/carbon/k8s/gitops/supabase/helm-repository.yaml +18 -0
- package/carbon/k8s/gitops/supabase/kustomization.yaml +33 -0
- package/carbon/k8s/infra/cert-manager-resources/cluster-issuers-cloudflare.yaml +51 -0
- package/carbon/k8s/infra/cert-manager-resources/cluster-issuers-hetzner.yaml +59 -0
- package/carbon/k8s/infra/cert-manager-resources/cluster-issuers-manual.yaml +43 -0
- package/carbon/k8s/infra/cert-manager-resources/kustomization.yaml +15 -0
- package/carbon/k8s/infra/kustomization.yaml +21 -0
- package/carbon/k8s/infra/traefik-crds/kustomization.yaml +10 -0
- package/carbon/k8s/overlays/local/configmap.yaml +23 -0
- package/carbon/k8s/overlays/local/ingressroute-studio.yaml +104 -0
- package/carbon/k8s/overlays/local/kustomization.yaml +215 -0
- package/carbon/k8s/overlays/local/namespace.yaml +8 -0
- package/carbon/k8s/overlays/local/secrets.yaml +32 -0
- package/carbon/k8s/overlays/production/kustomization.yaml +34 -0
- package/carbon/k8s/test-local.sh +318 -0
- package/carbon/k8s/values/supabase.values.yaml +133 -0
- package/carbon/package.json +154 -0
- package/carbon/runtime.Dockerfile +17 -0
- package/carbon/scripts/_dev-jwt.mjs +45 -0
- package/carbon/scripts/check-rls.ts +53 -0
- package/carbon/scripts/dev-init.js +191 -0
- package/carbon/scripts/dev.js +191 -0
- package/carbon/scripts/docker-down.js +63 -0
- package/carbon/scripts/docker-logs.js +59 -0
- package/carbon/scripts/docker-up.js +222 -0
- package/carbon/scripts/generate-dev-configs.sh +131 -0
- package/carbon/scripts/generate-rss.ts +116 -0
- package/carbon/scripts/generate-sitemap.ts +102 -0
- package/carbon/scripts/k8s-apply.js +71 -0
- package/carbon/scripts/k8s-delete.js +75 -0
- package/carbon/scripts/lib/manifest.js +176 -0
- package/carbon/scripts/secret-scan.mjs +278 -0
- package/carbon/scripts/validate-dev-configs.sh +101 -0
- package/carbon/src/client/App.tsx +202 -0
- package/carbon/src/client/assets/hyperformant-dark.svg +29 -0
- package/carbon/src/client/assets/hyperformant-light.svg +29 -0
- package/carbon/src/client/assets/logos/aider.svg +1 -0
- package/carbon/src/client/assets/logos/antigravity.svg +1 -0
- package/carbon/src/client/assets/logos/bolt.svg +1 -0
- package/carbon/src/client/assets/logos/claude-code.svg +1 -0
- package/carbon/src/client/assets/logos/copilot.svg +1 -0
- package/carbon/src/client/assets/logos/cursor.svg +1 -0
- package/carbon/src/client/assets/logos/gemini-cli.svg +1 -0
- package/carbon/src/client/assets/logos/lovable.svg +1 -0
- package/carbon/src/client/assets/logos/openai-codex.svg +1 -0
- package/carbon/src/client/assets/logos/v0.svg +1 -0
- package/carbon/src/client/assets/logos/windsurf.svg +1 -0
- package/carbon/src/client/assets/vibecarbon-icon.svg +19 -0
- package/carbon/src/client/assets/vibecarbon-logo-dark.svg +29 -0
- package/carbon/src/client/assets/vibecarbon-logo-light.svg +29 -0
- package/carbon/src/client/components/AIIntegrationSection.tsx +120 -0
- package/carbon/src/client/components/AppSidebar.tsx +760 -0
- package/carbon/src/client/components/ArchitectureSection.tsx +46 -0
- package/carbon/src/client/components/CTAFooter.tsx +59 -0
- package/carbon/src/client/components/ComparisonSection.tsx +132 -0
- package/carbon/src/client/components/ContentPanel.tsx +66 -0
- package/carbon/src/client/components/ContentSkeleton.tsx +21 -0
- package/carbon/src/client/components/ErrorBoundary.tsx +46 -0
- package/carbon/src/client/components/FAQSection.tsx +76 -0
- package/carbon/src/client/components/FileUpload.tsx +210 -0
- package/carbon/src/client/components/HeaderActions.tsx +17 -0
- package/carbon/src/client/components/Hero.tsx +608 -0
- package/carbon/src/client/components/ImpersonationBanner.tsx +31 -0
- package/carbon/src/client/components/LanguageSwitcher.tsx +67 -0
- package/carbon/src/client/components/Logo.tsx +87 -0
- package/carbon/src/client/components/LogoStrip.tsx +76 -0
- package/carbon/src/client/components/MetricsStrip.tsx +48 -0
- package/carbon/src/client/components/Nav.tsx +195 -0
- package/carbon/src/client/components/NewsletterSignup.tsx +147 -0
- package/carbon/src/client/components/NotificationDrawer.tsx +171 -0
- package/carbon/src/client/components/PageHeader.tsx +24 -0
- package/carbon/src/client/components/PlanGate.tsx +36 -0
- package/carbon/src/client/components/PricingSection.tsx +371 -0
- package/carbon/src/client/components/SEO.tsx +34 -0
- package/carbon/src/client/components/SmoothScroll.tsx +45 -0
- package/carbon/src/client/components/TechStackSection.tsx +165 -0
- package/carbon/src/client/components/WorkflowSection.tsx +604 -0
- package/carbon/src/client/components/admin/DockerLogs.tsx +276 -0
- package/carbon/src/client/components/admin/PerformanceMetrics.tsx +230 -0
- package/carbon/src/client/components/admin/ServiceCard.tsx +45 -0
- package/carbon/src/client/components/admin/ServicesStatus.tsx +296 -0
- package/carbon/src/client/components/architecture/ArchitectureDiagram.tsx +413 -0
- package/carbon/src/client/components/auth/AuthProvider.tsx +466 -0
- package/carbon/src/client/components/effects/FilmGrainOverlay.tsx +35 -0
- package/carbon/src/client/components/effects/FresnelEdge.tsx +49 -0
- package/carbon/src/client/components/effects/GlowTracker.tsx +46 -0
- package/carbon/src/client/components/effects/SparkBurst.tsx +145 -0
- package/carbon/src/client/components/effects/VGlowEffect.tsx +83 -0
- package/carbon/src/client/components/effects/index.ts +2 -0
- package/carbon/src/client/components/layouts/SidebarLayout.tsx +20 -0
- package/carbon/src/client/components/scroll/ScrollSection.tsx +76 -0
- package/carbon/src/client/components/scroll/ScrollytellingProvider.tsx +81 -0
- package/carbon/src/client/components/scroll/index.ts +2 -0
- package/carbon/src/client/components/ui/accordion.tsx +71 -0
- package/carbon/src/client/components/ui/alert-dialog.tsx +162 -0
- package/carbon/src/client/components/ui/alert.tsx +73 -0
- package/carbon/src/client/components/ui/aspect-ratio.tsx +22 -0
- package/carbon/src/client/components/ui/avatar.tsx +91 -0
- package/carbon/src/client/components/ui/badge.tsx +50 -0
- package/carbon/src/client/components/ui/breadcrumb.tsx +100 -0
- package/carbon/src/client/components/ui/button-group.tsx +78 -0
- package/carbon/src/client/components/ui/button.tsx +120 -0
- package/carbon/src/client/components/ui/calendar.tsx +182 -0
- package/carbon/src/client/components/ui/card.tsx +85 -0
- package/carbon/src/client/components/ui/carousel.tsx +227 -0
- package/carbon/src/client/components/ui/chart.tsx +357 -0
- package/carbon/src/client/components/ui/checkbox.tsx +27 -0
- package/carbon/src/client/components/ui/collapsible.tsx +15 -0
- package/carbon/src/client/components/ui/command.tsx +178 -0
- package/carbon/src/client/components/ui/context-menu.tsx +233 -0
- package/carbon/src/client/components/ui/dialog.tsx +132 -0
- package/carbon/src/client/components/ui/drawer.tsx +118 -0
- package/carbon/src/client/components/ui/dropdown-menu.tsx +242 -0
- package/carbon/src/client/components/ui/empty.tsx +94 -0
- package/carbon/src/client/components/ui/field.tsx +226 -0
- package/carbon/src/client/components/ui/hover-card.tsx +44 -0
- package/carbon/src/client/components/ui/input-group.tsx +146 -0
- package/carbon/src/client/components/ui/input-otp.tsx +83 -0
- package/carbon/src/client/components/ui/input.tsx +20 -0
- package/carbon/src/client/components/ui/item.tsx +188 -0
- package/carbon/src/client/components/ui/kbd.tsx +26 -0
- package/carbon/src/client/components/ui/label.tsx +21 -0
- package/carbon/src/client/components/ui/menubar.tsx +250 -0
- package/carbon/src/client/components/ui/navigation-menu.tsx +155 -0
- package/carbon/src/client/components/ui/pagination.tsx +102 -0
- package/carbon/src/client/components/ui/popover.tsx +75 -0
- package/carbon/src/client/components/ui/progress.tsx +66 -0
- package/carbon/src/client/components/ui/radio-group.tsx +36 -0
- package/carbon/src/client/components/ui/resizable.tsx +46 -0
- package/carbon/src/client/components/ui/scroll-area.tsx +48 -0
- package/carbon/src/client/components/ui/select.tsx +186 -0
- package/carbon/src/client/components/ui/separator.tsx +21 -0
- package/carbon/src/client/components/ui/sheet.tsx +124 -0
- package/carbon/src/client/components/ui/sidebar.tsx +702 -0
- package/carbon/src/client/components/ui/skeleton.tsx +13 -0
- package/carbon/src/client/components/ui/slider.tsx +57 -0
- package/carbon/src/client/components/ui/sonner.tsx +45 -0
- package/carbon/src/client/components/ui/spinner.tsx +15 -0
- package/carbon/src/client/components/ui/switch.tsx +30 -0
- package/carbon/src/client/components/ui/table.tsx +89 -0
- package/carbon/src/client/components/ui/tabs.tsx +73 -0
- package/carbon/src/client/components/ui/textarea.tsx +18 -0
- package/carbon/src/client/components/ui/toggle-group.tsx +87 -0
- package/carbon/src/client/components/ui/toggle.tsx +44 -0
- package/carbon/src/client/components/ui/tooltip.tsx +56 -0
- package/carbon/src/client/hooks/api/index.ts +14 -0
- package/carbon/src/client/hooks/api/useAuthSettings.ts +80 -0
- package/carbon/src/client/hooks/api/useSubscription.ts +87 -0
- package/carbon/src/client/hooks/use-mobile.ts +21 -0
- package/carbon/src/client/hooks/useMousePosition.ts +91 -0
- package/carbon/src/client/hooks/useNotifications.tsx +124 -0
- package/carbon/src/client/hooks/useOrganizationMembers.ts +127 -0
- package/carbon/src/client/hooks/useOrganizations.tsx +230 -0
- package/carbon/src/client/hooks/usePackageManager.ts +69 -0
- package/carbon/src/client/hooks/useReducedMotion.ts +20 -0
- package/carbon/src/client/hooks/useRunningServices.ts +114 -0
- package/carbon/src/client/hooks/useScrollProgress.ts +56 -0
- package/carbon/src/client/index.css +467 -0
- package/carbon/src/client/index.html +56 -0
- package/carbon/src/client/lib/admin-services.ts +151 -0
- package/carbon/src/client/lib/api.ts +32 -0
- package/carbon/src/client/lib/blog.ts +35 -0
- package/carbon/src/client/lib/changelog.ts +33 -0
- package/carbon/src/client/lib/docs-search.ts +101 -0
- package/carbon/src/client/lib/docs.ts +37 -0
- package/carbon/src/client/lib/i18n.ts +32 -0
- package/carbon/src/client/lib/supabase.ts +72 -0
- package/carbon/src/client/lib/tailwind-colors.ts +357 -0
- package/carbon/src/client/lib/theme.ts +117 -0
- package/carbon/src/client/lib/utils.ts +22 -0
- package/carbon/src/client/locales/de.json +529 -0
- package/carbon/src/client/locales/en.json +461 -0
- package/carbon/src/client/locales/es.json +529 -0
- package/carbon/src/client/locales/fr.json +529 -0
- package/carbon/src/client/locales/pt.json +529 -0
- package/carbon/src/client/main.tsx +56 -0
- package/carbon/src/client/mdx.d.ts +13 -0
- package/carbon/src/client/pages/ApiDocs.tsx +76 -0
- package/carbon/src/client/pages/AuthCallback.tsx +34 -0
- package/carbon/src/client/pages/Blog.tsx +167 -0
- package/carbon/src/client/pages/Changelog.tsx +171 -0
- package/carbon/src/client/pages/Charts.tsx +388 -0
- package/carbon/src/client/pages/Checkout.tsx +227 -0
- package/carbon/src/client/pages/Contact.tsx +174 -0
- package/carbon/src/client/pages/Dashboard.tsx +368 -0
- package/carbon/src/client/pages/Docs.tsx +372 -0
- package/carbon/src/client/pages/ForgotPassword.tsx +111 -0
- package/carbon/src/client/pages/Home.tsx +187 -0
- package/carbon/src/client/pages/Legal.tsx +100 -0
- package/carbon/src/client/pages/Login.tsx +408 -0
- package/carbon/src/client/pages/MFAVerify.tsx +156 -0
- package/carbon/src/client/pages/NotFound.tsx +21 -0
- package/carbon/src/client/pages/Onboarding.tsx +246 -0
- package/carbon/src/client/pages/ResetPassword.tsx +200 -0
- package/carbon/src/client/pages/UIComponents.tsx +390 -0
- package/carbon/src/client/pages/admin/ContactSubmissions.tsx +220 -0
- package/carbon/src/client/pages/admin/Dashboard.tsx +24 -0
- package/carbon/src/client/pages/admin/Infrastructure.tsx +257 -0
- package/carbon/src/client/pages/admin/Jobs.tsx +225 -0
- package/carbon/src/client/pages/admin/Logs.tsx +18 -0
- package/carbon/src/client/pages/admin/Newsletter.tsx +300 -0
- package/carbon/src/client/pages/admin/Notifications.tsx +603 -0
- package/carbon/src/client/pages/admin/Organizations.tsx +306 -0
- package/carbon/src/client/pages/admin/Settings.tsx +314 -0
- package/carbon/src/client/pages/admin/Theme.tsx +465 -0
- package/carbon/src/client/pages/admin/Users.tsx +365 -0
- package/carbon/src/client/pages/api-docs.css +156 -0
- package/carbon/src/client/pages/organizations/Details.tsx +200 -0
- package/carbon/src/client/pages/organizations/Members.tsx +402 -0
- package/carbon/src/client/pages/settings/Billing.tsx +473 -0
- package/carbon/src/client/pages/settings/Profile.tsx +160 -0
- package/carbon/src/client/pages/settings/Security.tsx +341 -0
- package/carbon/src/client/public/favicon.svg +19 -0
- package/carbon/src/client/public/robots.txt +8 -0
- package/carbon/src/server/billing/index.ts +104 -0
- package/carbon/src/server/billing/provider.ts +81 -0
- package/carbon/src/server/billing/providers/paddle.ts +314 -0
- package/carbon/src/server/billing/providers/polar.ts +325 -0
- package/carbon/src/server/billing/providers/stripe.ts +233 -0
- package/carbon/src/server/emails/templates.ts +116 -0
- package/carbon/src/server/index.ts +554 -0
- package/carbon/src/server/lib/auth.ts +6 -0
- package/carbon/src/server/lib/email.ts +64 -0
- package/carbon/src/server/lib/env.ts +112 -0
- package/carbon/src/server/lib/errors.ts +21 -0
- package/carbon/src/server/lib/logger.ts +17 -0
- package/carbon/src/server/lib/rate-limiter.ts +288 -0
- package/carbon/src/server/lib/request.ts +34 -0
- package/carbon/src/server/lib/stripe.ts +42 -0
- package/carbon/src/server/lib/supabase.ts +65 -0
- package/carbon/src/server/middleware/requirePlan.ts +80 -0
- package/carbon/src/server/routes/_internal/services-status.ts +958 -0
- package/carbon/src/server/routes/_internal/verify-role.ts +185 -0
- package/carbon/src/server/routes/health.ts +48 -0
- package/carbon/src/server/routes/v1/admin/contact.ts +128 -0
- package/carbon/src/server/routes/v1/admin/jobs.ts +171 -0
- package/carbon/src/server/routes/v1/admin/newsletter.ts +237 -0
- package/carbon/src/server/routes/v1/auth.ts +390 -0
- package/carbon/src/server/routes/v1/billing.ts +718 -0
- package/carbon/src/server/routes/v1/contact.ts +93 -0
- package/carbon/src/server/routes/v1/index.ts +1333 -0
- package/carbon/src/server/routes/v1/newsletter.ts +181 -0
- package/carbon/src/server/routes/v1/performance.ts +157 -0
- package/carbon/src/server/routes/v1/stats.ts +170 -0
- package/carbon/src/server/routes/v1/theme.ts +106 -0
- package/carbon/src/server/routes/webhooks/billing.ts +376 -0
- package/carbon/src/server/routes/webhooks/stripe.ts +276 -0
- package/carbon/src/server/types.ts +11 -0
- package/carbon/src/shared/pricing.ts +155 -0
- package/carbon/src/shared/types.ts +338 -0
- package/carbon/supabase/migrations/00001_init.sql +717 -0
- package/carbon/supabase/migrations/00002_theme_settings.sql +13 -0
- package/carbon/supabase/migrations/00003_pg_cron.sql +121 -0
- package/carbon/supabase/migrations/00004_contact_newsletter.sql +81 -0
- package/carbon/supabase/migrations/00005_localization_languages.sql +22 -0
- package/carbon/supabase/seed.sql +16 -0
- package/carbon/tests/_helpers/app.ts +45 -0
- package/carbon/tests/_helpers/env.ts +37 -0
- package/carbon/tests/_helpers/factories.ts +69 -0
- package/carbon/tests/_helpers/jwt.ts +23 -0
- package/carbon/tests/_helpers/setup-integration.ts +20 -0
- package/carbon/tests/_helpers/setup-rtl.ts +12 -0
- package/carbon/tests/component/ErrorBoundary.test.tsx +53 -0
- package/carbon/tests/component/use-auth-settings.test.tsx +119 -0
- package/carbon/tests/integration/server/routes/contact.test.ts +162 -0
- package/carbon/tests/integration/server/routes/health.test.ts +61 -0
- package/carbon/tests/structural/i18n-parity.test.ts +42 -0
- package/carbon/tests/unit/client/utils.test.ts +49 -0
- package/carbon/tests/unit/shared/pricing.test.ts +93 -0
- package/carbon/tsconfig.json +27 -0
- package/carbon/tsconfig.server.json +27 -0
- package/carbon/tsconfig.test.json +9 -0
- package/carbon/vite.config.ts +110 -0
- package/carbon/vitest.config.ts +74 -0
- package/carbon/volumes/db/jwt.sql +57 -0
- package/carbon/volumes/db/metabase-init.sh +29 -0
- package/carbon/volumes/db/n8n-init.sh +25 -0
- package/carbon/volumes/db/realtime.sql +33 -0
- package/carbon/volumes/db/roles.sql +93 -0
- package/carbon/volumes/db/set-passwords.sh +12 -0
- package/carbon/volumes/db/super-admin.dev.sql +113 -0
- package/carbon/volumes/db/super-admin.generated.sql +113 -0
- package/carbon/volumes/db/super-admin.sql +114 -0
- package/carbon/volumes/grafana/dashboards/logs.json +179 -0
- package/carbon/volumes/grafana/dashboards/overview.json +523 -0
- package/carbon/volumes/grafana/dashboards/postgresql.json +337 -0
- package/carbon/volumes/grafana/dashboards.dev/logs.json +179 -0
- package/carbon/volumes/grafana/dashboards.dev/overview.json +156 -0
- package/carbon/volumes/grafana/dashboards.dev/postgresql.json +337 -0
- package/carbon/volumes/grafana/provisioning/dashboards/dashboards.dev.yml +16 -0
- package/carbon/volumes/grafana/provisioning/dashboards/dashboards.yml +16 -0
- package/carbon/volumes/grafana/provisioning/datasources/datasources.yml +43 -0
- package/carbon/volumes/kong/docker-entrypoint.sh +9 -0
- package/carbon/volumes/kong/kong.yml +208 -0
- package/carbon/volumes/loki/loki-config.yml +58 -0
- package/carbon/volumes/n8n/hooks.js +131 -0
- package/carbon/volumes/n8n/scripts/setup.sh +66 -0
- package/carbon/volumes/prometheus/prometheus.yml +43 -0
- package/carbon/volumes/promtail/promtail-config.yml +64 -0
- package/carbon/volumes/traefik/middlewares.dev.yml +83 -0
- package/carbon/volumes/traefik/middlewares.yml +95 -0
- package/carbon/volumes/traefik/vite-dev.yml +20 -0
- package/package.json +95 -0
- package/src/access.js +354 -0
- package/src/activate.js +187 -0
- package/src/add.js +718 -0
- package/src/backup.js +786 -0
- package/src/cli.js +350 -0
- package/src/configure.js +967 -0
- package/src/console.js +155 -0
- package/src/create.js +1499 -0
- package/src/deploy.js +311 -0
- package/src/destroy.js +2033 -0
- package/src/diagnose.js +735 -0
- package/src/down.js +80 -0
- package/src/failover.js +1032 -0
- package/src/lib/backup-s3.js +179 -0
- package/src/lib/build.js +33 -0
- package/src/lib/checksum.js +28 -0
- package/src/lib/ci-setup.js +666 -0
- package/src/lib/cli/help.js +129 -0
- package/src/lib/cli/parse-flags.js +160 -0
- package/src/lib/cli/select-action.js +65 -0
- package/src/lib/cli/select-environment.js +108 -0
- package/src/lib/cli/tty-guard.js +75 -0
- package/src/lib/cloudflare.js +447 -0
- package/src/lib/colors.js +52 -0
- package/src/lib/command.js +361 -0
- package/src/lib/config.js +359 -0
- package/src/lib/cost.js +103 -0
- package/src/lib/deploy/bundle.js +231 -0
- package/src/lib/deploy/compose/acme-verify.js +121 -0
- package/src/lib/deploy/compose/build-args.js +78 -0
- package/src/lib/deploy/compose/ha.js +1874 -0
- package/src/lib/deploy/compose/index.js +1294 -0
- package/src/lib/deploy/compose/reconcile.js +74 -0
- package/src/lib/deploy/github.js +382 -0
- package/src/lib/deploy/image.js +191 -0
- package/src/lib/deploy/index.js +119 -0
- package/src/lib/deploy/k8s/LICENSE +99 -0
- package/src/lib/deploy/k8s/gitops-deploy.js +298 -0
- package/src/lib/deploy/k8s/ha/index.js +1000 -0
- package/src/lib/deploy/k8s/index.js +62 -0
- package/src/lib/deploy/k8s/k3s.js +2515 -0
- package/src/lib/deploy/orchestrator.js +1401 -0
- package/src/lib/deploy/prompts.js +545 -0
- package/src/lib/deploy/remote-build.js +130 -0
- package/src/lib/deploy/state.js +120 -0
- package/src/lib/deploy/utils.js +328 -0
- package/src/lib/deploy-logger.js +93 -0
- package/src/lib/dns-propagation.js +48 -0
- package/src/lib/environment.js +58 -0
- package/src/lib/fetch-retry.js +103 -0
- package/src/lib/github-environments.js +335 -0
- package/src/lib/hetzner-dns.js +377 -0
- package/src/lib/hetzner-guided-setup.js +275 -0
- package/src/lib/host-keys.js +37 -0
- package/src/lib/iac/cloud-init.js +52 -0
- package/src/lib/iac/index.js +325 -0
- package/src/lib/iac/programs/hetzner-compose.js +130 -0
- package/src/lib/iac/programs/hetzner-k8s.js +320 -0
- package/src/lib/kubectl.js +81 -0
- package/src/lib/licensing/index.js +259 -0
- package/src/lib/licensing/tiers.js +181 -0
- package/src/lib/licensing/validator.js +171 -0
- package/src/lib/merge-package-json.js +90 -0
- package/src/lib/operator-ip.js +381 -0
- package/src/lib/package-manager.js +111 -0
- package/src/lib/perf.js +71 -0
- package/src/lib/project-guard.js +39 -0
- package/src/lib/project.js +334 -0
- package/src/lib/providers/base.js +276 -0
- package/src/lib/providers/hetzner-s3.js +656 -0
- package/src/lib/providers/hetzner.js +755 -0
- package/src/lib/providers/index.js +164 -0
- package/src/lib/s3.js +510 -0
- package/src/lib/secret-scan.js +583 -0
- package/src/lib/secrets.js +63 -0
- package/src/lib/server-types.js +195 -0
- package/src/lib/shell.js +91 -0
- package/src/lib/ssh.js +241 -0
- package/src/lib/tracker.js +242 -0
- package/src/lib/upgrade-policy.js +170 -0
- package/src/lib/validators.js +105 -0
- package/src/lib/version.js +5 -0
- package/src/remove.js +292 -0
- package/src/reset.js +97 -0
- package/src/restore.js +871 -0
- package/src/scale.js +1734 -0
- package/src/shell.js +222 -0
- package/src/status.js +981 -0
- package/src/up.js +264 -0
- package/src/upgrade.js +721 -0
|
@@ -0,0 +1,603 @@
|
|
|
1
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
2
|
+
import {
|
|
3
|
+
AlertCircle,
|
|
4
|
+
AlertTriangle,
|
|
5
|
+
CheckCircle2,
|
|
6
|
+
Info,
|
|
7
|
+
Loader2,
|
|
8
|
+
MoreHorizontal,
|
|
9
|
+
Pencil,
|
|
10
|
+
Plus,
|
|
11
|
+
Trash2,
|
|
12
|
+
} from 'lucide-react';
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
import { PageHeader } from '@/components/PageHeader';
|
|
15
|
+
import { Badge } from '@/components/ui/badge';
|
|
16
|
+
import { Button } from '@/components/ui/button';
|
|
17
|
+
import {
|
|
18
|
+
Card,
|
|
19
|
+
CardAction,
|
|
20
|
+
CardContent,
|
|
21
|
+
CardDescription,
|
|
22
|
+
CardHeader,
|
|
23
|
+
CardTitle,
|
|
24
|
+
} from '@/components/ui/card';
|
|
25
|
+
import {
|
|
26
|
+
Dialog,
|
|
27
|
+
DialogContent,
|
|
28
|
+
DialogDescription,
|
|
29
|
+
DialogFooter,
|
|
30
|
+
DialogHeader,
|
|
31
|
+
DialogTitle,
|
|
32
|
+
} from '@/components/ui/dialog';
|
|
33
|
+
import {
|
|
34
|
+
DropdownMenu,
|
|
35
|
+
DropdownMenuContent,
|
|
36
|
+
DropdownMenuItem,
|
|
37
|
+
DropdownMenuSeparator,
|
|
38
|
+
DropdownMenuTrigger,
|
|
39
|
+
} from '@/components/ui/dropdown-menu';
|
|
40
|
+
import { Input } from '@/components/ui/input';
|
|
41
|
+
import { Label } from '@/components/ui/label';
|
|
42
|
+
import {
|
|
43
|
+
Select,
|
|
44
|
+
SelectContent,
|
|
45
|
+
SelectItem,
|
|
46
|
+
SelectTrigger,
|
|
47
|
+
SelectValue,
|
|
48
|
+
} from '@/components/ui/select';
|
|
49
|
+
import { Switch } from '@/components/ui/switch';
|
|
50
|
+
import { Textarea } from '@/components/ui/textarea';
|
|
51
|
+
import { supabase } from '@/lib/supabase';
|
|
52
|
+
import { ContentPanel } from '../../components/ContentPanel';
|
|
53
|
+
|
|
54
|
+
type NotificationType = 'info' | 'warning' | 'error' | 'success';
|
|
55
|
+
type NotificationVisibility = 'all' | 'authenticated' | 'public';
|
|
56
|
+
|
|
57
|
+
type AdminNotification = {
|
|
58
|
+
id: string;
|
|
59
|
+
title: string;
|
|
60
|
+
message?: string;
|
|
61
|
+
type: NotificationType;
|
|
62
|
+
visibility: NotificationVisibility;
|
|
63
|
+
dismissible: boolean;
|
|
64
|
+
organizationId?: string;
|
|
65
|
+
startsAt?: string;
|
|
66
|
+
endsAt?: string;
|
|
67
|
+
actionLabel?: string;
|
|
68
|
+
actionUrl?: string;
|
|
69
|
+
isActive: boolean;
|
|
70
|
+
createdBy?: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
type NotificationFormData = {
|
|
76
|
+
title: string;
|
|
77
|
+
message: string;
|
|
78
|
+
type: NotificationType;
|
|
79
|
+
visibility: NotificationVisibility;
|
|
80
|
+
dismissible: boolean;
|
|
81
|
+
isActive: boolean;
|
|
82
|
+
actionLabel: string;
|
|
83
|
+
actionUrl: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const defaultFormData: NotificationFormData = {
|
|
87
|
+
title: '',
|
|
88
|
+
message: '',
|
|
89
|
+
type: 'info',
|
|
90
|
+
visibility: 'all',
|
|
91
|
+
dismissible: true,
|
|
92
|
+
isActive: true,
|
|
93
|
+
actionLabel: '',
|
|
94
|
+
actionUrl: '',
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
async function getAuthHeaders() {
|
|
98
|
+
const {
|
|
99
|
+
data: { session },
|
|
100
|
+
} = await supabase.auth.getSession();
|
|
101
|
+
return {
|
|
102
|
+
'Content-Type': 'application/json',
|
|
103
|
+
Authorization: session ? `Bearer ${session.access_token}` : '',
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async function fetchAdminNotifications(): Promise<AdminNotification[]> {
|
|
108
|
+
const headers = await getAuthHeaders();
|
|
109
|
+
const response = await fetch('/api/v1/admin/notifications', { headers });
|
|
110
|
+
|
|
111
|
+
if (!response.ok) {
|
|
112
|
+
throw new Error('Failed to fetch notifications');
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const data = await response.json();
|
|
116
|
+
return data.notifications;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async function createNotification(data: NotificationFormData): Promise<AdminNotification> {
|
|
120
|
+
const headers = await getAuthHeaders();
|
|
121
|
+
const response = await fetch('/api/v1/admin/notifications', {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
headers,
|
|
124
|
+
body: JSON.stringify({
|
|
125
|
+
title: data.title,
|
|
126
|
+
message: data.message || undefined,
|
|
127
|
+
type: data.type,
|
|
128
|
+
visibility: data.visibility,
|
|
129
|
+
dismissible: data.dismissible,
|
|
130
|
+
isActive: data.isActive,
|
|
131
|
+
actionLabel: data.actionLabel || undefined,
|
|
132
|
+
actionUrl: data.actionUrl || undefined,
|
|
133
|
+
}),
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
if (!response.ok) {
|
|
137
|
+
const error = await response.json();
|
|
138
|
+
throw new Error(error.error || 'Failed to create notification');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const result = await response.json();
|
|
142
|
+
return result.notification;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function updateNotification(
|
|
146
|
+
id: string,
|
|
147
|
+
data: Partial<NotificationFormData>
|
|
148
|
+
): Promise<AdminNotification> {
|
|
149
|
+
const headers = await getAuthHeaders();
|
|
150
|
+
const response = await fetch(`/api/v1/admin/notifications/${id}`, {
|
|
151
|
+
method: 'PATCH',
|
|
152
|
+
headers,
|
|
153
|
+
body: JSON.stringify(data),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
if (!response.ok) {
|
|
157
|
+
const error = await response.json();
|
|
158
|
+
throw new Error(error.error || 'Failed to update notification');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const result = await response.json();
|
|
162
|
+
return result.notification;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
async function deleteNotification(id: string): Promise<void> {
|
|
166
|
+
const headers = await getAuthHeaders();
|
|
167
|
+
const response = await fetch(`/api/v1/admin/notifications/${id}`, {
|
|
168
|
+
method: 'DELETE',
|
|
169
|
+
headers,
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
if (!response.ok) {
|
|
173
|
+
const error = await response.json();
|
|
174
|
+
throw new Error(error.error || 'Failed to delete notification');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getTypeIcon(type: NotificationType) {
|
|
179
|
+
switch (type) {
|
|
180
|
+
case 'error':
|
|
181
|
+
return <AlertCircle className="size-4 text-destructive" />;
|
|
182
|
+
case 'warning':
|
|
183
|
+
return <AlertTriangle className="size-4 text-warning" />;
|
|
184
|
+
case 'success':
|
|
185
|
+
return <CheckCircle2 className="size-4 text-success" />;
|
|
186
|
+
default:
|
|
187
|
+
return <Info className="size-4 text-info" />;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function getTypeBadgeVariant(type: NotificationType) {
|
|
192
|
+
switch (type) {
|
|
193
|
+
case 'error':
|
|
194
|
+
return 'destructive';
|
|
195
|
+
case 'warning':
|
|
196
|
+
return 'outline';
|
|
197
|
+
case 'success':
|
|
198
|
+
return 'default';
|
|
199
|
+
default:
|
|
200
|
+
return 'secondary';
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export default function AdminNotifications() {
|
|
205
|
+
const queryClient = useQueryClient();
|
|
206
|
+
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
|
207
|
+
const [editingNotification, setEditingNotification] = useState<AdminNotification | null>(null);
|
|
208
|
+
const [deleteConfirm, setDeleteConfirm] = useState<AdminNotification | null>(null);
|
|
209
|
+
const [formData, setFormData] = useState<NotificationFormData>(defaultFormData);
|
|
210
|
+
|
|
211
|
+
const {
|
|
212
|
+
data: notifications = [],
|
|
213
|
+
isLoading,
|
|
214
|
+
error,
|
|
215
|
+
} = useQuery({
|
|
216
|
+
queryKey: ['admin-notifications'],
|
|
217
|
+
queryFn: fetchAdminNotifications,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
const createMutation = useMutation({
|
|
221
|
+
mutationFn: createNotification,
|
|
222
|
+
onSuccess: () => {
|
|
223
|
+
queryClient.invalidateQueries({ queryKey: ['admin-notifications'] });
|
|
224
|
+
queryClient.invalidateQueries({ queryKey: ['notifications'] });
|
|
225
|
+
setIsCreateOpen(false);
|
|
226
|
+
setFormData(defaultFormData);
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const updateMutation = useMutation({
|
|
231
|
+
mutationFn: ({ id, data }: { id: string; data: Partial<NotificationFormData> }) =>
|
|
232
|
+
updateNotification(id, data),
|
|
233
|
+
onSuccess: () => {
|
|
234
|
+
queryClient.invalidateQueries({ queryKey: ['admin-notifications'] });
|
|
235
|
+
queryClient.invalidateQueries({ queryKey: ['notifications'] });
|
|
236
|
+
setEditingNotification(null);
|
|
237
|
+
setFormData(defaultFormData);
|
|
238
|
+
},
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const deleteMutation = useMutation({
|
|
242
|
+
mutationFn: deleteNotification,
|
|
243
|
+
onSuccess: () => {
|
|
244
|
+
queryClient.invalidateQueries({ queryKey: ['admin-notifications'] });
|
|
245
|
+
queryClient.invalidateQueries({ queryKey: ['notifications'] });
|
|
246
|
+
setDeleteConfirm(null);
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
const handleCreate = () => {
|
|
251
|
+
createMutation.mutate(formData);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const handleUpdate = () => {
|
|
255
|
+
if (!editingNotification) return;
|
|
256
|
+
updateMutation.mutate({ id: editingNotification.id, data: formData });
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
const handleEdit = (notification: AdminNotification) => {
|
|
260
|
+
setFormData({
|
|
261
|
+
title: notification.title,
|
|
262
|
+
message: notification.message || '',
|
|
263
|
+
type: notification.type,
|
|
264
|
+
visibility: notification.visibility,
|
|
265
|
+
dismissible: notification.dismissible,
|
|
266
|
+
isActive: notification.isActive,
|
|
267
|
+
actionLabel: notification.actionLabel || '',
|
|
268
|
+
actionUrl: notification.actionUrl || '',
|
|
269
|
+
});
|
|
270
|
+
setEditingNotification(notification);
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
const handleToggleActive = (notification: AdminNotification) => {
|
|
274
|
+
updateMutation.mutate({
|
|
275
|
+
id: notification.id,
|
|
276
|
+
data: { isActive: !notification.isActive },
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
const isFormOpen = isCreateOpen || !!editingNotification;
|
|
281
|
+
const isPending = createMutation.isPending || updateMutation.isPending;
|
|
282
|
+
|
|
283
|
+
return (
|
|
284
|
+
<>
|
|
285
|
+
<PageHeader title="Notifications" description="System-wide notifications" />
|
|
286
|
+
|
|
287
|
+
<ContentPanel variant="full">
|
|
288
|
+
<Card>
|
|
289
|
+
<CardHeader>
|
|
290
|
+
<CardTitle>All Notifications</CardTitle>
|
|
291
|
+
<CardDescription>
|
|
292
|
+
Active notifications are shown to users. Inactive notifications are hidden.
|
|
293
|
+
</CardDescription>
|
|
294
|
+
<CardAction>
|
|
295
|
+
<Button onClick={() => setIsCreateOpen(true)}>
|
|
296
|
+
<Plus className="mr-2 size-4" />
|
|
297
|
+
Create Notification
|
|
298
|
+
</Button>
|
|
299
|
+
</CardAction>
|
|
300
|
+
</CardHeader>
|
|
301
|
+
<CardContent>
|
|
302
|
+
{isLoading ? (
|
|
303
|
+
<div className="flex items-center justify-center py-8">
|
|
304
|
+
<Loader2 className="size-6 animate-spin text-muted-foreground" />
|
|
305
|
+
</div>
|
|
306
|
+
) : error ? (
|
|
307
|
+
<div className="py-8 text-center text-destructive">
|
|
308
|
+
{error instanceof Error ? error.message : 'Failed to load notifications'}
|
|
309
|
+
</div>
|
|
310
|
+
) : notifications.length === 0 ? (
|
|
311
|
+
<div className="py-8 text-center text-muted-foreground">
|
|
312
|
+
No notifications yet. Create one to get started.
|
|
313
|
+
</div>
|
|
314
|
+
) : (
|
|
315
|
+
<div className="space-y-3">
|
|
316
|
+
{notifications.map((notification) => (
|
|
317
|
+
<div
|
|
318
|
+
key={notification.id}
|
|
319
|
+
className="flex items-center justify-between rounded-lg border p-4"
|
|
320
|
+
>
|
|
321
|
+
<div className="flex items-start gap-3">
|
|
322
|
+
{getTypeIcon(notification.type)}
|
|
323
|
+
<div>
|
|
324
|
+
<div className="flex items-center gap-2">
|
|
325
|
+
<p className="font-medium">{notification.title}</p>
|
|
326
|
+
<Badge variant={getTypeBadgeVariant(notification.type)}>
|
|
327
|
+
{notification.type}
|
|
328
|
+
</Badge>
|
|
329
|
+
{notification.visibility !== 'all' && (
|
|
330
|
+
<Badge variant="outline">{notification.visibility}</Badge>
|
|
331
|
+
)}
|
|
332
|
+
{!notification.isActive && <Badge variant="outline">Inactive</Badge>}
|
|
333
|
+
</div>
|
|
334
|
+
{notification.message && (
|
|
335
|
+
<p className="text-sm text-muted-foreground mt-1">
|
|
336
|
+
{notification.message}
|
|
337
|
+
</p>
|
|
338
|
+
)}
|
|
339
|
+
<p className="text-xs text-muted-foreground mt-2">
|
|
340
|
+
Created {new Date(notification.createdAt).toLocaleDateString()}
|
|
341
|
+
</p>
|
|
342
|
+
</div>
|
|
343
|
+
</div>
|
|
344
|
+
<div className="flex items-center gap-2">
|
|
345
|
+
<Switch
|
|
346
|
+
checked={notification.isActive}
|
|
347
|
+
onCheckedChange={() => handleToggleActive(notification)}
|
|
348
|
+
disabled={updateMutation.isPending}
|
|
349
|
+
/>
|
|
350
|
+
<DropdownMenu>
|
|
351
|
+
<DropdownMenuTrigger render={<Button variant="ghost" size="icon-sm" />}>
|
|
352
|
+
<MoreHorizontal className="size-4" />
|
|
353
|
+
</DropdownMenuTrigger>
|
|
354
|
+
<DropdownMenuContent align="end">
|
|
355
|
+
<DropdownMenuItem onClick={() => handleEdit(notification)}>
|
|
356
|
+
<Pencil className="mr-2 size-4" />
|
|
357
|
+
Edit
|
|
358
|
+
</DropdownMenuItem>
|
|
359
|
+
<DropdownMenuSeparator />
|
|
360
|
+
<DropdownMenuItem
|
|
361
|
+
className="text-destructive focus:text-destructive"
|
|
362
|
+
onClick={() => setDeleteConfirm(notification)}
|
|
363
|
+
>
|
|
364
|
+
<Trash2 className="mr-2 size-4" />
|
|
365
|
+
Delete
|
|
366
|
+
</DropdownMenuItem>
|
|
367
|
+
</DropdownMenuContent>
|
|
368
|
+
</DropdownMenu>
|
|
369
|
+
</div>
|
|
370
|
+
</div>
|
|
371
|
+
))}
|
|
372
|
+
</div>
|
|
373
|
+
)}
|
|
374
|
+
</CardContent>
|
|
375
|
+
</Card>
|
|
376
|
+
</ContentPanel>
|
|
377
|
+
|
|
378
|
+
{/* Create/Edit Dialog */}
|
|
379
|
+
<Dialog
|
|
380
|
+
open={isFormOpen}
|
|
381
|
+
onOpenChange={(open) => {
|
|
382
|
+
if (!open) {
|
|
383
|
+
setIsCreateOpen(false);
|
|
384
|
+
setEditingNotification(null);
|
|
385
|
+
setFormData(defaultFormData);
|
|
386
|
+
}
|
|
387
|
+
}}
|
|
388
|
+
>
|
|
389
|
+
<DialogContent className="max-w-lg">
|
|
390
|
+
<DialogHeader>
|
|
391
|
+
<DialogTitle>
|
|
392
|
+
{editingNotification ? 'Edit Notification' : 'Create Notification'}
|
|
393
|
+
</DialogTitle>
|
|
394
|
+
<DialogDescription>
|
|
395
|
+
{editingNotification
|
|
396
|
+
? 'Update the notification details below.'
|
|
397
|
+
: 'Create a new notification to display to all users.'}
|
|
398
|
+
</DialogDescription>
|
|
399
|
+
</DialogHeader>
|
|
400
|
+
<div className="grid gap-4 py-2">
|
|
401
|
+
<div className="grid gap-2">
|
|
402
|
+
<Label htmlFor="title">Title</Label>
|
|
403
|
+
<Input
|
|
404
|
+
id="title"
|
|
405
|
+
placeholder="Notification title"
|
|
406
|
+
value={formData.title}
|
|
407
|
+
onChange={(e) => setFormData({ ...formData, title: e.target.value })}
|
|
408
|
+
disabled={isPending}
|
|
409
|
+
/>
|
|
410
|
+
</div>
|
|
411
|
+
<div className="grid gap-2">
|
|
412
|
+
<Label htmlFor="message">Message (optional)</Label>
|
|
413
|
+
<Textarea
|
|
414
|
+
id="message"
|
|
415
|
+
placeholder="Additional details..."
|
|
416
|
+
value={formData.message}
|
|
417
|
+
onChange={(e) => setFormData({ ...formData, message: e.target.value })}
|
|
418
|
+
disabled={isPending}
|
|
419
|
+
rows={3}
|
|
420
|
+
/>
|
|
421
|
+
</div>
|
|
422
|
+
<div className="grid grid-cols-2 gap-4">
|
|
423
|
+
<div className="grid gap-2">
|
|
424
|
+
<Label htmlFor="type">Type</Label>
|
|
425
|
+
<Select
|
|
426
|
+
defaultValue="info"
|
|
427
|
+
value={formData.type}
|
|
428
|
+
onValueChange={(value) =>
|
|
429
|
+
setFormData({ ...formData, type: value as NotificationType })
|
|
430
|
+
}
|
|
431
|
+
disabled={isPending}
|
|
432
|
+
>
|
|
433
|
+
<SelectTrigger className="w-full">
|
|
434
|
+
<SelectValue />
|
|
435
|
+
</SelectTrigger>
|
|
436
|
+
<SelectContent>
|
|
437
|
+
<SelectItem value="info">
|
|
438
|
+
<span className="flex items-center gap-2">
|
|
439
|
+
<Info className="size-4 text-info" />
|
|
440
|
+
Info
|
|
441
|
+
</span>
|
|
442
|
+
</SelectItem>
|
|
443
|
+
<SelectItem value="success">
|
|
444
|
+
<span className="flex items-center gap-2">
|
|
445
|
+
<CheckCircle2 className="size-4 text-success" />
|
|
446
|
+
Success
|
|
447
|
+
</span>
|
|
448
|
+
</SelectItem>
|
|
449
|
+
<SelectItem value="warning">
|
|
450
|
+
<span className="flex items-center gap-2">
|
|
451
|
+
<AlertTriangle className="size-4 text-warning" />
|
|
452
|
+
Warning
|
|
453
|
+
</span>
|
|
454
|
+
</SelectItem>
|
|
455
|
+
<SelectItem value="error">
|
|
456
|
+
<span className="flex items-center gap-2">
|
|
457
|
+
<AlertCircle className="size-4 text-destructive" />
|
|
458
|
+
Error
|
|
459
|
+
</span>
|
|
460
|
+
</SelectItem>
|
|
461
|
+
</SelectContent>
|
|
462
|
+
</Select>
|
|
463
|
+
</div>
|
|
464
|
+
<div className="grid gap-2">
|
|
465
|
+
<Label htmlFor="visibility">Visibility</Label>
|
|
466
|
+
<Select
|
|
467
|
+
defaultValue="all"
|
|
468
|
+
value={formData.visibility}
|
|
469
|
+
onValueChange={(value) =>
|
|
470
|
+
setFormData({ ...formData, visibility: value as NotificationVisibility })
|
|
471
|
+
}
|
|
472
|
+
disabled={isPending}
|
|
473
|
+
>
|
|
474
|
+
<SelectTrigger className="w-full">
|
|
475
|
+
<SelectValue />
|
|
476
|
+
</SelectTrigger>
|
|
477
|
+
<SelectContent>
|
|
478
|
+
<SelectItem value="all">All users</SelectItem>
|
|
479
|
+
<SelectItem value="authenticated">Authenticated only</SelectItem>
|
|
480
|
+
<SelectItem value="public">Public only</SelectItem>
|
|
481
|
+
</SelectContent>
|
|
482
|
+
</Select>
|
|
483
|
+
</div>
|
|
484
|
+
</div>
|
|
485
|
+
<div className="grid gap-2">
|
|
486
|
+
<Label>Options</Label>
|
|
487
|
+
<div className="flex gap-6">
|
|
488
|
+
<label
|
|
489
|
+
htmlFor="notification-dismissible"
|
|
490
|
+
className="flex items-center gap-2 text-sm"
|
|
491
|
+
>
|
|
492
|
+
<Switch
|
|
493
|
+
id="notification-dismissible"
|
|
494
|
+
checked={formData.dismissible}
|
|
495
|
+
onCheckedChange={(checked) =>
|
|
496
|
+
setFormData({ ...formData, dismissible: checked })
|
|
497
|
+
}
|
|
498
|
+
disabled={isPending}
|
|
499
|
+
/>
|
|
500
|
+
Dismissible
|
|
501
|
+
</label>
|
|
502
|
+
<label htmlFor="notification-active" className="flex items-center gap-2 text-sm">
|
|
503
|
+
<Switch
|
|
504
|
+
id="notification-active"
|
|
505
|
+
checked={formData.isActive}
|
|
506
|
+
onCheckedChange={(checked) => setFormData({ ...formData, isActive: checked })}
|
|
507
|
+
disabled={isPending}
|
|
508
|
+
/>
|
|
509
|
+
Active
|
|
510
|
+
</label>
|
|
511
|
+
</div>
|
|
512
|
+
</div>
|
|
513
|
+
<div className="grid gap-2">
|
|
514
|
+
<Label>Action Button (optional)</Label>
|
|
515
|
+
<div className="grid grid-cols-2 gap-2">
|
|
516
|
+
<Input
|
|
517
|
+
placeholder="Button label"
|
|
518
|
+
value={formData.actionLabel}
|
|
519
|
+
onChange={(e) => setFormData({ ...formData, actionLabel: e.target.value })}
|
|
520
|
+
disabled={isPending}
|
|
521
|
+
/>
|
|
522
|
+
<Input
|
|
523
|
+
placeholder="URL"
|
|
524
|
+
value={formData.actionUrl}
|
|
525
|
+
onChange={(e) => setFormData({ ...formData, actionUrl: e.target.value })}
|
|
526
|
+
disabled={isPending}
|
|
527
|
+
/>
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
{(createMutation.error || updateMutation.error) && (
|
|
531
|
+
<p className="text-sm text-destructive">
|
|
532
|
+
{createMutation.error instanceof Error
|
|
533
|
+
? createMutation.error.message
|
|
534
|
+
: updateMutation.error instanceof Error
|
|
535
|
+
? updateMutation.error.message
|
|
536
|
+
: 'An error occurred'}
|
|
537
|
+
</p>
|
|
538
|
+
)}
|
|
539
|
+
</div>
|
|
540
|
+
<DialogFooter>
|
|
541
|
+
<Button
|
|
542
|
+
variant="outline"
|
|
543
|
+
onClick={() => {
|
|
544
|
+
setIsCreateOpen(false);
|
|
545
|
+
setEditingNotification(null);
|
|
546
|
+
setFormData(defaultFormData);
|
|
547
|
+
}}
|
|
548
|
+
disabled={isPending}
|
|
549
|
+
>
|
|
550
|
+
Cancel
|
|
551
|
+
</Button>
|
|
552
|
+
<Button
|
|
553
|
+
onClick={editingNotification ? handleUpdate : handleCreate}
|
|
554
|
+
disabled={!formData.title.trim() || isPending}
|
|
555
|
+
>
|
|
556
|
+
{isPending
|
|
557
|
+
? 'Saving...'
|
|
558
|
+
: editingNotification
|
|
559
|
+
? 'Save Changes'
|
|
560
|
+
: 'Create Notification'}
|
|
561
|
+
</Button>
|
|
562
|
+
</DialogFooter>
|
|
563
|
+
</DialogContent>
|
|
564
|
+
</Dialog>
|
|
565
|
+
|
|
566
|
+
{/* Delete Confirmation Dialog */}
|
|
567
|
+
<Dialog open={!!deleteConfirm} onOpenChange={() => setDeleteConfirm(null)}>
|
|
568
|
+
<DialogContent>
|
|
569
|
+
<DialogHeader>
|
|
570
|
+
<DialogTitle>Delete Notification</DialogTitle>
|
|
571
|
+
<DialogDescription>
|
|
572
|
+
Are you sure you want to delete "{deleteConfirm?.title}"? This action cannot be
|
|
573
|
+
undone.
|
|
574
|
+
</DialogDescription>
|
|
575
|
+
</DialogHeader>
|
|
576
|
+
{deleteMutation.error && (
|
|
577
|
+
<p className="text-sm text-destructive">
|
|
578
|
+
{deleteMutation.error instanceof Error
|
|
579
|
+
? deleteMutation.error.message
|
|
580
|
+
: 'Failed to delete notification'}
|
|
581
|
+
</p>
|
|
582
|
+
)}
|
|
583
|
+
<DialogFooter>
|
|
584
|
+
<Button
|
|
585
|
+
variant="outline"
|
|
586
|
+
onClick={() => setDeleteConfirm(null)}
|
|
587
|
+
disabled={deleteMutation.isPending}
|
|
588
|
+
>
|
|
589
|
+
Cancel
|
|
590
|
+
</Button>
|
|
591
|
+
<Button
|
|
592
|
+
variant="destructive"
|
|
593
|
+
onClick={() => deleteConfirm && deleteMutation.mutate(deleteConfirm.id)}
|
|
594
|
+
disabled={deleteMutation.isPending}
|
|
595
|
+
>
|
|
596
|
+
{deleteMutation.isPending ? 'Deleting...' : 'Delete'}
|
|
597
|
+
</Button>
|
|
598
|
+
</DialogFooter>
|
|
599
|
+
</DialogContent>
|
|
600
|
+
</Dialog>
|
|
601
|
+
</>
|
|
602
|
+
);
|
|
603
|
+
}
|