Skip to content

refactor: extract DeploymentStatus to shared location#5264

Merged
ogzhanolguncu merged 10 commits intomainfrom
deployment-status-shared
Mar 9, 2026
Merged

refactor: extract DeploymentStatus to shared location#5264
ogzhanolguncu merged 10 commits intomainfrom
deployment-status-shared

Conversation

@ogzhanolguncu
Copy link
Contributor

What does this PR do?

Use one shared DeploymentStatus and DeploymentStatusBadge.

How should this be tested?

  • Make a deployment make sure it works

@vercel
Copy link

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dashboard Ready Ready Preview, Comment Mar 9, 2026 8:03pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 9, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Deployment status values and types were centralized into a new module. The old local DeploymentStatusBadge was removed and replaced by a single, refactored badge component at a higher-level path using a data-driven config. Zod schemas, imports, and UI code were updated to use the shared status constant/type. A compound-duration formatter was added.

Changes

Cohort / File(s) Summary
Centralized status module
web/apps/dashboard/lib/collections/deploy/deployment-status.ts, web/apps/dashboard/lib/collections/index.ts
Introduce and export DEPLOYMENT_STATUSES tuple and DeploymentStatus type; re-export both from collections index.
DeploymentStatusBadge relocated & refactored
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx, web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/components/deployment-status-badge.tsx
Removed the old deep-path badge file and added a single higher-level badge implementation using a statusConfigs map (icon, label, colors, optional animation); new component requires status prop and validates config at runtime.
Schema & collection updates
web/apps/dashboard/lib/collections/deploy/deployments.ts
Replaced inline z.enum([...]) status list with z.enum(DEPLOYMENT_STATUSES) to use centralized status values.
UI import/path/type adjustments
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/filters.schema.ts, .../components/table/components/domain_list.tsx, .../components/table/deployments-list.tsx, .../deployment-info.tsx
Switched local status/heavy imports to use the centralized DeploymentStatus/DEPLOYMENT_STATUSES; updated import path for DeploymentStatusBadge where applicable.
Deployment status derivation / utils
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/deployment-utils.ts, .../page.tsx
Added shared deriveStatusFromSteps(steps, fallback) and isDeploymentStatus guard; replaced local helper usage with import of shared implementation in page.
Live deployment UI changes
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/new/steps/deployment-live.tsx, .../(deployment-progress)/deployment-progress.tsx, .../(deployment-progress)/deployment-step.tsx
Added TRPC steps fetching in deployment-live and pass stepsData/statusOverride to child components; changed now initializer to Date.now reference; switched duration formatting to new formatter with null guards.
Metric formatter
web/apps/dashboard/lib/utils/metric-formatters.ts
Added formatCompoundDuration(ms: number) to produce two-unit compound duration strings (ms, s, m s, h m).
Misc UI styling
web/apps/dashboard/components/navigation/sidebar/product-switcher.tsx
Minor style and spacing adjustments for product-switcher buttons and dropdown items; icon size and color token updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • refactor: deployment overview page v2 #4804 — Introduces the centralized DeploymentStatusBadge referenced by this change; directly related to badge relocation and implementation.
  • fix: ui inconsistencies #5167 — Overlaps on deployment UI, status handling, and deriveStatusFromSteps/deployment-utils changes; strongly related to the consolidated status and badge refactor.
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete. It lacks the 'Type of change' section, proper issue reference, and detailed testing instructions required by the template. Add the 'Type of change' checkbox section, reference the associated issue, and provide detailed testing steps beyond 'make a deployment' (e.g., test specific UI interactions, verify no console errors).
Docstring Coverage ⚠️ Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main refactoring work: extracting DeploymentStatus to a shared location for reuse across multiple components.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch deployment-status-shared

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx (1)

96-98: Defensive check for type-safe code.

Since status is typed as DeploymentStatus and statusConfigs is a complete Record<DeploymentStatus, StatusConfig>, this check will never trigger at runtime (TypeScript guarantees exhaustiveness). This is fine as defensive coding, but the error would only surface if there's a type mismatch at the boundary. Consider whether this runtime check adds value or could be removed in favor of trusting the type system.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx
around lines 96 - 98, Remove the redundant runtime null-check and throw for
`config` since `status` is typed as `DeploymentStatus` and `statusConfigs:
Record<DeploymentStatus, StatusConfig>` is exhaustive; delete the if (!config) {
throw new Error(`Invalid deployment status: ${status}`); } block (referencing
`status`, `statusConfigs`, `StatusConfig`, and the `config` variable) so the
code relies on the type system, or alternatively replace it with a compile-time
exhaustive check pattern (e.g., a `never`-case helper) if you want explicit
exhaustiveness handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx:
- Around line 96-98: Remove the redundant runtime null-check and throw for
`config` since `status` is typed as `DeploymentStatus` and `statusConfigs:
Record<DeploymentStatus, StatusConfig>` is exhaustive; delete the if (!config) {
throw new Error(`Invalid deployment status: ${status}`); } block (referencing
`status`, `statusConfigs`, `StatusConfig`, and the `config` variable) so the
code relies on the type system, or alternatively replace it with a compile-time
exhaustive check pattern (e.g., a `never`-case helper) if you want explicit
exhaustiveness handling.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 966c4bbb-847e-40be-a70b-a3f36766bb78

📥 Commits

Reviewing files that changed from the base of the PR and between 2ecdfc3 and b460d60.

📒 Files selected for processing (8)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/components/deployment-status-badge.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/components/domain_list.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/deployments-list.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/filters.schema.ts
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx
  • web/apps/dashboard/lib/collections/deploy/deployment-status.ts
  • web/apps/dashboard/lib/collections/deploy/deployments.ts
  • web/apps/dashboard/lib/collections/index.ts
💤 Files with no reviewable changes (1)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/components/deployment-status-badge.tsx

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/filters.schema.ts (1)

42-54: ⚠️ Potential issue | 🟡 Minor

Map ready to the success color.

Line 44 still checks "completed", but validValues in this file only allow "pending" | "deploying" | "ready" | "failed". As written, "ready" falls through to the default info color and renders like an in-progress state.

Minimal fix
     getColorClass: (value) => {
-      if (value === "completed") {
+      if (value === "ready") {
         return "bg-success-9";
       }
       if (value === "failed") {
         return "bg-error-9";
       }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/filters.schema.ts
around lines 42 - 54, The getColorClass function currently checks for
"completed" but GROUPED_DEPLOYMENT_STATUSES only contains "pending" |
"deploying" | "ready" | "failed", so "ready" falls through to the default;
update getColorClass (the function defined alongside validValues and
GROUPED_DEPLOYMENT_STATUSES) to map the "ready" value to the success color
(bg-success-9) instead of checking "completed" so ready deployments render with
the success color.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx:
- Around line 13-18: The file imports IconProps from the private path
"@unkey/icons/src/props"; update the import to use the public package entry
(e.g. import type { IconProps } from "@unkey/icons") or remove the dependency by
inferring the prop type directly via React.ComponentProps from a concrete icon
(e.g. ComponentProps<typeof CircleCheck>) and then update the StatusConfig type
(icon: FC<IconProps>) to use the chosen, public prop type so you no longer
depend on an internal path.

---

Outside diff comments:
In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/filters.schema.ts:
- Around line 42-54: The getColorClass function currently checks for "completed"
but GROUPED_DEPLOYMENT_STATUSES only contains "pending" | "deploying" | "ready"
| "failed", so "ready" falls through to the default; update getColorClass (the
function defined alongside validValues and GROUPED_DEPLOYMENT_STATUSES) to map
the "ready" value to the success color (bg-success-9) instead of checking
"completed" so ready deployments render with the success color.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a3400b13-9b66-477d-982d-e7ec5535e9db

📥 Commits

Reviewing files that changed from the base of the PR and between b460d60 and 8b18ab3.

📒 Files selected for processing (4)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/components/domain_list.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/deployments-list.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/filters.schema.ts
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/components/deployment-status-badge.tsx
🚧 Files skipped from review as they are similar to previous changes (2)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/components/domain_list.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/components/table/deployments-list.tsx

Copy link
Collaborator

@mcstepp mcstepp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@web/apps/dashboard/app/`(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/deployment-step.tsx:
- Around line 91-93: The span currently hides zero-duration values because it
uses a truthiness check on duration; update the conditional to explicitly check
for null/undefined (e.g., duration !== null && duration !== undefined) so that 0
is rendered (call formatCompoundDuration(duration) when duration is defined).
Locate the span that references duration and formatCompoundDuration in
deployment-step.tsx and replace the truthy check with an explicit null/undefined
check to ensure "0ms" is displayed.

In `@web/apps/dashboard/lib/utils/metric-formatters.ts`:
- Around line 17-18: The branch handling sub-second durations incorrectly uses
rounding and can yield "1000ms" for values like 999.6; change the logic in
metric-formatters.ts where the variable ms is checked (the if (ms < 1000)
branch) to floor the milliseconds instead of rounding so values remain below
1000 (i.e., use Math.floor on ms when formatting the `${...}ms` output).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 30219b06-aef8-4a4f-a0da-29564ac22d88

📥 Commits

Reviewing files that changed from the base of the PR and between 8b18ab3 and 440a405.

📒 Files selected for processing (3)
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/deployment-progress.tsx
  • web/apps/dashboard/app/(app)/[workspaceSlug]/projects/[projectId]/(overview)/deployments/[deploymentId]/(deployment-progress)/deployment-step.tsx
  • web/apps/dashboard/lib/utils/metric-formatters.ts

@ogzhanolguncu ogzhanolguncu force-pushed the deployment-status-shared branch from 9e3caed to a03ce3c Compare March 9, 2026 19:58
@ogzhanolguncu ogzhanolguncu added this pull request to the merge queue Mar 9, 2026
Merged via the queue into main with commit 7ac64ce Mar 9, 2026
11 of 12 checks passed
@ogzhanolguncu ogzhanolguncu deleted the deployment-status-shared branch March 9, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants