devpush 0.0.0-stage → 1.0.0-beta.4
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/README.md +22 -2
- package/agent-release.json +37 -0
- package/dist/package/LICENSE.md +21 -0
- package/dist/package/migrate.mjs +182 -0
- package/dist/package/plugins.mjs +125 -0
- package/dist/package/vite.mjs +439 -0
- package/package.json +168 -3
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon.svg +1 -0
- package/public/logo-email.png +0 -0
- package/public/robots.txt +3 -0
- package/public/social.png +0 -0
- package/src/cloudflare-runtime.d.ts +78 -0
- package/src/components/about-dialog.tsx +70 -0
- package/src/components/copy-button.tsx +74 -0
- package/src/components/logo-mark.tsx +20 -0
- package/src/components/pending-collection.tsx +103 -0
- package/src/components/resource-avatar.tsx +65 -0
- package/src/components/route-error-state.tsx +95 -0
- package/src/components/section-navigation.tsx +39 -0
- package/src/components/settings-layout.tsx +111 -0
- package/src/components/storage-capabilities.tsx +11 -0
- package/src/components/table-pager.tsx +101 -0
- package/src/components/ui/alert-dialog.tsx +180 -0
- package/src/components/ui/alert.tsx +78 -0
- package/src/components/ui/avatar.tsx +58 -0
- package/src/components/ui/badge.tsx +49 -0
- package/src/components/ui/button-group.tsx +38 -0
- package/src/components/ui/button.tsx +67 -0
- package/src/components/ui/card.tsx +82 -0
- package/src/components/ui/chart.tsx +307 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/combobox.tsx +256 -0
- package/src/components/ui/dialog.tsx +163 -0
- package/src/components/ui/dropdown-menu.tsx +110 -0
- package/src/components/ui/empty.tsx +65 -0
- package/src/components/ui/field.tsx +192 -0
- package/src/components/ui/input-group.tsx +118 -0
- package/src/components/ui/input-otp.tsx +70 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/label.tsx +24 -0
- package/src/components/ui/pagination.tsx +34 -0
- package/src/components/ui/popover.tsx +86 -0
- package/src/components/ui/select.tsx +145 -0
- package/src/components/ui/skeleton.tsx +19 -0
- package/src/components/ui/sonner.tsx +47 -0
- package/src/components/ui/switch.tsx +31 -0
- package/src/components/ui/table.tsx +81 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +55 -0
- package/src/features/admin/admin-settings.tsx +1048 -0
- package/src/features/auth/current-user-context-query.ts +11 -0
- package/src/features/auth/login-form.tsx +442 -0
- package/src/features/auth/sign-out-menu-item.tsx +42 -0
- package/src/features/deployments/deployment-actions.tsx +336 -0
- package/src/features/deployments/deployment-alias-badge.tsx +35 -0
- package/src/features/deployments/deployment-detail.tsx +596 -0
- package/src/features/deployments/deployment-filters.ts +66 -0
- package/src/features/deployments/deployment-list.tsx +465 -0
- package/src/features/deployments/deployment-visit-links.tsx +104 -0
- package/src/features/deployments/deployments-page.tsx +376 -0
- package/src/features/logs/log-scroll-area.tsx +69 -0
- package/src/features/notifications/email-preferences.tsx +232 -0
- package/src/features/onboarding/profile-onboarding.tsx +162 -0
- package/src/features/plugins/contributions.tsx +118 -0
- package/src/features/projects/backup-job-logs.tsx +143 -0
- package/src/features/projects/backup-policy-delete-dialog.tsx +82 -0
- package/src/features/projects/backup-restore-actions.tsx +573 -0
- package/src/features/projects/backup-status-icon.tsx +33 -0
- package/src/features/projects/backup-target-list.tsx +222 -0
- package/src/features/projects/backup-timestamp.tsx +32 -0
- package/src/features/projects/backup-volume-picker.tsx +158 -0
- package/src/features/projects/compose-service-input.tsx +64 -0
- package/src/features/projects/deploy-readiness.ts +28 -0
- package/src/features/projects/environment-dot.tsx +91 -0
- package/src/features/projects/log-keyword-filter.tsx +48 -0
- package/src/features/projects/manual-deploy-dialog.tsx +563 -0
- package/src/features/projects/pending-section.ts +26 -0
- package/src/features/projects/project-backup-details-pending.tsx +305 -0
- package/src/features/projects/project-backup-details.tsx +936 -0
- package/src/features/projects/project-backup-policy.tsx +644 -0
- package/src/features/projects/project-backup-utils.ts +190 -0
- package/src/features/projects/project-backups-pending.tsx +136 -0
- package/src/features/projects/project-backups.tsx +876 -0
- package/src/features/projects/project-environment-settings.tsx +1128 -0
- package/src/features/projects/project-heading.tsx +68 -0
- package/src/features/projects/project-layout.tsx +188 -0
- package/src/features/projects/project-logs.tsx +461 -0
- package/src/features/projects/project-overview.tsx +280 -0
- package/src/features/projects/project-route-pending.tsx +1064 -0
- package/src/features/projects/project-routing-settings.tsx +663 -0
- package/src/features/projects/project-settings-section.tsx +64 -0
- package/src/features/projects/project-settings-utils.ts +101 -0
- package/src/features/projects/project-settings.tsx +1472 -0
- package/src/features/projects/repository-picker-dialog.tsx +404 -0
- package/src/features/repositories/new-project-dialog-launcher.tsx +44 -0
- package/src/features/repositories/new-project-dialog.tsx +1204 -0
- package/src/features/repositories/new-project-pending.tsx +28 -0
- package/src/features/repositories/repository-list-pending.tsx +59 -0
- package/src/features/servers/server-availability-alert.tsx +44 -0
- package/src/features/servers/server-availability.ts +29 -0
- package/src/features/servers/server-avatar.tsx +52 -0
- package/src/features/servers/server-detail-pending.tsx +315 -0
- package/src/features/servers/server-detail.tsx +855 -0
- package/src/features/servers/server-metric-chart-pending.tsx +38 -0
- package/src/features/servers/server-metric-chart.tsx +182 -0
- package/src/features/servers/server-metric-format.ts +50 -0
- package/src/features/servers/server-metrics-pending.tsx +75 -0
- package/src/features/servers/server-metrics.tsx +136 -0
- package/src/features/servers/team-servers.tsx +432 -0
- package/src/features/settings/settings-route-pending.tsx +406 -0
- package/src/features/teams/backup-storage-settings.tsx +483 -0
- package/src/features/teams/navigation.ts +51 -0
- package/src/features/teams/new-team-dialog.tsx +132 -0
- package/src/features/teams/pending-section.ts +19 -0
- package/src/features/teams/team-header.tsx +1286 -0
- package/src/features/teams/team-heading.tsx +57 -0
- package/src/features/teams/team-home.tsx +391 -0
- package/src/features/teams/team-invite.tsx +155 -0
- package/src/features/teams/team-route-pending.tsx +505 -0
- package/src/features/teams/team-settings.tsx +1555 -0
- package/src/features/teams/use-workspace-updates.ts +126 -0
- package/src/features/users/api-keys-settings.tsx +544 -0
- package/src/features/users/api-scope-selection.tsx +269 -0
- package/src/features/users/connected-apps-settings.tsx +449 -0
- package/src/features/users/mcp-consent.tsx +220 -0
- package/src/features/users/profile-picture.tsx +171 -0
- package/src/features/users/user-settings.tsx +1064 -0
- package/src/lib/account-settings-schema.ts +78 -0
- package/src/lib/action-feedback.ts +81 -0
- package/src/lib/admin-search-schema.ts +8 -0
- package/src/lib/agent-release.d.mts +21 -0
- package/src/lib/agent-release.mjs +90 -0
- package/src/lib/allowlist-schema.ts +79 -0
- package/src/lib/api-key-schema.ts +176 -0
- package/src/lib/auth/client.ts +20 -0
- package/src/lib/avatar-schema.ts +11 -0
- package/src/lib/backup-cron.ts +118 -0
- package/src/lib/backup-database.ts +41 -0
- package/src/lib/backup-feature.ts +2 -0
- package/src/lib/backup-paths.ts +7 -0
- package/src/lib/backup-policy-schema.ts +85 -0
- package/src/lib/backup-resource-schema.ts +12 -0
- package/src/lib/backup-restore-schema.ts +15 -0
- package/src/lib/backup-storage-schema.ts +55 -0
- package/src/lib/deferred-module.ts +38 -0
- package/src/lib/deployment-logs-query.ts +63 -0
- package/src/lib/display-name.ts +7 -0
- package/src/lib/error-message.ts +119 -0
- package/src/lib/form-errors.ts +10 -0
- package/src/lib/internal-redirect.ts +25 -0
- package/src/lib/manual-deploy-options-query.ts +21 -0
- package/src/lib/notification-preferences.ts +43 -0
- package/src/lib/onboarding.ts +11 -0
- package/src/lib/operation-logs-query.ts +51 -0
- package/src/lib/page-head.ts +14 -0
- package/src/lib/project-context-query.ts +257 -0
- package/src/lib/project-creation-schema.ts +64 -0
- package/src/lib/project-env-schema.ts +23 -0
- package/src/lib/project-environments-schema.ts +56 -0
- package/src/lib/project-routing-schema.ts +94 -0
- package/src/lib/project-runtime-config.ts +131 -0
- package/src/lib/project-settings-schema.ts +75 -0
- package/src/lib/public-api-schema.ts +128 -0
- package/src/lib/public-error.ts +337 -0
- package/src/lib/query.ts +13 -0
- package/src/lib/repository-selection-query.ts +11 -0
- package/src/lib/resource-cache.ts +30 -0
- package/src/lib/runtime-id.ts +19 -0
- package/src/lib/search.ts +14 -0
- package/src/lib/server-context-query.ts +43 -0
- package/src/lib/server-name-schema.ts +11 -0
- package/src/lib/settings-conflict.ts +45 -0
- package/src/lib/settings-version.ts +7 -0
- package/src/lib/team-context-query.ts +126 -0
- package/src/lib/team-context-schema.ts +8 -0
- package/src/lib/team-forms-schema.ts +45 -0
- package/src/lib/team-role.ts +13 -0
- package/src/lib/team-settings-schema.ts +48 -0
- package/src/lib/urls.ts +3 -0
- package/src/lib/use-avatar-input.ts +61 -0
- package/src/lib/use-refresh-error.ts +18 -0
- package/src/lib/use-settings-version.ts +23 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/validation.ts +5 -0
- package/src/lib/workspace-updates.ts +53 -0
- package/src/package/config.ts +10 -0
- package/src/package/env.mjs +54 -0
- package/src/package/migrate-api.d.ts +5 -0
- package/src/package/migrate.ts +56 -0
- package/src/package/plugins.ts +141 -0
- package/src/package/sqlite.mjs +2 -0
- package/src/package/vite-api.d.ts +5 -0
- package/src/package/vite.ts +324 -0
- package/src/package/watch-guard.cjs +26 -0
- package/src/plugins/client.ts +57 -0
- package/src/plugins/contract.ts +188 -0
- package/src/plugins/default.server.ts +4 -0
- package/src/plugins/default.ui.ts +4 -0
- package/src/plugins/operations.ts +45 -0
- package/src/plugins/server.ts +197 -0
- package/src/plugins/version.ts +1 -0
- package/src/routeTree.gen.ts +1275 -0
- package/src/router.tsx +46 -0
- package/src/routes/$teamSlug.index.tsx +53 -0
- package/src/routes/$teamSlug.new-project.tsx +13 -0
- package/src/routes/$teamSlug.projects.$projectName.backups.$backupId.tsx +40 -0
- package/src/routes/$teamSlug.projects.$projectName.backups.tsx +82 -0
- package/src/routes/$teamSlug.projects.$projectName.deployments.$deploymentId.tsx +52 -0
- package/src/routes/$teamSlug.projects.$projectName.deployments.tsx +86 -0
- package/src/routes/$teamSlug.projects.$projectName.logs.tsx +55 -0
- package/src/routes/$teamSlug.projects.$projectName.settings.tsx +51 -0
- package/src/routes/$teamSlug.projects.$projectName.tsx +106 -0
- package/src/routes/$teamSlug.projects.tsx +40 -0
- package/src/routes/$teamSlug.servers.$serverId.tsx +31 -0
- package/src/routes/$teamSlug.servers.index.tsx +59 -0
- package/src/routes/$teamSlug.servers.tsx +7 -0
- package/src/routes/$teamSlug.settings.tsx +56 -0
- package/src/routes/$teamSlug.tsx +86 -0
- package/src/routes/[.]well-known.oauth-authorization-server.api.auth.ts +13 -0
- package/src/routes/[.]well-known.oauth-protected-resource.mcp.ts +6 -0
- package/src/routes/__root.tsx +155 -0
- package/src/routes/admin.tsx +55 -0
- package/src/routes/api/agents/certificates.ts +21 -0
- package/src/routes/api/agents/credentials/rotate.ts +22 -0
- package/src/routes/api/agents/heartbeat.ts +42 -0
- package/src/routes/api/agents/job-logs.ts +22 -0
- package/src/routes/api/agents/jobs/complete.ts +22 -0
- package/src/routes/api/agents/jobs/next.ts +29 -0
- package/src/routes/api/agents/jobs/progress.ts +32 -0
- package/src/routes/api/agents/jobs/status.ts +22 -0
- package/src/routes/api/agents/register.ts +45 -0
- package/src/routes/api/agents/runtime-logs.ts +22 -0
- package/src/routes/api/agents/switch.ts +25 -0
- package/src/routes/api/auth/$.ts +38 -0
- package/src/routes/api/cron/backups.ts +33 -0
- package/src/routes/api/cron/maintenance.ts +30 -0
- package/src/routes/api/github/install.callback.ts +51 -0
- package/src/routes/api/github/install.ts +41 -0
- package/src/routes/api/github/webhook.ts +11 -0
- package/src/routes/api/health.ts +19 -0
- package/src/routes/api/install/agent.$token.ts +50 -0
- package/src/routes/api/install/agent.binary.ts +83 -0
- package/src/routes/api/install/agent.checksum.ts +45 -0
- package/src/routes/api/install/agent.ts +26 -0
- package/src/routes/api/plugins/$.ts +11 -0
- package/src/routes/api/v1/$.ts +15 -0
- package/src/routes/api/workspaces/updates.ts +8 -0
- package/src/routes/auth.login.tsx +50 -0
- package/src/routes/deployments.$deploymentId.unavailable.tsx +21 -0
- package/src/routes/index.tsx +23 -0
- package/src/routes/invites.$token.tsx +35 -0
- package/src/routes/mcp.ts +13 -0
- package/src/routes/oauth.consent.tsx +54 -0
- package/src/routes/onboarding.tsx +37 -0
- package/src/routes/onboarding.workspace.tsx +44 -0
- package/src/routes/settings.tsx +30 -0
- package/src/routes/uploads/avatars/$fileName.ts +44 -0
- package/src/server/admin/access.ts +67 -0
- package/src/server/admin/functions.ts +122 -0
- package/src/server/admin/service.ts +260 -0
- package/src/server/agents/backup-state.ts +210 -0
- package/src/server/agents/certificates.ts +96 -0
- package/src/server/agents/claims.ts +116 -0
- package/src/server/agents/cleanup.ts +52 -0
- package/src/server/agents/compatibility.ts +116 -0
- package/src/server/agents/completion.ts +83 -0
- package/src/server/agents/container-cleanup-state.ts +51 -0
- package/src/server/agents/deployment-state.ts +111 -0
- package/src/server/agents/job-payloads.ts +159 -0
- package/src/server/agents/jobs.ts +1293 -0
- package/src/server/agents/protocol.ts +400 -0
- package/src/server/agents/reconciliation.ts +43 -0
- package/src/server/agents/runtime-logs.ts +337 -0
- package/src/server/agents/runtime-state.ts +125 -0
- package/src/server/api/admission.ts +12 -0
- package/src/server/api/authorization.ts +115 -0
- package/src/server/api/credentials.ts +569 -0
- package/src/server/api/cursors.ts +72 -0
- package/src/server/api/errors.ts +24 -0
- package/src/server/api/functions.ts +60 -0
- package/src/server/api/handler.ts +274 -0
- package/src/server/api/mutation-operations.ts +913 -0
- package/src/server/api/operation-context.ts +139 -0
- package/src/server/api/operation-contract.ts +1099 -0
- package/src/server/api/operations.ts +64 -0
- package/src/server/api/read-operations.ts +891 -0
- package/src/server/api/retention.ts +33 -0
- package/src/server/auth/access.ts +109 -0
- package/src/server/auth/auth-methods.ts +28 -0
- package/src/server/auth/better-auth.ts +518 -0
- package/src/server/auth/context.ts +28 -0
- package/src/server/auth/email-change.ts +47 -0
- package/src/server/auth/email-delivery.ts +51 -0
- package/src/server/auth/provider-identity.ts +19 -0
- package/src/server/auth/provider-tokens.ts +27 -0
- package/src/server/auth/session.server.ts +19 -0
- package/src/server/backups/database-commands.ts +40 -0
- package/src/server/backups/destination.ts +12 -0
- package/src/server/backups/feature.ts +6 -0
- package/src/server/backups/policy-validation.ts +51 -0
- package/src/server/backups/queue-state.ts +137 -0
- package/src/server/backups/service.ts +918 -0
- package/src/server/backups/storage-functions.ts +42 -0
- package/src/server/backups/storage-state.ts +67 -0
- package/src/server/backups/storage.ts +237 -0
- package/src/server/config.ts +274 -0
- package/src/server/db/atomic.ts +16 -0
- package/src/server/db/d1-connection.ts +83 -0
- package/src/server/db/errors.ts +17 -0
- package/src/server/db/index.cloudflare.ts +15 -0
- package/src/server/db/index.ts +35 -0
- package/src/server/db/libsql-connection.ts +72 -0
- package/src/server/db/log-schema.ts +102 -0
- package/src/server/db/migrate-libsql.ts +29 -0
- package/src/server/db/migrate-sqlite.ts +47 -0
- package/src/server/db/migration-history.ts +12 -0
- package/src/server/db/migrations-logs/0000_initial.sql +48 -0
- package/src/server/db/migrations-logs/0001_runtime_log_order.sql +2 -0
- package/src/server/db/migrations-logs/meta/0000_snapshot.json +327 -0
- package/src/server/db/migrations-logs/meta/0001_snapshot.json +329 -0
- package/src/server/db/migrations-logs/meta/_journal.json +20 -0
- package/src/server/db/migrations-sqlite/0000_initial.sql +894 -0
- package/src/server/db/migrations-sqlite/0001_agent_indexes.sql +5 -0
- package/src/server/db/migrations-sqlite/meta/0000_snapshot.json +5816 -0
- package/src/server/db/migrations-sqlite/meta/0001_snapshot.json +5841 -0
- package/src/server/db/migrations-sqlite/meta/_journal.json +20 -0
- package/src/server/db/oauth-schema.ts +216 -0
- package/src/server/db/remote-config.ts +47 -0
- package/src/server/db/schema.ts +1218 -0
- package/src/server/db/sqlite-connection.ts +94 -0
- package/src/server/db/sqlite-files.ts +27 -0
- package/src/server/db/sqlite-params.ts +19 -0
- package/src/server/db/worker-connection.ts +47 -0
- package/src/server/deleted-resources.ts +133 -0
- package/src/server/deletion-recovery.ts +272 -0
- package/src/server/email/layout.tsx +85 -0
- package/src/server/email/notification-template.tsx +62 -0
- package/src/server/email/otp-template.tsx +48 -0
- package/src/server/email/service.ts +251 -0
- package/src/server/email/team-invite-template.tsx +59 -0
- package/src/server/email/theme.ts +10 -0
- package/src/server/github/http.ts +14 -0
- package/src/server/github/install-state.ts +48 -0
- package/src/server/github/service.ts +831 -0
- package/src/server/github/webhook-handler.ts +198 -0
- package/src/server/github/webhooks.ts +205 -0
- package/src/server/http/auth.ts +11 -0
- package/src/server/http/error-diagnostics.ts +66 -0
- package/src/server/http/plugin-request.ts +15 -0
- package/src/server/http/proxy-request.ts +53 -0
- package/src/server/http/public-errors.ts +48 -0
- package/src/server/http/rate-limit.ts +59 -0
- package/src/server/http/request-body.ts +54 -0
- package/src/server/http/request-ip.ts +54 -0
- package/src/server/http/security-headers.ts +36 -0
- package/src/server/install/agent-binary.ts +230 -0
- package/src/server/install/agent-script.ts +565 -0
- package/src/server/install/release-binary.ts +65 -0
- package/src/server/logs/budget.ts +72 -0
- package/src/server/logs/cleanup.ts +64 -0
- package/src/server/logs/deployments.ts +98 -0
- package/src/server/logs/operations.ts +145 -0
- package/src/server/logs/retention.ts +39 -0
- package/src/server/maintenance.ts +61 -0
- package/src/server/mcp/connections.ts +358 -0
- package/src/server/mcp/functions.ts +63 -0
- package/src/server/mcp/handler.ts +295 -0
- package/src/server/mcp/oauth-discovery.cloudflare.ts +6 -0
- package/src/server/mcp/oauth-discovery.ts +8 -0
- package/src/server/mcp/oauth-provider.ts +220 -0
- package/src/server/mcp/urls.ts +20 -0
- package/src/server/notifications/functions.ts +51 -0
- package/src/server/notifications/observe.ts +303 -0
- package/src/server/notifications/outbox.ts +335 -0
- package/src/server/notifications/preferences.ts +131 -0
- package/src/server/notifications/query.ts +16 -0
- package/src/server/plugins/scope.ts +17 -0
- package/src/server/plugins/server-context.ts +157 -0
- package/src/server/plugins/services.server.ts +10 -0
- package/src/server/plugins/workspace-access.ts +74 -0
- package/src/server/projects/backup-policy-state.ts +68 -0
- package/src/server/projects/backups.ts +219 -0
- package/src/server/projects/compose-metadata.ts +174 -0
- package/src/server/projects/configuration-state.ts +90 -0
- package/src/server/projects/context.ts +909 -0
- package/src/server/projects/creation-state.ts +46 -0
- package/src/server/projects/deletion-state.ts +69 -0
- package/src/server/projects/deployment-config.ts +139 -0
- package/src/server/projects/deployment-logs.ts +97 -0
- package/src/server/projects/deployments.ts +1123 -0
- package/src/server/projects/domain-state.ts +71 -0
- package/src/server/projects/environment-branches.ts +75 -0
- package/src/server/projects/environment-state.ts +158 -0
- package/src/server/projects/environments.ts +424 -0
- package/src/server/projects/functions.ts +748 -0
- package/src/server/projects/generated-hostname.ts +77 -0
- package/src/server/projects/hostnames.ts +244 -0
- package/src/server/projects/mappers.ts +457 -0
- package/src/server/projects/names.ts +41 -0
- package/src/server/projects/project-env-vars.ts +28 -0
- package/src/server/projects/queue-state.ts +118 -0
- package/src/server/projects/repository.ts +368 -0
- package/src/server/projects/route-state.ts +37 -0
- package/src/server/projects/runtime-logs.ts +97 -0
- package/src/server/projects/settings-context.ts +58 -0
- package/src/server/projects/settings.ts +738 -0
- package/src/server/projects/types.ts +355 -0
- package/src/server/realtime/agent-events.ts +32 -0
- package/src/server/realtime/node-broadcaster.ts +71 -0
- package/src/server/realtime/node-handler.ts +55 -0
- package/src/server/realtime/service.ts +125 -0
- package/src/server/realtime/workspace-object.cloudflare.ts +62 -0
- package/src/server/realtime/workspace-object.ts +3 -0
- package/src/server/resources/color.ts +13 -0
- package/src/server/runtime/background.ts +21 -0
- package/src/server/runtime/node-asset-cache-plugin.ts +12 -0
- package/src/server/runtime/node-scheduler-plugin.ts +17 -0
- package/src/server/runtime/node-scheduler.ts +51 -0
- package/src/server/runtime/platform-env.cloudflare.ts +17 -0
- package/src/server/runtime/platform-env.ts +19 -0
- package/src/server/runtime/scheduled-task-error.ts +9 -0
- package/src/server/scheduled-tasks.ts +28 -0
- package/src/server/secrets/crypto.ts +56 -0
- package/src/server/servers/functions.ts +233 -0
- package/src/server/servers/lifecycle.ts +122 -0
- package/src/server/servers/metric-history-schema.ts +24 -0
- package/src/server/servers/metric-history.ts +55 -0
- package/src/server/servers/monitoring.ts +592 -0
- package/src/server/servers/service.ts +1211 -0
- package/src/server/servers/status.ts +32 -0
- package/src/server/servers/switch.ts +96 -0
- package/src/server/settings-version.ts +43 -0
- package/src/server/storage/capabilities.ts +6 -0
- package/src/server/storage/local-object-store.cloudflare.ts +7 -0
- package/src/server/storage/local-object-store.ts +50 -0
- package/src/server/storage/object-store.ts +160 -0
- package/src/server/teams/creation.ts +51 -0
- package/src/server/teams/delete-policy.ts +13 -0
- package/src/server/teams/deletion-state.ts +80 -0
- package/src/server/teams/functions.ts +324 -0
- package/src/server/teams/invitations.ts +38 -0
- package/src/server/teams/membership.ts +86 -0
- package/src/server/teams/queries.ts +261 -0
- package/src/server/teams/service.ts +1127 -0
- package/src/server/teams/types.ts +101 -0
- package/src/server/uploads/avatar.ts +133 -0
- package/src/server/users/deletion-state.ts +93 -0
- package/src/server/users/functions.ts +160 -0
- package/src/server/users/onboarding.ts +17 -0
- package/src/server/users/service.ts +644 -0
- package/src/server.ts +55 -0
- package/src/styles/shadcn.css +653 -0
- package/src/styles/theme.css +76 -0
- package/src/styles.css +177 -0
- package/wrangler.template.jsonc +37 -0
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
import { mutationErrorOptions } from '#devpush/lib/action-feedback'
|
|
2
|
+
import { showSettingsConflict } from '#devpush/lib/settings-conflict'
|
|
3
|
+
import {
|
|
4
|
+
AlertDialog,
|
|
5
|
+
AlertDialogContent,
|
|
6
|
+
AlertDialogHeader,
|
|
7
|
+
AlertDialogTitle,
|
|
8
|
+
AlertDialogDescription,
|
|
9
|
+
AlertDialogFooter,
|
|
10
|
+
} from '#devpush/components/ui/alert-dialog'
|
|
11
|
+
import { useEffect, useState } from 'react'
|
|
12
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
13
|
+
import { LoaderIcon, SettingsIcon, PlusIcon, TrashIcon } from 'lucide-react'
|
|
14
|
+
import { toast } from 'sonner'
|
|
15
|
+
import { SettingsSection } from '#devpush/components/settings-layout'
|
|
16
|
+
import { Button } from '#devpush/components/ui/button'
|
|
17
|
+
import {
|
|
18
|
+
Tooltip,
|
|
19
|
+
TooltipContent,
|
|
20
|
+
TooltipTrigger,
|
|
21
|
+
} from '#devpush/components/ui/tooltip'
|
|
22
|
+
import {
|
|
23
|
+
Dialog,
|
|
24
|
+
DialogContent,
|
|
25
|
+
DialogHeader,
|
|
26
|
+
DialogTitle,
|
|
27
|
+
DialogDescription,
|
|
28
|
+
DialogFooter,
|
|
29
|
+
} from '#devpush/components/ui/dialog'
|
|
30
|
+
import {
|
|
31
|
+
Field,
|
|
32
|
+
FieldLabel,
|
|
33
|
+
FieldDescription,
|
|
34
|
+
FieldError,
|
|
35
|
+
FieldGroup,
|
|
36
|
+
} from '#devpush/components/ui/field'
|
|
37
|
+
import { Input } from '#devpush/components/ui/input'
|
|
38
|
+
import {
|
|
39
|
+
Table,
|
|
40
|
+
TableHeader,
|
|
41
|
+
TableBody,
|
|
42
|
+
TableRow,
|
|
43
|
+
TableHead,
|
|
44
|
+
TableCell,
|
|
45
|
+
} from '#devpush/components/ui/table'
|
|
46
|
+
import {
|
|
47
|
+
Empty,
|
|
48
|
+
EmptyHeader,
|
|
49
|
+
EmptyTitle,
|
|
50
|
+
EmptyDescription,
|
|
51
|
+
EmptyContent,
|
|
52
|
+
} from '#devpush/components/ui/empty'
|
|
53
|
+
import { backupStorageSchema } from '#devpush/lib/backup-storage-schema'
|
|
54
|
+
import type { BackupStorageSummary } from '#devpush/lib/backup-storage-schema'
|
|
55
|
+
import { canManageTeamSettings } from '#devpush/lib/team-role'
|
|
56
|
+
import type { TeamSummary } from '#devpush/server/teams/types'
|
|
57
|
+
import {
|
|
58
|
+
saveBackupStorageAction,
|
|
59
|
+
deleteBackupStorageAction,
|
|
60
|
+
} from '#devpush/server/backups/storage-functions'
|
|
61
|
+
import { getPublicErrorMessage } from '#devpush/lib/public-error'
|
|
62
|
+
import { formErrors } from '#devpush/lib/form-errors'
|
|
63
|
+
import type { FormErrors } from '#devpush/lib/form-errors'
|
|
64
|
+
|
|
65
|
+
export function BackupStorageSettings({
|
|
66
|
+
team,
|
|
67
|
+
storage,
|
|
68
|
+
}: {
|
|
69
|
+
team: TeamSummary
|
|
70
|
+
storage: BackupStorageSummary[]
|
|
71
|
+
}) {
|
|
72
|
+
const canManage = canManageTeamSettings(team.role)
|
|
73
|
+
const queryClient = useQueryClient()
|
|
74
|
+
const [rows, setRows] = useState(storage)
|
|
75
|
+
const [editing, setEditing] = useState<BackupStorageSummary | 'new' | null>(
|
|
76
|
+
null,
|
|
77
|
+
)
|
|
78
|
+
const [removing, setRemoving] = useState<BackupStorageSummary | null>(null)
|
|
79
|
+
const [deleting, setDeleting] = useState(false)
|
|
80
|
+
async function refreshRows(next: BackupStorageSummary[]) {
|
|
81
|
+
setRows(next)
|
|
82
|
+
await Promise.all([
|
|
83
|
+
queryClient.invalidateQueries({ queryKey: ['team-context', team.slug] }),
|
|
84
|
+
queryClient.invalidateQueries({
|
|
85
|
+
queryKey: ['project-context', team.slug],
|
|
86
|
+
}),
|
|
87
|
+
])
|
|
88
|
+
}
|
|
89
|
+
useEffect(() => setRows(storage), [storage])
|
|
90
|
+
return (
|
|
91
|
+
<SettingsSection
|
|
92
|
+
id="backup-storage"
|
|
93
|
+
title="Backup storage"
|
|
94
|
+
description="S3-compatible destinations shared by this workspace’s project backup policies."
|
|
95
|
+
>
|
|
96
|
+
{rows.length ? (
|
|
97
|
+
<div className="space-y-4">
|
|
98
|
+
<div className="overflow-hidden rounded-lg border">
|
|
99
|
+
<Table className="table-fixed">
|
|
100
|
+
<TableHeader>
|
|
101
|
+
<TableRow>
|
|
102
|
+
<TableHead className="pl-4">Name</TableHead>
|
|
103
|
+
<TableHead>Bucket</TableHead>
|
|
104
|
+
<TableHead className="w-24">Region</TableHead>
|
|
105
|
+
<TableHead className="last:pr-4">Endpoint</TableHead>
|
|
106
|
+
{canManage ? (
|
|
107
|
+
<TableHead className="w-24">
|
|
108
|
+
<span className="sr-only">Actions</span>
|
|
109
|
+
</TableHead>
|
|
110
|
+
) : null}
|
|
111
|
+
</TableRow>
|
|
112
|
+
</TableHeader>
|
|
113
|
+
<TableBody>
|
|
114
|
+
{rows.map((row) => (
|
|
115
|
+
<TableRow key={row.id}>
|
|
116
|
+
<TableCell className="pl-4">
|
|
117
|
+
<span
|
|
118
|
+
className="block truncate font-medium"
|
|
119
|
+
title={row.name}
|
|
120
|
+
>
|
|
121
|
+
{row.name}
|
|
122
|
+
</span>
|
|
123
|
+
</TableCell>
|
|
124
|
+
<TableCell className="text-muted-foreground">
|
|
125
|
+
<span className="block truncate" title={row.bucket}>
|
|
126
|
+
{row.bucket}
|
|
127
|
+
</span>
|
|
128
|
+
</TableCell>
|
|
129
|
+
<TableCell className="text-muted-foreground">
|
|
130
|
+
<span className="block truncate" title={row.region}>
|
|
131
|
+
{row.region}
|
|
132
|
+
</span>
|
|
133
|
+
</TableCell>
|
|
134
|
+
<TableCell className="text-muted-foreground last:pr-4">
|
|
135
|
+
<span
|
|
136
|
+
className="block truncate"
|
|
137
|
+
title={row.endpoint ?? 'Amazon S3'}
|
|
138
|
+
>
|
|
139
|
+
{row.endpoint ?? 'Amazon S3'}
|
|
140
|
+
</span>
|
|
141
|
+
</TableCell>
|
|
142
|
+
{canManage ? (
|
|
143
|
+
<TableCell>
|
|
144
|
+
<div className="-mr-2 flex justify-end gap-1">
|
|
145
|
+
<Tooltip>
|
|
146
|
+
<TooltipTrigger asChild>
|
|
147
|
+
<Button
|
|
148
|
+
type="button"
|
|
149
|
+
size="icon"
|
|
150
|
+
variant="ghost"
|
|
151
|
+
aria-label={`Settings for ${row.name}`}
|
|
152
|
+
onClick={() => setEditing(row)}
|
|
153
|
+
>
|
|
154
|
+
<SettingsIcon />
|
|
155
|
+
</Button>
|
|
156
|
+
</TooltipTrigger>
|
|
157
|
+
<TooltipContent>Storage settings</TooltipContent>
|
|
158
|
+
</Tooltip>
|
|
159
|
+
<Tooltip>
|
|
160
|
+
<TooltipTrigger asChild>
|
|
161
|
+
<Button
|
|
162
|
+
type="button"
|
|
163
|
+
size="icon"
|
|
164
|
+
variant="destructive"
|
|
165
|
+
aria-label={`Remove ${row.name}`}
|
|
166
|
+
onClick={() => {
|
|
167
|
+
setRemoving(row)
|
|
168
|
+
}}
|
|
169
|
+
>
|
|
170
|
+
<TrashIcon />
|
|
171
|
+
</Button>
|
|
172
|
+
</TooltipTrigger>
|
|
173
|
+
<TooltipContent>Remove storage</TooltipContent>
|
|
174
|
+
</Tooltip>
|
|
175
|
+
</div>
|
|
176
|
+
</TableCell>
|
|
177
|
+
) : null}
|
|
178
|
+
</TableRow>
|
|
179
|
+
))}
|
|
180
|
+
</TableBody>
|
|
181
|
+
</Table>
|
|
182
|
+
</div>
|
|
183
|
+
{canManage ? (
|
|
184
|
+
<Button
|
|
185
|
+
variant="outline"
|
|
186
|
+
type="button"
|
|
187
|
+
onClick={() => setEditing('new')}
|
|
188
|
+
>
|
|
189
|
+
<PlusIcon data-icon="inline-start" />
|
|
190
|
+
Add storage
|
|
191
|
+
</Button>
|
|
192
|
+
) : null}
|
|
193
|
+
</div>
|
|
194
|
+
) : (
|
|
195
|
+
<Empty className="min-h-40">
|
|
196
|
+
<EmptyHeader>
|
|
197
|
+
<EmptyTitle>No backup storage.</EmptyTitle>
|
|
198
|
+
<EmptyDescription>
|
|
199
|
+
{canManage
|
|
200
|
+
? 'Add storage to upload backups to an existing S3-compatible bucket.'
|
|
201
|
+
: 'An owner or admin can add backup storage for this workspace.'}
|
|
202
|
+
</EmptyDescription>
|
|
203
|
+
</EmptyHeader>
|
|
204
|
+
{canManage ? (
|
|
205
|
+
<EmptyContent>
|
|
206
|
+
<Button
|
|
207
|
+
variant="outline"
|
|
208
|
+
type="button"
|
|
209
|
+
onClick={() => setEditing('new')}
|
|
210
|
+
>
|
|
211
|
+
<PlusIcon data-icon="inline-start" />
|
|
212
|
+
Add storage
|
|
213
|
+
</Button>
|
|
214
|
+
</EmptyContent>
|
|
215
|
+
) : null}
|
|
216
|
+
</Empty>
|
|
217
|
+
)}
|
|
218
|
+
{removing ? (
|
|
219
|
+
<AlertDialog
|
|
220
|
+
open
|
|
221
|
+
onOpenChange={(open) => {
|
|
222
|
+
if (!open && !deleting) setRemoving(null)
|
|
223
|
+
}}
|
|
224
|
+
>
|
|
225
|
+
<AlertDialogContent>
|
|
226
|
+
<AlertDialogHeader>
|
|
227
|
+
<AlertDialogTitle>Remove storage?</AlertDialogTitle>
|
|
228
|
+
<AlertDialogDescription>
|
|
229
|
+
Remove {removing.name} from this workspace. This does not delete
|
|
230
|
+
the bucket or its files. Storage used by policies, active
|
|
231
|
+
backups or retained remote backups cannot be removed.
|
|
232
|
+
</AlertDialogDescription>
|
|
233
|
+
</AlertDialogHeader>
|
|
234
|
+
<AlertDialogFooter>
|
|
235
|
+
<Button
|
|
236
|
+
variant="ghost"
|
|
237
|
+
disabled={deleting}
|
|
238
|
+
onClick={() => setRemoving(null)}
|
|
239
|
+
>
|
|
240
|
+
Cancel
|
|
241
|
+
</Button>
|
|
242
|
+
<Button
|
|
243
|
+
variant="destructive"
|
|
244
|
+
disabled={deleting}
|
|
245
|
+
onClick={async () => {
|
|
246
|
+
setDeleting(true)
|
|
247
|
+
|
|
248
|
+
try {
|
|
249
|
+
await refreshRows(
|
|
250
|
+
await deleteBackupStorageAction({
|
|
251
|
+
data: {
|
|
252
|
+
teamSlug: team.slug,
|
|
253
|
+
storageId: removing.id,
|
|
254
|
+
settingsVersion: removing.settingsVersion,
|
|
255
|
+
},
|
|
256
|
+
}),
|
|
257
|
+
)
|
|
258
|
+
setRemoving(null)
|
|
259
|
+
toast.success('Backup storage removed.')
|
|
260
|
+
} catch (cause) {
|
|
261
|
+
if (showSettingsConflict(cause)) return
|
|
262
|
+
toast.error(
|
|
263
|
+
getPublicErrorMessage(cause, 'Unable to remove storage.'),
|
|
264
|
+
...mutationErrorOptions(cause),
|
|
265
|
+
)
|
|
266
|
+
} finally {
|
|
267
|
+
setDeleting(false)
|
|
268
|
+
}
|
|
269
|
+
}}
|
|
270
|
+
>
|
|
271
|
+
{deleting ? (
|
|
272
|
+
<LoaderIcon
|
|
273
|
+
data-icon="inline-start"
|
|
274
|
+
className="animate-spin"
|
|
275
|
+
/>
|
|
276
|
+
) : null}
|
|
277
|
+
Remove storage
|
|
278
|
+
</Button>
|
|
279
|
+
</AlertDialogFooter>
|
|
280
|
+
</AlertDialogContent>
|
|
281
|
+
</AlertDialog>
|
|
282
|
+
) : null}
|
|
283
|
+
|
|
284
|
+
{editing ? (
|
|
285
|
+
<BackupStorageDialog
|
|
286
|
+
key={editing === 'new' ? 'new' : editing.id}
|
|
287
|
+
storage={editing === 'new' ? undefined : editing}
|
|
288
|
+
onClose={() => setEditing(null)}
|
|
289
|
+
onSave={async (input) => {
|
|
290
|
+
const saved = await saveBackupStorageAction({
|
|
291
|
+
data: {
|
|
292
|
+
teamSlug: team.slug,
|
|
293
|
+
input,
|
|
294
|
+
settingsVersion:
|
|
295
|
+
editing === 'new' ? null : editing.settingsVersion,
|
|
296
|
+
},
|
|
297
|
+
})
|
|
298
|
+
await refreshRows(saved)
|
|
299
|
+
}}
|
|
300
|
+
/>
|
|
301
|
+
) : null}
|
|
302
|
+
</SettingsSection>
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
function BackupStorageDialog({
|
|
307
|
+
storage,
|
|
308
|
+
onSave,
|
|
309
|
+
onClose,
|
|
310
|
+
}: {
|
|
311
|
+
storage?: BackupStorageSummary
|
|
312
|
+
onSave: (input: ReturnType<typeof backupStorageSchema.parse>) => Promise<void>
|
|
313
|
+
onClose: () => void
|
|
314
|
+
}) {
|
|
315
|
+
const [draft, setDraft] = useState({
|
|
316
|
+
name: storage?.name ?? '',
|
|
317
|
+
bucket: storage?.bucket ?? '',
|
|
318
|
+
region: storage?.region ?? 'auto',
|
|
319
|
+
endpoint: storage?.endpoint ?? '',
|
|
320
|
+
accessKeyId: storage?.accessKeyId ?? '',
|
|
321
|
+
secretAccessKey: '',
|
|
322
|
+
})
|
|
323
|
+
const [errors, setErrors] = useState<FormErrors>({})
|
|
324
|
+
const [busy, setBusy] = useState(false)
|
|
325
|
+
const fields = [
|
|
326
|
+
{ key: 'name', label: 'Name', placeholder: 'Production backups' },
|
|
327
|
+
{
|
|
328
|
+
key: 'bucket',
|
|
329
|
+
label: 'Bucket',
|
|
330
|
+
placeholder: 'my-backups',
|
|
331
|
+
location: true,
|
|
332
|
+
},
|
|
333
|
+
{
|
|
334
|
+
key: 'region',
|
|
335
|
+
label: 'Region',
|
|
336
|
+
placeholder: 'us-east-1 or auto',
|
|
337
|
+
location: true,
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
key: 'endpoint',
|
|
341
|
+
label: 'Endpoint',
|
|
342
|
+
placeholder: 'https://…',
|
|
343
|
+
location: true,
|
|
344
|
+
optional: true,
|
|
345
|
+
description:
|
|
346
|
+
'Leave empty for Amazon S3. For other providers, use the S3 API endpoint.',
|
|
347
|
+
},
|
|
348
|
+
{ key: 'accessKeyId', label: 'Access key ID' },
|
|
349
|
+
{
|
|
350
|
+
key: 'secretAccessKey',
|
|
351
|
+
label: 'Secret access key',
|
|
352
|
+
secret: true,
|
|
353
|
+
},
|
|
354
|
+
] as const
|
|
355
|
+
async function submit() {
|
|
356
|
+
if (busy) return
|
|
357
|
+
const parsed = backupStorageSchema.safeParse({ ...draft, id: storage?.id })
|
|
358
|
+
const validationErrors: FormErrors = parsed.success
|
|
359
|
+
? {}
|
|
360
|
+
: formErrors(parsed.error.issues)
|
|
361
|
+
if (!storage && !draft.secretAccessKey.trim()) {
|
|
362
|
+
validationErrors.secretAccessKey = 'Enter a secret access key.'
|
|
363
|
+
}
|
|
364
|
+
if (!parsed.success || Object.keys(validationErrors).length > 0) {
|
|
365
|
+
if (validationErrors.form) toast.error(validationErrors.form)
|
|
366
|
+
setErrors(validationErrors)
|
|
367
|
+
return
|
|
368
|
+
}
|
|
369
|
+
setErrors({})
|
|
370
|
+
setBusy(true)
|
|
371
|
+
try {
|
|
372
|
+
await onSave(parsed.data)
|
|
373
|
+
toast.success(
|
|
374
|
+
storage ? 'Backup storage updated.' : 'Backup storage added.',
|
|
375
|
+
)
|
|
376
|
+
onClose()
|
|
377
|
+
} catch (cause) {
|
|
378
|
+
if (showSettingsConflict(cause)) return
|
|
379
|
+
toast.error(
|
|
380
|
+
getPublicErrorMessage(cause, 'Unable to save backup storage.'),
|
|
381
|
+
...mutationErrorOptions(cause),
|
|
382
|
+
)
|
|
383
|
+
} finally {
|
|
384
|
+
setBusy(false)
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
return (
|
|
388
|
+
<Dialog
|
|
389
|
+
open
|
|
390
|
+
onOpenChange={(open) => {
|
|
391
|
+
if (!open && !busy) onClose()
|
|
392
|
+
}}
|
|
393
|
+
>
|
|
394
|
+
<DialogContent className="max-h-[calc(100dvh-2rem)] grid-cols-1 overflow-y-auto sm:max-w-xl">
|
|
395
|
+
<DialogHeader>
|
|
396
|
+
<DialogTitle>
|
|
397
|
+
{storage ? 'Edit backup storage' : 'Add backup storage'}
|
|
398
|
+
</DialogTitle>
|
|
399
|
+
<DialogDescription>
|
|
400
|
+
{storage
|
|
401
|
+
? 'Changes to credentials apply to every policy using this destination. Create another destination to use a different bucket or endpoint.'
|
|
402
|
+
: 'Create the bucket with your provider first, then add its connection here.'}
|
|
403
|
+
</DialogDescription>
|
|
404
|
+
</DialogHeader>
|
|
405
|
+
<form
|
|
406
|
+
id="backup-storage-form"
|
|
407
|
+
noValidate
|
|
408
|
+
onSubmit={(event) => {
|
|
409
|
+
event.preventDefault()
|
|
410
|
+
void submit()
|
|
411
|
+
}}
|
|
412
|
+
>
|
|
413
|
+
<fieldset className="min-w-0" disabled={busy}>
|
|
414
|
+
<FieldGroup className="grid grid-cols-1 items-start gap-4 sm:grid-cols-2">
|
|
415
|
+
{fields.map((field) => (
|
|
416
|
+
<Field
|
|
417
|
+
key={field.key}
|
|
418
|
+
className={
|
|
419
|
+
field.key === 'name' || field.key === 'endpoint'
|
|
420
|
+
? 'sm:col-span-2'
|
|
421
|
+
: undefined
|
|
422
|
+
}
|
|
423
|
+
>
|
|
424
|
+
<FieldLabel htmlFor={`storage-${field.key}`}>
|
|
425
|
+
{field.label}
|
|
426
|
+
{'optional' in field ? ' (optional)' : ''}
|
|
427
|
+
</FieldLabel>
|
|
428
|
+
<Input
|
|
429
|
+
id={`storage-${field.key}`}
|
|
430
|
+
value={
|
|
431
|
+
storage && field.key === 'secretAccessKey'
|
|
432
|
+
? '••••••••••••••••'
|
|
433
|
+
: draft[field.key]
|
|
434
|
+
}
|
|
435
|
+
type={'secret' in field ? 'password' : 'text'}
|
|
436
|
+
readOnly={Boolean(
|
|
437
|
+
storage &&
|
|
438
|
+
('location' in field || field.key === 'secretAccessKey'),
|
|
439
|
+
)}
|
|
440
|
+
placeholder={
|
|
441
|
+
'placeholder' in field ? field.placeholder : undefined
|
|
442
|
+
}
|
|
443
|
+
aria-invalid={Boolean(errors[field.key])}
|
|
444
|
+
aria-describedby={
|
|
445
|
+
errors[field.key]
|
|
446
|
+
? `storage-${field.key}-error`
|
|
447
|
+
: undefined
|
|
448
|
+
}
|
|
449
|
+
onChange={(event) =>
|
|
450
|
+
setDraft({ ...draft, [field.key]: event.target.value })
|
|
451
|
+
}
|
|
452
|
+
/>
|
|
453
|
+
{'description' in field ? (
|
|
454
|
+
<FieldDescription>{field.description}</FieldDescription>
|
|
455
|
+
) : null}
|
|
456
|
+
<FieldError id={`storage-${field.key}-error`}>
|
|
457
|
+
{errors[field.key]}
|
|
458
|
+
</FieldError>
|
|
459
|
+
</Field>
|
|
460
|
+
))}
|
|
461
|
+
</FieldGroup>
|
|
462
|
+
</fieldset>
|
|
463
|
+
</form>
|
|
464
|
+
<DialogFooter>
|
|
465
|
+
<Button
|
|
466
|
+
type="button"
|
|
467
|
+
variant="ghost"
|
|
468
|
+
disabled={busy}
|
|
469
|
+
onClick={onClose}
|
|
470
|
+
>
|
|
471
|
+
Cancel
|
|
472
|
+
</Button>
|
|
473
|
+
<Button type="submit" form="backup-storage-form" disabled={busy}>
|
|
474
|
+
{busy ? (
|
|
475
|
+
<LoaderIcon data-icon="inline-start" className="animate-spin" />
|
|
476
|
+
) : null}
|
|
477
|
+
{storage ? 'Save' : 'Add storage'}
|
|
478
|
+
</Button>
|
|
479
|
+
</DialogFooter>
|
|
480
|
+
</DialogContent>
|
|
481
|
+
</Dialog>
|
|
482
|
+
)
|
|
483
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { SectionNavigationItem } from '#devpush/components/section-navigation'
|
|
2
|
+
|
|
3
|
+
import { backupsEnabled } from '#devpush/lib/backup-feature'
|
|
4
|
+
|
|
5
|
+
export const teamSettingsNavigationItems: Array<SectionNavigationItem> = [
|
|
6
|
+
{ href: '#general', label: 'General' },
|
|
7
|
+
{ href: '#members', label: 'Members' },
|
|
8
|
+
...(backupsEnabled
|
|
9
|
+
? [{ href: '#backup-storage' as const, label: 'Backup storage' }]
|
|
10
|
+
: []),
|
|
11
|
+
{ href: '#notifications', label: 'Notifications' },
|
|
12
|
+
{ href: '#danger', label: 'Danger', destructive: true },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
export const teamTabs = [
|
|
16
|
+
{ label: 'Overview', to: '/$teamSlug' },
|
|
17
|
+
{ label: 'Projects', to: '/$teamSlug/projects' },
|
|
18
|
+
{ label: 'Servers', to: '/$teamSlug/servers' },
|
|
19
|
+
{ label: 'Settings', to: '/$teamSlug/settings' },
|
|
20
|
+
] as const
|
|
21
|
+
|
|
22
|
+
const allProjectTabs = [
|
|
23
|
+
{ label: 'Overview', to: '/$teamSlug/projects/$projectName' },
|
|
24
|
+
{
|
|
25
|
+
label: 'Deployments',
|
|
26
|
+
to: '/$teamSlug/projects/$projectName/deployments',
|
|
27
|
+
},
|
|
28
|
+
{ label: 'Logs', to: '/$teamSlug/projects/$projectName/logs' },
|
|
29
|
+
{ label: 'Backups', to: '/$teamSlug/projects/$projectName/backups' },
|
|
30
|
+
{ label: 'Settings', to: '/$teamSlug/projects/$projectName/settings' },
|
|
31
|
+
] as const
|
|
32
|
+
|
|
33
|
+
export const projectTabs = allProjectTabs.filter(
|
|
34
|
+
(tab) => backupsEnabled || tab.label !== 'Backups',
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export function isProjectTabActive(pathname: string, label: string) {
|
|
38
|
+
const segments = pathname.split('/').filter(Boolean)
|
|
39
|
+
const projectsIndex = segments.findIndex(
|
|
40
|
+
(segment, index) => index > 0 && segment === 'projects',
|
|
41
|
+
)
|
|
42
|
+
const section = segments[projectsIndex + 2] ?? 'overview'
|
|
43
|
+
|
|
44
|
+
return section === label.toLowerCase()
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function isTeamTabActive(pathname: string, label: string) {
|
|
48
|
+
const section = pathname.split('/').filter(Boolean)[1] ?? 'overview'
|
|
49
|
+
if (label === 'Projects' && section === 'new-project') return true
|
|
50
|
+
return section === label.toLowerCase()
|
|
51
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { hasWorkspaceOnboarding } from '#devpush/features/plugins/contributions'
|
|
2
|
+
import { useState } from 'react'
|
|
3
|
+
import type { ReactNode } from 'react'
|
|
4
|
+
import { LoaderIcon } from 'lucide-react'
|
|
5
|
+
import { toast } from 'sonner'
|
|
6
|
+
import { createTeamSchema } from '#devpush/lib/team-forms-schema'
|
|
7
|
+
import { getPublicErrorMessage } from '#devpush/lib/public-error'
|
|
8
|
+
import { afterMutation } from '#devpush/lib/action-feedback'
|
|
9
|
+
import { createTeamAction } from '#devpush/server/teams/functions'
|
|
10
|
+
import { Button } from '#devpush/components/ui/button'
|
|
11
|
+
import {
|
|
12
|
+
Dialog,
|
|
13
|
+
DialogContent,
|
|
14
|
+
DialogHeader,
|
|
15
|
+
DialogTitle,
|
|
16
|
+
DialogDescription,
|
|
17
|
+
DialogFooter,
|
|
18
|
+
} from '#devpush/components/ui/dialog'
|
|
19
|
+
import { Field, FieldError, FieldLabel } from '#devpush/components/ui/field'
|
|
20
|
+
import { Input } from '#devpush/components/ui/input'
|
|
21
|
+
|
|
22
|
+
export function NewTeamDialogLauncher({
|
|
23
|
+
children,
|
|
24
|
+
onCreated,
|
|
25
|
+
}: {
|
|
26
|
+
children: (open: () => void) => ReactNode
|
|
27
|
+
onCreated: (teamSlug: string) => Promise<void>
|
|
28
|
+
}) {
|
|
29
|
+
const [open, setOpen] = useState(false)
|
|
30
|
+
const [name, setName] = useState('')
|
|
31
|
+
const [formError, setFormError] = useState<string | null>(null)
|
|
32
|
+
const [nameError, setNameError] = useState<string | null>(null)
|
|
33
|
+
const [isCreating, setIsCreating] = useState(false)
|
|
34
|
+
|
|
35
|
+
async function createTeam() {
|
|
36
|
+
if (isCreating) return
|
|
37
|
+
const parsed = createTeamSchema.safeParse({ name })
|
|
38
|
+
if (!parsed.success) {
|
|
39
|
+
setNameError(parsed.error.issues[0]?.message ?? 'Enter a team name.')
|
|
40
|
+
document.getElementById('new-team-name')?.focus()
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
setNameError(null)
|
|
44
|
+
setFormError(null)
|
|
45
|
+
setIsCreating(true)
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
const team = await createTeamAction({ data: parsed.data })
|
|
49
|
+
setName('')
|
|
50
|
+
setOpen(false)
|
|
51
|
+
toast.success('Team created.')
|
|
52
|
+
if (hasWorkspaceOnboarding()) {
|
|
53
|
+
window.location.assign(
|
|
54
|
+
`/onboarding/workspace?team=${encodeURIComponent(team.slug)}`,
|
|
55
|
+
)
|
|
56
|
+
return
|
|
57
|
+
}
|
|
58
|
+
await afterMutation(
|
|
59
|
+
() => onCreated(team.slug),
|
|
60
|
+
'Team created, but opening it failed. Please reload.',
|
|
61
|
+
)
|
|
62
|
+
} catch (error) {
|
|
63
|
+
setFormError(getPublicErrorMessage(error, 'Unable to create team.'))
|
|
64
|
+
} finally {
|
|
65
|
+
setIsCreating(false)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Dialog
|
|
71
|
+
open={open}
|
|
72
|
+
onOpenChange={(next) => {
|
|
73
|
+
if (!isCreating) setOpen(next)
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
{children(() => setOpen(true))}
|
|
77
|
+
<DialogContent>
|
|
78
|
+
<form
|
|
79
|
+
id="create-team-form"
|
|
80
|
+
noValidate
|
|
81
|
+
className="grid gap-4"
|
|
82
|
+
onSubmit={(event) => {
|
|
83
|
+
event.preventDefault()
|
|
84
|
+
void createTeam()
|
|
85
|
+
}}
|
|
86
|
+
>
|
|
87
|
+
<DialogHeader>
|
|
88
|
+
<DialogTitle>Create team</DialogTitle>
|
|
89
|
+
<DialogDescription>
|
|
90
|
+
Create a team to group projects, servers, and settings.
|
|
91
|
+
</DialogDescription>
|
|
92
|
+
</DialogHeader>
|
|
93
|
+
<Field data-invalid={Boolean(nameError)}>
|
|
94
|
+
<FieldLabel htmlFor="new-team-name">Name</FieldLabel>
|
|
95
|
+
<Input
|
|
96
|
+
aria-invalid={Boolean(nameError)}
|
|
97
|
+
id="new-team-name"
|
|
98
|
+
required
|
|
99
|
+
maxLength={100}
|
|
100
|
+
disabled={isCreating}
|
|
101
|
+
aria-describedby="new-team-name-error"
|
|
102
|
+
autoFocus
|
|
103
|
+
value={name}
|
|
104
|
+
onChange={(event) => {
|
|
105
|
+
setName(event.target.value)
|
|
106
|
+
setNameError(null)
|
|
107
|
+
}}
|
|
108
|
+
/>
|
|
109
|
+
<FieldError id="new-team-name-error">{nameError}</FieldError>
|
|
110
|
+
</Field>
|
|
111
|
+
<FieldError role="alert">{formError}</FieldError>
|
|
112
|
+
<DialogFooter>
|
|
113
|
+
<Button
|
|
114
|
+
type="button"
|
|
115
|
+
variant="ghost"
|
|
116
|
+
disabled={isCreating}
|
|
117
|
+
onClick={() => setOpen(false)}
|
|
118
|
+
>
|
|
119
|
+
Cancel
|
|
120
|
+
</Button>
|
|
121
|
+
<Button type="submit" disabled={isCreating}>
|
|
122
|
+
{isCreating ? (
|
|
123
|
+
<LoaderIcon data-icon="inline-start" className="animate-spin" />
|
|
124
|
+
) : null}
|
|
125
|
+
Create team
|
|
126
|
+
</Button>
|
|
127
|
+
</DialogFooter>
|
|
128
|
+
</form>
|
|
129
|
+
</DialogContent>
|
|
130
|
+
</Dialog>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type TeamPendingSection =
|
|
2
|
+
| 'new-project'
|
|
3
|
+
| 'overview'
|
|
4
|
+
| 'project'
|
|
5
|
+
| 'projects'
|
|
6
|
+
| 'server'
|
|
7
|
+
| 'servers'
|
|
8
|
+
| 'settings'
|
|
9
|
+
|
|
10
|
+
export function getTeamPendingSection(pathname: string): TeamPendingSection {
|
|
11
|
+
const [, section, itemId] = pathname.split('/').filter(Boolean)
|
|
12
|
+
|
|
13
|
+
if (section === 'projects') return itemId ? 'project' : 'projects'
|
|
14
|
+
if (section === 'new-project') return 'new-project'
|
|
15
|
+
if (section === 'servers') return itemId ? 'server' : 'servers'
|
|
16
|
+
if (section === 'settings') return 'settings'
|
|
17
|
+
|
|
18
|
+
return 'overview'
|
|
19
|
+
}
|