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,57 @@
|
|
|
1
|
+
import { Link } from '@tanstack/react-router'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
|
|
4
|
+
import { ResourceAvatar } from '#devpush/components/resource-avatar'
|
|
5
|
+
|
|
6
|
+
type HeadingTeam = {
|
|
7
|
+
color?:
|
|
8
|
+
| 'amber'
|
|
9
|
+
| 'blue'
|
|
10
|
+
| 'green'
|
|
11
|
+
| 'neutral'
|
|
12
|
+
| 'rose'
|
|
13
|
+
| 'lime'
|
|
14
|
+
| 'sky'
|
|
15
|
+
| 'zinc'
|
|
16
|
+
image?: string | null
|
|
17
|
+
name: string
|
|
18
|
+
slug: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function TeamHeading({
|
|
22
|
+
actions,
|
|
23
|
+
crumb,
|
|
24
|
+
team,
|
|
25
|
+
}: {
|
|
26
|
+
actions?: ReactNode
|
|
27
|
+
crumb?: ReactNode
|
|
28
|
+
team: HeadingTeam
|
|
29
|
+
}) {
|
|
30
|
+
return (
|
|
31
|
+
<header className="flex min-h-10 items-center justify-between gap-4">
|
|
32
|
+
<h1 className="flex min-w-0 items-center gap-x-3 text-2xl font-medium">
|
|
33
|
+
<Link
|
|
34
|
+
className="shrink-0"
|
|
35
|
+
to="/$teamSlug"
|
|
36
|
+
params={{ teamSlug: team.slug }}
|
|
37
|
+
>
|
|
38
|
+
<ResourceAvatar
|
|
39
|
+
name={team.name}
|
|
40
|
+
src={team.image ?? undefined}
|
|
41
|
+
color={team.color}
|
|
42
|
+
size="md"
|
|
43
|
+
/>
|
|
44
|
+
</Link>
|
|
45
|
+
{crumb ? (
|
|
46
|
+
<>
|
|
47
|
+
<span className="text-muted-foreground/25 font-normal">/</span>
|
|
48
|
+
{crumb}
|
|
49
|
+
</>
|
|
50
|
+
) : (
|
|
51
|
+
<span className="truncate">{team.name}</span>
|
|
52
|
+
)}
|
|
53
|
+
</h1>
|
|
54
|
+
{actions}
|
|
55
|
+
</header>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import { refreshView } from '#devpush/lib/action-feedback'
|
|
2
|
+
import { Link, useRouter } from '@tanstack/react-router'
|
|
3
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
4
|
+
import { GithubIcon, Link2Icon, PlusIcon, SettingsIcon } from 'lucide-react'
|
|
5
|
+
import { useState } from 'react'
|
|
6
|
+
|
|
7
|
+
import { Button } from '#devpush/components/ui/button'
|
|
8
|
+
import {
|
|
9
|
+
Empty,
|
|
10
|
+
EmptyContent,
|
|
11
|
+
EmptyDescription,
|
|
12
|
+
EmptyHeader,
|
|
13
|
+
EmptyTitle,
|
|
14
|
+
} from '#devpush/components/ui/empty'
|
|
15
|
+
import {
|
|
16
|
+
DeploymentList,
|
|
17
|
+
DeploymentListPending,
|
|
18
|
+
} from '#devpush/features/deployments/deployment-list'
|
|
19
|
+
import { NewProjectDialogLauncher } from '#devpush/features/repositories/new-project-dialog-launcher'
|
|
20
|
+
import { ResourceAvatar } from '#devpush/components/resource-avatar'
|
|
21
|
+
import { AddServerDialog } from '#devpush/features/servers/team-servers'
|
|
22
|
+
import { routeUrl } from '#devpush/lib/urls'
|
|
23
|
+
import { invalidateTeamContext } from '#devpush/lib/team-context-query'
|
|
24
|
+
import { canManageTeamSettings } from '#devpush/lib/team-role'
|
|
25
|
+
import type { DeploymentSummary } from '#devpush/server/projects/types'
|
|
26
|
+
import {
|
|
27
|
+
Tooltip,
|
|
28
|
+
TooltipContent,
|
|
29
|
+
TooltipTrigger,
|
|
30
|
+
} from '#devpush/components/ui/tooltip'
|
|
31
|
+
import type {
|
|
32
|
+
ProjectSummary,
|
|
33
|
+
ServerSummary,
|
|
34
|
+
TeamSummary,
|
|
35
|
+
} from '#devpush/server/teams/types'
|
|
36
|
+
import { TeamHeading } from './team-heading'
|
|
37
|
+
|
|
38
|
+
export function TeamHome({
|
|
39
|
+
team,
|
|
40
|
+
deployments,
|
|
41
|
+
deploymentsPending = false,
|
|
42
|
+
projects,
|
|
43
|
+
servers,
|
|
44
|
+
}: {
|
|
45
|
+
team: TeamSummary
|
|
46
|
+
deployments: Array<DeploymentSummary>
|
|
47
|
+
deploymentsPending?: boolean
|
|
48
|
+
projects: Array<ProjectSummary>
|
|
49
|
+
servers: Array<ServerSummary>
|
|
50
|
+
}) {
|
|
51
|
+
const router = useRouter()
|
|
52
|
+
const queryClient = useQueryClient()
|
|
53
|
+
const [addServerOpen, setAddServerOpen] = useState(false)
|
|
54
|
+
const hasProjects = projects.length > 0
|
|
55
|
+
const canManageServers = canManageTeamSettings(team.role)
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
<TeamHeading team={team} />
|
|
60
|
+
|
|
61
|
+
{hasProjects ? (
|
|
62
|
+
<section className="space-y-4">
|
|
63
|
+
<header className="flex h-8 items-center justify-between gap-4">
|
|
64
|
+
<h2 className="text-base font-medium">Recent projects</h2>
|
|
65
|
+
<NewProjectButton teamSlug={team.slug} />
|
|
66
|
+
</header>
|
|
67
|
+
<RecentProjects teamSlug={team.slug} projects={projects} />
|
|
68
|
+
</section>
|
|
69
|
+
) : servers.length === 0 ? (
|
|
70
|
+
<section>
|
|
71
|
+
<EmptyServers
|
|
72
|
+
canAddServer={canManageServers}
|
|
73
|
+
onAddServer={() => setAddServerOpen(true)}
|
|
74
|
+
/>
|
|
75
|
+
</section>
|
|
76
|
+
) : (
|
|
77
|
+
<section>
|
|
78
|
+
<EmptyProjects teamSlug={team.slug} />
|
|
79
|
+
</section>
|
|
80
|
+
)}
|
|
81
|
+
|
|
82
|
+
{deploymentsPending ? (
|
|
83
|
+
<section className="space-y-4">
|
|
84
|
+
<header className="flex h-8 items-center">
|
|
85
|
+
<h2 className="text-base font-medium">Latest deployments</h2>
|
|
86
|
+
</header>
|
|
87
|
+
<DeploymentListPending
|
|
88
|
+
displayProject
|
|
89
|
+
label="Latest deployments loading"
|
|
90
|
+
/>
|
|
91
|
+
</section>
|
|
92
|
+
) : deployments.length > 0 ? (
|
|
93
|
+
<section className="space-y-4">
|
|
94
|
+
<header className="flex h-8 items-center">
|
|
95
|
+
<h2 className="text-base font-medium">Latest deployments</h2>
|
|
96
|
+
</header>
|
|
97
|
+
<DeploymentList
|
|
98
|
+
deployments={deployments}
|
|
99
|
+
displayProject
|
|
100
|
+
teamSlug={team.slug}
|
|
101
|
+
/>
|
|
102
|
+
</section>
|
|
103
|
+
) : null}
|
|
104
|
+
|
|
105
|
+
{canManageServers ? (
|
|
106
|
+
<AddServerDialog
|
|
107
|
+
open={addServerOpen}
|
|
108
|
+
teamSlug={team.slug}
|
|
109
|
+
onOpenChange={setAddServerOpen}
|
|
110
|
+
onCreated={() => {
|
|
111
|
+
void refreshView(
|
|
112
|
+
() =>
|
|
113
|
+
invalidateTeamContext(queryClient, team.slug).then(() =>
|
|
114
|
+
router.invalidate(),
|
|
115
|
+
),
|
|
116
|
+
'teams-team-home-refresh',
|
|
117
|
+
)
|
|
118
|
+
}}
|
|
119
|
+
/>
|
|
120
|
+
) : null}
|
|
121
|
+
</>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export function TeamProjects({
|
|
126
|
+
team,
|
|
127
|
+
projects,
|
|
128
|
+
}: {
|
|
129
|
+
team: TeamSummary
|
|
130
|
+
projects: Array<ProjectSummary>
|
|
131
|
+
}) {
|
|
132
|
+
return (
|
|
133
|
+
<>
|
|
134
|
+
<TeamHeading
|
|
135
|
+
team={team}
|
|
136
|
+
crumb={<span>Projects</span>}
|
|
137
|
+
actions={
|
|
138
|
+
projects.length > 0 ? <NewProjectButton teamSlug={team.slug} /> : null
|
|
139
|
+
}
|
|
140
|
+
/>
|
|
141
|
+
|
|
142
|
+
<section>
|
|
143
|
+
{projects.length > 0 ? (
|
|
144
|
+
<ProjectRows teamSlug={team.slug} projects={projects} />
|
|
145
|
+
) : (
|
|
146
|
+
<EmptyProjects teamSlug={team.slug} />
|
|
147
|
+
)}
|
|
148
|
+
</section>
|
|
149
|
+
</>
|
|
150
|
+
)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function EmptyServers({
|
|
154
|
+
canAddServer,
|
|
155
|
+
onAddServer,
|
|
156
|
+
}: {
|
|
157
|
+
canAddServer: boolean
|
|
158
|
+
onAddServer: () => void
|
|
159
|
+
}) {
|
|
160
|
+
return (
|
|
161
|
+
<Empty className="min-h-60 border bg-card text-card-foreground">
|
|
162
|
+
<EmptyHeader>
|
|
163
|
+
<EmptyTitle>Connect your first server.</EmptyTitle>
|
|
164
|
+
<EmptyDescription>
|
|
165
|
+
Add a server before creating and deploying projects.
|
|
166
|
+
</EmptyDescription>
|
|
167
|
+
</EmptyHeader>
|
|
168
|
+
{canAddServer ? (
|
|
169
|
+
<EmptyContent>
|
|
170
|
+
<Button type="button" onClick={onAddServer}>
|
|
171
|
+
<PlusIcon data-icon="inline-start" />
|
|
172
|
+
Add server
|
|
173
|
+
</Button>
|
|
174
|
+
</EmptyContent>
|
|
175
|
+
) : null}
|
|
176
|
+
</Empty>
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function RecentProjects({
|
|
181
|
+
teamSlug,
|
|
182
|
+
projects,
|
|
183
|
+
}: {
|
|
184
|
+
teamSlug: string
|
|
185
|
+
projects: Array<ProjectSummary>
|
|
186
|
+
}) {
|
|
187
|
+
return (
|
|
188
|
+
<ul className="grid gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
|
|
189
|
+
{projects.slice(0, 6).map((item) => (
|
|
190
|
+
<li
|
|
191
|
+
key={item.name}
|
|
192
|
+
className="rounded-xl border bg-card p-4 text-sm text-card-foreground"
|
|
193
|
+
>
|
|
194
|
+
<article>
|
|
195
|
+
<header className="mb-4 flex items-center gap-2">
|
|
196
|
+
<Link
|
|
197
|
+
to="/$teamSlug/projects/$projectName"
|
|
198
|
+
params={{ teamSlug, projectName: item.name }}
|
|
199
|
+
className="flex min-w-0 items-center gap-2.5"
|
|
200
|
+
>
|
|
201
|
+
<ResourceAvatar
|
|
202
|
+
name={item.name}
|
|
203
|
+
src={item.avatarUrl ?? undefined}
|
|
204
|
+
color={item.color}
|
|
205
|
+
size="xs"
|
|
206
|
+
/>
|
|
207
|
+
<h3 className="truncate font-medium">{item.name}</h3>
|
|
208
|
+
</Link>
|
|
209
|
+
</header>
|
|
210
|
+
<ul className="space-y-1">
|
|
211
|
+
<li>
|
|
212
|
+
{item.defaultHost ? (
|
|
213
|
+
<Tooltip>
|
|
214
|
+
<TooltipTrigger asChild>
|
|
215
|
+
<a
|
|
216
|
+
className="flex min-w-0 items-center gap-2 text-muted-foreground transition-colors hover:text-foreground [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:opacity-50"
|
|
217
|
+
href={routeUrl({
|
|
218
|
+
host: item.defaultHost,
|
|
219
|
+
https: item.defaultRouteHttps,
|
|
220
|
+
})}
|
|
221
|
+
target="_blank"
|
|
222
|
+
rel="noreferrer"
|
|
223
|
+
>
|
|
224
|
+
<Link2Icon />
|
|
225
|
+
<span className="truncate">{item.defaultHost}</span>
|
|
226
|
+
</a>
|
|
227
|
+
</TooltipTrigger>
|
|
228
|
+
<TooltipContent>Visit</TooltipContent>
|
|
229
|
+
</Tooltip>
|
|
230
|
+
) : (
|
|
231
|
+
<span className="flex min-w-0 items-center gap-2 text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:opacity-50">
|
|
232
|
+
<Link2Icon />
|
|
233
|
+
<span className="truncate">No public route</span>
|
|
234
|
+
</span>
|
|
235
|
+
)}
|
|
236
|
+
</li>
|
|
237
|
+
<li>
|
|
238
|
+
<Tooltip>
|
|
239
|
+
<TooltipTrigger asChild>
|
|
240
|
+
<a
|
|
241
|
+
className="flex min-w-0 items-center gap-2 text-muted-foreground transition-colors hover:text-foreground [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:opacity-50"
|
|
242
|
+
href={`https://github.com/${item.githubRepo}`}
|
|
243
|
+
target="_blank"
|
|
244
|
+
rel="noreferrer"
|
|
245
|
+
>
|
|
246
|
+
<GithubIcon />
|
|
247
|
+
<span className="truncate">{item.githubRepo}</span>
|
|
248
|
+
</a>
|
|
249
|
+
</TooltipTrigger>
|
|
250
|
+
<TooltipContent>Repository</TooltipContent>
|
|
251
|
+
</Tooltip>
|
|
252
|
+
</li>
|
|
253
|
+
</ul>
|
|
254
|
+
</article>
|
|
255
|
+
</li>
|
|
256
|
+
))}
|
|
257
|
+
</ul>
|
|
258
|
+
)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function ProjectRows({
|
|
262
|
+
teamSlug,
|
|
263
|
+
projects,
|
|
264
|
+
}: {
|
|
265
|
+
teamSlug: string
|
|
266
|
+
projects: Array<ProjectSummary>
|
|
267
|
+
}) {
|
|
268
|
+
return (
|
|
269
|
+
<ul className="scrollbar overflow-x-auto rounded-xl border bg-card text-card-foreground">
|
|
270
|
+
{projects.map((project) => (
|
|
271
|
+
<li
|
|
272
|
+
className="flex h-11 min-w-[24rem] items-center gap-4 border-b px-4 text-sm whitespace-nowrap sm:gap-x-8 last:border-b-0 hover:bg-muted/50"
|
|
273
|
+
key={project.id}
|
|
274
|
+
>
|
|
275
|
+
<Tooltip>
|
|
276
|
+
<TooltipTrigger asChild>
|
|
277
|
+
<Link
|
|
278
|
+
to="/$teamSlug/projects/$projectName"
|
|
279
|
+
params={{ teamSlug, projectName: project.name }}
|
|
280
|
+
className="flex min-w-0 max-w-64 items-center gap-x-2 font-medium"
|
|
281
|
+
>
|
|
282
|
+
<ResourceAvatar
|
|
283
|
+
name={project.name}
|
|
284
|
+
src={project.avatarUrl ?? undefined}
|
|
285
|
+
color={project.color}
|
|
286
|
+
size="xs"
|
|
287
|
+
/>
|
|
288
|
+
<span className="max-w-3xs truncate">{project.name}</span>
|
|
289
|
+
</Link>
|
|
290
|
+
</TooltipTrigger>
|
|
291
|
+
<TooltipContent>Name</TooltipContent>
|
|
292
|
+
</Tooltip>
|
|
293
|
+
|
|
294
|
+
{project.defaultHost ? (
|
|
295
|
+
<Tooltip>
|
|
296
|
+
<TooltipTrigger asChild>
|
|
297
|
+
<a
|
|
298
|
+
className="flex min-w-0 items-center gap-x-2 text-muted-foreground transition-colors hover:text-foreground [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:opacity-50"
|
|
299
|
+
href={routeUrl({
|
|
300
|
+
host: project.defaultHost,
|
|
301
|
+
https: project.defaultRouteHttps,
|
|
302
|
+
})}
|
|
303
|
+
target="_blank"
|
|
304
|
+
rel="noreferrer"
|
|
305
|
+
>
|
|
306
|
+
<Link2Icon />
|
|
307
|
+
<span className="truncate">{project.defaultHost}</span>
|
|
308
|
+
</a>
|
|
309
|
+
</TooltipTrigger>
|
|
310
|
+
<TooltipContent>URL</TooltipContent>
|
|
311
|
+
</Tooltip>
|
|
312
|
+
) : (
|
|
313
|
+
<span className="flex min-w-0 items-center gap-x-2 text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:opacity-50">
|
|
314
|
+
<Link2Icon />
|
|
315
|
+
<span className="truncate">No public route</span>
|
|
316
|
+
</span>
|
|
317
|
+
)}
|
|
318
|
+
|
|
319
|
+
<Tooltip>
|
|
320
|
+
<TooltipTrigger asChild>
|
|
321
|
+
<a
|
|
322
|
+
className="hidden min-w-0 max-w-64 items-center gap-x-2 text-muted-foreground transition-colors hover:text-foreground md:flex [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:opacity-50"
|
|
323
|
+
href={`https://github.com/${project.githubRepo}`}
|
|
324
|
+
target="_blank"
|
|
325
|
+
rel="noreferrer"
|
|
326
|
+
>
|
|
327
|
+
<GithubIcon />
|
|
328
|
+
<span className="truncate">{project.githubRepo}</span>
|
|
329
|
+
</a>
|
|
330
|
+
</TooltipTrigger>
|
|
331
|
+
<TooltipContent>GitHub</TooltipContent>
|
|
332
|
+
</Tooltip>
|
|
333
|
+
|
|
334
|
+
<div className="ml-auto shrink-0">
|
|
335
|
+
<div className="-mr-2 flex items-center">
|
|
336
|
+
<Tooltip>
|
|
337
|
+
<TooltipTrigger asChild>
|
|
338
|
+
<Button asChild variant="outline" size="icon-sm">
|
|
339
|
+
<Link
|
|
340
|
+
to="/$teamSlug/projects/$projectName/settings"
|
|
341
|
+
params={{ teamSlug, projectName: project.name }}
|
|
342
|
+
aria-label="Settings"
|
|
343
|
+
>
|
|
344
|
+
<SettingsIcon />
|
|
345
|
+
</Link>
|
|
346
|
+
</Button>
|
|
347
|
+
</TooltipTrigger>
|
|
348
|
+
<TooltipContent>Settings</TooltipContent>
|
|
349
|
+
</Tooltip>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
</li>
|
|
353
|
+
))}
|
|
354
|
+
</ul>
|
|
355
|
+
)
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
function EmptyProjects({ teamSlug }: { teamSlug: string }) {
|
|
359
|
+
return (
|
|
360
|
+
<Empty className="min-h-60 border bg-card text-card-foreground">
|
|
361
|
+
<EmptyHeader>
|
|
362
|
+
<EmptyTitle>Deploy your first project.</EmptyTitle>
|
|
363
|
+
<EmptyDescription>
|
|
364
|
+
Add a new project from an existing GitHub repository.
|
|
365
|
+
</EmptyDescription>
|
|
366
|
+
</EmptyHeader>
|
|
367
|
+
<EmptyContent>
|
|
368
|
+
<NewProjectButton teamSlug={teamSlug} />
|
|
369
|
+
</EmptyContent>
|
|
370
|
+
</Empty>
|
|
371
|
+
)
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function NewProjectButton({
|
|
375
|
+
size,
|
|
376
|
+
teamSlug,
|
|
377
|
+
}: {
|
|
378
|
+
size?: 'default' | 'sm'
|
|
379
|
+
teamSlug: string
|
|
380
|
+
}) {
|
|
381
|
+
return (
|
|
382
|
+
<NewProjectDialogLauncher teamSlug={teamSlug}>
|
|
383
|
+
{(open) => (
|
|
384
|
+
<Button onClick={open} size={size} type="button">
|
|
385
|
+
<PlusIcon data-icon="inline-start" />
|
|
386
|
+
New project
|
|
387
|
+
</Button>
|
|
388
|
+
)}
|
|
389
|
+
</NewProjectDialogLauncher>
|
|
390
|
+
)
|
|
391
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { useQueryClient } from '@tanstack/react-query'
|
|
2
|
+
import { invalidateResourceQueries } from '#devpush/lib/resource-cache'
|
|
3
|
+
import { Link, useNavigate } from '@tanstack/react-router'
|
|
4
|
+
import { useState } from 'react'
|
|
5
|
+
import { Button } from '#devpush/components/ui/button'
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
CardDescription,
|
|
10
|
+
CardFooter,
|
|
11
|
+
CardHeader,
|
|
12
|
+
CardTitle,
|
|
13
|
+
} from '#devpush/components/ui/card'
|
|
14
|
+
import {
|
|
15
|
+
acceptTeamInviteAction,
|
|
16
|
+
declineTeamInviteAction,
|
|
17
|
+
} from '#devpush/server/teams/functions'
|
|
18
|
+
import { getPublicErrorMessage } from '#devpush/lib/public-error'
|
|
19
|
+
import { afterMutation } from '#devpush/lib/action-feedback'
|
|
20
|
+
|
|
21
|
+
export function TeamInvite({ token }: { token: string }) {
|
|
22
|
+
const navigate = useNavigate()
|
|
23
|
+
const queryClient = useQueryClient()
|
|
24
|
+
const [error, setError] = useState<string | null>(null)
|
|
25
|
+
const [pendingAction, setPendingAction] = useState<
|
|
26
|
+
'accept' | 'decline' | null
|
|
27
|
+
>(null)
|
|
28
|
+
const pending = pendingAction !== null
|
|
29
|
+
|
|
30
|
+
const [accepted, setAccepted] = useState(false)
|
|
31
|
+
const [declined, setDeclined] = useState(false)
|
|
32
|
+
|
|
33
|
+
async function accept() {
|
|
34
|
+
if (pending || accepted || declined) return
|
|
35
|
+
setPendingAction('accept')
|
|
36
|
+
setError(null)
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const teamSlug = await acceptTeamInviteAction({ data: { token } })
|
|
40
|
+
await invalidateResourceQueries(queryClient)
|
|
41
|
+
setAccepted(true)
|
|
42
|
+
await afterMutation(
|
|
43
|
+
() => navigate({ to: '/$teamSlug', params: { teamSlug } }),
|
|
44
|
+
'Invitation accepted, but opening the team failed. Please reload.',
|
|
45
|
+
)
|
|
46
|
+
} catch (cause) {
|
|
47
|
+
setError(
|
|
48
|
+
getPublicErrorMessage(cause, 'The invitation could not be accepted.'),
|
|
49
|
+
)
|
|
50
|
+
} finally {
|
|
51
|
+
setPendingAction(null)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function decline() {
|
|
56
|
+
if (pending || accepted || declined) return
|
|
57
|
+
setPendingAction('decline')
|
|
58
|
+
setError(null)
|
|
59
|
+
try {
|
|
60
|
+
await declineTeamInviteAction({ data: { token } })
|
|
61
|
+
setDeclined(true)
|
|
62
|
+
await afterMutation(async () => {
|
|
63
|
+
await invalidateResourceQueries(queryClient)
|
|
64
|
+
await navigate({ to: '/settings', hash: 'teams' })
|
|
65
|
+
}, 'Invitation declined, but opening Account failed. Please reload.')
|
|
66
|
+
} catch (cause) {
|
|
67
|
+
setError(
|
|
68
|
+
getPublicErrorMessage(cause, 'The invitation could not be declined.'),
|
|
69
|
+
)
|
|
70
|
+
} finally {
|
|
71
|
+
setPendingAction(null)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<main className="grid min-h-screen place-items-center p-6">
|
|
77
|
+
<Card className="w-full max-w-md">
|
|
78
|
+
<CardHeader>
|
|
79
|
+
<CardTitle>Join this team?</CardTitle>
|
|
80
|
+
<CardDescription>
|
|
81
|
+
Accept the invitation to add this team to your devpush account.
|
|
82
|
+
</CardDescription>
|
|
83
|
+
</CardHeader>
|
|
84
|
+
{error ? (
|
|
85
|
+
<CardContent role="alert" className="text-destructive">
|
|
86
|
+
{error}
|
|
87
|
+
</CardContent>
|
|
88
|
+
) : null}
|
|
89
|
+
<CardFooter className="flex-col items-stretch gap-2 sm:flex-row sm:justify-end">
|
|
90
|
+
{pending ? (
|
|
91
|
+
<Button variant="ghost" disabled>
|
|
92
|
+
Cancel
|
|
93
|
+
</Button>
|
|
94
|
+
) : (
|
|
95
|
+
<Button asChild variant="ghost">
|
|
96
|
+
<Link to="/settings" hash="teams">
|
|
97
|
+
{accepted || declined ? 'Account' : 'Cancel'}
|
|
98
|
+
</Link>
|
|
99
|
+
</Button>
|
|
100
|
+
)}
|
|
101
|
+
<Button
|
|
102
|
+
variant="outline"
|
|
103
|
+
disabled={pending || accepted || declined}
|
|
104
|
+
onClick={() => void decline()}
|
|
105
|
+
>
|
|
106
|
+
{pendingAction === 'decline'
|
|
107
|
+
? 'Declining…'
|
|
108
|
+
: declined
|
|
109
|
+
? 'Invitation declined'
|
|
110
|
+
: 'Decline invitation'}
|
|
111
|
+
</Button>
|
|
112
|
+
<Button
|
|
113
|
+
data-accept-invite
|
|
114
|
+
disabled={pending || accepted || declined}
|
|
115
|
+
onClick={() => void accept()}
|
|
116
|
+
>
|
|
117
|
+
{pendingAction === 'accept'
|
|
118
|
+
? 'Accepting…'
|
|
119
|
+
: accepted
|
|
120
|
+
? 'Invitation accepted'
|
|
121
|
+
: 'Accept invitation'}
|
|
122
|
+
</Button>
|
|
123
|
+
</CardFooter>
|
|
124
|
+
</Card>
|
|
125
|
+
</main>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function TeamInvitePending() {
|
|
130
|
+
return (
|
|
131
|
+
<main className="grid min-h-screen place-items-center p-6">
|
|
132
|
+
<Card
|
|
133
|
+
className="w-full max-w-md"
|
|
134
|
+
aria-label="Loading invitation"
|
|
135
|
+
aria-busy="true"
|
|
136
|
+
>
|
|
137
|
+
<CardHeader>
|
|
138
|
+
<CardTitle>Join this team?</CardTitle>
|
|
139
|
+
<CardDescription>
|
|
140
|
+
Accept the invitation to add this team to your devpush account.
|
|
141
|
+
</CardDescription>
|
|
142
|
+
</CardHeader>
|
|
143
|
+
<CardFooter className="flex-col items-stretch gap-2 sm:flex-row sm:justify-end">
|
|
144
|
+
<Button variant="ghost" disabled>
|
|
145
|
+
Cancel
|
|
146
|
+
</Button>
|
|
147
|
+
<Button variant="outline" disabled>
|
|
148
|
+
Decline invitation
|
|
149
|
+
</Button>
|
|
150
|
+
<Button disabled>Accept invitation</Button>
|
|
151
|
+
</CardFooter>
|
|
152
|
+
</Card>
|
|
153
|
+
</main>
|
|
154
|
+
)
|
|
155
|
+
}
|