Skip to content

Conversation

@adityachoudhari26
Copy link
Contributor

@adityachoudhari26 adityachoudhari26 commented May 3, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new sidebar cell components to display deployment version status, including active jobs, approval requirements, and blocking policies, with interactive menus for redeploy and force deploy actions.
    • Added helper functions for extracting policy evaluation results and blocking policies.
  • Refactor

    • Modularized sidebar cell components for better maintainability and standardized prop handling.
    • Streamlined approval dialog and dropdown menu interactions for deployment versions.
    • Updated several components to use a system object prop instead of a string identifier for improved consistency.
    • Simplified approval dialog UI and logic to focus on version/environment-based approval with optional reason input.
  • Bug Fixes

    • Improved handling of environment and system identifiers in deployment-related components, ensuring accurate data flow and links.
  • Chores

    • Removed deprecated flow diagram components and related logic.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 3, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This set of changes refactors and modularizes the deployment approval and policy evaluation UI components in the webservice application. Several previously inlined or local components (such as ApprovalCheck, EnvironmentNode, PolicyNode, and related flow diagram nodes) are removed or replaced with new, more focused components (e.g., ActiveJobsCell, ApprovalRequiredCell, BlockedByVersionSelectorCell). The approval dialog flow is simplified and its API is changed to receive explicit version and environment identifiers. Prop handling is standardized, with system information now passed as an object rather than a string slug. Type definitions are updated to support these changes, and code is reorganized to promote reuse and maintainability.

Changes

File(s) Change Summary
.../flow-diagram/ApprovalCheck.tsx, .../flow-diagram/FlowNode.tsx, .../flow-diagram/FlowPolicyNode.tsx Deleted React components for approval checks and flow diagram nodes, removing their exports and associated logic.
.../flow-diagram/checks/Approval.tsx Replaces local ApprovalDialog implementation with an imported, shared component; simplifies approval check UI.
.../jobs/release-table/EnvironmentApprovalRow.tsx, .../jobs/release-table/ResourceReleaseTable.tsx Adds environmentId prop to approval row, updates prop passing in table rows.
.../sidebar/DeploymentPageContent.tsx, .../sidebar/systems/_components/system-deployment-table/TableDeployments.tsx, .../sidebar/deployments/TableDeployments.tsx, .../deployments/environment-cell/DeploymentEnvironmentCell.tsx Updates prop passing to use system object instead of systemSlug string; propagates this change to child components.
.../sidebar/_components/release-cell/ActiveJobsCell.tsx Adds new ActiveJobsCell component to display job statuses and deployment version info, with redeploy/force deploy actions.
.../sidebar/_components/release-cell/ApprovalRequiredCell.tsx Adds new component to display and handle deployments requiring policy approval, with approval dialog and force deploy options.
.../sidebar/_components/release-cell/BlockedByVersionSelectorCell.tsx Adds new component for deployments blocked by policy version selectors, with force deploy option.
.../sidebar/_components/release-cell/DeploymentVersionEnvironmentCell.tsx Refactors to use new modular cell components; updates prop passing and removes inlined logic.
.../sidebar/_components/release-cell/policy-evaluation.ts Adds new type alias PolicyEvaluationResult for policy evaluation structure.
.../deploy/_components/deployment-version/ApprovalDialog.tsx Refactors and simplifies ApprovalDialog API and logic; now takes explicit IDs and submits approval/rejection with optional reason.
.../deploy/_components/deployment-version/DeploymentVersionDropdownMenu.tsx Removes disabled menu logic, exports dialog components, and simplifies dropdown actions; removes dependency on job status for enabling actions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant ApprovalDialog
    participant API

    User->>UI: Click "Approve" or "Force deploy"
    UI->>ApprovalDialog: Open dialog with version/environment info
    User->>ApprovalDialog: Confirm approval/rejection (optional reason)
    ApprovalDialog->>API: Submit approval record (status, reason)
    API-->>ApprovalDialog: Respond with success
    ApprovalDialog->>UI: Close dialog, refresh state
Loading

Possibly related PRs

  • ctrlplanedev/ctrlplane#385: Refactors ApprovalCheck props and query usage to deployment version-based identifiers, directly related to approval status handling.
  • ctrlplanedev/ctrlplane#386: Updates ApprovalDialog import within ApprovalCheck.tsx, directly related to the components removed or refactored in this PR.
  • ctrlplanedev/ctrlplane#488: Adds and integrates a new ApprovalDialog component, directly related to the approval UI changes and dialog refactoring in this PR.

Suggested reviewers

  • jsbroks

Poem

A bunny hops through code so neat,
Refactors flow, approval complete!
Cells now modular, dialogs clear,
System slugs as objects appear.
Approvals, blocks, and jobs in view—
All streamlined for the dev crew.
🐇✨ Hoppily merged, this code anew!


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adb0fd9 and 24902ef.

📒 Files selected for processing (3)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ActiveJobsCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ApprovalRequiredCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/BlockedByVersionSelectorCell.tsx (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 4

🧹 Nitpick comments (4)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/policy-evaluation.ts (1)

1-9: Consider adding documentation comments to the type definition

The PolicyEvaluationResult type is well-structured, but adding JSDoc comments would improve maintainability by explaining what each property represents, especially for the various approval record types.

+/**
+ * Represents the result of a policy evaluation process
+ */
 export type PolicyEvaluationResult = {
+  /** The policies being evaluated */
   policies: { id: string; name: string }[];
   rules: {
+    /** Maps policy IDs to arrays of required approvals */
     anyApprovals: Record<string, string[]>;
+    /** Maps policy IDs to arrays of required role approvals */
     roleApprovals: Record<string, string[]>;
+    /** Maps policy IDs to arrays of required user approvals */
     userApprovals: Record<string, string[]>;
+    /** Maps policy IDs to boolean flags indicating if they're blocked by version selectors */
     versionSelector: Record<string, boolean>;
   };
 };
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/BlockedByVersionSelectorCell.tsx (1)

29-37: Minor: give getPoliciesBlockingByVersionSelector an explicit return type

Adding an explicit type (e.g. Array<{ id: string; name: string }> or Policy[]) makes the helper self-documenting and guards against accidental API changes.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ApprovalRequiredCell.tsx (1)

32-70: Helper could be simplified & de-duplicated

getPoliciesWithApprovalRequired performs three almost identical passes over the evaluation object and then uniqBy.
Consider extracting the repeated logic or iterating once over the rules object to improve readability and reduce work.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployment-version/ApprovalDialog.tsx (1)

34-47: Reason field never resets after dialog closes

If the user opens the dialog, types a reason, approves/rejects, and later re-opens the dialog, the previous reason remains.
Resetting the state on close prevents accidental reuse of stale input.

-      .then(() => setOpen(false))
+      .then(() => {
+        setOpen(false);
+        setReason("");
+      })

Alternatively, add a useEffect that clears reason whenever open becomes false.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between aeaeab8 and adb0fd9.

📒 Files selected for processing (17)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/ApprovalCheck.tsx (0 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowNode.tsx (0 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowPolicyNode.tsx (0 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/checks/Approval.tsx (3 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/EnvironmentApprovalRow.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ActiveJobsCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ApprovalRequiredCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/BlockedByVersionSelectorCell.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx (6 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/policy-evaluation.ts (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(sidebar)/deployments/TableDeployments.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(sidebar)/systems/_components/system-deployment-table/TableDeployments.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployment-version/ApprovalDialog.tsx (1 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployment-version/DeploymentVersionDropdownMenu.tsx (5 hunks)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployments/environment-cell/DeploymentEnvironmentCell.tsx (3 hunks)
💤 Files with no reviewable changes (3)
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowNode.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/ApprovalCheck.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/FlowPolicyNode.tsx
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error...

**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.

  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(sidebar)/systems/_components/system-deployment-table/TableDeployments.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(sidebar)/deployments/TableDeployments.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/EnvironmentApprovalRow.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/checks/Approval.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/policy-evaluation.ts
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployments/environment-cell/DeploymentEnvironmentCell.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ApprovalRequiredCell.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployment-version/ApprovalDialog.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/ActiveJobsCell.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployment-version/DeploymentVersionDropdownMenu.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/BlockedByVersionSelectorCell.tsx
  • apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx
🧬 Code Graph Analysis (1)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx (1)
packages/db/src/schema/environment.ts (1)
  • environment (59-84)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Lint
  • GitHub Check: Typecheck
  • GitHub Check: build (linux/amd64)
🔇 Additional comments (25)
apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(sidebar)/systems/_components/system-deployment-table/TableDeployments.tsx (1)

214-214: Standardized system data passing.

The change from passing systemSlug to passing the entire system object ensures consistency across deployment components and allows downstream components to access additional system properties if needed in the future.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/ResourceReleaseTable.tsx (1)

198-198: Added explicit environmentId for better approval context.

Adding the environmentId prop to the EnvironmentApprovalRow component explicitly passes the environment context to the approval flow, which helps in making environment-specific approval operations more clear and maintainable.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(sidebar)/deployments/TableDeployments.tsx (1)

233-233: Standardized system data using object structure.

Converting the systemSlug string prop to a system object prop with a slug property aligns with the broader refactoring effort and creates consistency with other deployment-related components.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/DeploymentPageContent.tsx (1)

360-360: Standardized system data passing in environment cell.

The change from passing a systemSlug string to passing a system object maintains consistency with other related components and supports the modularization of deployment environment cells.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/jobs/release-table/EnvironmentApprovalRow.tsx (3)

12-12: Props interface extended correctly

Added the necessary environmentId string property to the EnvironmentApprovalRowProps type, which is required for the updated ApprovalDialog component API.


18-18: Prop destructuring updated correctly

The component destructuring now includes the new environmentId prop, which matches the updated props interface.


23-25: Improved API usage with explicit props

The refactored ApprovalDialog implementation is now using explicit properties instead of passing the entire deploymentVersion object. This change:

  1. Makes the interface more explicit and easier to understand
  2. Provides better type safety
  3. Follows React best practices for prop drilling

This is a positive improvement to the codebase.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployments/environment-cell/DeploymentEnvironmentCell.tsx (3)

27-27: Improved prop structure with object instead of string

Changing from systemSlug: string to system: { slug: string } is a good improvement that:

  1. Makes the component more extensible for future additions
  2. Follows the pattern of structured data objects rather than primitive values
  3. Creates a more consistent API across components

This structural change aligns with React best practices.


33-33: Prop usage updated correctly throughout component

All instances of systemSlug have been correctly updated to use system.slug instead, ensuring the component works as expected with the new API.

Also applies to: 44-44


67-67: System object now properly passed to child component

The system prop is now correctly passed to the LazyDeploymentVersionEnvironmentCell component, which ensures proper propagation of the system data through the component hierarchy. This is important for maintaining context consistency.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(raw)/releases/[releaseId]/checks/_components/flow-diagram/checks/Approval.tsx (3)

9-9: Good modularization with shared component import

Adding the import for the shared ApprovalDialog component is a good step toward code reuse and maintainability.


53-57: Improved code modularity by using shared component

Replacing the inline approval dialog implementation with the shared ApprovalDialog component:

  1. Reduces code duplication
  2. Centralizes the dialog logic for easier maintenance
  3. Ensures consistent behavior across the application
  4. Simplifies this component's implementation

The implementation correctly passes all required props and the onSubmit callback for cache invalidation.


78-82: Consistent usage of shared component

The shared ApprovalDialog component is consistently used in all relevant sections of the component, ensuring uniform behavior throughout the UI.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/_components/deployment-version/DeploymentVersionDropdownMenu.tsx (5)

49-94: Export reusable component to improve code modularity.

The RedeployVersionDialog component is now exported to facilitate reuse in other parts of the application. Additionally, the handleRedeploy function has been simplified while maintaining the same functionality.


96-140: Export ForceDeployVersionDialog component for reuse.

Making this dialog component exportable improves code modularity and allows it to be reused in other components, which aligns with the overall refactoring approach seen in this PR.


150-168: Simplify DropdownAction component by removing disabled state.

The component no longer supports disabled states (disabled and disabledMessage props have been removed), which simplifies the implementation. Menu items will now always be enabled and trigger dialogs instead of showing disabled states with tooltips.

This change alters the UX by always showing enabled actions - please verify this behavior is intentional and doesn't lead to user confusion in cases where actions would have previously been disabled with explanatory messages.


177-177: Remove conditional disabling from DeploymentVersionDropdownMenu.

The isVersionBeingDeployed prop has been removed from the component signature, which means the redeploy action will no longer be conditionally disabled. This aligns with the changes to the DropdownAction component.


183-183: Add shrink-0 class to prevent button from collapsing.

Adding the shrink-0 utility class prevents the dropdown trigger button from shrinking when space is limited, maintaining consistent button dimensions.

apps/webservice/src/app/[workspaceSlug]/(app)/(deploy)/(raw)/systems/[systemSlug]/(raw)/deployments/[deploymentSlug]/(sidebar)/_components/release-cell/DeploymentVersionEnvironmentCell.tsx (7)

7-7: Simplify imports to include only necessary icons.

Keeping only the required icon imports helps maintain clean code and reduces bundle size.


14-22: Import modularized components for better code organization.

The file now imports components and helper functions from separate modules instead of defining them inline. This improves code modularity, reusability, and maintainability.


51-56: Update NoJobAgentCell props to use object pattern.

The component now accepts system and deployment objects instead of individual properties, standardizing prop handling across components. The workspaceSlug is now retrieved using useParams inside the component, making it more self-contained.


59-61: Simplify URL construction with object properties.

URL construction now uses properties from the passed objects, which is more maintainable and less error-prone.


82-82: Update props type to include system object.

The props type now includes a system object, aligning with the standardization of passing objects rather than individual strings throughout the codebase.


90-91: Improve props handling with simplified pattern.

The component now accepts a single props object and destructures only what's needed at the top level, making the code more maintainable.


116-116: Standardize props passing with spread operator.

Props are now passed wholesale to child components using the spread operator, reducing code duplication and standardizing prop handling across the components.

Also applies to: 134-135, 148-149, 154-154

Comment on lines +17 to +19
import { JobStatus } from "@ctrlplane/validators/jobs";

import {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Enum mismatch can cause false negatives when detecting active jobs

statuses is typed as SCHEMA.JobStatus[], yet the comparison is done against JobStatus imported from the validator package.
Although the underlying literal values may coincide today, nothing enforces that they will stay in sync.

-import { JobStatus } from "@ctrlplane/validators/jobs";
+// Re-use the enum that the array is already typed with.
+import { JobStatus as DbJobStatus } from "@ctrlplane/db/schema";

and

-const hasActiveJobs = statuses.some((s) => s === JobStatus.InProgress);
+const hasActiveJobs = statuses.includes(DbJobStatus.InProgress);

Aligning the source of truth prevents drift and removes an unnecessary extra import.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { JobStatus } from "@ctrlplane/validators/jobs";
import {
-import { JobStatus } from "@ctrlplane/validators/jobs";
+// Re-use the enum that the array is already typed with.
+import { JobStatus as DbJobStatus } from "@ctrlplane/db/schema";
import {
/* … */
Suggested change
import { JobStatus } from "@ctrlplane/validators/jobs";
import {
-const hasActiveJobs = statuses.some((s) => s === JobStatus.InProgress);
+const hasActiveJobs = statuses.includes(DbJobStatus.InProgress);

@adityachoudhari26 adityachoudhari26 merged commit 919b90c into main May 3, 2025
3 of 6 checks passed
@adityachoudhari26 adityachoudhari26 deleted the cell-cleanup branch May 3, 2025 18:18
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.

2 participants